put the build script into the makepkg-overlay script

This commit is contained in:
Fleshless Builder 2017-11-21 17:41:40 +03:00
parent c2b5d134a4
commit 0e280608cc
4 changed files with 31 additions and 6 deletions

View File

@ -1,7 +1,27 @@
#!/usr/bin/env bash #!/usr/bin/env bash
cleanup() { buildscript() {
umount "$cnt_dir/rootfs" 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' wrk_dir='/home/lxc'
@ -11,12 +31,15 @@ pkg_dest=$2
cnt="_makepkg.$$" cnt="_makepkg.$$"
cnt_dir="$wrk_dir/containers/$cnt" cnt_dir="$wrk_dir/containers/$cnt"
# Unmount the thing in any case
cleanup() { lxf umount "$cnt"; }
trap 'cleanup' INT TERM EXIT 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 # Add the build script
cp "$wrk_dir/files/buildpackage" "$cnt_dir/rootfs/init" buildscript > "$cnt_dir/rootfs/init"
chmod 755 "$cnt_dir/rootfs/init" chmod 755 "$cnt_dir/rootfs/init"
# Tell it where to fetch the package # Tell it where to fetch the package
@ -25,7 +48,7 @@ echo "$pkg_url" > "$cnt_dir/rootfs/repo"
export PKG_GIT_URL="$pkg_url" export PKG_GIT_URL="$pkg_url"
# Start the container # Start the container
lxc-start -n "$cnt" -F; lxc_exit=$? lxc-start -n "$cnt" -F /init; lxc_exit=$?
(( lxc_exit )) && exit "$lxc_exit" (( lxc_exit )) && exit "$lxc_exit"
# Put the artifacts where asked to # Put the artifacts where asked to

View File

@ -1,6 +1,6 @@
#!/usr/bin/env bash #!/usr/bin/env bash
PATH+=":/usr/local/bin" PATH+=":/usr/local/bin:$HOME/.local/bin"
self="${PWD##*/}"; self="${self%.git}" self="${PWD##*/}"; self="${self%.git}"
self_url="https://pkg.fleshless.org/$self" self_url="https://pkg.fleshless.org/$self"

View File

@ -1,4 +1,5 @@
#!/usr/bin/bash #!/usr/bin/bash
shopt -s nullglob
parse_pkg_filename() { parse_pkg_filename() {
declare filename=$1 declare filename=$1

View File

@ -1,4 +1,5 @@
#!/usr/bin/bash #!/usr/bin/bash
shopt -s nullglob
for i in *.pkg.*; do for i in *.pkg.*; do
if ! [[ "$i" == "${i%.*}.sig" ]]; then if ! [[ "$i" == "${i%.*}.sig" ]]; then