summarylogtreecommitdiffstats
path: root/chroot-build.sh
blob: f6045161f2b5ceafd3185cc18d54e43147648019 (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
54
55
56
57
58
59
60
61
#!/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|g' -i PKGBUILD
sed 's|_microarchitecture=93|_microarchitecture=15|g' -i PKGBUILD
sed "s|Microarchitecture='CONFIG_GENERIC_CPU3'|Microarchitecture='CONFIG_MZEN3'|g" -i PKGBUILD 
updpkgsums

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

# either use makechrootpkg ...
# makechrootpkg -c -r "${CHROOT}" "$@"

# or clean-chroot-manager (AUR)
sudo ccm s

# sync repos afterwards (again)
sudo pacman -Sy

rm PKGBUILD
mv .PKGBUILD PKGBUILD