2017-10-23 19:44:08 +00:00
|
|
|
#!/bin/sh -e
|
aportgen: Gracefully handle old aports_upstream (#1291)
In order to get cross-compilers, we generate a few aports (e.g.
binutils-armhf, gcc-armhf) automatically from Alpine's aports.
pmbootstrap was already able to perform a git checkout of Alpine's
aports repository. But it needed to be manually updated. Otherwise
the `pmbootstrap aportgen` command could actually downgrade the aport
instead of updating it to the current version.
After thinking about adding a dedicated pmbootstrap command for
updating git repositories, I thought it would be better to not open
that can of worms (pmbootstrap as general git wrapper? no thanks).
The solution implemented here compares the upstream aport version of
the git checkout of a certain package (e.g. gcc for gcc-armhf) with the
version in Alpine's binary package APKINDEX. When the aport version is
lower than the binary package version, it shows the user how to update
the git repository with just one command:
pmbootstrap chroot --add=git --user -- \
git -C /mnt/pmbootstrap-git/aports_upstream pull
Changes:
* `pmb.aportgen.core.get_upstream_aport()`: new function, that returns
the absolute path to the upstream aport on disk, after checking the
version of the aport against the binary package.
* Use that new function in pmb.aportgen.gcc and pmb.aportgen.binutils
* New function `pmb.helpers.repo.alpine_apkindex_path()`: updates the
APKINDEX if necessary and returns the absolute path to the APKINDEX.
This code was basically present already, but not as function, so now
we have a bit less overhead there.
* `pmbootstrap chroot`: new `--user` argument
* `pmb.parse.apkbuild`: make pkgname check optional, as it fails with
the official gcc APKBUILD before we modify it (the current APKBUILD
parser is not meant to be perfect, as this would require a full shell
parsing implementation).
* Extended `test_aportgen.py` and enabled it by default in
`testcases_fast.sh`. Previously it was disabled due to traffic
concerns (cloning the aports repo, but then again we do a full KDE
plasma mobile installation in Travis now, so that shouldn't matter
too much).
* `testcases_fast.sh`: With "test_aport_in_sync_with_git" removed
from the disabled-by-default list (left over from timestamp based
rebuilds), there were no more test cases disabled by default. I've
changed it, so now the qemu_running_processes test case is disabled,
and added an `--all` parameter to the script to disable no test
cases. Travis runs with the `--all` parameter while it's useful to
do a quick local test without `--all` in roughly 2 minutes instead of
10.
* `aports/cross/binutils-*`: Fix `_mirror` variable to point to current
default Alpine mirror (so the aportgen testcase runs through).
2018-03-11 14:18:21 +00:00
|
|
|
# usage: testcases_fast.sh [--all]
|
2017-10-23 19:44:08 +00:00
|
|
|
|
2018-07-08 23:06:00 +00:00
|
|
|
# Disable QEMU and aports/upstream compatibility tests
|
|
|
|
# (These run with different CI runners in parallel, see #1610)
|
2018-07-30 22:00:55 +00:00
|
|
|
disabled="aports aports_kde aportgen upstream_compatibility soname_bump qemu_running_processes"
|
aportgen: Gracefully handle old aports_upstream (#1291)
In order to get cross-compilers, we generate a few aports (e.g.
binutils-armhf, gcc-armhf) automatically from Alpine's aports.
pmbootstrap was already able to perform a git checkout of Alpine's
aports repository. But it needed to be manually updated. Otherwise
the `pmbootstrap aportgen` command could actually downgrade the aport
instead of updating it to the current version.
After thinking about adding a dedicated pmbootstrap command for
updating git repositories, I thought it would be better to not open
that can of worms (pmbootstrap as general git wrapper? no thanks).
The solution implemented here compares the upstream aport version of
the git checkout of a certain package (e.g. gcc for gcc-armhf) with the
version in Alpine's binary package APKINDEX. When the aport version is
lower than the binary package version, it shows the user how to update
the git repository with just one command:
pmbootstrap chroot --add=git --user -- \
git -C /mnt/pmbootstrap-git/aports_upstream pull
Changes:
* `pmb.aportgen.core.get_upstream_aport()`: new function, that returns
the absolute path to the upstream aport on disk, after checking the
version of the aport against the binary package.
* Use that new function in pmb.aportgen.gcc and pmb.aportgen.binutils
* New function `pmb.helpers.repo.alpine_apkindex_path()`: updates the
APKINDEX if necessary and returns the absolute path to the APKINDEX.
This code was basically present already, but not as function, so now
we have a bit less overhead there.
* `pmbootstrap chroot`: new `--user` argument
* `pmb.parse.apkbuild`: make pkgname check optional, as it fails with
the official gcc APKBUILD before we modify it (the current APKBUILD
parser is not meant to be perfect, as this would require a full shell
parsing implementation).
* Extended `test_aportgen.py` and enabled it by default in
`testcases_fast.sh`. Previously it was disabled due to traffic
concerns (cloning the aports repo, but then again we do a full KDE
plasma mobile installation in Travis now, so that shouldn't matter
too much).
* `testcases_fast.sh`: With "test_aport_in_sync_with_git" removed
from the disabled-by-default list (left over from timestamp based
rebuilds), there were no more test cases disabled by default. I've
changed it, so now the qemu_running_processes test case is disabled,
and added an `--all` parameter to the script to disable no test
cases. Travis runs with the `--all` parameter while it's useful to
do a quick local test without `--all` in roughly 2 minutes instead of
10.
* `aports/cross/binutils-*`: Fix `_mirror` variable to point to current
default Alpine mirror (so the aportgen testcase runs through).
2018-03-11 14:18:21 +00:00
|
|
|
|
|
|
|
# Optionally enable all test cases
|
|
|
|
if [ "$1" = "--all" ]; then
|
|
|
|
disabled=""
|
|
|
|
else
|
|
|
|
echo "Disabled test case(s): $disabled"
|
|
|
|
echo "Use '$(basename "$0") --all' to enable all test cases."
|
|
|
|
fi
|
2017-10-23 19:44:08 +00:00
|
|
|
|
pmb: fix test suite not running through twice
The test suite needed a `pmbootstrap shutdown` after running through,
before it could successfully run again.
Explanation:
This was caused by `test/test_pkgrel_bump.py`, which creates a
temporary work folder with every subfolder ("chroot_native",
"cache_apk_x86_64", ...) linked to the original work folder except for
the "packages" folder. At the end of the test case,
`pmbootstrap shutdown` gets executed and is expected to umount
everything as usual. But it does not umount anything because of the
symlinks, so `work/chroot_native/mnt/pmbootstrap-packages` points to
the fake packages folder of that test case, even after it is finished.
As a result, any test case that tries to access the packages folder in
the native chroot, will fail until `pmbootstrap shutdown` gets called.
Detailed Changes:
* Umount all folders inside the work folder, even if these are symlinks
* Remove obsolete reference to "disable timestamp based rebuilds" in a
comment in `test/test_pkgrel_bump.py`
* Run `pmbootstrap work_migrate` and `pmbootstrap shutdown` at the
beginning of `test/testcases_fast.sh`, in case the pkgrel_bump test
case was aborted before it could properly shutdown and to make it
more robust in general (user may have changed the mountpoints, work
folder may need to be migrated)
2018-07-14 00:38:33 +00:00
|
|
|
# Make sure that the work folder format is up to date, and that there are no
|
|
|
|
# mounts from aborted test cases (#1595)
|
2018-01-24 20:14:43 +00:00
|
|
|
cd "$(dirname "$0")/.."
|
pmb: fix test suite not running through twice
The test suite needed a `pmbootstrap shutdown` after running through,
before it could successfully run again.
Explanation:
This was caused by `test/test_pkgrel_bump.py`, which creates a
temporary work folder with every subfolder ("chroot_native",
"cache_apk_x86_64", ...) linked to the original work folder except for
the "packages" folder. At the end of the test case,
`pmbootstrap shutdown` gets executed and is expected to umount
everything as usual. But it does not umount anything because of the
symlinks, so `work/chroot_native/mnt/pmbootstrap-packages` points to
the fake packages folder of that test case, even after it is finished.
As a result, any test case that tries to access the packages folder in
the native chroot, will fail until `pmbootstrap shutdown` gets called.
Detailed Changes:
* Umount all folders inside the work folder, even if these are symlinks
* Remove obsolete reference to "disable timestamp based rebuilds" in a
comment in `test/test_pkgrel_bump.py`
* Run `pmbootstrap work_migrate` and `pmbootstrap shutdown` at the
beginning of `test/testcases_fast.sh`, in case the pkgrel_bump test
case was aborted before it could properly shutdown and to make it
more robust in general (user may have changed the mountpoints, work
folder may need to be migrated)
2018-07-14 00:38:33 +00:00
|
|
|
./pmbootstrap.py work_migrate
|
|
|
|
./pmbootstrap.py -q shutdown
|
|
|
|
|
|
|
|
# Make sure we have a valid device (#1128)
|
2018-01-24 20:14:43 +00:00
|
|
|
device="$(./pmbootstrap.py config device)"
|
2018-09-05 05:57:38 +00:00
|
|
|
work="$(./pmbootstrap.py config work)"
|
|
|
|
deviceinfo="$work/cache_git/pmaports/device/device-$device/deviceinfo"
|
2018-01-24 20:14:43 +00:00
|
|
|
if ! [ -e "$deviceinfo" ]; then
|
|
|
|
echo "ERROR: Could not find deviceinfo file for selected device '$device'."
|
|
|
|
echo "Expected path: $deviceinfo"
|
|
|
|
echo "Maybe you have switched to a branch where your device does not exist?"
|
|
|
|
echo "Use 'pmbootstrap config device qemu-amd64' to switch to a valid device."
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2017-10-23 19:44:08 +00:00
|
|
|
# Filter out disabled testcases
|
|
|
|
enabled=""
|
|
|
|
for file in test/test_*.py; do
|
|
|
|
for test in $disabled; do
|
|
|
|
[ "test/test_${test}.py" = "$file" ] && continue 2
|
|
|
|
done
|
|
|
|
enabled="$enabled $file"
|
|
|
|
done
|
|
|
|
|
|
|
|
# Run enabled testcases with coverage enabled
|
2018-06-05 21:45:17 +00:00
|
|
|
# Note: Pytest is called through python so that this is compatible with
|
|
|
|
# running from a venv (e.g. in gitlab CI)
|
2017-10-23 19:44:08 +00:00
|
|
|
# shellcheck disable=SC2086
|
2018-10-25 05:12:18 +00:00
|
|
|
python3 -m pytest -vv -x --cov=pmb $enabled --tb=native
|