lbellonda / qxmledit

QXmlEdit XML editor. Downloads: https://sourceforge.net/projects/qxmledit/files
http://qxmledit.org
Other
160 stars 46 forks source link

Working on Snap package for QXmlEdit #50

Closed frederickjh closed 5 years ago

frederickjh commented 6 years ago

Hi @lbellonda !

I wanted to let you know that I have started work on a Snap package for QXmlEdit. This should make it easier for people on many Linux distros to install, as it packages all the needed libraries. You will not find it in the store but it is available to test. See the installation instructions on the QXmlEdit Snap project page.

I am new to QXmlEdit as just started using it for a project at work. If you could test out the Snap Package and see if you find any issues that would be appreciated. I have two issues in the Issue Queue for the QXmlEdit Snap project.

I would appreciate any help you can give me on issue #2, regarding the non-working "User Manual" button. Should this button open the pdf manual? The pdf manual gets installed in the /opt/qxmledit/ folder with the qxmledit binary. The binary gets moved to /bin in the project. Where is the binary expecting the pdf to be? That way I can move it there in the snap build so QXmlEdit can open it.

As you will see in the check list on the QXmlEdit Snap project page the eventual goal is to get to the point when I submit a pull request to this project and the project can then create an account with the snap store and take over ownership and building of the Snap package. God Bless! Frederick

lbellonda commented 6 years ago

Hello, glad to hear that someone is working on that.

The documentation is searched where specified at configuration time via the environment variable QXMLEDIT_INST_DOC_DIR as specified in the INSTALL file that you find in the root of the sources. The user manual is part of documentation. For the missing icon, probably you should take a look to the install_scripts/environment folder. You will find the .desktop file and some other file needed to the desktop integration.

Best regards.

frederickjh commented 6 years ago

@lbellonda I have not compiled programs from tarballs in a few years. I am also new to building Snaps. I am trying to figure out how to correctly override the build. That is where I should be able to set the environment variables for the build, however when I do this it seems that he build does not finish correctly. It is like something in the build tools does not run.

lbellonda commented 6 years ago

Maybe I can help if you show me the build logs and the commands you used.

frederickjh commented 6 years ago

@lbellonda Thanks! If I don't figure this out soon I will see if I can get you access to that information.

Just to confirm if I set QXMLEDIT_INST_DOC_DIR to a path that is where QXmlEdit will look for QXmlEdit_manual.pdf? Is that correct?

lbellonda commented 6 years ago

Yes, it is correct.

frederickjh commented 6 years ago

@lbellonda What is the default path for QXMLEDIT_INST_DOC_DIR?

I do not think that setting environment variables is working with override-build:. I do not find any examples of it, only using its predecessor prepare:. Something like: export QXMLEDIT_INST_DOC_DIR=${SNAP}/meta/gui/.

I need to ask in the forums and see what others experience is.

Currently when I run qxmledit from the command line and click the "User Manual" button I get the error: user-open error: no such file or directory that tells me I still have not gotten it in the correct place.

lbellonda commented 6 years ago

The default path is: /opt/qxmledit When running qmake the installation folders are printed on console.

frederickjh commented 6 years ago

Thanks @lbellonda I still have not gotten this to work. I have not figure out how to set environment variables for the build. Just got an email from the Snap Store and rebuild the snap to get newer packages that fix the "USN-3670-1: elfutils vulnerabilities" security issue.

frederickjh commented 6 years ago

Link to issue "User Manual" Button in Help section of "QXmlEdit Guided Operations" window does not work. #2 on the QXmlEdit Snap project issue queue.

lbellonda commented 6 years ago

Maybe you can use a scriptlet as stated here: https://docs.snapcraft.io/build-snaps/scriptlets and insert the enviroment variables management in the section override-pull or override-build

In a next version I may handle command line variables to qmake.

frederickjh commented 6 years ago

@lbellonda this is exactly what I was trying to do. Here is a diff of my git stash from when I last worked on this:

