3
# ipkg-build -- construct a .ipk from a directory
4
# Carl Worth <cworth@east.isi.edu>
5
# based on a script by Steve Redler IV, steve@sr-tech.com 5-21-2001
9
sed -e "s/^[^:]*:[[:space:]]*//"
15
value=`grep "^$field:" < $CONTROL/control | ipkg_extract_value`
16
if [ -z "$value" ]; then
17
echo "*** Error: $CONTROL/control is missing field $field" >&2
32
# large_uid_files=`find . -uid +99`
33
# if [ -n "$large_uid_files" ]; then
34
# echo "*** Warning: The following files have a UID greater than 99.
35
#You probably want to chown these to a system user: " >&2
36
# ls -ld $large_uid_files
41
if [ ! -f "$CONTROL/control" ]; then
42
echo "*** Error: Control file $pkg_dir/$CONTROL/control not found." >&2
47
pkg=`required_field Package`
48
[ "$?" -ne 0 ] && PKG_ERROR=1
50
version=`required_field Version | sed 's/.*://;'`
51
[ "$?" -ne 0 ] && PKG_ERROR=1
53
arch=`required_field Architecture`
54
[ "$?" -ne 0 ] && PKG_ERROR=1
56
required_field Maintainer >/dev/null
57
[ "$?" -ne 0 ] && PKG_ERROR=1
59
required_field Description >/dev/null
60
[ "$?" -ne 0 ] && PKG_ERROR=1
62
section=`required_field Section`
63
[ "$?" -ne 0 ] && PKG_ERROR=1
64
if [ -z "$section" ]; then
65
echo "The Section field should have one of the following values:" >&2
66
echo "admin, base, comm, editors, extras, games, graphics, kernel, libs, misc, net, text, web, x11" >&2
69
priority=`required_field Priority`
70
[ "$?" -ne 0 ] && PKG_ERROR=1
71
if [ -z "$priority" ]; then
72
echo "The Priority field should have one of the following values:" >&2
73
echo "required, important, standard, optional, extra." >&2
74
echo "If you don't know which priority value you should be using, then use \`optional'" >&2
77
if echo $pkg | egrep '[^a-zA-Z0-9.+-]'; then
78
echo "*** Error: Package name $name contains illegal characters, (other than [a-z0-9.+-])" >&2
82
local bad_fields=`sed -ne 's/^\([^[:space:]][^:[:space:]]\+[[:space:]]\+\)[^:].*/\1/p' < $CONTROL/control | sed -e 's/\\n//'`
83
if [ -n "$bad_fields" ]; then
84
bad_fields=`echo $bad_fields`
85
echo "*** Error: The following fields in $CONTROL/control are missing a ':'" >&2
86
echo " $bad_fields" >&2
87
echo "ipkg-build: This may be due to a missing initial space for a multi-line field value" >&2
91
for script in $CONTROL/preinst $CONTROL/postinst $CONTROL/prerm $CONTROL/postrm; do
92
if [ -f $script -a ! -x $script ]; then
93
echo "*** Error: package script $script is not executable" >&2
98
if [ -f $CONTROL/conffiles ]; then
99
for cf in `cat $CONTROL/conffiles`; do
100
if [ ! -f ./$cf ]; then
101
echo "*** Error: $CONTROL/conffiles mentions conffile $cf which does not exist" >&2
123
echo "Usage: ipkg-build <pkg_directory> [<destination_directory>]" >&2
130
if [ ! -d $pkg_dir ]; then
131
echo "*** Error: Directory $pkg_dir does not exist" >&2
135
# CONTROL is second so that it takes precedence
137
[ -d $pkg_dir/DEBIAN ] && CONTROL=DEBIAN
138
[ -d $pkg_dir/CONTROL ] && CONTROL=CONTROL
139
if [ -z "$CONTROL" ]; then
140
echo "*** Error: Directory $pkg_dir has no CONTROL subdirectory." >&2
144
if ! pkg_appears_sane $pkg_dir; then
146
echo "ipkg-build: Please fix the above errors and try again." >&2
150
tmp_dir=/tmp/IPKG_BUILD.$$
153
tar -C $pkg_dir -cpf $tmp_dir/data.tar . --exclude=$CONTROL
154
gzip -9 $tmp_dir/data.tar
155
tar -C $pkg_dir/$CONTROL -cf $tmp_dir/control.tar .
156
gzip -9 $tmp_dir/control.tar
158
echo "2.0" > $tmp_dir/debian-binary
160
pkg_file=${pkg}_${version}_${arch}.ipk
161
tar -C $tmp_dir -cf $tmp_dir/$pkg_file ./debian-binary ./data.tar.gz ./control.tar.gz
162
gzip -9 $tmp_dir/$pkg_file
163
mv $tmp_dir/$pkg_file.gz $dest_dir/$pkg_file
165
rm $tmp_dir/debian-binary $tmp_dir/data.tar.gz $tmp_dir/control.tar.gz
168
echo "Packaged contents of $pkg_dir into $pkg_file"