diff options
author | Karel Kočí <cynerd@email.cz> | 2018-09-02 22:55:51 +0200 |
---|---|---|
committer | Karel Kočí <cynerd@email.cz> | 2018-09-02 23:18:50 +0200 |
commit | e753a4d1af740a3cfeb4a4c994395f3a0a5a3c73 (patch) | |
tree | 43f8f15d1309d8b101e6feba431a10fc6aa5d4ae | |
parent | 0f6273a567c504ed4dc631ba18252ea0e16146b0 (diff) | |
download | laminar-cnf-e753a4d1af740a3cfeb4a4c994395f3a0a5a3c73.tar.gz laminar-cnf-e753a4d1af740a3cfeb4a4c994395f3a0a5a3c73.tar.bz2 laminar-cnf-e753a4d1af740a3cfeb4a4c994395f3a0a5a3c73.zip |
alpine-amd64: try to change how we do chroot
-rwxr-xr-x | jobs/alpine-amd64.run | 63 | ||||
-rwxr-xr-x | jobs/alpine-amd64.sh | 55 | ||||
-rwxr-xr-x | scripts/uchroot | 15 |
3 files changed, 63 insertions, 70 deletions
diff --git a/jobs/alpine-amd64.run b/jobs/alpine-amd64.run index 96bfb2b..80e8644 100755 --- a/jobs/alpine-amd64.run +++ b/jobs/alpine-amd64.run @@ -6,68 +6,7 @@ set -e if [ -n "$CLEAN" ]; then echo_stage "Remove root" flock --exclusive "$WORKSPACE/root.lock" uroot rm -rf "$WORKSPACE/root" - exit 0 fi -cat >abuild-system.conf <<EOF -export CFLAGS="-Os -fomit-frame-pointer" -export CXXFLAGS="\$CFLAGS" -export CPPFLAGS="\$CFLAGS" -export LDFLAGS="-Wl,--as-needed" - -export JOBS=4 -export MAKEFLAGS=-j\$JOBS - -USE_COLORS=1 - -SRCDEST=/var/cache/distfiles -REPODEST=\$HOME/packages/ - -CLEANUP="srcdir bldroot pkgdir deps" -ERROR_CLEANUP="bldroot deps" -EOF - export ROOT="$WORKSPACE/root" -# TODO get latest uri from latest-releases.yml file -flock --exclusive "$WORKSPACE/root.lock" /bin/sh -se <<EOF - . utils - if [ ! -d "$ROOT" ]; then - echo_stage "Setting up new root" - wget "http://dl-cdn.alpinelinux.org/alpine/edge/releases/x86_64/alpine-minirootfs-3.8.0-x86_64.tar.gz" -O alpine.tar.gz - gunzip alpine.tar.gz - tar -f alpine.tar --delete ./dev/null - mkdir "$ROOT" - uroot tar -xf alpine.tar -C "$ROOT" - chmod 755 "$ROOT" # This is intentional, tar changes access rights - uchroot "$ROOT" root /bin/sh -sxe <<EEOF - apk update - apk add alpine-sdk lua-aports - adduser -s /bin/sh -D build - addgroup build abuild - mkdir -p /var/cache/distfiles - chgrp abuild /var/cache/distfiles - chmod g+w /var/cache/distfiles -EEOF - uchroot "$ROOT" build:build /bin/sh -sxe <<EEOF - cd && mkdir .abuild - echo 'PACKAGER_PRIVKEY="/home/build/.abuild/key.rsa"' > .abuild/abuild.conf -EEOF - uroot cp ~/alpinelinux.rsa.key "$ROOT/home/build/.abuild/key.rsa" - uchroot "$ROOT" root chown build:build "/home/build/.abuild/key.rsa" - uroot cp ~/alpinelinux.rsa.key.pub "$ROOT/etc/apk/keys/cynerd@email.cz-5b8aeb6d.rsa.pub" - uroot cp abuild-system.conf "$ROOT/etc/abuild.conf" - fi - - echo_stage "Update system" - uchroot "$ROOT" root /bin/sh -ce 'apk update && apk upgrade' - - echo_stage "Update package sources" - git_clone "git@cynerd.cz:alpine-personal-pkgs" "aports" - uroot rm -rf "$ROOT/home/build/aports" - uroot mv aports "$ROOT/home/build/aports" - uchroot "$ROOT" root chown -R build:build /home/build/aports - - echo_stage "Build packages" - # TODO generate list of repositories automatically - uchroot "$ROOT" build:build buildrepo --purge personal hacked -EOF +flock --exclusive "$WORKSPACE/root.lock" "$(readlink -f "$0" | sed 's/\.run$/\.sh/')" diff --git a/jobs/alpine-amd64.sh b/jobs/alpine-amd64.sh new file mode 100755 index 0000000..e5a6df3 --- /dev/null +++ b/jobs/alpine-amd64.sh @@ -0,0 +1,55 @@ +#!/bin/sh +. utils + +# TODO get latest uri from latest-releases.yml file + +if [ ! -d "$ROOT" ]; then + echo_stage "Setting up new root" + wget "http://dl-cdn.alpinelinux.org/alpine/edge/releases/x86_64/alpine-minirootfs-3.8.0-x86_64.tar.gz" -O alpine.tar.gz + gunzip alpine.tar.gz + tar -f alpine.tar --delete ./dev/null + mkdir "$ROOT" + uroot tar -xf alpine.tar -C "$ROOT" + chmod 755 "$ROOT" # This is intentional, tar changes access rights + uchroot "$ROOT" root /bin/sh <<EOF + set -ex + apk update + apk add alpine-sdk lua-aports + adduser -s /bin/sh -D -h /build build + addgroup build abuild + mkdir -p /var/cache/distfiles + chgrp abuild /var/cache/distfiles + chmod g+w /var/cache/distfiles +EOF + uchroot "$ROOT" build 'mkdir .abuild && echo "PACKAGER_PRIVKEY=\"/build/.abuild/cynerd@email.cz-5b8aeb6d.rsa\"" > .abuild/abuild.conf' + uroot cp ~/alpinelinux.rsa.key "$ROOT/build/.abuild/cynerd@email.cz-5b8aeb6d.rsa" + uchroot "$ROOT" root 'chown build:build "/build/.abuild/cynerd@email.cz-5b8aeb6d.rsa"' + uroot cp ~/alpinelinux.rsa.key.pub "$ROOT/etc/apk/keys/cynerd@email.cz-5b8aeb6d.rsa.pub" + uroot cat >"$ROOT/etc/abuild.conf" <<EOF +export CFLAGS="-Os -fomit-frame-pointer" +export CXXFLAGS="\$CFLAGS" +export CPPFLAGS="\$CFLAGS" +export LDFLAGS="-Wl,--as-needed" + +export JOBS=4 +export MAKEFLAGS=-j\$JOBS + +USE_COLORS=1 + +SRCDEST=/var/cache/distfiles +REPODEST=\$HOME/packages/ + +CLEANUP="srcdir bldroot pkgdir deps" +ERROR_CLEANUP="bldroot deps" +EOF +fi + +echo_stage "Update system" +uchroot "$ROOT" root 'apk update && apk upgrade' + +echo_stage "Get packages source" +git_clone "git@cynerd.cz:alpine-personal-pkgs" "$ROOT/aports" +uchroot "$ROOT" root "rm -rf /build/aports && chown -R build:build /aports && mv /aports /build/aports" + +echo_stage "Build packages" +uchroot "$ROOT" build buildrepo --purge $(ls "$ROOT/build/aports") diff --git a/scripts/uchroot b/scripts/uchroot index 6aa76b2..b11981a 100755 --- a/scripts/uchroot +++ b/scripts/uchroot @@ -1,7 +1,7 @@ #!/bin/sh set -e -[ $# -ge 2 ] || { - echo "Usage: uchroot ROOT USER[:GROUP] [CMD] [ARG].." >&2 +[ $# -ge 1 ] || { + echo "Usage: uchroot ROOT [USER] [CMD]" >&2 exit 1 } @@ -11,8 +11,10 @@ fi ############################################################### ROOT="$1" -USERSPEC="$2" +USR="${2:-root}" shift 2 +[ $# -lt 1 ] && CMD="" || CMD="-c '$@'" + [ -d "$ROOT" ] || { echo "There is no such directory: $ROOT" >&2 exit 1 @@ -22,14 +24,11 @@ shift 2 exit 1 } - +mount --rbind "$ROOT" "$ROOT" mount -t proc none "$ROOT/proc" mount --rbind /dev "$ROOT/dev" mount --rbind /sys "$ROOT/sys" cp -f /etc/resolv.conf "$ROOT/etc/resolv.conf" cp -f /etc/hosts "$ROOT/etc/hosts" -if [ $# -lt 1 ]; then - set "/bin/sh" -fi -exec chroot --userspec="$USERSPEC" "$ROOT" "$@" +exec chroot "$ROOT" /bin/sh -c ". /etc/profile && exec su $CMD -l $USR" "$0" |