Permalink
Switch branches/tags
Nothing to show
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
executable file 119 lines (108 sloc) 2.72 KB
#!/bin/sh
# --pancake // 2010-2011
whereami() {
for a in $PWD `echo $PATH | sed 's,:, ,g'` ; do
if [ -e "$a/$1" ]; then
echo "$a/$1"
return
fi
done
echo $1
}
ROOT="`whereami $BIN`"
. "${ROOT}/config"
if [ -n "${IGNDIRS}" ]; then
igncmd="grep -v $(echo "-e$IGNDIRS" | sed -e 's, , -e,g')"
else
igncmd="cat"
fi
export igncmd
gentoo_files() {
qlist $1
desc=$(emerge -s $1 | grep Description | cut -d -f 10-)
echo "DESC=\"${desc}\"" > slpm.nfo
echo "URL=\"none\"" >> slpm.nfo
echo "TYPE=genpkg" >> slpm.nfo
}
gentoo_version() {
emerge -s $1 | grep "version installed" | awk '{print $4}' | grep -v "\["
}
debian_files() {
dpkg -L $1
desc=$(dpkg -s $1 | grep Descrip | cut -d : -f 2- | cut -c 2-)
echo "DESC=\"${desc}\"" > slpm.nfo
echo "URL=\"none\"" >> slpm.nfo
echo "TYPE=genpkg" >> slpm.nfo
}
debian_version() {
dpkg -s $1 | grep Version | cut -d : -f 2- | cut -c 2-
}
arch_files() {
pacman -Ql $1 | cut -d ' ' -f 2- | grep -v /$
desc=$(pacman -Qi $1 | grep Descr | cut -d : -f 2- | cut -c 2-)
url=$(pacman -Qi $1 | grep URL | cut -d : -f 2- | cut -c 2-)
echo "DESC=\"$desc\"" > slpm.nfo
echo "URL=\"$url\"" >> slpm.nfo
echo "TYPE=genpkg" >> slpm.nfo
}
arch_version() {
pacman -Qi $1 | grep Version | awk '{print $3}'
}
port_files() {
port contents $1 | cut -c 3-
desc=$(port info $1 | grep Description | cut -c 23-)
url=$(port info $1 | grep Homepage | awk '{print $2}')
echo "DESC=\"$desc\"" > slpm.nfo
echo "URL=\"$url\"" >> slpm.nfo
echo "TYPE=genpkg" >> slpm.nfo
}
port_version() {
port info xz | head -n 1 | cut -d '@' -f 2 | awk '{print $1}'
}
getdistro() {
pacman -h >/dev/null 2>&1
if [ $? = 2 ]; then echo arch ; return ; fi
emerge -h >/dev/null 2>&1
if [ $? = 0 ]; then echo gentoo ; return ; fi
dpkg -h >/dev/null 2>&1
if [ $? = 0 ]; then echo debian ; return ; fi
port help >/dev/null 2>&1
if [ $? = 0 ]; then echo port ; return ; fi
}
if [ -z "$1" ]; then
echo "Usage: $0 [pkgname]"
echo "Supports osx-ports, debian, gentoo and pacman packages"
exit 1
fi
distro=$(getdistro)
if [ -z "$distro" ]; then
echo "Cannot find port, pacman, emerge or dpkg programs."
exit 1
fi
pkg=$1
export pkg distro
rm -rf .tmp
mkdir -p .tmp
cd .tmp
pkgver=$(${distro}_version $pkg)
if [ -z "$pkgver" ]; then
echo "Error: unknown package version"
else
echo version: $pkgver
files=`${distro}_files $pkg`
for a in $files ; do
[ -z "`echo $a | $igncmd `" ] && continue
[ -d "$a" ] && continue
dir=$(dirname $a)
mkdir -p ./$dir
if [ -z "`echo $a|grep /$`" ]; then
echo $a
cp -fa $a ./$a
fi
done
tar cpzf ../slpm-${pkg}-${pkgver}.tgz *
echo
echo slpm-${pkg}-${pkgver}.tgz
fi
cd ..
rm -rf .tmp