Chinaunix首页 | 论坛 | 博客
  • 博客访问: 884276
  • 博文数量: 286
  • 博客积分: 0
  • 博客等级: 民兵
  • 技术积分: 1841
  • 用 户 组: 普通用户
  • 注册时间: 2015-05-09 16:26
文章分类

全部博文(286)

文章存档

2016年(38)

2015年(248)

我的朋友

分类: LINUX

2015-05-18 20:35:58

ipkgmake概述
-----------------------------------------------------------------------------------
把ipkgmake拷贝到/usr/bin下,制作ipk文件的时候输入命令:
ipkgmake [-i] 包名 版本号 文件列表
即可
-i开关是是否使用安装脚本。安装脚本包括preinst,postinst,prerm,postrm,分别是安装前执行,安装后配置,删除前执行,删除后配置。
比如打包test:

ipkgmake test 3.4.1 /usr/local/bin/test /usr/local/share/test/* /usr/local/bin/test2*
这 个命令会在当前目录生成一个不带安装脚本的ipk包。首先输入上面的命令,ipkgmake会调用leafpad来编辑control文件,你可以在里面 输入你想输入的内容。输入完保存之后关闭leafpad,程序就会在当前目录生成一个叫做test-3.4.1.ipk的包。

如果你想使用安装脚本,输入:
ipkgmake -i test 3.4.1 /usr/local/bin/test /usr/local/test/* /usr/local/bin/test2*
ipkgmake首先会调用leafpad来编辑control文件,编辑保存后然后会调用leafpad编辑脚本文件。你可以在脚本文件中添加你的代码。 

-----------------------------------------------------------------------------------
测试实例
-----------------------------------------------------------------------------------
op/------>文件目录
op/etc/
op/config/test

kevin@debian:~/test$ ./ipkgmake hellokevin 1.0.0 op/*
leafpad: cannot open display: 
kevin@debian:~/test$ ls
hellokevin-1.0.0.ipk  ipkg-build  ipkgmake  op  testme  testme_1.0.0_mips.ipk
-----------------------------------------------------------------------------------
ipkgmake文件
-----------------------------------------------------------------------------------
kevin@debian:~/test$ cat ipkgmake
#!/bin/sh

if [ $# -lt 3 ]; then
    echo "Usage: `basename $0` [-i] pkgname version filelist"
    echo "Options:"
    echo "    -i    Include pre/postinstall configuration shell"
    exit 1
fi

tmpdir="/var/tmp/IPKMAKE_$$"
mkdir -p $tmpdir
conf=0
if [ $1 = "-i" ]; then
    conf=1
    shift
fi
name=$1
version=$2
shift
shift

while [ $# -gt 0 ]
do
    
    if [ -e $1 ]; then
        #mkdir -p $tmpdir`dirname $1`    
&nb sp;       cp -r $1 $tmpdir
    fi
    shift
done
curdir=`pwd -L`
cd $tmpdir
tar zcf /var/tmp/IPKDATA$$.tar.gz .
rm -rf * 
echo "Package: $name" >control
echo "Source: " >>control
echo "Priority: " >>control
echo "Section: " >>control
echo "Maintainer:" >>control
echo "Architecture: mips" >>control
echo "Version: $version" >>control
echo "Depends: " >>control
echo "Description: n-mesh" >>control
echo "Size: `du -h ../IPKDATA$$.tar.gz |awk '{print $1}'`" >>control
leafpad control
if [ $conf = 1 ]; then
    echo "#!/bin/sh" > preinst
    echo 'case $1 in' >>preinst
    echo "    update)" >>preinst
    echo "        exit 0;; #update operation" >>preinst
    echo "    install)" >>preinst
    echo "        exit 0;; #pre-install operation" >>preinst
    echo "    configure)" >>preinst
    echo "        exit 0;; #pre-install operation" >>preinst
    echo "    remove)" >>preinst
    echo '        script=`basename $0`' >>preinst
    echo '        if [ $script = prerm ] ; then' >>preinst
    echo "            exit 0 #pre-delete operation" >>preinst
    echo "        else" >>preinst
    echo "      & nbsp;     exit 0 #post-delete operation" >>preinst
    echo "        fi" >>preinst
    echo "        ;;" >>preinst
    echo "    *) # unknown error" >>preinst
    echo "        exit 1;;" >>preinst
    echo "    esac" >>preinst
    leafpad preinst
    ln preinst postinst
    ln preinst prerm
    ln preinst postrm
    chmod 755 p*
fi
tar zcf /var/tmp/IPKCONT$$.tar.gz .
rm -rf * 
mv /var/tmp/IPKDATA$$.tar.gz data.tar.gz
mv /var/tmp/IPKCONT$$.tar.gz control.tar.gz
echo '2.0' > debian-binary
tar zcf "$curdir/$name-$version.ipk" ./debian-binary ./data.tar.gz ./control.tar.gz
cd ..
rm -rf $tmpdir
cd $curdir
阅读(2314) | 评论(0) | 转发(0) |
0

上一篇:Buildroot

下一篇:iPKG包制作(ipkg-build)?

给主人留下些什么吧!~~