aboutsummarylogtreecommitdiffstats
diff options
context:
space:
mode:
authorGaetan Bisson2016-08-28 06:48:44 -1000
committerGaetan Bisson2016-08-28 06:48:44 -1000
commitaac70d2686759458807fda1185ce4c0835ab69e8 (patch)
treeb826a043d5f164c6f4e8db2ee70cdae823dcd6cc
parent906396775aae17567547ac8a6beb37c7d2c019ae (diff)
downloadaur-aac70d2686759458807fda1185ce4c0835ab69e8.tar.gz
upstream update
-rw-r--r--.SRCINFO35
-rw-r--r--LICENSE2
-rw-r--r--PKGBUILD49
-rw-r--r--README84
-rwxr-xr-xarch.build44
-rwxr-xr-xarch.install128
-rw-r--r--cirrus.conf2
-rw-r--r--fstab5
-rw-r--r--pacman.conf102
-rwxr-xr-xproxy.cgi25
-rw-r--r--sudoers.d1
-rw-r--r--syslinux.cfg5
12 files changed, 156 insertions, 326 deletions
diff --git a/.SRCINFO b/.SRCINFO
index 90c439e429b7..46be4e108604 100644
--- a/.SRCINFO
+++ b/.SRCINFO
@@ -1,34 +1,25 @@
pkgbase = buildstuff
pkgdesc = Stuff to build packages in virtual machines
- pkgver = 0.8
+ pkgver = 0.9
pkgrel = 1
url = http://arch.vesath.org/
arch = any
- license = ISC
- depends = qemu
+ license = custom:ISC
+ depends = qemu-headless
depends = openssh
depends = e2fsprogs
- depends = jfsutils
+ depends = parted
+ depends = arch-install-scripts
+ source = README
+ source = LICENSE
+ source = proxy.cgi
source = arch.build
source = arch.install
- source = cirrus.conf
- source = fstab
- source = pacman.conf
- source = proxy.cgi
- source = sudoers.d
- source = syslinux.cfg
- source = LICENSE
- source = README
- sha1sums = fb8d7856d925bd92f1e9ba84d1a75ea43e107844
- sha1sums = 0a0a12473122c73c2a536c9a77d46cfd9e5a1424
- sha1sums = 315fc0847eaf46e74a92b4c62c0cd3ef73d1e89a
- sha1sums = e7e2949822a35d2e70f826e3e942f40c5c6f41bb
- sha1sums = 2b709786e16586baf28278292472e58dea10da5f
- sha1sums = ef7077f9e61da1eb53a3ba5ea096daf8d733cba7
- sha1sums = 7d19d155ab1887ac1f84e682cbec54078c63758d
- sha1sums = c3ea9e9250bba2fbfa591fc85065e0dabe4b8e46
- sha1sums = 352a7d6d53c2945f8fbbfff47d4f1dccc8d33829
- sha1sums = b0071da8f3dd319be0b8c637349c949ae5e71291
+ sha1sums = 9065a73d67c5c021ae9d0624b973ca93053ee1dc
+ sha1sums = 6ecd04bec1630ddd9ceb947e330b9624c3fa8d64
+ sha1sums = 853f64797cdd0a57e7049f594340db20bd4e1eba
+ sha1sums = 7aaae57187d06bf65fe99417daa17780d6e5312a
+ sha1sums = 39d491e77bb573ef17d3a41dc149735c2c107b6c
pkgname = buildstuff
diff --git a/LICENSE b/LICENSE
index c5fa00e2ba81..af799558ea00 100644
--- a/LICENSE
+++ b/LICENSE
@@ -1,4 +1,4 @@
-Copyright (C) 2012, Gaetan Bisson <bisson@archlinux.org>.
+Copyright (C) 2012-2016, Gaetan Bisson <bisson@archlinux.org>.
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted, provided that the above
diff --git a/PKGBUILD b/PKGBUILD
index d107e73e584b..edd56a302102 100644
--- a/PKGBUILD
+++ b/PKGBUILD
@@ -1,47 +1,32 @@
# Maintainer: Gaetan Bisson <bisson@archlinux.org>
pkgname=buildstuff
-pkgver=0.8
+pkgver=0.9
pkgrel=1
pkgdesc='Stuff to build packages in virtual machines'
url='http://arch.vesath.org/'
arch=('any')
-license=('ISC')
-depends=('qemu' 'openssh' 'e2fsprogs' 'jfsutils')
-
-source=('arch.build'
- 'arch.install'
- 'cirrus.conf'
- 'fstab'
- 'pacman.conf'
- 'proxy.cgi'
- 'sudoers.d'
- 'syslinux.cfg'
+license=('custom:ISC')
+depends=('qemu-headless' 'openssh' 'e2fsprogs' 'parted'
+ 'arch-install-scripts')
+source=('README'
'LICENSE'
- 'README')
+ 'proxy.cgi'
+ 'arch.build'
+ 'arch.install')
package() {
cd "${srcdir}"
- install -d "${pkgdir}/var/lib/${pkgname}"
- install -Dm755 arch.build "${pkgdir}/usr/bin/arch.build"
- install -Dm755 arch.install "${pkgdir}/usr/bin/arch.install"
+ install -d "${pkgdir}/usr/bin"
+ install arch.* "${pkgdir}/usr/bin"
+ install -d "${pkgdir}/var/lib/buildstuff"
+ install -Dm644 README "${pkgdir}/usr/share/${pkgname}/README"
install -Dm755 proxy.cgi "${pkgdir}/usr/share/${pkgname}/proxy.cgi"
- install -Dm644 pacman.conf "${pkgdir}/usr/share/${pkgname}/pacman.conf"
- install -Dm644 fstab "${pkgdir}/usr/share/${pkgname}/guest/etc/fstab"
- install -Dm644 sudoers.d "${pkgdir}/usr/share/${pkgname}/guest/etc/sudoers.d/user"
- install -Dm644 cirrus.conf "${pkgdir}/usr/share/${pkgname}/guest/etc/modprobe.d/cirrus.conf"
- install -Dm644 syslinux.cfg "${pkgdir}/usr/share/${pkgname}/guest/boot/syslinux/syslinux.cfg"
install -Dm644 LICENSE "${pkgdir}/usr/share/licenses/${pkgname}/LICENSE"
- install -Dm644 README "${pkgdir}/usr/share/doc/${pkgname}/README"
}
-sha1sums=('fb8d7856d925bd92f1e9ba84d1a75ea43e107844'
- '0a0a12473122c73c2a536c9a77d46cfd9e5a1424'
- '315fc0847eaf46e74a92b4c62c0cd3ef73d1e89a'
- 'e7e2949822a35d2e70f826e3e942f40c5c6f41bb'
- '2b709786e16586baf28278292472e58dea10da5f'
- 'ef7077f9e61da1eb53a3ba5ea096daf8d733cba7'
- '7d19d155ab1887ac1f84e682cbec54078c63758d'
- 'c3ea9e9250bba2fbfa591fc85065e0dabe4b8e46'
- '352a7d6d53c2945f8fbbfff47d4f1dccc8d33829'
- 'b0071da8f3dd319be0b8c637349c949ae5e71291')
+sha1sums=('9065a73d67c5c021ae9d0624b973ca93053ee1dc'
+ '6ecd04bec1630ddd9ceb947e330b9624c3fa8d64'
+ '853f64797cdd0a57e7049f594340db20bd4e1eba'
+ '7aaae57187d06bf65fe99417daa17780d6e5312a'
+ '39d491e77bb573ef17d3a41dc149735c2c107b6c')
diff --git a/README b/README
index 4435055b45bc..051685202605 100644
--- a/README
+++ b/README
@@ -1,83 +1,39 @@
IF YOU ARE IN A HURRY
=====================
-Go to any directory that contains a PKGBUILD and run
+From a directory that contains a PKGBUILD, run:
arch.build i686
-This will build your package for the given architecture. You may also append a
+This will build the package for the given architecture. You may also append a
list of repositories to use on top of [core], [extra], and [community], for
instance:
arch.build x86_64 testing multilib-testing multilib
-FOR BETTER PERFORMANCES
-=======================
+FOR BETTER PERFORMANCE
+======================
-Make sure that hardware virtualization is enabled.
+Enable hardware virtualization.
-Make sure that your /tmp is a tmpfs; this is where the copy-on-write drive is
-stored and there is no point that it ever be synced to disk.
+Make /tmp a tmpfs. (This is where the copy-on-write drive is stored.)
-Make your host and guest share their pacman package cache through the use of
-the /usr/share/buildstuff/proxy.cgi script; proceed as follows:
-- install any HTTP server on your host computer
-- make this sript run as CGI when called as http://localhost/proxy.cgi
-- make /var/cache/pacman/pkg writeable by the user running this CGI instance
+Make the host and guest share their pacman package cache using the proxy.cgi
+script:
+- install any HTTP server on the host
+- make this sript run as CGI when called as http://10.0.2.2/proxy.cgi
+- make /var/cache/pacman/pkg writeable by this CGI instance
-HOW THIS ALL WORKS
-==================
+REQUIREMENTS FOR ARCH.INSTALL
+=============================
-The arch.install script creates a base Arch Linux disk image, and configures it
-for unattended use in qemu. You may simply call it as:
+The arch.install script creates an Arch Linux disk image which:
+- has [base] and [base-devel] installed
+- has a "user" user able to sudo at will
+- boots unattended with networking enabled
+- runs an SSH daemon accepting the host user's keys
- arch.install i686 ~/vm.img
-
-It creates a sparse disk image and partitions it as 8 GB swap, 64 MB ext2 boot,
-8 GB JFS root, and 16 GB JFS home (where packages are built), and installs it
-with [base] and [base-devel] using syslinux as boot loader and systemd as init.
-All this is to reduce VM latency as much as possible. Eventually the disk image
-amounts roughly to 700 MB of actual disk space.
-
-Any other Arch installer would do too, provided that:
-- the guest system has a "user" user able to sudo at will
-- the guest system runs an SSH server at bootup
-- the host user is able to access the guest "user" user account
-
-The latter is achieved in arch.install by copying the host user's SSH public
-keys into the guest user's authorized_keys file.
-
-Once created, these disk images will be used as read-only most of the time: the
-virtual machines run in arch.build do copy-on-write on top of those base disk
-images, storing the changes into a temporary file discarded after each use. The
-base images are then only updated if they have not been in a day.
-
-Let us go through what happens step by step in arch.build:
-
-1. A (hopefully unique to this instance) random number gets picked: vport; it
-is used as the dmsetup device name, port of the host that gets forwarded to the
-guest SSH's, and name for the temporary copy-on-write drive.
-
-2. If the base disk image does not exist yet, create it by calling arch.install
-
-3. If the base disk image has not been updated for a day, run it within qemu
-and update it. Note that this image never runs any repository beyond [core],
-[extra], and [community].
-
-4. Create the temporary drive and set up the dmsetup copy-on-write instance.
-Run this within qemu.
-
-5. Add to this qemu instance the repositories that the user provided as
-arguments; for instance, above, that was [testing], [multilib-testing], and
-[multilib] so that the former takes precedence over the latter.
-
-6. Update the qemu instance.
-
-7. Run the build job.
-
-8. If everything went well, run cleanup instructions located in cleanup.$vport;
-if anything went wrong, arch.build aborts and it is up to you to kill the qemu
-instance and then run cleanup.$vport after you have investigated the build
-problem.
+Once created, this disk image is read-only most of the time: the virtual
+machines created in arch.build use copy-on-write on top of it.
diff --git a/arch.build b/arch.build
index c0cdefb7b4cc..68ebba3f113d 100755
--- a/arch.build
+++ b/arch.build
@@ -12,31 +12,30 @@ case $arch in
*) exit 1 ;;
esac
-img=/var/lib/buildstuff/$arch.img
+img=/var/lib/buildstuff/$arch.qcow2
vport=$((32768+$RANDOM))
vhost="
- -o ConnectTimeout=5
+ -o ConnectTimeout=3
-o StrictHostKeyChecking=no
-o UserKnownHostsFile=/dev/null
-o Port=$vport user@localhost
"
start_vm() {
- local kvm
- pacman -Qoq qemu-system-x86_64 | grep -q kvm || kvm='-machine accel=kvm:tcg'
qemu-system-x86_64 \
- -smp 2 -m 768 -cpu $cpu $kvm \
+ -machine accel=kvm:tcg \
+ -cpu $cpu -smp 2 -m 1024 \
-device virtio-net,netdev=vlan \
-netdev user,id=vlan,hostfwd=::$vport-:22 \
- -drive file=$1,cache=none,aio=native \
- -display none &
- while sleep 3; do ssh $vhost true && break; done
+ -drive file=$1 &
+ while sleep 1; do
+ ssh $vhost 'curl -o /dev/null -s vesath.org' &&
+ break
+ done
}
stop_vm() {
- ssh $vhost 'sudo poweroff' ||
- pkill -f $vport ||
- true
+ ssh $vhost 'sudo poweroff' || true
wait
}
@@ -45,13 +44,11 @@ trap_err() {
trap - INT
cat <<EOF
-Please investigate the error that occured via \`ssh -p $vport user@localhost\`;
-when you are ready, you may press enter to stop the virtual machine.
+Investigate the error with \`ssh -p $vport user@localhost\`
+then press enter here to terminate the virtual machine.
EOF
read x
stop_vm
- sudo sh cleanup.$vport ||
- echo "Run: \`cd `pwd`; sudo sh cleanup.$vport\`"
}
trap trap_err ERR
trap trap_err INT
@@ -63,31 +60,26 @@ set -E
sudo chown "$USER" $img
}
-(( $(stat -c%Y $img) < $(date +%s) - 86400 )) && {
+(( $(date +%s) - $(stat -c%Y $img) > 86400 )) && {
start_vm $img
ssh $vhost 'sudo pacman --noconfirm -Syu'
ssh $vhost 'sudo pacman --noconfirm -Su'
stop_vm
}
-dd if=/dev/zero count=0 bs=4K seek=1M of=/tmp/$vport
-loopn=$(sudo losetup -f --show /tmp/$vport)
-loopr=$(sudo losetup -f --show $img)
-echo "dmsetup remove $vport && losetup -d $loopn $loopr && rm /tmp/$vport cleanup.$vport" > cleanup.$vport
-sudo dmsetup create $vport --table "0 $(sudo blockdev --getsize $loopr) snapshot $loopr $loopn N 1"
-sudo chown "$USER" /dev/mapper/$vport
+qemu-img create -f qcow2 -o backing_file=$img /tmp/$vport 8G
-start_vm /dev/mapper/$vport
+start_vm /tmp/$vport
for r in $repo; do
echo "sudo sed '/\[core\]/i [$r]\nInclude = /etc/pacman.d/mirrorlist\n' -i /etc/pacman.conf"
done | ssh $vhost
ssh $vhost 'sudo pacman --noconfirm -Syu'
ssh $vhost 'sudo pacman --noconfirm -Su'
-sftp $vhost <<<'mkdir build'
-sftp $vhost <<<'put * build'
+sftp $vhost <<<'put -r . build'
+sftp $vhost <<<"mkdir $HOME/.gnupg"
sftp $vhost <<<"put $HOME/.makepkg.conf"
+sftp $vhost <<<"put $HOME/.gnupg/pubring.kbx .gnupg/pubring.kbx"
ssh $vhost 'cd build; makepkg --log --noconfirm --syncdeps'
sftp $vhost <<<'get build/*.pkg.tar.xz'
sftp $vhost <<<'get build/*.log'
stop_vm
-sudo sh cleanup.$vport
diff --git a/arch.install b/arch.install
index 094db0e5f9c5..1f084078deef 100755
--- a/arch.install
+++ b/arch.install
@@ -2,78 +2,90 @@
set -e
-(( ! $UID ))
-
arch=${1-x86_64}
-img=${2-arch.img}
+file=${2-arch.qcow2}
+loop=/dev/nbd0
+
+(( ! $UID ))
-(( $(</sys/module/loop/parameters/max_part) )) || {
- modprobe -r loop || true
- modprobe loop max_part=9 max_loop=9
-}
+[[ ! -e ${file} ]]
-[[ -e ${img} ]] || dd if=/dev/zero count=0 bs=4K seek=8M of="${img}"
-sda=$(losetup -f --show "${img}")
+qemu-img create -f qcow2 ${file} 8G
+modprobe nbd max_part=8
+qemu-nbd -c ${loop} ${file}
-sfdisk -u M ${sda} <<\EOF
-,8192
-,64
-,8192
+sfdisk ${loop} <<\EOF
+,131072
,
EOF
+partprobe "${loop}"
+
+mkfs.ext2 -L boot ${loop}p1
+mkfs.ext4 -L root ${loop}p2
+
+mnt=${file}.mnt
+install -d ${mnt}
+mount ${loop}p2 ${mnt}
-mkswap ${sda}p1
-mke2fs -q ${sda}p2
-jfs_mkfs -q ${sda}p3
-jfs_mkfs -q ${sda}p4
+pushd ${mnt}
-install -d "${img}.mnt"
-mount ${sda}p3 "${img}.mnt"
-pushd "${img}.mnt"
+install -d boot
+mount ${loop}p1 boot
-install -d boot home dev proc sys tmp
-mount ${sda}p2 boot
-mount ${sda}p4 home
-mount -o bind /dev dev
-mount -t proc proc proc
-mount -t sysfs sys sys
-mount -t tmpfs tmp tmp
+setarch ${arch} pacstrap -C /usr/share/devtools/pacman-extra.conf -c . base base-devel syslinux openssh sudo haveged
+systemctl --root=. enable systemd-{networkd,resolved} sshd haveged
-install -d var/lib/pacman
-setarch "${arch}" pacman --config /usr/share/buildstuff/pacman.conf --root . \
- --noconfirm -Sy base base-devel openssh sudo syslinux
+ln -sf ../run/systemd/resolve/resolv.conf etc/resolv.conf
-find /usr/share/buildstuff/guest/ -type f |
-while read i; do install -Dm644 "${i}" "${i##*/guest/}"; done
+install -d home/user/.ssh
+cat ~/.ssh/id_*.pub > home/user/.ssh/authorized_keys
+
+setarch ${arch} arch-chroot . <<EOF
+useradd -p 00as1wm0AZG56 user
+chown -R user:users /home/user
+mkinitcpio -p linux
+syslinux-install_update -i -m
+sfdisk --activate ${loop} 1 || true
+EOF
+
+cat > boot/syslinux/syslinux.cfg <<EOF
+DEFAULT arch
+LABEL arch
+LINUX ../vmlinuz-linux
+APPEND root=LABEL=root ro
+INITRD ../initramfs-linux-fallback.img
+EOF
+
+cat > etc/fstab <<EOF
+tmpfs /tmp tmpfs nodev,nosuid 0 0
+LABEL=boot /boot ext2 defaults 0 1
+LABEL=root / ext4 defaults 0 1
+EOF
+
+cat > etc/hostname <<EOF
+guest
+EOF
+
+cat > etc/sudoers.d/user <<EOF
+user ALL=(ALL) NOPASSWD: ALL
+EOF
+
+cat > etc/systemd/network/any.network <<EOF
+[Match]
+
+[Network]
+DHCP=yes
+EOF
+
+# To use the pacman cache from the host system, arrange for
+# /usr/share/buildstuff/proxy.cgi to be run as CGI when called as
+# http://10.0.2.2/proxy.cgi and make /var/cache/pacman/pkg writeable by it.
install -Dm644 /etc/pacman.d/mirrorlist etc/pacman.d/mirrorlist
-install -d home/user/.ssh; cat ~/.ssh/id_*.pub > home/user/.ssh/authorized_keys
sed -i etc/pacman.d/mirrorlist -e '1i Server = http://10.0.2.2/proxy.cgi/$repo/os/$arch/'
-setarch "${arch}" chroot . bash -c '
- mkinitcpio -S autodetect -k /boot/vmlinuz-linux -g /boot/initramfs-linux.img
- syslinux-install_update -i -a -m
- systemctl enable multi-user.target
- systemctl enable {dhcpcd,sshd}.service
-
- useradd -p 00as1wm0AZG56 -d /home/user user
- chown -R user:users /home/user
- passwd -l root
-
- sed "s/--quiet --lsign-key/--batch --yes --quiet --lsign-key/" -i /usr/bin/pacman-key
- pacman-key --init
- pacman-key --populate archlinux
- sed "s/--batch --yes//" -i /usr/bin/pacman-key
-'
-
-umount dev
-umount proc
-umount sys
-umount tmp
-umount home
umount boot
popd
-umount "${img}.mnt"
-rmdir "${img}.mnt"
-
-losetup -d ${sda}
+umount ${mnt}
+rmdir ${mnt}
+killall qemu-nbd
diff --git a/cirrus.conf b/cirrus.conf
deleted file mode 100644
index 55054c01a467..000000000000
--- a/cirrus.conf
+++ /dev/null
@@ -1,2 +0,0 @@
-# kvm breaks qemu's text-mode ncurses output
-blacklist cirrus
diff --git a/fstab b/fstab
deleted file mode 100644
index 60d75aeea3b8..000000000000
--- a/fstab
+++ /dev/null
@@ -1,5 +0,0 @@
-tmpfs /tmp tmpfs nodev,nosuid 0 0
-/dev/sda1 swap swap defaults 0 0
-/dev/sda2 /boot ext2 defaults 0 1
-/dev/sda3 / jfs defaults 0 1
-/dev/sda4 /home jfs defaults 0 2
diff --git a/pacman.conf b/pacman.conf
deleted file mode 100644
index df5aec796f9b..000000000000
--- a/pacman.conf
+++ /dev/null
@@ -1,102 +0,0 @@
-#
-# /etc/pacman.conf
-#
-# See the pacman.conf(5) manpage for option and repository directives
-
-#
-# GENERAL OPTIONS
-#
-[options]
-# The following paths are commented out with their default values listed.
-# If you wish to use different paths, uncomment and update the paths.
-#RootDir = /
-#DBPath = /var/lib/pacman/
-#CacheDir = /var/cache/pacman/pkg/
-#LogFile = /var/log/pacman.log
-#GPGDir = /etc/pacman.d/gnupg/
-HoldPkg = pacman glibc
-#XferCommand = /usr/bin/curl -C - -f %u > %o
-#XferCommand = /usr/bin/wget --passive-ftp -c -O %o %u
-#CleanMethod = KeepInstalled
-#UseDelta = 0.7
-Architecture = auto
-
-# Pacman won't upgrade packages listed in IgnorePkg and members of IgnoreGroup
-#IgnorePkg =
-#IgnoreGroup =
-
-#NoUpgrade =
-#NoExtract =
-
-# Misc options
-#UseSyslog
-Color
-TotalDownload
-CheckSpace
-VerbosePkgLists
-
-# By default, pacman accepts packages signed by keys that its local keyring
-# trusts (see pacman-key and its man page), as well as unsigned packages.
-SigLevel = Required DatabaseOptional
-LocalFileSigLevel = Optional
-#RemoteFileSigLevel = Required
-
-# NOTE: You must run `pacman-key --init` before first using pacman; the local
-# keyring can then be populated with the keys of all official Arch Linux
-# packagers with `pacman-key --populate archlinux`.
-
-#
-# REPOSITORIES
-# - can be defined here or included from another file
-# - pacman will search repositories in the order defined here
-# - local/custom mirrors can be added here or in separate files
-# - repositories listed first will take precedence when packages
-# have identical names, regardless of version number
-# - URLs will have $repo replaced by the name of the current repo
-# - URLs will have $arch replaced by the name of the architecture
-#
-# Repository entries are of the format:
-# [repo-name]
-# Server = ServerName
-# Include = IncludePath
-#
-# The header [repo-name] is crucial - it must be present and
-# uncommented to enable the repo.
-#
-
-# The testing repositories are disabled by default. To enable, uncomment the
-# repo name header and Include lines. You can add preferred servers immediately
-# after the header, and they will be used before the default mirrors.
-
-#[testing]
-#Include = /etc/pacman.d/mirrorlist
-
-[core]
-Include = /etc/pacman.d/mirrorlist
-
-[extra]
-Include = /etc/pacman.d/mirrorlist
-
-#[community-testing]
-#Include = /etc/pacman.d/mirrorlist
-
-[community]
-Include = /etc/pacman.d/mirrorlist
-
-# If you want to run 32 bit applications on your x86_64 system,
-# enable the multilib repositories as required here.
-
-#[multilib-testing]
-#Include = /etc/pacman.d/mirrorlist
-
-#[multilib]
-#Include = /etc/pacman.d/mirrorlist
-
-# An example of a custom package repository. See the pacman manpage for
-# tips on creating your own repositories.
-#[custom]
-#SigLevel = Optional TrustAll
-#Server = file:///home/custompkgs
-
-[vesath]
-Server = http://arch.vesath.org/$arch/
diff --git a/proxy.cgi b/proxy.cgi
index 6ee2e8079b5a..2338201cf429 100755
--- a/proxy.cgi
+++ b/proxy.cgi
@@ -3,23 +3,28 @@
set -e
# This CGI script is a caching Arch Linux mirror proxy: it forwards new package
-# requests to an actual mirror while caching content to /var/cache/pacman/pkg.
+# requests to an actual mirror while caching contents to /var/cache/pacman/pkg.
# Use in pacman.conf with:
#
# Server = http://server/path/to/proxy.cgi/$repo/os/$arch/
[[ $REMOTE_ADDR = 127.0.0.1 ]]
+
cd /var/cache/pacman/pkg
+
touch used-by-proxy
-read MIR < /etc/pacman.d/mirrorlist
-MIR=${MIR%%\$*}
-MIR=${MIR##*= }
+MIR=$(awk -F '[$=]' '(!/^#/){print$2;exit}' /etc/pacman.d/mirrorlist)
+
+MIR=${MIR# }
-[[ $PATH_INFO = /vesath/* ]] && MIR='http://arch.vesath.org'
+[[ $PATH_INFO = /vesath/* ]] &&
+MIR='http://arch.vesath.org'
PKG=${PATH_INFO##*/}
-[[ $PKG = *.db* ]] && exec curl --silent --include "$MIR$PATH_INFO"
+
+[[ $PKG = *.db* ]] &&
+exec curl --silent --include "${MIR# }$PATH_INFO"
cat <<EOF
Content-Type: application/octet-stream
@@ -27,6 +32,10 @@ Connection: close
EOF
-[[ -e $PKG ]] && exec cat "$PKG"
-curl --silent "$MIR$PATH_INFO" | tee "$PKG.part"
+[[ -s $PKG ]] &&
+exec cat "$PKG"
+
+curl --silent "$MIR$PATH_INFO" |
+tee "$PKG.part"
+
mv "$PKG.part" "$PKG"
diff --git a/sudoers.d b/sudoers.d
deleted file mode 100644
index 5841129998fe..000000000000
--- a/sudoers.d
+++ /dev/null
@@ -1 +0,0 @@
-user ALL=(ALL) NOPASSWD: ALL
diff --git a/syslinux.cfg b/syslinux.cfg
deleted file mode 100644
index 95a066cdc053..000000000000
--- a/syslinux.cfg
+++ /dev/null
@@ -1,5 +0,0 @@
-DEFAULT linux
-LABEL linux
-LINUX ../vmlinuz-linux
-APPEND root=/dev/sda3 ro
-INITRD ../initramfs-linux.img