From d3fcb9b4ee817bafe7b8b1a88d966c9f7187eed9 Mon Sep 17 00:00:00 2001 From: fbt Date: Sat, 27 Feb 2021 02:47:54 +0300 Subject: [PATCH] new builder stuff Signed-off-by: fbt --- lxf | 70 ------------------------------------------------ makepkg-overlay | 69 ----------------------------------------------- pkgbuilder | 6 ++--- repo-clean | 2 +- repo-maintenance | 1 + 5 files changed, 5 insertions(+), 143 deletions(-) delete mode 100755 lxf delete mode 100755 makepkg-overlay diff --git a/lxf b/lxf deleted file mode 100755 index 953582f..0000000 --- a/lxf +++ /dev/null @@ -1,70 +0,0 @@ -#!/usr/bin/env bash - -mkconf() { - for i in "${includes[@]}"; do - echo "lxc.include = $lxf_conf_dir/$i.conf" - done - - echo "lxc.rootfs.path = $lxf_cont_dir/$cont_name/rootfs" - echo "lxc.uts.name = $cont_name" -} - -mount_cont() { - ov-mount -n "$cont_name" "$rootfs" "$cont_dir/rootfs" -} - -lxf_conf_dir='/etc/lxf/conf' -lxf_cont_dir='/var/lib/lxf/cont' -lxf_rootfs_dir='/var/lib/lxf/fs' - -[[ -f '/etc/lxf.conf' ]] && source '/etc/lxf.conf' - -while (( $# )); do - case $1 in - (-i) includes+=( "$2" ); shift;; - (-r) rootfs="$2"; shift;; - - (--cont-dir) lxf_cont_dir=$2; shift;; - (--conf-dir) lxf_conf_dir=$2; shift;; - - (--) shift; break;; - (-*) echo "Unknown key: $1" >&2: exit 1;; - (*) break;; - esac - - shift -done - - -action=$1; shift; [[ $action ]] || exit 1 -cont_name=$1; shift; [[ $cont_name ]] || exit 1 - -cont_dir="$lxf_cont_dir/$cont_name" - -case $action in - (create|new) - [[ "$rootfs" ]] || exit 1 - rootfs="$lxf_rootfs_dir/$rootfs" - - [[ -d "$cont_dir" ]] && { - printf 'Container already exists: %s\n' "$cont_dir" >&2 - exit 1 - } - - mkdir -p "$cont_dir" || exit $? - - mkconf > "$cont_dir/config" - mount_cont - ;; - - (mount) - mountpoint -q "$cont_dir/rootfs" && { - printf 'Container already mounted: %s\n' "$cont_dir/rootfs" >&2 - exit 1 - } - - mount_cont - ;; - - (umount) umount "$cont_dir/rootfs";; -esac diff --git a/makepkg-overlay b/makepkg-overlay deleted file mode 100755 index 07d2fd1..0000000 --- a/makepkg-overlay +++ /dev/null @@ -1,69 +0,0 @@ -#!/usr/bin/env bash -# Depends on lxf -shopt -s nullglob - -cleanup() { lxf umount "$cnt"; } - -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 - chown builder:builder /buildroot - - # Build the damn thing - cd /buildroot - sudo -u builder git clone "$pkg_url" . - sudo -u builder makepkg -s --noconfirm -L - EOF -} - -# Config -wrk_dir='/home/lxc' - -# Parameters -pkg_url=$1 -pkg_dest=$2 -cnt="_makepkg.$$" -cnt_dir="$wrk_dir/containers/$cnt" - -# Create new container -lxf -r builder -i base new "$cnt" || exit $? - -# Unmount the thing in any case -trap 'cleanup' INT TERM EXIT - -# Add the build script -buildscript > "$cnt_dir/rootfs/init" -chmod 755 "$cnt_dir/rootfs/init" - -# Start the container -lxc-start -n "$cnt" -F /init || exit $? - -# Put the artifacts where asked to -[[ "$pkg_dest" ]] && { - artifacts=( "$cnt_dir/rootfs/buildroot/"*.pkg.* ) - - for i in "${artifacts[@]}"; do - i_name="${i##*/}" - - printf 'Found artifact: %s\n' "$i_name" - - if [[ -f "$pkg_dest/$i_name" ]]; then - echo "$pkg_dest/$i_name already exists, not overwriting." - else - cp -vn "$i" "$pkg_dest" - fi - done -} diff --git a/pkgbuilder b/pkgbuilder index 98ec586..72aae09 100755 --- a/pkgbuilder +++ b/pkgbuilder @@ -2,7 +2,7 @@ err() { printf '%s\n' "$*" >&2; } -build_remote() { sudo makepkg-overlay "$@"; } +build_remote() { sudo makepkg-docker "$@"; } cleanup() { rm -f "$lockfile"; } lock() { @@ -44,11 +44,11 @@ while (($#>1)); do mkdir -p "$wrkdir/${repo_path%$repo_name}" git clone "$pkg_repo" "$repo_local" - build_remote "$pkg_repo" "$pkg_dest" + build_remote "$pkg_dest" "$pkg_repo" else git -C "$repo_local" remote update if git -C "$repo_local" status --porcelain -bu | grep -q behind; then - build_remote "$pkg_repo" "$pkg_dest" + build_remote "$pkg_dest" "$pkg_repo" git -C "$repo_local" pull fi fi diff --git a/repo-clean b/repo-clean index 55ac22f..561c3ad 100755 --- a/repo-clean +++ b/repo-clean @@ -27,7 +27,7 @@ is_latest() { _pacsort() { declare i - for i in *.pkg.tar.xz; do + for i in *.pkg.tar.xz *.pkg.tar.zst; do printf '%s\n' "$i" done | pacsort -f } diff --git a/repo-maintenance b/repo-maintenance index 7418a35..cca4567 100755 --- a/repo-maintenance +++ b/repo-maintenance @@ -34,6 +34,7 @@ for f in import/*; do f_name="${f##*/}" if [[ -f "$f_name" ]]; then printf 'Package already exists: %s, not overwriting\n' "$f_name" >&2 + rm -vf "$f" else mv -vf "$f" ./ new_pkgs+=( "$f_name" )