summarylogtreecommitdiffstats
path: root/chroot-build.sh
blob: c90e44035f19f26122ee4b523b1c5ae0d700df92 (plain)
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
#!/bin/bash

## builds done in a clean chroot
## source files taken from pkgdir/src-cache if present
## output packages placed in pkgdir/release-pkg if present

# NOTE: you can send environment variables to chroot/makepkg by stuffing them on the end of the makechrootpkg command after --

#CHROOT="$HOME/work/arch-kernels/build-chroot"
HOME="$HOME"

fatal() { echo "$@" >&2; exit 1; }
# look for a PKGBUILD
if ! [[ -s PKGBUILD ]]; then
  fatal "no PKGBUILD in this directory!"
fi
# look for valid chroot
if ! [[ -d "${CHROOT}/root" ]]; then
  fatal "${CHROOT}/root doesn't exist, womp womp"
fi

# if SRCDEST is empty then look for pkg src-cache/ directory and use it
if [[ -z ${SRCDEST+x} ]] && [[ -d "$(pwd)/src-cache" ]]; then
  export SRCDEST="$(pwd)/src-cache"
fi

# use supplied output directory or fall back to ./release-pkg/ if present
if [[ -d "$DEST" ]]; then
  export PKGDEST="$DEST"
  export LOGDEST="$DEST"
elif [[ -d "$(pwd)/release-pkg" ]]; then
  export PKGDEST="$(pwd)/release-pkg"
  export LOGDEST="$(pwd)/release-pkg"
fi

# use modprobed-db
cp PKGBUILD .PKGBUILD
cp $HOME/.config/modprobed.db "$(dirname "$(readlink -f -- "$0")")"
sed 's/#  modprobed-db/  modprobed-db/g' -i PKGBUILD
sed 's/#  modprobed.db/  modprobed.db/g' -i PKGBUILD
sed 's/# _make LSMOD/_make LSMOD/' -i PKGBUILD
sed 's/_microarchitecture=93/_microarchitecture=15/' -i PKGBUILD
sed "s//Microarchitecture='CONFIG_GENERIC_CPU3'/Microarchitecture='CONFIG_MZEN3'/" -i PKGBUILD 

#
# To send environment variable to a PKGBUILD call this script like this:
#   `rbuild.sh -- {any makepkg flags} VAR=VALUE VAR2=VALUE etc..`
#

makechrootpkg -c -r "${CHROOT}" "$@"

rm PKGBUILD
mv .PKGBUILD PKGBUILD