[imagebuilder] fix a small typo in sed pattern
[openwrt/svn-archive/archive.git] / target / imagebuilder / files / opkg-generate-config.sh
1 #!/bin/sh
2
3 TOPDIR="$(pwd)"
4 TARGETDIR="${1}"
5
6 [ -f "$TOPDIR/scripts/${0##*/}" ] || {
7 echo "Please execute within the toplevel directory" >&2
8 exit 1
9 }
10
11 # Try to find package architecture from packages directory
12 PKGARCH=
13 for pkg in $TOPDIR/packages/*.ipk; do
14 if [ -f "$pkg" ]; then
15 PKGARCH="${pkg##*/}"
16 PKGARCH="${PKGARCH#*_*_}"
17 PKGARCH="${PKGARCH%.ipk}"
18 [ "$PKGARCH" = all ] || break
19 fi
20 done
21
22 # Try to find package architecture from the target directory
23 [ -n "$PKGARCH" ] || {
24 PKGARCH="${TARGETDIR##*/root-}"
25 [ "$PKGARCH" != "$TARGETDIR" ] || {
26 echo "Cannot determine package architecture" >&2
27 exit 1
28 }
29 }
30
31 rm -f $TOPDIR/tmp/opkg.conf
32
33 [ -f $TOPDIR/repositories.conf ] && \
34 $TOPDIR/staging_dir/host/bin/sed \
35 -n -e "s/\$A/$PKGARCH/g" -e "/^[[:space:]]*src/p" \
36 $TOPDIR/repositories.conf > $TOPDIR/tmp/opkg.conf
37
38 cat <<EOT >> $TOPDIR/tmp/opkg.conf
39 dest root /
40 arch all 100
41 arch $PKGARCH 200
42 option offline_root $TARGETDIR
43 src imagebuilder file:$TOPDIR/packages
44 EOT
45
46 exit 0