如何安装ipk包

如何安装ipk包,第1张

ipk文件实际上是用ar命令打包的一个归档包。没有数字签名的ipk中一般包含control.tar.gz、data.tar.gz和debian-binary这三个文件。

其中debian-binary里面是固定的。

control.tar.gz中包含了control、md5sums、preinst、postinst、prerm、postrm这几个文件,其中control是必须的,其它都是可选的。

data.tar.gz中包含了要安装的程序和数据。

ipk的安装对于大多数用户来说都是使用preware、WebOS Quick Install、Internalz Pro来安装程序的。如果不考虑postinst脚本,那么使用这些工具安装的文件都是相对于/media/cryptofs/apps目录进行安装的。如果直接使用不带-o参数的ipkg install命令安装的话,那么安装的文件都是相对于/目录的。也就是说ipk包中实际上并不包含相对于那个路径进行安装的信息。安装到哪儿只跟安装的方式有关。

rootfs.tar.gz中那些预先安装好的包都是相对于/目录安装的。相对于/目录安装的程序,用户通过preware、WebOS Quick Install和系统自带的软件包管理器都是无法卸载的,但并不是说就真的无法卸载,实际上只要你愿意,这些包都可以在root帐号下用ipkg remove命令来卸载掉。

我们在上一节中有一个<carrier>.tar没有介绍(<carrier>表示att、wr、verizon等),之所以没介绍主要原因就是我们需要先了解上面的这些内容,然后才比较容易解释这个<carrier>.tar。

这个<carrier>.tar中的主要内容就是一些ipk包,另外,还有一个installer.xml。这个installer.xml如果不是要做跨运营商或跨机型移植,是不需要修改的。那么剩下的就是运营商定制的一些ipk包了。这些包是在刷机程序把rootfs.tar.gz写入设备之后,进行安装的。他们都是相对于/目录进行安装的。因此这些包从本质上来讲,跟rootfs.tar.gz中预先安装的包是没有区别的。唯一的区别就是rootfs.tar.gz中的包是预先安装好的,<carrier>.tar中的包是在刷机过程中进行安装的。而ROM验证md5sums的过程是在<carrier>.tar中的所有ipk安装之后才进行的。因此,<carrier>.tar中的包也是需要进行md5sums验证的。

既然<carrier>.tar中的包也需要验证,所以对于放在<carrier>.tar中的包来说,它的control.tar.gz中的md5sums不是可选的,而是必须的。如果缺少了这个md5sums,那么刷机到82%时,同样会因为无法通过md5sums验证而终止刷机,无法重启。

要生成一个带md5sums的ipk,如果靠手工来计算编写md5sums,并自己通过tar、gzip、ar等命令来打包实在是麻烦的很。实际上前人早在10年前就做好了这样的打包脚本,叫ipkg-build。我们可以直接拿来用。

下面是这个脚本的完整内容:

#!/bin/sh

# ipkg-build -- construct a .ipk from a directory

# Carl Worth [email protected]>

# based on a script by Steve Redler IV, [email protected] 5-21-2001

set -e

ipkg_extract_value() {

sed -e "s/^[^:]*:[[:space:]]*//"

}

