From 0e280608ccd5b0ae47f29f68b6d2fb0506dc6cb9 Mon Sep 17 00:00:00 2001 From: Fleshless Builder Date: Tue, 21 Nov 2017 17:41:40 +0300 Subject: [PATCH] put the build script into the makepkg-overlay script --- makepkg-overlay | 33 ++++++++++++++++++++++++++++----- post-receive | 2 +- repo-clean | 1 + repo-sign | 1 + 4 files changed, 31 insertions(+), 6 deletions(-) diff --git a/makepkg-overlay b/makepkg-overlay index 6148bfd..92adefa 100755 --- a/makepkg-overlay +++ b/makepkg-overlay @@ -1,7 +1,27 @@ #!/usr/bin/env bash -cleanup() { - umount "$cnt_dir/rootfs" +buildscript() { + cat <<- EOF + #!/usr/bin/env bash + # The builder user is already created in the rootfs + + export PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin + export LC_ALL=en_US.UTF-8 + + # Network + dhcpcd eth0 + + # Upgrade + pacman -Suy --noconfirm + + # Build dir + mkdir -m777 /buildroot + + # Build the damn thing + cd /buildroot + sudo -u builder git clone "$pkg_url" . + sudo -u builder makepkg -s --noconfirm -L + EOF } wrk_dir='/home/lxc' @@ -11,12 +31,15 @@ pkg_dest=$2 cnt="_makepkg.$$" cnt_dir="$wrk_dir/containers/$cnt" +# Unmount the thing in any case +cleanup() { lxf umount "$cnt"; } trap 'cleanup' INT TERM EXIT -lxf -r builder -i builder new "$cnt" +# Create new container +lxf -r builder -i base new "$cnt" # Add the build script -cp "$wrk_dir/files/buildpackage" "$cnt_dir/rootfs/init" +buildscript > "$cnt_dir/rootfs/init" chmod 755 "$cnt_dir/rootfs/init" # Tell it where to fetch the package @@ -25,7 +48,7 @@ echo "$pkg_url" > "$cnt_dir/rootfs/repo" export PKG_GIT_URL="$pkg_url" # Start the container -lxc-start -n "$cnt" -F; lxc_exit=$? +lxc-start -n "$cnt" -F /init; lxc_exit=$? (( lxc_exit )) && exit "$lxc_exit" # Put the artifacts where asked to diff --git a/post-receive b/post-receive index 0cded9a..02ce922 100755 --- a/post-receive +++ b/post-receive @@ -1,6 +1,6 @@ #!/usr/bin/env bash -PATH+=":/usr/local/bin" +PATH+=":/usr/local/bin:$HOME/.local/bin" self="${PWD##*/}"; self="${self%.git}" self_url="https://pkg.fleshless.org/$self" diff --git a/repo-clean b/repo-clean index c195f3b..55ac22f 100755 --- a/repo-clean +++ b/repo-clean @@ -1,4 +1,5 @@ #!/usr/bin/bash +shopt -s nullglob parse_pkg_filename() { declare filename=$1 diff --git a/repo-sign b/repo-sign index 288eb48..f1297fd 100755 --- a/repo-sign +++ b/repo-sign @@ -1,4 +1,5 @@ #!/usr/bin/bash +shopt -s nullglob for i in *.pkg.*; do if ! [[ "$i" == "${i%.*}.sig" ]]; then