diff options
author | Alex Butler | 2018-01-29 20:42:53 +0000 |
---|---|---|
committer | Alex Butler | 2018-01-29 20:42:53 +0000 |
commit | 7258764d1648925cde25f84bf8148ec6f73c1e9e (patch) | |
tree | 74599ae09077c13478df6ee6cccb41f56df4af17 | |
download | aur-7258764d1648925cde25f84bf8148ec6f73c1e9e.tar.gz |
0.1-1
-rw-r--r-- | .SRCINFO | 14 | ||||
-rw-r--r-- | .gitignore | 1 | ||||
-rw-r--r-- | PKGBUILD | 26 | ||||
-rw-r--r-- | aurto.install | 78 |
4 files changed, 119 insertions, 0 deletions
diff --git a/.SRCINFO b/.SRCINFO new file mode 100644 index 000000000000..0b482753af47 --- /dev/null +++ b/.SRCINFO @@ -0,0 +1,14 @@ +pkgbase = aurto + pkgver = 0.1 + pkgrel = 1 + install = aurto.install + arch = any + license = MIT + depends = aurutils + depends = devtools + depends = systemd + source = https://github.com/alexheretic/aurto/archive/v0.1.tar.gz + sha256sums = 91435ee92ae97e94011e27eb646c0ec7e0c3da486b4df7f173686fa9250f59eb + +pkgname = aurto + diff --git a/.gitignore b/.gitignore new file mode 100644 index 000000000000..9881fec21af4 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +*.tar.* diff --git a/PKGBUILD b/PKGBUILD new file mode 100644 index 000000000000..7476af080e4d --- /dev/null +++ b/PKGBUILD @@ -0,0 +1,26 @@ +# Maintainer: Alex Butler <alexheretic@gmail.com> +pkgname=aurto +pkgver=0.1 +pkgrel=1 +pkgdesc="A simple aur tool for managing a local 'aurto' repository" +arch=('any') +url="https://github.com/alexheretic/aurto" +license=('MIT') +depends=('aurutils' + 'devtools' + 'systemd') +optdepends=() +makedepends=() +install="aurto.install" +source=("https://github.com/alexheretic/$pkgname/archive/v$pkgver.tar.gz") +sha256sums=('91435ee92ae97e94011e27eb646c0ec7e0c3da486b4df7f173686fa9250f59eb') + +build() { + cd "$pkgname-$pkgver" + make +} + +package() { + cd "$pkgname-$pkgver" + cp -r target/* "$pkgdir"/ +} diff --git a/aurto.install b/aurto.install new file mode 100644 index 000000000000..de2b499a5f5f --- /dev/null +++ b/aurto.install @@ -0,0 +1,78 @@ +#!/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 + if ! test -f /etc/pacman.conf.aurto-backup; then + cp /etc/pacman.conf /etc/pacman.conf.aurto-backup + fi + 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: Creating /var/lib/aurto-builder chroot' + rm -rf /var/lib/aurto-builder* + mkarchroot /var/lib/aurto-builder base-devel pigz >/dev/null 2>&1 + arch-nspawn /var/lib/aurto-builder /bin/bash -c " + sed -i 's/COMPRESSGZ=(gzip -c -f -n)/COMPRESSGZ=(pigz -c -f -n)/' /etc/makepkg.conf + sed -i \"s/PKGEXT='.pkg.tar.xz'/PKGEXT='.pkg.tar.gz'/\" /etc/makepkg.conf + " + + 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 aurto rules from /etc/sudoers' >&2 + sed -i '/^## aurto rules$/,/^## \/aurto rules$/d' /etc/sudoers + + echo 'aurto: Removing /var/lib/aurto-builder' >&2 + rm -rf /var/lib/aurto-builder* || true + + echo 'aurto: Removing /var/cache/pacman/aurto' >&2 + rm -rf /var/cache/pacman/aurto || true + + 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 +} |