Home
Categories
WIKI
Topic
User
LANGUAGE:
中文
English
Deb32位包转换64位包的脚本
Experiences and Insight
2027
views ·
3
replies ·
To
floor
Go
Coollove
deepin
2012-04-11 23:38
Author
Deb32位包转换64位包的脚本
#!/bin/bash
#
#Make 32 bit deb package installable in 64 bit system.
#author Jarlyyn hsu http://jarln.net
#usage: deb32toall 32bir_deb_filename
#depandment:zenity see about http://library.gnome.org/users/zenity/stable/
#depandment:mktemp to make temp unzip folder
#depandment:sed
#depandment:dpkg dpkg-deb
main()
{
init_string
check_depandment
check_infile "$@"
convert_file
}
#Output string list
init_string()
{
outfile="%s.all.deb"
err_nofile="No selected file."
err_notdeb="文件必须以.deb结尾。"
err_notexist="指定的文件 %s 不存在。"
err_outfileexist="输出文件%s 已存在。转换终止。"
err_unparkerr="无法展开deb包,请检查 ' %s '的文件格式。\r\n%s"
err_makeerr="无法制作deb包,请检查 ' %s '文件及所在目录的权限。\r\n%s"
err_ok="转换完成,输出文件为 %s 。"
title_ok="转换完毕"
title_inputfile="请输入您要处理的32位deb文件"
progress_title="转换deb文件"
progress_text="正在转换……"
progress_unpack="解压缩DEB文件。"
progress_unpackcontrol="解压缩控制文件"
progress_sed="替换控制文件"
progress_make="生成deb文件。可能会花费较长时间,请稍候……"
progress_ok="转换完成,输出文件为 %s 。"
progress_rm="删除临时文件"
addition_depand=", ia32-libs, ia32-libs-gtk"
}
check_depandment()
{
for cmd in "/usr/bin/zenity" "/bin/sed" "/bin/mktemp" "/usr/bin/dpkg" "/usr/bin/dpkg-deb"
do
if [ ! -e $cmd ] ;then
echo "$cmd not found"
exit
fi
done
}
err(){
zenity --error --text="`printf "$@"`"
exit
}
info(){
zenity --info --title="$3" --text="`printf "$1" $2`"
}
# check input file
check_infile()
{
infile="$@"
if [ -z "$infile" ] ;then
#show file dialog
infile=`zenity --file-selection --file-filter="*.deb" --title "$title_inputfile"`
if [ $? != 0 ] ;then
echo $err_nofile
exit
fi
fi
#Validate Filename
filename=`expr match "$infile" "\(.*\)\.deb$"`
if [ -z "$filename" ] ;then
err "$err_notdeb"
fi
filename=`printf "$outfile" "$filename"`
#find file
if [ ! -e "$infile" ] ;then
err "$err_notexist" "$infile"
fi
if [ -e "$filename" ] ;then
err "$err_outfileexist" "$filename"
fi
}
convert_file()
{
tmpdir=`mktemp -d /tmp/deb32toall.XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX`
if [ ${tmpdir:0:5} != "/tmp/" -o ! -d "$tmpdir" ] ;then
#make sure tmpdir
#make sure tmpdir is in /tmp/ for avoid wrong rm.
exit
fi
#########convert begin###########
(echo "10" ; echo "# $progress_unpack" ; dpgk_err=`dpkg-deb -x "$infile" "$tmpdir"`
if [ $? != 0 ] ;then
echo "100"
progress_err=-1
err "$err_unparkerr" "$infile" "$dpgk_err"
fi
echo "30" ; echo "# $progress_unpackcontrol" ; dpkg-deb --control "$infile" "$tmpdir/DEBIAN" > /dev/null
echo "35" ; echo "# $progress_sed" ; sed -i "s/^\s*Architecture:\s*i386\s*$/Architecture: all/" "$tmpdir/DEBIAN/control" > /dev/null
echo "40" ;sed -i -r "s/^\s*(Depends: .*)$/\1$addition_depand/" "$tmpdir/DEBIAN/control" > /dev/null
echo "50" ; echo "# $progress_make" ; dpgk_err=`dpkg -b "$tmpdir" "$filename"`
if [ $? != 0 ] ;then
progress_err=-1
err "$err_makeerr" "$filename" "$dpgk_err"
fi
echo "100";
)|zenity --progress \
--title="$progress_title" \
--text="$progress_text" \
--auto-close\
--percentage=0
rm "$tmpdir" -r -f
if [ "$?" == "-1" -o "$progress_err" == "-1" -o ! -e "$filename" ] ;then
exit
fi
info "$err_ok" "$filename" "$title_ok"
###########convert end###########
###########check for gdebi gui??
if [ -e "/usr/bin/gdebi-gtk" ] ;then
/usr/bin/gdebi-gtk "$filename"
elif [ -e "/usr/bin/gdebi-kde" ] ;then
/usr/bin/gdebi-kde "$filename"
fi
}
main "$@"
Copy the Code
Reply
Like 0
Favorite
View the author
All Replies
cxbii
deepin
2012-04-11 23:46
#1
楼主自己写的?测试怎么样呢?
Reply
Like 0
View the author
Coollove
deepin
2012-04-12 00:35
#2
楼主自己写的?测试怎么样呢?
网上淘的,可以转换完成安装,终端启动安装后的程序查看缺少的lib。。自已ln -s
Reply
Like 0
View the author
cxbii
deepin
2012-04-12 00:59
#3
[quote]楼主自己写的?测试怎么样呢?
网上淘的,可以转换完成安装,终端启动安装后的程序查看缺少的lib。。自已ln -s[/quote]
ok!
Reply
Like 0
View the author
Please
sign
in first
New Thread
Popular Ranking
Change
translation
剪切板增加关键字过滤功能
gaming on deepin 23 wine installation
configurar teclado macbook pro 2011
Muon app from app store
Install Deepin 23 (preview) for LOONGSON 3A6000 Machine.
Popular Events
More