diff --git a/snap/snapcraft.yaml b/snap/snapcraft.yaml
index afefe81..a1caefa 100644
--- a/snap/snapcraft.yaml
+++ b/snap/snapcraft.yaml
@@ -45,6 +45,7 @@ parts:
       - libqwtplot3d-qt5-dev
       - libqt5opengl5-dev
     override-build: |
+      export QXMLEDIT_INST_DOC_DIR=${SNAP}/meta/gui/
       snapcraftctl build
       sed -i 's|Icon=qxmledit|Icon=\${SNAP}/meta/gui/icon.svg|' ${SNAPCRAFT_PART_INSTALL}/opt/qxmledit/QXmlEdit.desktop
     stage-packages:
@@ -68,5 +69,6 @@ parts:
       opt/qxmledit/qxmledit: bin/qxmledit
       opt/qxmledit/QXmlEdit.appdata.xml: meta/gui/QXmlEdit.appdata.xml
       opt/qxmledit/sample.style: bin/sample.stlye
+      opt/qxmledit/QXmlEdit_manual.pdf: meta/gui/QXmlEdit_manual.pdf
     after: [desktop-qt5]

The first added line should set the environment variable for the location of the document. The second added line should move the pdf to the location that QXmlEdit expects it to be in.

Does this look correct to you? Frederick

lbellonda commented 6 years ago

Sorry, I have not enough experience with snap packages. You can apply a patch changing the file src/cconfig.pri setting the variable INST_DOC_DIR to the desired value.

lbellonda commented 6 years ago

Hello, in the devel branch you can use command line arguments to qmake. You can switch from environment variables to command line variables, e,g,:

qmake "CONFIG+=release" "QXMLEDIT_INST_DOC_DIR = /path/folder"

I think you can use the option section of qmake plugin. Please, give me a feedback in order to include this feature in the next release.

Best regards.

lbellonda commented 6 years ago

Hello, version 0.9.11 has the possibility to use command line arguments to qmake instead of environment variables. I think that this solves your problem.

frederickjh commented 6 years ago

Hello @lbellonda I am on an extended trip right now I will look into this when I get back sometime after the middle of August. God bless! Frederick

frederickjh commented 6 years ago

Hello @lbellonda !

I just tried fixing this but I did not have success. Here is the diff if my changes:

diff --git a/snap/snapcraft.yaml b/snap/snapcraft.yaml
index afefe81..ccb2ea9 100644
--- a/snap/snapcraft.yaml
+++ b/snap/snapcraft.yaml
@@ -27,7 +27,7 @@ parts:
     plugin: qmake
     qt-version: qt5
     options:
-      - CONFIG+=release
+      - CONFIG+=release QXMLEDIT_INST_DOC_DIR=${SNAP}/meta/gui/
     source:
       - on amd64: https://github.com/lbellonda/qxmledit/archive/$SNAPCRAFT_PROJECT_VERSION.tar.gz
       - on i386: https://github.com/lbellonda/qxmledit/archive/$SNAPCRAFT_PROJECT_VERSION.tar.gz
@@ -68,5 +68,6 @@ parts:
       opt/qxmledit/qxmledit: bin/qxmledit
       opt/qxmledit/QXmlEdit.appdata.xml: meta/gui/QXmlEdit.appdata.xml
       opt/qxmledit/sample.style: bin/sample.stlye
+      opt/qxmledit/QXmlEdit_manual.pdf: meta/gui/QXmlEdit_manual.pdf
     after: [desktop-qt5]

The edited line should set the environment variable for the location of the document. The added line should move the pdf to the location that QXmlEdit expects it to be in.

I am using similar syntax for the icon file to tell the .desktop file where it is, and this is working. Is the path and filename I am copying the document file from correct?

When I run QXmlEdit and click the User Manual button in the terminal I get the message: user-open error: no such file or directory. This tells me that I do not have it right but I feel like I am working in the dark as I do not know where the file are.

