-
Notifications
You must be signed in to change notification settings - Fork 8
/
copy-and-cleanup
executable file
·42 lines (39 loc) · 1.39 KB
/
copy-and-cleanup
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#!/bin/bash
##
# takes a look at all new packages in our temp dir
# moves them into our repo dir
# updates repo.db
# cleans up build dir
##
# written by Tim 'bastelfreak' Meusel'
##
TMPDIR="/var/lib/jenkins/packages"
FINALDIR="/var/www/archlinux/aur/os/x86_64"
BUILDDIR="/mnt/aur/build_test"
if [ "$(whoami)" != "jenkins" ]; then
echo "only execute this as user jenkins"
exit 1
fi
cd "${TMPDIR}" || exit 1
while read -r package; do
pkgfile="$(basename "${package}")"
mv "$package" "${FINALDIR}/"
repo-add --remove "${FINALDIR}/aur.db.tar.gz" "${FINALDIR}/${pkgfile}"
echo "added ${package}"
# clean up if jenkins provided us the package name
if [ -n "$1" ]; then
packagebase="$1"
echo "cleaning up $packagebase"
# build that installed systemd components have another btrfs subvol
# this needs to be cleaned up first
if [ -d "${BUILDDIR}/${packagebase}/var/lib/machines" ]; then
sudo /usr/bin/btrfs subvolume delete "${BUILDDIR}/${packagebase}/var/lib/machines"
echo "cleaned up ${BUILDDIR}/${packagebase}/var/lib/machines"
fi
# this should be true for all builds, but you never know...
if [ -d "${BUILDDIR}/${packagebase}" ]; then
sudo /usr/bin/btrfs subvolume delete "${BUILDDIR}/${packagebase}"
echo "cleaned up ${BUILDDIR}/${packagebase}"
fi
fi
done < <(find "${TMPDIR}" -maxdepth 1 -type f -iname '*.pkg.tar.xz' -o -iname '*.pkg.tar.zst')