From 8e6d6e5f316ae55bcbec2ff2bae45ad8aa331ac3 Mon Sep 17 00:00:00 2001 From: Alex Butler Date: Mon, 29 Jan 2018 19:40:18 +0000 Subject: [PATCH] Use /var/lib/aurto-builder chroot container --- LICENSE | 22 +++++++++++++++ bin/aurto | 5 ++-- install/aurto.install | 65 ------------------------------------------- lib/check-aurto-git | 5 ++-- lib/update-aurto | 4 +-- makefile | 2 +- 6 files changed, 29 insertions(+), 74 deletions(-) create mode 100644 LICENSE delete mode 100755 install/aurto.install diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..1e947eb --- /dev/null +++ b/LICENSE @@ -0,0 +1,22 @@ +Copyright (c) 2018 Alex Butler + +MIT License + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/bin/aurto b/bin/aurto index 74e6903..60a13bf 100755 --- a/bin/aurto +++ b/bin/aurto @@ -5,9 +5,8 @@ command=${1:-} arg1=${2:-} if [ "$command" == "add" ] && [ -n "$arg1" ]; then - echo "aurto: Running: \`aursync --no-view --rmdeps --no-confirm --chroot --repo=aurto ${*:2}\`" >&2 - # TODO use -M /usr/liv/aurto/aurto-makepkg.conf - aursync --no-view --rmdeps --no-confirm --chroot --repo=aurto "${@:2}" + echo "aurto: Running: \`aursync --no-view --rmdeps --no-confirm -C /var/lib/aurto-builder --repo=aurto ${*:2}\`" >&2 + aursync --no-view --rmdeps --no-confirm -C /var/lib/aurto-builder --repo=aurto "${@:2}" elif [ "$command" == "remove" ] && [ -n "$arg1" ]; then removed="" for pkg in "${@:2}"; do diff --git a/install/aurto.install b/install/aurto.install deleted file mode 100755 index 6ac9bd4..0000000 --- a/install/aurto.install +++ /dev/null @@ -1,65 +0,0 @@ -#!/usr/bin/env bash - -set -eu -user="${SUDO_USER:-$USER}" - -function initialised { - grep -q '^Include = /etc/pacman.d/aurto$' /etc/pacman.conf -} - -post_install() { - if initialised; then - echo 'Already initialised' >&2 - exit 0 - fi - - echo "aurto: Initialising for user: $user" - echo "$user" > /usr/lib/aurto/user - chmod 700 /usr/lib/aurto/user - - echo 'aurto: Adding include /etc/pacman.d/aurto to pacman.conf' >&2 - cp /etc/pacman.conf /etc/pacman.conf.aurto-backup - echo -e "# aurto repo\\nInclude = /etc/pacman.d/aurto" >> /etc/pacman.conf - - install -d /var/cache/pacman/aurto -o "$user" - sudo -u "$user" repo-add /var/cache/pacman/aurto/aurto.db.tar 2>/dev/null - - echo 'aurto: Adding passwordless use of arch-nspawn, mkarchroot, makechrootpkg, aurbuild_chroot' >&2 - cp /etc/sudoers /etc/sudoers.aurto-backup - echo "## aurto rules -%$user ALL=(ALL) NOPASSWD: /usr/bin/arch-nspawn -%$user ALL=(ALL) NOPASSWD: /usr/bin/mkarchroot -%$user ALL=(ALL) NOPASSWD:SETENV: /usr/bin/makechrootpkg -%$user ALL=(ALL) NOPASSWD:SETENV: /usr/bin/aurbuild_chroot -## /aurto rules" >> /etc/sudoers - - echo 'aurto: Adding systemd timer update tasks' >&2 - systemctl enable --now /usr/lib/systemd/system/check-aurto-git-trigger.timer - systemctl enable --now /usr/lib/systemd/system/update-aurto.timer -} - -pre_remove() { - if ! initialised; then - exit 0 - fi - - echo 'aurto: Removing systemd timer update tasks' >&2 - systemctl disable --now check-aurto-git-trigger.timer - systemctl disable --now update-aurto.timer -} - -post_remove() { - if ! initialised; then - exit 0 - fi - - echo 'aurto: Removing include from pacman.conf' >&2 - sed -i '/^Include = \/etc\/pacman.d\/aurto$/d' /etc/pacman.conf - sed -i '/^# aurto repo$/d' /etc/pacman.conf - - echo 'aurto: Removing /var/cache/pacman/aurto' >&2 - rm -rf /var/cache/pacman/aurto - - echo 'aurto: Removing aurto rules from /etc/sudoers' >&2 - sed -i '/^## aurto rules$/,/^## \/aurto rules$/d' /etc/sudoers -} diff --git a/lib/check-aurto-git b/lib/check-aurto-git index 1ff91c3..f1954b9 100755 --- a/lib/check-aurto-git +++ b/lib/check-aurto-git @@ -4,19 +4,18 @@ set -u SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" -user=$(cat /usr/lib/aurto/user) command -v aurfetch >/dev/null 2>&1 || { echo >&2 "aurfetch not installed. Aborting."; exit 1; } function check_auto_updates { for dir in *; do if [[ -d $dir ]] && pacman -Qq "$dir" >/dev/null 2>&1; then - cd "$dir" || exit + cd "$dir" || exit echo -n "Checking $dir..." >&2 before_ver=$(grep -m1 pkgver= PKGBUILD | sed -e 's/^[^=]*=//g') before_rel=$(grep -m1 pkgrel= PKGBUILD | sed -e 's/^[^=]*=//g') installed_ver=$(pacman -Q "$dir" | sed -e 's/^[^ ]* //g') - arch-nspawn /var/lib/aurbuild/x86_64/"$user" \ + arch-nspawn /var/lib/aurto-builder \ --bind="$SCRIPT_DIR"/tmp/"$dir" \ -u builduser \ /usr/bin/env bash -c " diff --git a/lib/update-aurto b/lib/update-aurto index b8f38ec..de0da93 100755 --- a/lib/update-aurto +++ b/lib/update-aurto @@ -13,8 +13,8 @@ fi pacman -Sy >/dev/null 2>&1 -sudo -u "$user" aursync --no-view --rmdeps --no-confirm --chroot \ - --repo aurto --update +sudo -u "$user" aursync --no-view --rmdeps --no-confirm --repo aurto \ + -C /var/lib/aurto-builder --update if [ -e /usr/lib/aurto/check-vcs ]; then rm -f /usr/lib/aurto/check-vcs || true diff --git a/makefile b/makefile index 1a3ce53..cea3705 100644 --- a/makefile +++ b/makefile @@ -6,7 +6,7 @@ all: @rm -rf target @mkdir -p target/etc/pacman.d - @cp conf/aurto.pacman.conf target/etc/pacman.d/ + @cp conf/aurto.pacman.conf target/etc/pacman.d/aurto @mkdir -p target$(PREFIX)/bin @cp -r bin/* target$(PREFIX)/bin/