|
| 1 | +#!/bin/sh |
| 2 | + |
| 3 | +cp ../build/classes/*class packaging/home/QtPalmtop/java/ebbeflut/ |
| 4 | + |
| 5 | +# ipkg-build -- construct a .ipk from a directory |
| 6 | + |
| 7 | +# based on a script by Steve Redler IV, [email protected] 5-21-2001 |
| 8 | +set -e |
| 9 | + |
| 10 | +ipkg_extract_value() { |
| 11 | + sed -e "s/^[^:]*:[[:space:]]*//" |
| 12 | +} |
| 13 | + |
| 14 | +required_field() { |
| 15 | + field=$1 |
| 16 | + |
| 17 | + value=`grep "^$field:" < $CONTROL/control | ipkg_extract_value` |
| 18 | + if [ -z "$value" ]; then |
| 19 | + echo "*** Error: $CONTROL/control is missing field $field" >&2 |
| 20 | + return 1 |
| 21 | + fi |
| 22 | + echo $value |
| 23 | + return 0 |
| 24 | +} |
| 25 | + |
| 26 | +pkg_appears_sane() { |
| 27 | + local pkg_dir=$1 |
| 28 | + |
| 29 | + local owd=`pwd` |
| 30 | + cd $pkg_dir |
| 31 | + |
| 32 | + PKG_ERROR=0 |
| 33 | + |
| 34 | + large_uid_files=`find . -uid +99` |
| 35 | + if [ -n "$large_uid_files" ]; then |
| 36 | + echo "*** Warning: The following files have a UID greater than 99. |
| 37 | +You probably want to chown these to a system user: " >&2 |
| 38 | + ls -ld $large_uid_files |
| 39 | + echo >&2 |
| 40 | + fi |
| 41 | + |
| 42 | + |
| 43 | + if [ ! -f "$CONTROL/control" ]; then |
| 44 | + echo "*** Error: Control file $pkg_dir/$CONTROL/control not found." >&2 |
| 45 | + cd $owd |
| 46 | + return 1 |
| 47 | + fi |
| 48 | + |
| 49 | + pkg=`required_field Package` |
| 50 | + [ "$?" -ne 0 ] && PKG_ERROR=1 |
| 51 | + |
| 52 | + version=`required_field Version | sed 's/.*://;'` |
| 53 | + [ "$?" -ne 0 ] && PKG_ERROR=1 |
| 54 | + |
| 55 | + arch=`required_field Architecture` |
| 56 | + [ "$?" -ne 0 ] && PKG_ERROR=1 |
| 57 | + |
| 58 | + required_field Maintainer >/dev/null |
| 59 | + [ "$?" -ne 0 ] && PKG_ERROR=1 |
| 60 | + |
| 61 | + required_field Description >/dev/null |
| 62 | + [ "$?" -ne 0 ] && PKG_ERROR=1 |
| 63 | + |
| 64 | + section=`required_field Section` |
| 65 | + [ "$?" -ne 0 ] && PKG_ERROR=1 |
| 66 | + if [ -z "$section" ]; then |
| 67 | + echo "The Section field should have one of the following values:" >&2 |
| 68 | + echo "Games, Multimedia, Communications, Settings, Utilies, Applications, Console, Misc" >&2 |
| 69 | + fi |
| 70 | + |
| 71 | + priority=`required_field Priority` |
| 72 | + [ "$?" -ne 0 ] && PKG_ERROR=1 |
| 73 | + if [ -z "$priority" ]; then |
| 74 | + echo "The Priority field should have one of the following values:" >&2 |
| 75 | + echo "required, important, standard, optional, extra." >&2 |
| 76 | + echo "If you don't know which priority value you should be using, then use \`optional'" >&2 |
| 77 | + fi |
| 78 | + |
| 79 | + if echo $pkg | grep '[^a-z0-9.+-]'; then |
| 80 | + echo "*** Error: Package name $name contains illegal characters, (other than [a-z0-9.+-])" >&2 |
| 81 | + PKG_ERROR=1; |
| 82 | + fi |
| 83 | + |
| 84 | + local bad_fields=`sed -ne 's/^\([^[:space:]][^:[:space:]]\+[[:space:]]\+\)[^:].*/\1/p' < $CONTROL/control | sed -e 's/\\n//'` |
| 85 | + if [ -n "$bad_fields" ]; then |
| 86 | + bad_fields=`echo $bad_fields` |
| 87 | + echo "*** Error: The following fields in $CONTROL/control are missing a ':'" >&2 |
| 88 | + echo " $bad_fields" >&2 |
| 89 | + echo "ipkg-build: This may be due to a missing initial space for a multi-line field value" >&2 |
| 90 | + PKG_ERROR=1 |
| 91 | + fi |
| 92 | + |
| 93 | + for script in $CONTROL/preinst $CONTROL/postinst $CONTROL/prerm $CONTROL/postrm; do |
| 94 | + if [ -f $script -a ! -x $script ]; then |
| 95 | + echo "*** Error: package script $script is not executable" >&2 |
| 96 | + PKG_ERROR=1 |
| 97 | + fi |
| 98 | + done |
| 99 | + |
| 100 | + if [ -f $CONTROL/conffiles ]; then |
| 101 | + for cf in `cat $CONTROL/conffiles`; do |
| 102 | + if [ ! -f ./$cf ]; then |
| 103 | + echo "*** Error: $CONTROL/conffiles mentions conffile $cf which does not exist" >&2 |
| 104 | + PKG_ERROR=1 |
| 105 | + fi |
| 106 | + done |
| 107 | + fi |
| 108 | + |
| 109 | + cd $owd |
| 110 | + return $PKG_ERROR |
| 111 | +} |
| 112 | + |
| 113 | +### |
| 114 | +# ipkg-build "main" |
| 115 | +### |
| 116 | + |
| 117 | +case $# in |
| 118 | +1) |
| 119 | + dest_dir=. |
| 120 | + ;; |
| 121 | +2) |
| 122 | + dest_dir=$2 |
| 123 | + ;; |
| 124 | +*) |
| 125 | + echo "Usage: ipkg-build <pkg_directory> [<destination_directory>]" >&2 |
| 126 | + exit 1 |
| 127 | + ;; |
| 128 | +esac |
| 129 | + |
| 130 | +pkg_dir=$1 |
| 131 | +echo "using dir to package ipk: $pkg_dir" |
| 132 | +if [ ! -d $pkg_dir ]; then |
| 133 | + echo "*** Error: Directory $pkg_dir does not exist" >&2 |
| 134 | + exit 1 |
| 135 | +fi |
| 136 | + |
| 137 | +# CONTROL is second so that it takes precedence |
| 138 | +CONTROL="CONTROL" |
| 139 | +echo "using CONTROL dir: $CONTROL" |
| 140 | + |
| 141 | +if [ -z "$CONTROL" ]; then |
| 142 | + echo "*** Error: Directory $pkg_dir has no CONTROL subdirectory." >&2 |
| 143 | + exit 1 |
| 144 | +fi |
| 145 | + |
| 146 | +if ! pkg_appears_sane $pkg_dir; then |
| 147 | + echo >&2 |
| 148 | + echo "ipkg-build: Please fix the above errors and try again." >&2 |
| 149 | + exit 1 |
| 150 | +fi |
| 151 | + |
| 152 | +tmp_dir=$dest_dir/IPKG_BUILD.$$ |
| 153 | +mkdir $tmp_dir |
| 154 | + |
| 155 | +tar -C $pkg_dir -czf $tmp_dir/data.tar.gz . --exclude=$CONTROL |
| 156 | +tar -C $pkg_dir/$CONTROL -czf $tmp_dir/control.tar.gz . |
| 157 | + |
| 158 | +echo "2.0" > $tmp_dir/debian-binary |
| 159 | + |
| 160 | +pkg_file=$dest_dir/${pkg}_${version}_${arch}.ipk |
| 161 | +tar -C $tmp_dir -czf $pkg_file ./debian-binary ./data.tar.gz ./control.tar.gz |
| 162 | +rm $tmp_dir/debian-binary $tmp_dir/data.tar.gz $tmp_dir/control.tar.gz |
| 163 | +rmdir $tmp_dir |
| 164 | + |
| 165 | +echo "Packaged contents of $pkg_dir into $pkg_file" |
0 commit comments