-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathipkg-build
executable file
·168 lines (140 loc) · 4.13 KB
/
ipkg-build
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
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
#!/bin/sh
# This is ipkg-build from the Vix opkg-tools with a few modifications to
# make it specific to this package
#GML ln -sfn /media/hdd/ipkg-tools/ar /usr/bin/ar
#GML Copy the version number from the source code to the control file.
#
sfile=src/usr/lib/enigma2/python/Plugins/Extensions/EPGTranslator/plugin.py
vers=`grep 'EPGTrans_vers =' $sfile | sed -e's/[^"]*\"//' -e's/\".*//'`
ed -s src/CONTROL/control <<EOE
/^Version:/c
Version: $vers
.
wq
EOE
# ipkg-build -- construct a .ipk from a directory
# Carl Worth <[email protected]>
# based on a script by Steve Redler IV, [email protected] 5-21-2001
set -e
ipkg_extract_value() {
sed -e "s/^[^:]*:[[:space:]]*//"
}
required_field() {
field=$1
value=`grep "^$field:" < $CONTROL/control | ipkg_extract_value`
if [ -z "$value" ]; then
echo "ipkg-build: Error: $CONTROL/control is missing field $field" ;
PKG_ERROR=1
fi
echo $value
}
pkg_appears_sane() {
local pkg_dir=$1
local owd=`pwd`
cd $pkg_dir
PKG_ERROR=0
if [ ! -f "$CONTROL/control" ]; then
echo "ipkg-build: Error: Control file $pkg_dir/$CONTROL/control not found."
cd $owd
return 1
fi
pkg=`required_field Package`
version=`required_field Version | sed 's/.*://;'`
arch=`required_field Architecture`
required_field Maintainer >/dev/null
required_field Description >/dev/null
if echo $pkg | grep '[^a-z0-9.+-]'; then
echo "ipkg-build: Error: Package name $name contains illegal characters, (other than [a-z0-9.+-])"
PKG_ERROR=1;
fi
local bad_fields=`sed -ne 's/^\([^[:space:]][^:[:space:]]\+[[:space:]]\+\)[^:].*/\1/p' < $CONTROL/control | sed -e 's/\\n//'`
if [ -n "$bad_fields" ]; then
bad_fields=`echo $bad_fields`
echo "ipkg-build: Error: The following fields in $CONTROL/control are missing a ':'"
echo " $bad_fields"
echo "ipkg-build: This may be due to a missing initial space for a multi-line field value"
PKG_ERROR=1
fi
for script in $CONTROL/preinst $CONTROL/postinst $CONTROL/prerm $CONTROL/postrm; do
if [ -f $script -a ! -x $script ]; then
echo "ipkg-build: Error: package script $script is not executable"
PKG_ERROR=1
fi
done
if [ -f $CONTROL/conffiles ]; then
for cf in `cat $CONTROL/conffiles`; do
if [ ! -f ./$cf ]; then
echo "ipkg-build: Error: $CONTROL/conffiles mentions conffile $cf which does not exist"
PKG_ERROR=1
fi
done
fi
cd $owd
return $PKG_ERROR
}
###
# ipkg-build "main"
###
#GML case $# in
#GML 1)
#GML dest_dir=.
#GML ;;
#GML 2)
#GML dest_dir=$2
#GML ;;
#GML *)
#GML echo "Usage: ipkg-build <pkg_directory> [<destination_directory>]" ;
#GML exit 1
#GML ;;
#GML esac
#GML
#GML pkg_dir=$1
#
pkg_dir=src
dest_dir=.
if [ ! -d $pkg_dir ]; then
echo "ipkg-build: Error: Directory $pkg_dir does not exist"
exit 1
fi
# CONTROL is second so that it takes precedence
CONTROL=
[ -d $pkg_dir/DEBIAN ] && CONTROL=DEBIAN
[ -d $pkg_dir/CONTROL ] && CONTROL=CONTROL
if [ -z "$CONTROL" ]; then
echo "ipkg-build: Error: Directory $pkg_dir has no CONTROL subdirectory."
exit 1
fi
if ! pkg_appears_sane $pkg_dir; then
echo "Please fix the above errors and try again."
exit 1
fi
tmp_dir=$dest_dir/IPKG_BUILD.$$
mkdir $tmp_dir
#tar -C $pkg_dir -czf $tmp_dir/data.tar.gz . --exclude=$pkg_dir/CONTROL
#
# gutemine's fix for --exclude bug
#
FILESWITHOUTCONTROL=`cd $pkg_dir; ls -1 | grep -v CONTROL`
#echo $FILESWITHOUTCONTROL
#GML Set owner/group to 0/0
tar --owner=0 --group=0 -C $pkg_dir -czf $tmp_dir/data.tar.gz $FILESWITHOUTCONTROL
tar --owner=0 --group=0 -C $pkg_dir/$CONTROL -czf $tmp_dir/control.tar.gz .
echo "2.0" > $tmp_dir/debian-binary
pkg_file=$dest_dir/${pkg}_${version}_${arch}.ipk
#if [ -f /usr/bin/enigma2 ]; then
# if [ ! -f /usr/local/bin/ar ]; then
# BUSYBOX=`ls -F /usr/bin/ar | grep @ | wc -l`
# if [ $BUSYBOX -eq 1 ]; then
# echo ar seems to be from busybox - not capable to create archive
# echo Install ar from binutils at /usr/local/bin
# echo or replace link from /usr/bin/ar to busybox with real ar binary
# exit 0
# fi
# fi
#fi
cd $tmp_dir
ar -r $pkg_file ./debian-binary ./control.tar.gz ./data.tar.gz
mv $pkg_file ..
cd ..
rm -r -f $tmp_dir
echo "Packaged content was moved at $pkg_dir into $pkg_file"