-
Notifications
You must be signed in to change notification settings - Fork 5
/
slpm-genpkg
executable file
·118 lines (108 loc) · 2.72 KB
/
slpm-genpkg
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
#!/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