~ubuntu-branches/ubuntu/quantal/gnurobbo/quantal

« back to all changes in this revision

Viewing changes to zaurus/_ipkg-build

  • Committer: Bazaar Package Importer
  • Author(s): Ansgar Burchardt, Ansgar Burchardt, Gonéri Le Bouder
  • Date: 2009-03-14 23:10:50 UTC
  • mfrom: (1.1.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20090314231050-70zcgdcmp7177pql
Tags: 0.61-1
[ Ansgar Burchardt ]
* New Upstream Version (LP: #337089)
* Do not dump vm usage information
  + New patch: do-not-dump-vmusage.diff
* Update packaging for debhelper 7
* Update copyright information
* Update Vcs-* fields for the Git repository
* Bump Standards Version to 3.8.0
  + add debian/README.source
* Add watch file

[ Gonéri Le Bouder ]
* Do not install the LICENSE-font files 

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/bin/sh
 
2
 
 
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
 
6
set -e
 
7
 
 
8
ipkg_extract_value() {
 
9
        sed -e "s/^[^:]*:[[:space:]]*//"
 
10
}
 
11
 
 
12
required_field() {
 
13
        field=$1
 
14
 
 
15
        value=`grep "^$field:" < $CONTROL/control | ipkg_extract_value`
 
16
        if [ -z "$value" ]; then
 
17
                echo "*** Error: $CONTROL/control is missing field $field" >&2
 
18
                return 1
 
19
        fi
 
20
        echo $value
 
21
        return 0
 
22
}
 
23
 
 
24
pkg_appears_sane() {
 
25
        local pkg_dir=$1
 
26
 
 
27
        local owd=`pwd`
 
28
        cd $pkg_dir
 
29
 
 
30
        PKG_ERROR=0
 
31
 
 
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
 
37
#               echo >&2
 
38
#       fi
 
39
            
 
40
 
 
41
        if [ ! -f "$CONTROL/control" ]; then
 
42
                echo "*** Error: Control file $pkg_dir/$CONTROL/control not found." >&2
 
43
                cd $owd
 
44
                return 1
 
45
        fi
 
46
 
 
47
        pkg=`required_field Package`
 
48
        [ "$?" -ne 0 ] && PKG_ERROR=1
 
49
 
 
50
        version=`required_field Version | sed 's/.*://;'`
 
51
        [ "$?" -ne 0 ] && PKG_ERROR=1
 
52
 
 
53
        arch=`required_field Architecture`
 
54
        [ "$?" -ne 0 ] && PKG_ERROR=1
 
55
 
 
56
        required_field Maintainer >/dev/null
 
57
        [ "$?" -ne 0 ] && PKG_ERROR=1
 
58
 
 
59
        required_field Description >/dev/null
 
60
        [ "$?" -ne 0 ] && PKG_ERROR=1
 
61
 
 
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
 
67
        fi
 
68
 
 
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
 
75
        fi
 
76
 
 
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
 
79
                PKG_ERROR=1;
 
80
        fi
 
81
 
 
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
 
88
                PKG_ERROR=1
 
89
        fi
 
90
 
 
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
 
94
                        PKG_ERROR=1
 
95
                fi
 
96
        done
 
97
 
 
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
 
102
                                PKG_ERROR=1
 
103
                        fi
 
104
                done
 
105
        fi
 
106
 
 
107
        cd $owd
 
108
        return $PKG_ERROR
 
109
}
 
110
 
 
111
###
 
112
# ipkg-build "main"
 
113
###
 
114
 
 
115
case $# in
 
116
1)
 
117
        dest_dir=.
 
118
        ;;
 
119
2)
 
120
        dest_dir=$2
 
121
        ;;
 
122
*)
 
123
        echo "Usage: ipkg-build <pkg_directory> [<destination_directory>]" >&2
 
124
        exit 1 
 
125
        ;;
 
126
esac
 
127
 
 
128
pkg_dir=$1
 
129
 
 
130
if [ ! -d $pkg_dir ]; then
 
131
        echo "*** Error: Directory $pkg_dir does not exist" >&2
 
132
        exit 1
 
133
fi
 
134
 
 
135
# CONTROL is second so that it takes precedence
 
136
CONTROL=
 
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
 
141
        exit 1
 
142
fi
 
143
 
 
144
if ! pkg_appears_sane $pkg_dir; then
 
145
        echo >&2
 
146
        echo "ipkg-build: Please fix the above errors and try again." >&2
 
147
        exit 1
 
148
fi
 
149
 
 
150
tmp_dir=/tmp/IPKG_BUILD.$$
 
151
mkdir $tmp_dir
 
152
 
 
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
 
157
 
 
158
echo "2.0" > $tmp_dir/debian-binary
 
159
 
 
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
 
164
 
 
165
rm $tmp_dir/debian-binary $tmp_dir/data.tar.gz $tmp_dir/control.tar.gz
 
166
rmdir $tmp_dir
 
167
 
 
168
echo "Packaged contents of $pkg_dir into $pkg_file"