#6 flatpak-module local-build doesn't apply patches
Opened 5 months ago by zlopez. Modified 3 months ago

I'm trying to build keepassxc flatpak using flatpak-module-tools and I'm ending up with no patch applied.

Spec file snip:

Name:           keepassxc
Version:        2.5.2
Release:        1%{?dist}
Summary:        Cross-platform password manager
License:        Boost and BSD and CC0 and GPLv3 and LGPLv2 and LGPLv2+ and LGPLv3+ and Public Domain
URL:            http://www.keepassxc.org/
Source0:        keepassxc-%{version}-src.tar.xz

Patch1:         0001-command-wrapper-flatpak.patch
...
%if 0%{?flatpak}
install -Dm755 -t %{_bindir} command-wrapper.sh
%endif

The build itself fails on install -Dm755 -t %{_bindir} command-wrapper.sh because this file should be created by patch. Here is the exact error from build log:

DEBUG: + install -Dm755 -t /app/bin command-wrapper.sh
ld DEBUG: install: cannot stat 'command-wrapper.sh': No such file or directory
DEBUG: error: Bad exit status from /var/tmp/rpm-tmp.PhvEuM (%install)
DEBUG: RPM build errors:
DEBUG:     Bad exit status from /var/tmp/rpm-tmp.PhvEuM (%install)
DEBUG: Child return code was: 1
INFO: EXCEPTION: [Error()]
Traceback (most recent call last):
  File "/usr/lib/python3.7/site-packages/mockbuild/trace_decorator.py", line 95, in trace
    result = func(*args, **kw)
  File "/usr/lib/python3.7/site-packages/mockbuild/util.py", line 746, in do_with_status
    raise exception.Error("Command failed: \n # %s\n%s" % (command, output), child.returncode)
mockbuild.exception.Error: Command failed:
 # bash --login -c /usr/bin/rpmbuild -bb --target x86_64 --nodeps /builddir/build/SPECS/keepassxc.spec

Certainly many patches do get successfully applied - so I'm not sure what's going on here. Can you put a source RPM somewhere?

I would have a preference for doing this like:

Source1: command-wrapper.sh
...
install -Dm755 -t %{_bindir} %{SOURCE1}

so that command-wrapper.sh is directly in the git repo, and not as a patch, but that's style - creating a file with patching should work as well.

I tried your advice and got this:

DEBUG: install: cannot create regular file '/app/bin/command-wrapper.sh': Permission denied
DEBUG: error: Bad exit status from /var/tmp/rpm-tmp.sROddv (%install)
DEBUG:     Bad exit status from /var/tmp/rpm-tmp.sROddv (%install)
DEBUG: RPM build errors:
DEBUG: Child return code was: 1
INFO: EXCEPTION: [Error()]
Traceback (most recent call last):
  File "/usr/lib/python3.7/site-packages/mockbuild/trace_decorator.py", line 95, in trace
    result = func(*args, **kw)
  File "/usr/lib/python3.7/site-packages/mockbuild/util.py", line 746, in do_with_status
    raise exception.Error("Command failed: \n # %s\n%s" % (command, output), child.returncode)
mockbuild.exception.Error: Command failed: 
 # bash --login -c /usr/bin/rpmbuild -bb --target x86_64 --nodeps /builddir/build/SPECS/keepassxc.spec

Finish: rpmbuild keepassxc-2.5.3-2.module+f31+2+6de7f721.src.rpm
Finish: build phase for keepassxc-2.5.3-2.module+f31+2+6de7f721.src.rpm

In the spec I have this:

Source1:        command-wrapper.sh
...
install -Dm755 -t %{_bindir} %{SOURCE1}

A little confused - how did you get to this error, if the download of the keepassxc sources didn't work? Is this using 'flatpak-module local-build' or doing a manual build?

I'm using flatpak-module local-build and I have the keepassxc sources downloaded locally in the repo and using local source for keepassxc.

Source0:        keepassxc-%{version}-src.tar.xz

@otaylor After trying the advice you gave me on IRC:

install -Dm755 -t %{buildroot}%{_bindir} %{SOURCE1}

I'm getting this:

DEBUG: + install -D -m 644 -p x-keepassxc.desktop /builddir/build/BUILDROOT/keepassxc-2.5.3-2.module+f31+2+e3047473.x86_64/app/share/mimelnk/application/x-keepassxc.desktop
DEBUG: + install -Dm755 -t /app/bin /builddir/build/SOURCES/command-wrapper.sh
DEBUG: install: cannot create regular file '/app/bin/command-wrapper.sh': Permission denied
DEBUG: RPM build errors:
DEBUG: error: Bad exit status from /var/tmp/rpm-tmp.PkyR4S (%install)
DEBUG:     Bad exit status from /var/tmp/rpm-tmp.PkyR4S (%install)
DEBUG: Child return code was: 1
INFO: EXCEPTION: [Error()]
Traceback (most recent call last):
  File "/usr/lib/python3.7/site-packages/mockbuild/trace_decorator.py", line 95, in trace
    result = func(*args, **kw)
  File "/usr/lib/python3.7/site-packages/mockbuild/util.py", line 746, in do_with_status
    raise exception.Error("Command failed: \n # %s\n%s" % (command, output), child.returncode)
