summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: d8a5552c187ef252d0a9a7370562139b414f2ef5 (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
62
63
# Maintainer: Anton Hvornum <anton.feeds+AUR@gmail.com>
# makepkg --printsrcinfo > .SRCINFO
# TODO: lower case all variables, just so we don't mess something up and poke people in the eye.
_owner=Torxed
_name=archiso-offline-releng
pkgname=$_name
pkgver=0.0.1.r1
pkgrel=1
pkgdesc="A simple, offline-installable modification on archiso/releng"
arch=('x86_64')
url="https://github.com/Torxed"
license=('custom:BSD' 'cc-by-nc-sa-3.0')
depends=('archiso' 'pacman' 'wget' 'tar' 'ed')
provides=('archiso-offline-releng')
source=("https://aur.archlinux.org/cgit/aur.git/snapshot/archiso-offline-releng.tar.gz")
sha256sums=('SKIP')

# Target function is the function we'll be looking for to prepend our offline functions
# (function won't get replaced, just moved down a little bit to make space for our own)
#
# target function chain is where in the build process to inject our own chain right before.
TARGET_FUNCTION="make_iso()"
TARGET_FUNCTION_CHAIN="make_customize_airootfs"
OFFLINE_MIRROR_PATH="${script_path}/${work_dir}/x86_64/airootfs/srv/http/arch_offline"

prepare() {
    mkdir -p "$srcdir/usr/share/archiso/configs/offline_releng"
    cp -r /usr/share/archiso/configs/releng/* "$srcdir/usr/share/archiso/configs/offline_releng/"
}

build() {
    ## Instead of a patch file, which, requires more maintanance between upgrades..
	## We'll use these stringified functions and prepend these before a known function
	## in the standard build.sh script. That way it doesn't matter if functions get patched
	## and line numbers/content changes. As long as the overall work-flow of build.sh
	## stays intact, we'll have a greater success of injecting the offline functions.

	BUILD_FUNCTIONS=$(<$srcdir/${_name}/offline_functions.sh)

	CHAIN_INJECT="run_once make_aur_packages\n"
	CHAIN_INJECT+="run_once make_offline_mirror\n"
	CHAIN_INJECT+="run_once patch_in_local_mirror\n"
	CHAIN_INJECT+="run_once install_aur\n"
	CHAIN_INJECT+="run_once finalize_offline\n"

	# Patch in the functions right before $TARGET_FUNCTION and migrate over the OFFLINE_MIRROR_PATH.
	# TODO: use sed to replace a fancy variable in offline_function.sh and insert $TARGET_FUNCTION,
	#       since now it's hard coded and if we change in here, it won't work after this `ed` oneliner.
	printf '%s\n' "/${TARGET_FUNCTION}/r $srcdir/${_name}/offline_functions.sh" 1 "/${TARGET_FUNCTION}/d" w | ed "$srcdir/usr/share/archiso/configs/offline_releng/build.sh"
	sed -i "s;verbose=;offline_mirror_path=${OFFLINE_MIRROR_PATH}\n&;" "$srcdir/usr/share/archiso/configs/offline_releng/build.sh"

	# Patch in the function calls before $TARGET_FUNCTION_CHAIN
	sed -i "s/run_once ${TARGET_FUNCTION_CHAIN}/${CHAIN_INJECT}\n&/" "$srcdir/usr/share/archiso/configs/offline_releng/build.sh"
}

package() {
    cd ${srcdir}

    # Install the offline-modified releng
    install -dm 755 "$pkgdir/usr/share/archiso/configs"
    cp -r "$srcdir/usr/share/archiso/configs/offline_releng" "$pkgdir/usr/share/archiso/configs/"
}