1
0

tarpkg 1.2 KB

1234567891011121314151617181920212223242526272829303132333435
  1. #!/usr/bin/env bash
  2. # create/install compressed tar balls
  3. #set -x
  4. if [ "$1" = "build" ];then
  5. if [ ! -d $2 ];then
  6. echo "not a directory"
  7. exit 1
  8. fi
  9. pkgname=$(grep "^Package:" $2/CONTROL/control | sed -e "s/^[^:]*:[[:space:]]*//")
  10. version=$(grep "^Version:" $2/CONTROL/control | sed -e "s/^[^:]*:[[:space:]]*//")
  11. arch=$(grep "^Architecture:" $2/CONTROL/control | sed -e "s/^[^:]*:[[:space:]]*//")
  12. mkdir -p ${2}/usr/lib/pkg
  13. for file in preinst postinst prerm postrm; do
  14. [ ! -f $2/CONTROL/$file ] || ( cp $2/CONTROL/$file \
  15. ${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
  25. fi
  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
  30. fi
  31. else
  32. echo "unknown command"
  33. exit 1
  34. fi