Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100755 164 lines (136 sloc) 4.319 kB
117f991 @magthe - Move build script from zsh to bash.
magthe authored
1 #! /bin/bash
39ca212 @magthe Add database and patches that matches the old status.
magthe authored
2
3 set -eu
4
5 ##################################################
6 # some useful stuff
7
8 ALL_OFF="$(tput sgr0)"
9 BOLD="$(tput bold)"
10 BLUE="${BOLD}$(tput setaf 4)"
11 GREEN="${BOLD}$(tput setaf 2)"
12 RED="${BOLD}$(tput setaf 1)"
13 YELLOW="${BOLD}$(tput setaf 3)"
14
15 msg() {
16 local msg=$1; shift
17 printf "${GREEN}***${ALL_OFF}${BOLD} ${msg}${ALL_OFF}\n" $@ >&2
18 }
19
20 error() {
21 local msg=$1; shift
22 printf "${RED}*** ERROR:${ALL_OFF}${BOLD} ${msg}${ALL_OFF}\n" $@ >&2
23 }
24
25 die() {
26 [ -n "${1}" ] && error ${1}
27 exit 1
28 }
29 ##################################################
30
31 # default values
32 arch=$(uname -m)
33 chrootdir=.
34 pristine_chrootdir=root
35 build_chrootdir=build
36 habs_dir=.
37 clean_build_first=0
38 update_pristine_first=0
39
40 usage() {
41 cat << EOF
1d53a34 @magthe Replace individual packages in the chroot with the base group.
magthe authored
42 Usage: makeahpkg [options] -- [packages]
39ca212 @magthe Add database and patches that matches the old status.
magthe authored
43
44 Run this script in your HABS dir to build the named packages inside a
45 chroot.
46
47 The chroot dir consists of two dirs, a pristine chroot (root), and a build
48 chroot (build). This script handles both of them.
49
50 Options:
51 -h This help
52 -c Clean the build chroot before building
53 -x Update the pristine chroot first (implies -c)
54 -l <dir> Location of chroot (default .)
55 -a <arch> Architecture to build for i686 or x86_64 (default is local arch)
56 -b <dir> Location of your HABS dir (default .)
57 EOF
58 }
59
60 buildpkg() {
3a23ea2 @np Make the `Skipping build' check more precise
np authored
61 eval "$(grep '^pkg\(rel\|ver\)=' PKGBUILD)"
117f991 @magthe - Move build script from zsh to bash.
magthe authored
62 if [[ -f ${pkg}-${pkgver}-${pkgrel}-${arch}.pkg.tar.xz ]]; then
63 sudo mkdir -p ${CHROOT_BUILDDIR}/repo
64 sudo cp ${pkg}-${pkgver}-${pkgrel}-${arch}.pkg.tar.xz \
65 ${CHROOT_BUILDDIR}/repo
66 (cd ${CHROOT_BUILDDIR}/repo; sudo repo-add repo.db.tar.gz \
67 ${pkg}-${pkgver}-${pkgrel}-${arch}.pkg.tar.xz)
68 msg "Skipping build in $PWD"
69 else
39ca212 @magthe Add database and patches that matches the old status.
magthe authored
70 msg "Building in $PWD"
71 sudo setarch ${arch} makechrootpkg -u -d -l ${build_chrootdir} -r ${CHROOT_DIR} -- -i
72 fi
73 }
74
75 while getopts hcxa:l:b: opt; do
76 case "${opt}" in
77 h) usage; exit 0;;
78 c) clean_build_first=1;;
79 x) update_pristine_first=1;;
80 a) arch=${OPTARG};;
81 l) chrootdir="${OPTARG}";;
82 b) habs_dir="${OPTARG}";;
83 esac
84 done
85 shift $((OPTIND - 1))
86
87 CHROOT_DIR=$(readlink -f ${chrootdir}/${arch}-chroot)
88 CHROOT_ROOTDIR=${CHROOT_DIR}/${pristine_chrootdir}
89 CHROOT_BUILDDIR=${CHROOT_DIR}/${build_chrootdir}
90
91 if [ ! -d ${CHROOT_ROOTDIR} ]; then
92 msg "Creating the pristine chroot ${CHROOT_DIR} ..."
93 mkdir -p "${CHROOT_DIR}" || die "Couldn't create ${CHROOT_DIR}"
94
95 pacman_conf=$(mktemp "/tmp/pacman-habs.XXXXXXXX.conf")
96 trap 'rm -f "${pacman_conf}"' 0
97 cat > "${pacman_conf}" << EOF
98 [options]
99 HoldPkg = pacman libc
100 SyncFirst = pacman
101 Architecture = auto
ee4be48 @magthe Fix the make script so it works with pacman 4.
magthe authored
102 SigLevel = Never
39ca212 @magthe Add database and patches that matches the old status.
magthe authored
103
ee4be48 @magthe Fix the make script so it works with pacman 4.
magthe authored
104 #[repo]
105 #Server = file:///repo
39ca212 @magthe Add database and patches that matches the old status.
magthe authored
106
107 [haskell]
108 Server = http://www.kiwilight.com/\$repo/\$arch
109
110 [core]
111 Include = /etc/pacman.d/mirrorlist
e0078a5 @magthe Adding an explicit server to the pacman conf.
magthe authored
112 Server = http://mirrors.kernel.org/archlinux/\$repo/os/\$arch
39ca212 @magthe Add database and patches that matches the old status.
magthe authored
113
114 [extra]
115 Include = /etc/pacman.d/mirrorlist
e0078a5 @magthe Adding an explicit server to the pacman conf.
magthe authored
116 Server = http://mirrors.kernel.org/archlinux/\$repo/os/\$arch
39ca212 @magthe Add database and patches that matches the old status.
magthe authored
117
118 [community]
119 Include = /etc/pacman.d/mirrorlist
e0078a5 @magthe Adding an explicit server to the pacman conf.
magthe authored
120 Server = http://mirrors.kernel.org/archlinux/\$repo/os/\$arch
39ca212 @magthe Add database and patches that matches the old status.
magthe authored
121 EOF
122
123 sudo setarch ${arch} mkarchroot -f -C ${pacman_conf} \
124 -M /usr/share/devtools/makepkg-${arch}.conf ${CHROOT_ROOTDIR} \
828561a @magthe From the looks of it crl needs to be installed explicitly in the chro…
magthe authored
125 base base-devel curl \
1d53a34 @magthe Replace individual packages in the chroot with the base group.
magthe authored
126 sudo ghc
39ca212 @magthe Add database and patches that matches the old status.
magthe authored
127
ee4be48 @magthe Fix the make script so it works with pacman 4.
magthe authored
128 # fix up the local repo
129 sudo mkdir ${CHROOT_ROOTDIR}/repo
130 sudo touch ${CHROOT_ROOTDIR}/repo/repo.db
131 sudo sed -i.org -e 's/^#\(.*\)/\1/' ${CHROOT_ROOTDIR}/etc/pacman.conf
132
39ca212 @magthe Add database and patches that matches the old status.
magthe authored
133 # no point in updating the newly built pristine
134 update_pristine_first=0
135 msg "Done"
136 fi
137
138 if [[ "${update_pristine_first}" == "1" ]]; then
e76beff @magthe Adding a delay on cleaning of the chroot, I have been bitten a few to…
magthe authored
139 msg "Updating the the pristine chroot (in 5 sec)..."
140 sleep 5
39ca212 @magthe Add database and patches that matches the old status.
magthe authored
141 sudo setarch ${arch} mkarchroot -u ${CHROOT_ROOTDIR}
142 clean_build_first=1
143 msg " Done"
144 fi
145
117f991 @magthe - Move build script from zsh to bash.
magthe authored
146 if [[ "${clean_build_first}" == "1" ]]; then
147 msg "Cleaning up the build chroot (in 5 sec)..."
148 sleep 5
39ca212 @magthe Add database and patches that matches the old status.
magthe authored
149 sudo rsync -a --delete -q -W -x "${CHROOT_ROOTDIR}/" "${CHROOT_BUILDDIR}"
150 msg " Done"
151 fi
152
153 for pkg0 in $@; do
117f991 @magthe - Move build script from zsh to bash.
magthe authored
154 pkg1=${pkg0,,}
39ca212 @magthe Add database and patches that matches the old status.
magthe authored
155 [ -d ${habs_dir}/${pkg1} ] && pkg=${pkg1}
156 [ -d ${habs_dir}/haskell-${pkg1} ] && pkg=haskell-${pkg1}
157 if [[ "x${pkg}" != "x" ]]; then
158 (cd ${habs_dir}/$pkg; buildpkg )
159 else
160 die "No such package: $pkg0"
161 fi
162 pkg=
163 done
Something went wrong with that request. Please try again.