a385d9fa9b93b988c7407622aa444a36b8435848
[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%.ipk}"
17 [ "$PKGARCH" = all ] || break
18 fi
19 done
20
21 # Try to find package architecture from the target directory
22 [ -n "$PKGARCH" ] || {
23 PKGARCH="${TARGETDIR##*/root-}"
24 [ "$PKGARCH" != "$TARGETDIR" ] || {
25 echo "Cannot determine package architecture" >&2
26 exit 1
27 }
28 }
29
30 rm -f $TOPDIR/tmp/opkg.conf
31
32 [ -f $TOPDIR/repositories.conf ] && \
33 $TOPDIR/staging_dir/host/bin/sed \
34 -n -e "s/\$A/$PKGARCH/g" -e "/^[[:space:]*]src/p" \
35 $TOPDIR/repositories.conf > $TOPDIR/tmp/opkg.conf
36
37 cat <<EOT >> $TOPDIR/tmp/opkg.conf
38 dest root /
39 arch all 100
40 arch $PKGARCH 200
41 option offline_root $TARGETDIR
42 src imagebuilder file:$TOPDIR/packages
43 EOT
44
45 exit 0