Repository navigation
Expand file tree
/
Copy pathmakeworld
More file actions
executable file
·108 lines (91 loc) · 2.96 KB
/
Copy pathmakeworld
File metadata and controls
executable file
·108 lines (91 loc) · 2.96 KB
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
#!/bin/bash
#
# This script compiles the Haskell ABS tree into a binary repository.
#
die() # error reporting helper
{
echo >&2 "*** makeworld error: $@"
exit 1
}
# Set global defaults.
set -eu
shopt -s nullglob
export LC_ALL="C"
do_rsync="${HABSCHROOTRSYNC:-y}"
host_arch=$(uname -m) || die "cannot determine host architecture"
chroot_dir="${HABSCHROOTDIR:-/var/tmp}/chroot-${host_arch}"
chroot_rootdir="${chroot_dir}/root"
chroot_copydir="${chroot_dir}/copy"
declare -r do_rsync host_arch chroot_dir chroot_rootdir chroot_copydir
# If a command line argument was given, interpret it as the path to the
# habs directory, and change into it. The default argument is "habs".
cd "${1:-habs}" || die "habs tree doesn't exist at expected location"
# If the chroot sandbox doesn't exist, create it.
if [ ! -d "${chroot_dir}" ]; then
# it doesn't exist, create it
pacman_conf=$(mktemp "/tmp/pacman-haskell-XXX.conf") || die "failed to create temporary file"
trap 'rm -f "${pacman_conf}"' 0
for n in $(seq 9 -1 1); do
echo -ne "\rGenerating chroot environment at ${chroot_dir} in ${n} seconds ... "
sleep 1
done
echo ""
cat >"${pacman_conf}" <<EOF
[options]
HoldPkg = pacman glibc
SyncFirst = pacman
Architecture = auto
[core]
Include = /etc/pacman.d/mirrorlist
[extra]
Include = /etc/pacman.d/mirrorlist
[community]
Include = /etc/pacman.d/mirrorlist
[repo]
Server = file:///repo
EOF
sudo mkdir -p "${chroot_dir}"
sudo setarch "${host_arch}" mkarchroot -f \
-M "/usr/share/devtools/makepkg-${host_arch}.conf" \
-C "${pacman_conf}" \
"${chroot_rootdir}" util-linux-ng pacman file wget base-devel sudo ghc
echo "Build environment has been set up."
fi
# Synchronize the master repository into the sandbox environment.
if [ "${do_rsync}" == "y" ]; then
sudo rsync -rtlvH --delete-after --delay-updates --safe-links \
rsync://andromeda.kiwilight.com/haskell/${host_arch}/ ${chroot_rootdir}/repo/
fi
# Compute the list of all available packages in topological order.
pkglist=$(
for name in *; do
source "${name}/PKGBUILD"
echo "${pkgname} non-existent-dummy-package"
for dep in ${depends[@]} ${makedepends[@]:-}; do
if [[ "${dep}" =~ ([^=\<\>]+) ]]; then
dep="${BASH_REMATCH[1]}"
if [ -d "${dep}" ]; then
echo "${pkgname} ${dep}"
fi
else
die "can't parse dependencies of ${name}/PKGBUILD"
fi
done
done | tsort | tac | sed -e "/^non-existent-dummy-package/d"
)
# Build all packages that don't exist in the repository yet.
for name in ${pkglist}; do
source "${name}/PKGBUILD"
pkgspec="${pkgname}-${pkgver}-${pkgrel}"
outname="${pkgspec}-${host_arch}.pkg.tar.xz"
if [ -f "${chroot_copydir}/repo/${outname}" \
-o -f "${chroot_rootdir}/repo/${outname}" ]; then
echo "Not building ${outname} (already built)."
else
echo "Building ${outname} ..."
pushd >/dev/null "${pkgname}"
sudo setarch "${host_arch}" makechrootpkg -u -d -r "${chroot_dir}"
popd >/dev/null
fi
done
# vim: set tw=0 :