package/hostapd: enhance compile-options a bit, eases testing
[openadk.git] / scripts / tarpkg
blob37c0b2079fea7a913267dbd1c578f79454f7efaa
1 #!/usr/bin/env bash
2 # create/install compressed tar balls
3 #set -x
5 if [ "$1" = "build" ];then
6 if [ ! -d $2 ];then
7 echo "not a directory"
8 exit 1
9 fi
10 pkgname=$(grep "^Package:" $2/CONTROL/control | sed -e "s/^[^:]*:[[:space:]]*//")
11 version=$(grep "^Version:" $2/CONTROL/control | sed -e "s/^[^:]*:[[:space:]]*//")
12 arch=$(grep "^Architecture:" $2/CONTROL/control | sed -e "s/^[^:]*:[[:space:]]*//")
13 for file in preinst postinst prerm postrm; do
14 [ ! -f $2/CONTROL/$file ] || ( mkdir -p ${2}/usr/lib/pkg && \
15 cp $2/CONTROL/$file ${2}/usr/lib/pkg/${pkgname}.$file && \
16 chmod +x ${2}/usr/lib/pkg/${pkgname}.$file )
17 done
18 rm -rf $2/CONTROL
19 (cd $2 && tar -czf $3/${pkgname}_${version}_${arch}.tar.gz .)
20 elif [ "$1" = "install" ];then
21 pkg=$(echo $(basename $2)|sed -e "s#_.*##")
22 if [ -x ${PKG_INSTROOT}/usr/lib/pkg/${pkg}.preinst ]; then
23 IPKG_INSTROOT="$PKG_INSTROOT" ${PKG_INSTROOT}/usr/lib/pkg/${pkg}.preinst
24 rm ${PKG_INSTROOT}/usr/lib/pkg/${pkg}.preinst
26 tar -xzpf $2 -C ${PKG_INSTROOT}
27 if [ -x ${PKG_INSTROOT}/usr/lib/pkg/${pkg}.postinst ]; then
28 IPKG_INSTROOT="$PKG_INSTROOT" ${PKG_INSTROOT}/usr/lib/pkg/${pkg}.postinst
29 rm ${PKG_INSTROOT}/usr/lib/pkg/${pkg}.postinst
31 rm -rf ${PKG_INSTROOT}/usr/lib/pkg
32 else
33 echo "unknown command"
34 exit 1