mockbuild.exception.Error: Command failed: 
 # bash --login -c /usr/bin/rpmbuild -bb --target x86_64 --nodeps /builddir/build/SPECS/keepassxc.spec

The DEBUG output doesn't show the %{buildroot} directory on the install line. Are you sure you are using the new specfile? You used to have to commit changes in a local git checkout of a package directory for them to be picked up by module-build-service - I'm not sure if that's still true with the latest module-build-service changes, but certainly I'd try that. When in doubt, add something to the spec file, like 'echo "HERE I AM"' to make sure that your spec file changes are actually begin seen.

You were right, I forgot to commit changes. Now the flatpak is built and installed, but I'm hitting the issue I had in past, the command-wrapper.sh has wrong permissions:

$> flatpak run --user --command=sh org.keepassxc.KeePassXC
[📦 org.keepassxc.KeePassXC keepassxc]$ ls -l /app/bin/command-wrapper.sh 
-rw-r--r--. 2 zlopez zlopez 1004 Jan  1  1970 /app/bin/command-wrapper.sh

But in the keepassxc.spec you can see, that I'm installing it with 755:

install -Dm755 -t %{buildroot}%{_bindir} %{SOURCE1}

This looks like a flatpak-module-tools issue to me.

This looks like a flatpak-module-tools issue to me.

Hundreds of different rpm's have been built successfully with flatpak-module-tools and the local build mode of module-build-service. I would really make the assumption that problems you are hitting are not flatpak-module-tools / MBS problems until proven otherwise :-)

I'm not immediately seeing hte problem with the install command above.
* Can you add '[-x %{buildroot}%{_bindir}/command-wrapper.sh] || (echo NOT EXECUTABLE
&& false) to your spec file temporarily (and commit) - that should cause the build to fail if the install command didn't work as expected.
* If that passes, can you find the RPM in ~/modulebuild/builds/module-keepassxc-<most-recent>, and check ' rpm2cpio <rpm> | cpio -tv' and check the permissions there to see if something is going bad in container creation.

@otaylor I tried adding '[-x %{buildroot}%{_bindir}/command-wrapper.sh] || (echo NOT EXECUTABLE && false) after

%if 0%{?flatpak}
install -Dm755 -t %{buildroot}%{_bindir} %{SOURCE1}
%endif

And it failed on the check:

DEBUG: + install -Dm755 -t /builddir/build/BUILDROOT/keepassxc-2.5.3-2.module+f31+2+e7432ecf.x86_64/app/bin /builddir/build/SOURCES/command-wrapper.sh
DEBUG: + '[-x' '/builddir/build/BUILDROOT/keepassxc-2.5.3-2.module+f31+2+e7432ecf.x86_64/app/bin/command-wrapper.sh]'
DEBUG: /var/tmp/rpm-tmp.AmZgJW: line 90: [-x: command not found
DEBUG: + echo NOT EXECUTABLE
DEBUG: NOT EXECUTABLE
DEBUG: + false
DEBUG: error: Bad exit status from /var/tmp/rpm-tmp.AmZgJW (%install)
DEBUG: RPM build errors:
DEBUG:     Bad exit status from /var/tmp/rpm-tmp.AmZgJW (%install)
DEBUG: Child return code was: 1
INFO: EXCEPTION: [Error()]
Traceback (most recent call last):
  File "/usr/lib/python3.7/site-packages/mockbuild/trace_decorator.py", line 95, in trace
    result = func(*args, **kw)
  File "/usr/lib/python3.7/site-packages/mockbuild/util.py", line 746, in do_with_status
    raise exception.Error("Command failed: \n # %s\n%s" % (command, output), child.returncode)
mockbuild.exception.Error: Command failed: 
 # bash --login -c /usr/bin/rpmbuild -bb --target x86_64 --nodeps /builddir/build/SPECS/keepassxc.spec

EDIT: I noticed the fail is on my side. I forgot the space in bash check. So I fixed this and tried again, the flatpak was build this time.
So I tried to check the rpm with rpm2cpio and here is the result:

$ ~/modulebuild/builds/module-keepassxc-master-3120200218080131/results/keepassxc-2.5.3-2.module+f31+2+9bb3d9f4.x86_64.rpm  | cpio -tv
-rw-r--r--   1 root     root         1004 Feb 18 09:37 ./app/bin/command-wrapper.sh

As you can see, the file is not executable.

@otaylor Do you need more info, or is the above enough?

Login to comment on this ticket.

Metadata