Skip to content

Instantly share code, notes, and snippets.

@7shi
Created May 1, 2012 16:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save 7shi/2569475 to your computer and use it in GitHub Desktop.
Save 7shi/2569475 to your computer and use it in GitHub Desktop.
適当パッケージャ
#!/bin/sh
# This file is in the public domain.
dest=/dest
prefix=/usr/local
pkgdir=/pkg
suffix=msys
type=$1
shift
case $type in
make)
cmd=$@
if [ -z "$cmd" ]; then cmd=install; fi
pwd=`pwd`
pkg=`basename $pwd`
pkgfile=$pkgdir/$pkg-$suffix.tar.xz
rm -rf $dest
DESTDIR=$dest make $cmd
if [ ! -d $dest$prefix ]
then
echo "error: $dest$prefix"
exit 1
fi
cd $dest$prefix
find . -name "*.exe" -or -name "*.dll" | xargs strip
mkdir -p $pkgdir
tar cvJf $pkgfile *
cd $pwd
mkdir -p $prefix
tar xvJf $pkgfile -C $prefix
exit;;
install)
for arg in $@
do
mkdir -p $prefix
tar xvJf $arg -C $prefix
done
exit;;
delete)
for arg in $@
do
for f in `tar tJf $arg`
do
if [ -f $prefix/$f ]
then
echo rm $f
rm $prefix/$f
elif [ -d $prefix/$f ]
then
dirs="$f $dirs"
fi
done
for d in $dirs
do
echo rmdir $d
rmdir $prefix/$d
done
done
exit;;
esac
echo "usage: `basename $0` make|install|delete package [options ...]"
exit 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment