x11vnc: fix compile error
[openadk.git] / scripts / tarpkg
blob40ff9412270c17fd4579621c17940584003af33f
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 -cf - .|xz -c > $3/${pkgname}_${version}_${arch}.tar.xz)
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 xz -d -c $2|tar -xpf - -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