3
# ipkg-deb-build -- construct a debian file format .ipk from a directory
4
# Jamey Hicks <jamey.hicks@hp.com>
5
# Carl Worth <cworth@east.isi.edu>
6
# based on a script by Steve Redler IV, steve@sr-tech.com 5-21-2001
10
sed -e "s/^[^:]*:[[:space:]]*//"
16
value=`grep "^$field:" < $CONTROL/control | ipkg_extract_value`
17
if [ -z "$value" ]; then
18
echo "*** Error: $CONTROL/control is missing field $field" >&2
33
tilde_files=`find . -name '*~'`
34
if [ -n "$tilde_files" ]; then
35
echo "*** Warning: The following files have names ending in '~'.
36
You probably want to remove them: " >&2
41
large_uid_files=`find . -uid +99`
42
if [ -n "$large_uid_files" ]; then
43
echo "*** Warning: The following files have a UID greater than 99.
44
You probably want to chown these to a system user: " >&2
45
ls -ld $large_uid_files
50
if [ ! -f "$CONTROL/control" ]; then
51
echo "*** Error: Control file $pkg_dir/$CONTROL/control not found." >&2
56
pkg=`required_field Package`
57
[ "$?" -ne 0 ] && PKG_ERROR=1
59
version=`required_field Version | sed 's/.*://;'`
60
[ "$?" -ne 0 ] && PKG_ERROR=1
62
arch=`required_field Architecture`
63
[ "$?" -ne 0 ] && PKG_ERROR=1
65
required_field Maintainer >/dev/null
66
[ "$?" -ne 0 ] && PKG_ERROR=1
68
required_field Description >/dev/null
69
[ "$?" -ne 0 ] && PKG_ERROR=1
71
section=`required_field Section`
72
[ "$?" -ne 0 ] && PKG_ERROR=1
73
if [ -z "$section" ]; then
74
echo "The Section field should have one of the following values:" >&2
75
echo "admin, base, comm, editors, extras, games, graphics, kernel, libs, misc, net, text, web, x11" >&2
78
priority=`required_field Priority`
79
[ "$?" -ne 0 ] && PKG_ERROR=1
80
if [ -z "$priority" ]; then
81
echo "The Priority field should have one of the following values:" >&2
82
echo "required, important, standard, optional, extra." >&2
83
echo "If you don't know which priority value you should be using, then use \`optional'" >&2
86
if echo $pkg | grep '[^a-z0-9.+-]'; then
87
echo "*** Error: Package name $name contains illegal characters, (other than [a-z0-9.+-])" >&2
91
local bad_fields=`sed -ne 's/^\([^[:space:]][^:[:space:]]\+[[:space:]]\+\)[^:].*/\1/p' < $CONTROL/control | sed -e 's/\\n//'`
92
if [ -n "$bad_fields" ]; then
93
bad_fields=`echo $bad_fields`
94
echo "*** Error: The following fields in $CONTROL/control are missing a ':'" >&2
95
echo " $bad_fields" >&2
96
echo "ipkg-build: This may be due to a missing initial space for a multi-line field value" >&2
100
for script in $CONTROL/preinst $CONTROL/postinst $CONTROL/prerm $CONTROL/postrm; do
101
if [ -f $script -a ! -x $script ]; then
102
echo "*** Error: package script $script is not executable" >&2
107
if [ -f $CONTROL/conffiles ]; then
108
for cf in `cat $CONTROL/conffiles`; do
109
if [ ! -f ./$cf ]; then
110
echo "*** Error: $CONTROL/conffiles mentions conffile $cf which does not exist" >&2
132
echo "Usage: ipkg-build <pkg_directory> [<destination_directory>]" >&2
139
if [ ! -d $pkg_dir ]; then
140
echo "*** Error: Directory $pkg_dir does not exist" >&2
144
# CONTROL is second so that it takes precedence
146
[ -d $pkg_dir/DEBIAN ] && CONTROL=DEBIAN
147
[ -d $pkg_dir/CONTROL ] && CONTROL=CONTROL
148
if [ -z "$CONTROL" ]; then
149
echo "*** Error: Directory $pkg_dir has no CONTROL subdirectory." >&2
153
if ! pkg_appears_sane $pkg_dir; then
155
echo "ipkg-build: Please fix the above errors and try again." >&2
159
tmp_dir=$dest_dir/IPKG_BUILD.$$
162
tar -C $pkg_dir -czf $tmp_dir/data.tar.gz . --exclude=$CONTROL
163
tar -C $pkg_dir/$CONTROL -czf $tmp_dir/control.tar.gz .
165
echo "2.0" > $tmp_dir/debian-binary
167
pkg_file=${pkg}_${version}_${arch}.ipk
170
ar crf $pkg_dir/$pkg_file ./debian-binary ./data.tar.gz ./control.tar.gz
172
mv $pkg_file $dest_dir
173
rm -f $tmp_dir/debian-binary $tmp_dir/data.tar.gz $tmp_dir/control.tar.gz
176
echo "Packaged contents of $pkg_dir into $pkg_file"