aboutsummaryrefslogtreecommitdiffstats
path: root/target/imagebuilder/files/opkg-generate-config.sh
blob: d8fb0e40653b2598914ded34e9e9c005853f8131 (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
#!/bin/sh

TOPDIR="$(pwd)"
TARGETDIR="${1}"

[ -f "$TOPDIR/scripts/${0##*/}" ] || {
	echo "Please execute within the toplevel directory" >&2
	exit 1
}

# Try to find package architecture from packages directory
PKGARCH=
for pkg in $TOPDIR/packages/*.ipk; do
	if [ -f "$pkg" ]; then
		PKGARCH="${pkg##*/}"
		PKGARCH="${PKGARCH#*_*_}"
		PKGARCH="${PKGARCH%.ipk}"
		[ "$PKGARCH" = all ] || break
	fi
done

# Try to find package architecture from the target directory
[ -n "$PKGARCH" ] || {
	PKGARCH="${TARGETDIR##*/root-}"
	[ "$PKGARCH" != "$TARGETDIR" ] || {
		echo "Cannot determine package architecture" >&2
		exit 1
	}
}

rm -f $TOPDIR/tmp/opkg.conf

[ -f $TOPDIR/repositories.conf ] && \
	$TOPDIR/staging_dir/host/bin/sed \
		-n -e "s/\$A/$PKGARCH/g" -e "/^[[:space:]*]src/p" \
		$TOPDIR/repositories.conf > $TOPDIR/tmp/opkg.conf

cat <<EOT >> $TOPDIR/tmp/opkg.conf
dest root /
arch all 100
arch $PKGARCH 200
option offline_root $TARGETDIR
src imagebuilder file:$TOPDIR/packages
EOT

exit 0