unos-repository

APK repository for unos
git clone git://git.finwo.net/misc/unos-repository
Log | Files | Refs | README

test_packaging.sh (2005B)


      1 #!/bin/sh
      2 # Packaging layout assertions: what ends up inside the .apk.
      3 #
      4 # The daemon's own behaviour is tested in the linkd repo. What matters here is
      5 # that the package presents it correctly -- above all the argv[0] symlinks,
      6 # since linkd dispatches on basename(argv[0]) and a plain file instead of a
      7 # symlink turns `ifup` into a daemon launch.
      8 set -eu
      9 HERE=$(cd "$(dirname "$0")" && pwd)
     10 ROOT=$(cd "${HERE}/../.." && pwd)
     11 . "${HERE}/../helpers.sh"
     12 
     13 echo "==> test_packaging: apk contents and symlinks"
     14 
     15 APK=$(newest_apk linkd)
     16 if [ -z "${APK}" ]; then
     17   echo "SKIP: no linkd .apk built yet (run ./mk/build.sh linkd)"
     18   echo "==> test_packaging done"
     19   exit 0
     20 fi
     21 
     22 echo "using $(basename "${APK}")"
     23 
     24 # The built artifact must correspond to what the template currently declares.
     25 # The previous version of this test hardcoded linkd-0.1.0-r4.apk while the
     26 # template had moved to r5: it kept passing against a stale package, and would
     27 # have started silently skipping once r4 was pruned.
     28 want=$(template_pkgver linkd)
     29 case "$(basename "${APK}")" in
     30   "linkd-${want}.apk") echo "PASS: newest .apk matches template revision (${want})" ;;
     31   *)
     32     echo "FAIL: newest .apk is $(basename "${APK}") but template declares ${want}" >&2
     33     echo "      rebuild with ./mk/build.sh linkd" >&2
     34     exit 1 ;;
     35 esac
     36 
     37 listing=$(tar -tvf "${APK}" 2>&1)
     38 
     39 for link in linkctl ifup ifdown ifquery ifreload; do
     40   if printf '%s\n' "${listing}" | grep -q "usr/bin/${link} -> linkd"; then
     41     echo "PASS: ${link} -> linkd"
     42   else
     43     echo "FAIL: usr/bin/${link} is not a symlink to linkd" >&2
     44     printf '%s\n' "${listing}" | grep -E "usr/bin/(${link}|linkd)" | head -5 >&2 || true
     45     exit 1
     46   fi
     47 done
     48 
     49 # The runit service dir has to be present or the daemon never starts on boot.
     50 for f in etc/sv/linkd/run etc/sv/linkd/check etc/sv/linkd/log/run; do
     51   if printf '%s\n' "${listing}" | grep -q "${f}"; then
     52     echo "PASS: ships ${f}"
     53   else
     54     echo "FAIL: missing ${f}" >&2
     55     exit 1
     56   fi
     57 done
     58 
     59 echo "==> test_packaging done"