The ipk file is actually an archive package packaged with the ar command. An ipk without a digital signature generally contains three files: control.tar.gz, data.tar.gz and debian-binary.
The debian-binary version is fixed.
control.tar.gz contains the files control, md5sums, preinst, postinst, prerm, and postrm. Control is required, and the others are optional.
data.tar.gz contains the programs and data to be installed.
For the installation of ipk, most users use preware, WebOS Quick Install, and Internalz Pro to install the program. If the postinst script is not considered, the files installed using these tools are installed relative to the /media/cryptofs/apps directory. If you install directly using the ipkg install command without the -o parameter, the installed files are relative to the / directory. In other words, the ipk package does not actually contain installation information relative to that path. Where to install it only depends on the installation method.
Those pre-installed packages in rootfs.tar.gz are installed relative to the / directory. Compared with the programs installed in the / directory, users cannot uninstall them through preware, WebOS Quick Install and the system's own software package manager. However, this does not mean that it is really impossible to uninstall. In fact, as long as you are willing, these packages can be uninstalled. Use the ipkg remove command under the root account to uninstall it.
In the previous section, we had a lt; carriergt;.tar that was not introduced (lt; carriergt; represents att, wr, verizon, etc.). The main reason why we did not introduce it is that we need to understand the above first. These contents make it easier to explain this
The main content of this lt;carriergt;.tar is some ipk packages, and there is also an installer.xml. If this installer.xml is not to be transplanted across operators or models, there is no need to modify it. Then what is left are some ipk packages customized by the operator. These packages are installed after the flash program writes rootfs.tar.gz to the device. They are all installed relative to the / directory. Therefore, these packages are essentially the same as the pre-installed packages in rootfs.tar.gz. The only difference is that the packages in rootfs.tar.gz are pre-installed, while the packages in carriergt.tar are installed during the flashing process. The process of ROM verification md5sums is carried out after all ipk in
Since the packages in lt;carriergt;.tar also need to be verified, so for the packages placed in lt;carriergt;.tar, the md5sums in its control.tar.gz are not optional. Yes, but necessary. If this md5sums is missing, then when the flash reaches 82, the flash will also be terminated because it cannot pass the md5sums verification and cannot be restarted.
To generate an ipk with md5sums, it is really troublesome to calculate and write md5sums manually and package it yourself through tar, gzip, ar and other commands.
In fact, predecessors had already prepared such a packaging script 10 years ago, called ipkg-build. We can use it directly.
The following is the complete content of this script:
#!/bin/sh
# ipkg-build -- construct a .ipk from a directory
p># Carl Worth lt;cworth@east.isi.edugt;
# based on a script by Steve Redler IV, steve@sr-tech.com 5-21-2001
set -e
ipkg_extract_value() {
sed -e "s/^[^:]*:[[:space:]]*//"
}
required_field() {
field=$1
value=`grep "^$field:" lt; $CONTROL/ control | ipkg_extract_value`
if [ -z "$value" ]; then
echo "*** Error: $CONTROL/control is missing field $field" gt; amp; 2
return 1
fi
echo $value
return 0
}
pkg_appears_sane() {
local pkg_dir=$1
local owd=`pwd`
cd $pkg_dir
PKG_ERROR=0
large_uid_files=`find . -uid 99`
if [ -n "$large_uid_files" ]; then
echo "*** Warning: The following files have a UID greater than 99.
You probably want to chown these to a system user: " gt;amp; 2
ls -ld $large_uid_files
echo gt;amp;2
fi
if [ ! -f "$CONTROL/control" ]; then
echo "*** Error: Control file $pkg_dir/$CONTROL/control not found." gt;amp;2
cd $owd
return 1
fi
pkg=`required_field Package`
[ "$?" -ne 0 ] amp;amp; PKG_ERROR=1
version=`required_field Version | sed 's/.* ://;'`
[ "$?" -ne 0 ] amp; PKG_ERROR=1
arch=`required_field Architecture`
[ "$?" -ne 0 ] amp; PKG_ERROR=1
required_field Maintainer gt;/dev/null
[ "$?" -ne 0 ] amp;amp; PKG_ERROR=1
required_field Description gt;/dev/null
[ "$?" -ne 0 ] amp; PKG_ERROR=1
section=`required_field Section`
[ "$?" -ne 0 ] amp; amp; PKG_ERROR=1
if [ -z "$section" ]; then
echo "The Section field should have one of the following values:" gt;amp; 2
echo "Games, Multimedia, Communications, Settings, Utilies, Applications, Console, Misc" gt;amp; 2
fi
priority=`required_field Priority`
[ "$?" -ne 0 ] amp; PKG_ERROR=1
if [ -z "$priority" ]; then
echo " The Priority field should have one of the following values:" gt;amp; 2
echo "required, important, standard, optional, extra." gt;amp; 2
echo "If you don't know which priority value you should be using, then use \`optional'" gt;amp;2
fi
if echo $pkg | grep '[ ^a-z0-9. -]'; then
echo "*** Error: Package name $name contains illegal characters, (other than [a-z0-9. -])" gt; amp;2
PKG_ERROR=1;
fi
local bad_fields=`sed -ne 's/^\([^[:space:]] [^:[:space:]]\ [[:space:]]\ \)[^:].*/\1/p' lt; $CONTROL/control | sed -e 's/\\n// '`
if [ -n "$bad_fields" ]; then
bad_fields=`echo $bad_fields`
echo "*** Error: The following fields in $CONTROL/control are missing a ':'" gt;amp;2
echo "$bad_fields" gt;amp;2
echo "ipkg-build: Thi
s may be due to a missing initial space for a multi-line field value" gt;amp; 2
PKG_ERROR=1
fi
for script in $CONTROL/preinst $CONTROL/postinst $CONTROL/prerm $CONTROL/postrm; do
if [ -f $script -a ! -x $script ]; then
echo " *** Error: package script $script is not executable" gt;amp; 2
PKG_ERROR=1
fi
done
if [ -f $CONTROL/conffiles ]; then
for cf in `cat $CONTROL/conffiles`; do
if [ ! -f ./$cf ]; then
echo "*** Error: $CONTROL/conffiles mentions conffile $cf which does not exist" gt;amp; 2
PKG_ERROR=1
fi
done
fi
cd $owd
return $PKG_ERROR
}
###
# ipkg-build "main"
###
case $# in
1) p>
dest_dir=.
;;
2)
dest_dir=$2
;;
*)
echo "Usage: ipkg-build lt; pkg_directorygt; [lt; destination_directorygt;]" gt; amp; 2
exit 1
;;
esac
pkg_dir=$1
if [ ! -d $pkg_dir ]; then
echo "*** Error : Directory $pkg_dir does not exist" gt;amp; 2
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 "*** Error: Directory $pkg_dir has no CONTROL subdirectory." gt;amp; 2
exit 1
fi
if ! pkg_appears_s
ane $pkg_dir; then
echo gt;amp;2
echo "ipkg-build: Please fix the above errors and try again." gt;amp;2
exit 1
fi
tmp_dir=$dest_dir/IPKG_BUILD.$$
mkdir $tmp_dir
(cd $pkg_dir /data; find . -type f -print0 | p>
(cd $pkg_dir/data; find . -type f -print0 |xargs -0 grep '' -l) gt; $pkg_dir/files.txt
fi
# tar -C $pkg_dir/data -cf $tmp_dir/data.tar -T $pkg_dir/files.txt -h --verify
tar -C $pkg_dir/data -cf $tmp_dir/ data.tar . --verify
gzip -f $tmp_dir/data.tar
tar -C $pkg_dir/$CONTROL -czf $tmp_dir/control.tar.gz .
echo "2.0" gt; $tmp_dir/debian-binary
pkg_file=$dest_dir/${pkg}_${version}_${arch}.ipk
#tar -C $tmp_dir -czf $pkg_file ./debian-binary ./data.tar.gz ./control.tar.gz
(cd $tmp_dir ;ar -qc $pkg_file . /debian-binary ./data.tar.gz ./control.tar.gz ; mv $pkg_file ../)
rm $tmp_dir/debian-binary $tmp_dir/data.tar.gz $tmp_dir /control.tar.gz
rmdir $tmp_dir
echo "Packaged contents of $pkg_dir into $pkg_file"
I have made this script once A very slight modification. When packaging data.tar.gz in the old script, the file pointed to by the connection is packaged for soft links and hard links. In fact, we don't need to do this. We can directly package the connection into the data.tar.gz of ipk in the original way, which is allowed by the ipk package. And in fact, many packages in the webOS system originally have soft connections. If we don't make this modification, we will not be able to correctly package all the systems back to ipk later.
Okay, with this script, we can make our own ipk package. First create a package directory, usually named after the package name, and then create two directories under it, namely CONTROL and data. Pay attention to the case.
The CONTROL directory contains the decompressed content of control.tar.gz. It is not necessary to include md5sums, even if included it will be regenerated when packaging, so you don't have to worry about the correctness of md5sums.
The data directory contains the decompressed content of data.tar.gz. Note that it is relative to /, and the content inside must contain the path relative to /. In addition, even if you want these contents to be installed to /media/cryptofs/apps, do not create this path in the data directory. This path is determined during installation.
Afterwards, you can modify and edit the contents of these two directories, add or delete content. After the modification is completed, return to the upper-level directory of the package directory, and then change its owner and user group to root (this is the case for ordinary packages. For system packages, we should keep the system package when decompressing the system package. The user group of the package, do not change the user group of the original file when modifying). Finally, execute ipkg-build package name to repackage and generate the modified ipk.