Thanks again for your time and helpful suggestions!

lbellonda commented 6 years ago

Hello, may I suggest you to update the file applicationdata.cpp, updating the function showUserManual inserting the line with "error". You will see a popup showing the location of the file.

void ApplicationData::showUserManual() { QString resourceHelp = getDocsDir() + "/" + HELP_FILE ; Utils::error(resourceHelp); QDesktopServices::openUrl(QUrl::fromLocalFile(resourceHelp)); }

frederickjh commented 6 years ago

Hello @lbellonda I am embarrassed to say that previously I forgot to change the QXmlEdit version to 0.9.11 in my 'snapcraft.yaml' file. However after doing so, I am running into other issues now. First my buildoverride in snapcraft.yaml could not find QXmlEdit.desktop to fix the location of the icon.

sed: can't read /home/fhenderson/workarea/snapcraft-projects/qxmledit/parts/qxmledit/install/opt/qxmledit/QXmlEdit.desktop: No such file or directory

So I removed it, for now, trying to get the build working again.

After cleaning and pulling and trying to build again I am getting the following error:

Failed to stage: Parts 'desktop-qt5' and 'qxmledit' have the following files, but with different contents:

image

Maybe you have an idea as to what the issue is but have to say that I do not understand the issue that is causing the failed build nor how to fix it.

Thanks for any guidance you can give in fixing this! Frederick

frederickjh commented 6 years ago

@lbellonda I have also noticed that when I start QXmlEdit on the command line I get a list of messages. Should we be concerned about these? Or is this normal?

$ qxmledit
Gtk-Message: Failed to load module "overlay-scrollbar"
Gtk-Message: Failed to load module "gail"
Gtk-Message: Failed to load module "atk-bridge"
Gtk-Message: Failed to load module "unity-gtk-module"
Gtk-Message: Failed to load module "canberra-gtk-module"
Qt: Session management error: None of the authentication protocols specified are supported
libGL error: No matching fbConfigs or visuals found
libGL error: failed to load driver: swrast
frederickjh commented 6 years ago

I fixed the issue with duplicate files with different content by files in the following folders not to be staged by adding the flowing to the snapcraft.yaml:

    stage:
      - -usr/lib/x86_64-linux-gnu/
      - -lib/x86_64-linux-gnu/
      - -usr/share/doc/
frederickjh commented 6 years ago

@lbellonda Is it possible or could it be made possible to have QXmlEdit read environmental variables upon startup? It seems that I cannot get the exact path to give to qmake for QXMLEDIT_INST_DOC_DIR, but it is possible to define environment variables in the snapcraft.yaml file that will be loaded when the program is run. See this forum thread.

frederickjh commented 6 years ago

Hello, may I suggest you to update the file applicationdata.cpp, updating the function showUserManual inserting the line with "error". You will see a popup showing the location of the file.

void ApplicationData::showUserManual() { QString resourceHelp = getDocsDir() + "/" + HELP_FILE ; Utils::error(resourceHelp); QDesktopServices::openUrl(QUrl::fromLocalFile(resourceHelp)); }


@lbellonda I added this code that you suggested, but no popup ever appeared. I would be just happy if it would print out where it is trying to find the file in the terminal like the user-open error: no such file or directory message.

In the Snapcraft forum, one person suggested using /snap/qxmledit/current/opt/qxmledit/ as the QXMLEDIT_INST_DOC_DIR. This did not work even though running evince /snap/qxmledit/current/opt/qxmledit/QXmlEdit_manual.pdf does open the PDF document.

frederickjh commented 6 years ago

@lbellonda can you take a look at what Saviq is saying in the Snapcraft forum and give some feedback?

Saviq says:

So maybe the problem isn’t the path but rather the way it tries to open it? The only supported way for snaps to open files in other apps is through calling xdg-open (which QDesktopServices.openUrl uses by default, so that should work).

