-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpackmaker
executable file
·119 lines (109 loc) · 2.26 KB
/
packmaker
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
119
#!/bin/bash
#
# PACKMAKER (c) 2009 Bati Sengul <[email protected]>
#
# I hereby let you (presumably a user) to use, modify and redistribute the software
# with no conditions imposed. It would be nice to let me know if you do plan to
# modify and redistribute.
#
#
VERSION=0.1
AUTHOR="Bati Sengul <[email protected]>"
BPACK_DIR="/var/bpack"
ret="default"
inst=1
newest=1
file=1
output="default"
options (){
i=0
for line in $*
do
case $line in
-n)
inst=0
;;
-i)
newest=0
;;
esac
let 'i=i+1'
done
}
getname (){
temp=$1
#Remove the 2.5-8 and such and make it 2.5.8
index=${temp%[0-9]-[0-9]*}
while [ ${#temp} -gt ${#index} ]
do
temp=${temp:0:${#index}+1}.${temp:${#index}+2}
index=${temp%[0-9]-[0-9]*}
done
#Remove the rc
index=${temp%[0-9]rc[0-9]*}
while [ ${#temp} -gt ${#index} ]
do
temp=${temp:0:${#index}+1}.${temp:${#index}+3}
index=${temp%[0-9]rc[0-9]*}
done
#Remove the beta
index=${temp%[0-9]beta-[0-9]*}
while [ ${#temp} -gt ${#index} ]
do
temp=${temp:0:${#index}+1}.${temp:${#index}+6}
index=${temp%[0-9]beta-[0-9]*}
done
#Remove the git
index=${temp%[0-9]git[0-9]*}
while [ ${#temp} -gt ${#index} ]
do
temp=${temp:0:${#index}+1}.${temp:${#index}+4}
index=${temp%[0-9]git[0-9]*}
done
ret=$temp
}
pack (){
pack=$1
file=""
# Check if they have the package installed
for lin in $( ls $BPACK_DIR/installed/ | grep $1)
do
if [ "${lin:0:${#pack}}" == "$pack" ]; then
file=$lin
break
fi
done
if [ -n $file ] && [ $inst -eq 0 ]; then
output="$file.bpack"
tar cf $output $( cat $BPACK_DIR/installed/$file ) $BPACK_DIR/installed/$file
return
fi
if [ $inst -eq 1 ]; then
out=$( `bpack install $pack` )
echo $out
fi
}
case $1 in
-h| --help)
echo "Packmaker version $VERSION"
echo " Author: $AUTHOR"
echo "Packmaker makes binary packages from installed or uninstalled bpack packages. Usage: "
echo -e "\tpackmaker [options] [package]\n"
echo "Options"
echo -e " -n\tDo not install the file if it is not already installed"
echo -e " -i\tAllways try to use the installed version (not necessarily the newest)"
exit 0
;;
# *)
# echo -n "Usage: "
# echo -e "\tpackamker [options] [package]"
# exit 0
# ;;
esac
options $*
for line in $*
do
if [ ! "${line:0:1}" == '-' ]; then
pack $line
fi
done