flatpak-builder: 1.0.6 -> 1.0.7 (#62413)

flatpak-builder: 1.0.6 -> 1.0.7
This commit is contained in:
Jan Tojnar 2019-06-16 01:39:09 +02:00 committed by GitHub
commit c96ee919cf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 170 additions and 3 deletions

View File

@ -83,6 +83,7 @@ in
fish = handleTest ./fish.nix {};
flannel = handleTestOn ["x86_64-linux"] ./flannel.nix {};
flatpak = handleTest ./flatpak.nix {};
flatpak-builder = handleTest ./flatpak-builder.nix {};
fsck = handleTest ./fsck.nix {};
fwupd = handleTestOn ["x86_64-linux"] ./fwupd.nix {}; # libsmbios is unsupported on aarch64
gdk-pixbuf = handleTest ./gdk-pixbuf.nix {};

View File

@ -0,0 +1,19 @@
# run installed tests
import ./make-test.nix ({ pkgs, ... }:
{
name = "flatpak-builder";
meta = {
maintainers = pkgs.flatpak-builder.meta.maintainers;
};
machine = { pkgs, ... }: {
services.flatpak.enable = true;
environment.systemPackages = with pkgs; [ gnome-desktop-testing flatpak-builder ] ++ flatpak-builder.installedTestsDependencies;
virtualisation.diskSize = 2048;
};
testScript = ''
$machine->succeed("gnome-desktop-testing-runner -d '${pkgs.flatpak-builder.installedTests}/share' --timeout 3600");
'';
})

View File

@ -24,6 +24,9 @@
, flatpak
, gitMinimal
, glib
, glibcLocales
, gnumake
, gnupg
, gnutar
, json-glib
, libcap
@ -32,20 +35,23 @@
, libyaml
, ostree
, patch
, python2
, rpm
, unzip
}:
let
version = "1.0.6";
installed_testdir = "${placeholder "installedTests"}/libexec/installed-tests/flatpak-builder";
installed_test_metadir = "${placeholder "installedTests"}/share/installed-tests/flatpak-builder";
version = "1.0.7";
in stdenv.mkDerivation rec {
name = "flatpak-builder-${version}";
outputs = [ "out" "doc" "man" ];
outputs = [ "out" "doc" "man" "installedTests" ];
src = fetchurl {
url = "https://github.com/flatpak/flatpak-builder/releases/download/${version}/${name}.tar.xz";
sha256 = "1fw9lzf9cy3fnnvn9q3g0schxcj7kaj6kjijhrmcmsfcnzbjlmrv";
sha256 = "04z9i2kahj4mffzq8ny0jvc4g3ah8kv8ilqv2rx9r1l8fhbq30jj";
};
nativeBuildInputs = [
@ -95,8 +101,38 @@ in stdenv.mkDerivation rec {
eustrip = "${elfutils}/bin/eu-strip";
euelfcompress = "${elfutils}/bin/eu-elfcompress";
})
# The test scripts in Flatpak repo were updated so we are basing
# this on our patch for Flatpak 0.99.
(substituteAll {
src = ./fix-test-paths.patch;
inherit glibcLocales python2;
})
];
configureFlags = [
"--enable-installed-tests"
];
makeFlags = [
"installed_testdir=${installed_testdir}"
"installed_test_metadir=${installed_test_metadir}"
];
# Some scripts used by tests need to use shebangs that are available in Flatpak runtimes.
dontPatchShebangs = true;
# Installed tests
postFixup = ''
for file in ${installed_testdir}/{test-builder.sh,test-builder-python.sh}; do
patchShebangs $file
done
'';
passthru = {
installedTestsDependencies = [ gnupg ostree python2 gnumake ];
};
meta = with stdenv.lib; {
description = "Tool to build flatpaks from source";
homepage = https://flatpak.org/;

View File

@ -0,0 +1,111 @@
--- a/tests/libtest.sh
+++ b/tests/libtest.sh
@@ -301,7 +301,7 @@
}
skip_without_python2 () {
- if ! test -f /usr/bin/python2 || ! /usr/bin/python2 -c "import sys; sys.exit(0 if sys.version_info >= (2, 7) else 1)" ; then
+ if ! test -f @python2@/bin/python2 || ! @python2@/bin/python2 -c "import sys; sys.exit(0 if sys.version_info >= (2, 7) else 1)" ; then
echo "1..0 # SKIP this test requires /usr/bin/python2 (2.7) support"
exit 0
fi
--- a/tests/make-test-runtime.sh
+++ b/tests/make-test-runtime.sh
@@ -26,6 +26,7 @@
PATH="$PATH:/usr/sbin:/sbin"
# Add bash and dependencies
+mkdir -p ${DIR}/nix/store
mkdir -p ${DIR}/usr/bin
mkdir -p ${DIR}/usr/lib
ln -s ../lib ${DIR}/usr/lib64
@@ -35,73 +36,28 @@
else
cp `which ldconfig` ${DIR}/usr/bin
fi
-LIBS=`mktemp`
-BINS=`mktemp`
-
-add_bin() {
- local f=$1
- shift
-
- if grep -qFe "${f}" $BINS; then
- # Already handled
- return 0
- fi
-
- echo $f >> $BINS
-
- # Add library dependencies
- (ldd "${f}" | sed "s/.* => //" | awk '{ print $1}' | grep ^/ | sort -u -o $LIBS $LIBS -) || true
-
- local shebang=$(sed -n '1s/^#!\([^ ]*\).*/\1/p' "${f}")
- if [ x$shebang != x ]; then
- add_bin "$shebang"
- fi
-}
for i in $@; do
- I=`which $i`
- add_bin $I
- if test $i == python2; then
- mkdir -p ${DIR}/usr/lib/python2.7/lib-dynload
- # This is a hardcoded minimal set of modules we need in the current tests.
- # Pretty hacky stuff. Add modules as needed.
- PYDIR=/usr/lib/python2.7
- if test -d /usr/lib64/python2.7; then PYDIR=/usr/lib64/python2.7; fi
- for py in site os stat posixpath genericpath warnings \
- linecache types UserDict abc _abcoll \
- _weakrefset copy_reg traceback sysconfig \
- re sre_compile sre_parse sre_constants \
- _sysconfigdata ; do
- cp ${PYDIR}/$py.py ${DIR}/usr/lib/python2.7
- done
- # These might not exist, depending how Python was configured; and the
- # part after ${so} might be "module" or ".x86_64-linux-gnu" or
- # something else
- for so in _locale strop ; do
- cp ${PYDIR}/lib-dynload/${so}*.so ${DIR}/usr/lib/python2.7/lib-dynload || :
- done
- for plat in $( cd ${PYDIR} && echo plat-* ); do
- test -e ${PYDIR}/${plat} || continue
- mkdir -p ${DIR}/usr/lib/python2.7/${plat}
- cp ${PYDIR}/${plat}/*.py ${DIR}/usr/lib/python2.7/${plat}/
- done
- fi
-done
-for i in `cat $BINS`; do
- echo Adding binary $i 1>&2
- cp "$i" ${DIR}/usr/bin/
-done
-for i in `cat $LIBS`; do
- echo Adding library $i 1>&2
- cp "$i" ${DIR}/usr/lib/
+ I=$(readlink -f $(which $i))
+ requisites=$(nix-store --query --requisites "$I")
+ for r in $requisites; do
+ # a single store item can be needed by multiple paths, no need to copy it again
+ if [ ! -e ${DIR}/$r ]; then
+ cp -r $r ${DIR}/$r
+ fi
+ done
+ ln -s $I ${DIR}/usr/bin/$i
done
ln -s bash ${DIR}/usr/bin/sh
-# We copy the C.UTF8 locale and call it en_US. Its a bit of a lie, but
-# the real en_US locale is often not available, because its in the
-# local archive.
+mv ${DIR}/nix/store ${DIR}/usr/store # files outside /usr are not permitted, we will have to replace /nix/store with /usr/store
+chmod -R u+w ${DIR} # nix store has read-only directories which would cause problems during clean-up, files need to be writable for sed
+find ${DIR} -type f -print0 | xargs -0 sed -i 's~/nix/store/~/usr/store/~g' # replace hardcoded paths
+find ${DIR} -type l | xargs -I '{}' sh -c 'tg="$(readlink "$1")"; newtg="${tg#/nix/store/}"; if [ "$tg" != "$newtg" ]; then ln -fs "/usr/store/$newtg" "$1"; fi' -- '{}' # replace symlink targets
+
+# We copy the whole locale archive because we do not have C.UTF8 locale
mkdir -p ${DIR}/usr/lib/locale/
-cp -r /usr/lib/locale/C.* ${DIR}/usr/lib/locale/en_US
+cp @glibcLocales@/lib/locale/locale-archive ${DIR}/usr/lib/locale/locale-archive
if [ x$COLLECTION_ID != x ]; then
collection_args=--collection-id=${COLLECTION_ID}