lbellonda commented 6 years ago

Hello, I need to try to start my self the Snap version of QXmlEdit. Please, give me some time to do it.

frederickjh commented 6 years ago

@lbellonda if you have the Snap service (snapd) installed then you should be able to run:

sudo snap install --edge qxmledit

to install the snap version of QXmlEdit.

lbellonda commented 6 years ago

Hello, regarding this line: QXMLEDIT_INST_DOC_DIR=${SNAP}/meta/gui/

this is the folder where the doc is searched at runtime, so I think that it is not correct. This I guess is the location where the pdf is at compile time.

If you do not see any messagebox, it can be that your are starting the unpatched program. Try to write the string resourceHelp in a file to check it.

frederickjh commented 6 years ago

@lbellonda regarding the line you mentioned above: I was trying to use the organized to move it to that location. I have also tried: QXMLEDIT_INST_DOC_DIR=/snap/qxmledit/current/opt/qxmledit as a qmake option. This is where the folder where the PDF is on my computer. current is a link to the current version. However this also did not work.

lbellonda commented 6 years ago

Hello, I think that the correct syntax for qmake options is:

options: [CONFIG+=release, QXMLEDIT_INST_DOC_DIR=xxx]

else the arguments will be considered one string only

frederickjh commented 6 years ago

@lbellonda Setting the qmake options this way:

    options:
      - CONFIG+=release
      - QXMLEDIT_INST_DOC_DIR=/opt/qxmledit

or this way:

    options:
      - CONFIG+=release, QXMLEDIT_INST_DOC_DIR=/opt/qxmledit

Does the same thing. I have figured out that if I do not launch QXmlEdit from the Unity launcher or via the command line with qxmledit but instead run it using the full path to the binary /snap/qxmledit/current/bin/qxmledit that then the program will give me feed back about the PDF file it is trying to find.

I also figured out that running it this way that setting QXMLEDIT_INST_DOC_DIR to /opt/qxmledit (the default) that the PDF loads, but it still does not work when running in from the Unity launcher or from the command line with only `qxmledit'.

If I set QXMLEDIT_INST_DOC_DIR to /snap/qxmledit/current/opt/qxmledit/ then it tries to find the PDF in /snap/qxmledit/current/opt/qxmledit/ but the PDF document QXmlEdit_manual.pdf gets put in /snap/qxmledit/current/snap/qxmledit/current/opt/qxmledit/.

Here is the message from the terminal when running qxmledit with the full path: gvfs-open: file:///snap/qxmledit/current/opt/qxmledit/QXmlEdit_manual.pdf: error opening location: Error when getting information for file '/snap/qxmledit/current/opt/qxmledit/QXmlEdit_manual.pdf': No such file or directory

If I am understanding this correctly QXMLEDIT_INST_DOC_DIR is only saying where to install the file not where to find the file.

It seems to me that QXmlEdit is using a relative path to find the PDF document and somehow when run as a snap does not know exactly where it is, unless it is run with the full path.

From other examples I need to be able to set the path to the directory that QXmlEdit looks to find the file at to $SNAP/opt/qxmledit. If you look at my snapcraft.yaml (and also the qxmledit.desktop file) you will see this is what I did so that the .desktop file could find the icon. I believe that the $SNAP variable will be set at runtime so that the path to the document file will be correct.

Can you add a qmake option to allow setting where QXmlEdit will look for the documentation file? It means that QXmlEdit will need to get the $SNAP environment variable at runtime?

Thanks again for your time and help! Frederick

frederickjh commented 6 years ago

I have decided to release this as a beta version even though the documentation is not working. Here is the Call for testing post on the Snapcraft Forum.

frederickjh commented 5 years ago

@lbellonda I am going to close this issue in favor of issue #2 on the QXmlEdit Snap project. Lets post any further discussion about issues related to snapping QXmlEdit on issues in that issue queue.