required_field() {

field=$1

value=`grep "^$field:" <$CONTROL/control | ipkg_extract_value`

if [ -z "$value" ]then

echo "*** Error: $CONTROL/control is missing field $field" >&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: " >&2

ls -ld $large_uid_files

echo >&2

fi

if [ ! -f "$CONTROL/control" ]then

echo "*** Error: Control file $pkg_dir/$CONTROL/control not found." >&2

cd $owd

return 1

fi

pkg=`required_field Package`

[ "$?" -ne 0 ] &&PKG_ERROR=1

version=`required_field Version | sed 's/.*://'`

[ "$?" -ne 0 ] &&PKG_ERROR=1

arch=`required_field Architecture`

[ "$?" -ne 0 ] &&PKG_ERROR=1

required_field Maintainer >/dev/null

[ "$?" -ne 0 ] &&PKG_ERROR=1

required_field Description >/dev/null

[ "$?" -ne 0 ] &&PKG_ERROR=1

section=`required_field Section`

[ "$?" -ne 0 ] &&PKG_ERROR=1

if [ -z "$section" ]then

echo "The Section field should have one of the following values:" >&2

echo "Games, Multimedia, Communications, Settings, Utilies, Applications, Console, Misc" >&2

fi

priority=`required_field Priority`

[ "$?" -ne 0 ] &&PKG_ERROR=1

if [ -z "$priority" ]then

echo "The Priority field should have one of the following values:" >&2

echo "required, important, standard, optional, extra." >&2

echo "If you don't know which priority value you should be using, then use \`optional'" >&2

fi

if echo $pkg | grep '[^a-z0-9.+-]'then

echo "*** Error: Package name $name contains illegal characters, (other than [a-z0-9.+-])" >&2

PKG_ERROR=1

fi

local bad_fields=`sed -ne 's/^\([^[:space:]][^:[:space:]]\+[[:space:]]\+\)[^:].*/\1/p' <$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 ':'" >&2

echo " $bad_fields" >&2

echo "ipkg-build: This may be due to a missing initial space for a multi-line field value" >&2

PKG_ERROR=1

fi

for script in $CONTROL/preinst $CONTROL/postinst $CONTROL/prerm $CONTROL/postrmdo

if [ -f $script -a ! -x $script ]then

echo "*** Error: package script $script is not executable" >&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" >&2

PKG_ERROR=1

fi

done

fi

cd $owd

return $PKG_ERROR

}

###

# ipkg-build "main"

###

case $# in

1)

dest_dir=.

2)

dest_dir=$2

*)

echo "Usage: ipkg-build <pkg_directory>[<destination_directory>]" >&2

exit 1

esac

pkg_dir=$1

if [ ! -d $pkg_dir ]then

echo "*** Error: Directory $pkg_dir does not exist" >&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." >&2

exit 1

fi

if ! pkg_appears_sane $pkg_dirthen

echo >&2

echo "ipkg-build: Please fix the above errors and try again." >&2

exit 1

fi

tmp_dir=$dest_dir/IPKG_BUILD.$$

mkdir $tmp_dir

(cd $pkg_dir/datafind . -type f -print0 | xargs -0 md5sum ) >$pkg_dir/$CONTROL/md5sums

if [ ! -f "$pkg_dir/files.txt" ]then

(cd $pkg_dir/datafind . -type f -print0 |xargs -0 grep '' -l) >$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" >$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"

这个脚本我对它作过一处非常细微的修改,旧的脚本中在打包data.tar.gz时,对软连接和硬连接是将连接指向的文件进行打包的。而实际上我们没有必要这样做,我们可以直接将连接以原始方式打包到ipk的data.tar.gz中,这是ipk包允许的。而且实际上webOS系统中原本有好多包本来就是带有软连接的,如果不做这个修改,后面我们就不能正确的将系统全部打包回ipk。

好了,有了这个脚本,我们就可以自制ipk包了。首先建立一个包的目录,通常我们以包名来命名,然后在其下建立两个目录,分别为CONTROL和data,注意大小写。

CONTROL目录下放control.tar.gz解压之后的内容。其中不必包含md5sums,即使包含在打包时也会重新生成,因此不必担心md5sums的正确性。

data目录下放data.tar.gz解压之后的内容。注意它是相对于/的,里面的内容要包含相对于/的路径。另外,即使你希望这些内容被安装到/media/cryptofs/apps,也不要把这个路径建立到data目录下,这个路径是在安装时才决定的。

之后你可以对这两个目录下的内容进行修改编辑,添加删除内容都可以。修改完毕之后,退回到这个包目录的上级目录下,然后将其拥有者和用户组都改为root(对于普通包是这样的,对于系统包来说,我们应该在解压系统包时就保留系统包的用户组,在修改时不要变更原来文件的用户组)。最后执行ipkg-build 包名,就可以重新打包生成修改之后的ipk了。

这类ipk文件是基于WebOS手机系统的应用文件,自palm公司开发出WebOS *** 作系统,ipk应用以惊人速度增长。后由于2010年惠普公司收购palm,WebOS转至惠普旗下。

其作用是:某安装文件,ipk是一种图片格式,ipk是nds掌机的漫画文件。

使用方法:先把ipk漫画文件放入内存卡目录,安装moonshell多媒体软件,直接打开漫画浏览。

*** 作如下:

IPK是DS用的漫画格式(当然要有DS)

软件imgview

下面是教程和下载

http://tieba.baidu.com/f?kz=454949021


欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/tougao/12057478.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-05-20
下一篇 2023-05-20

发表评论

登录后才能评论

评论列表(0条)

保存