[gui]debian/ubuntu下转换限定32位的deb为所有平台的脚本。

sh/bash/dash/ksh/zsh等Shell脚本
回复
头像
jarlyyn
帖子: 4671
注册时间: 2006-04-12 18:54
联系:

[gui]debian/ubuntu下转换限定32位的deb为所有平台的脚本。

#1

帖子 jarlyyn » 2011-08-19 14:25

随着内存的白菜价,用64位系统的linux用户也越来越多了。

64 Windows的可以直接安装 32位的引用程序,而64位的linux系统由于有着完善的包管理系统,安装部分只提供32位包的私有程序,比如Adobe air .Draftsight,会略费些周折。

其实在安装了ia32-libs包之后,大部分air,draftsight这样的应用程序都是可以直接在64位系统上运行的。

所以写了个脚本,作用就是为选定DEB文件替换deb包控制文件的 系统限制,并加入ia32-libs以及ia32-libs-gtk的依赖

代码: 全选

#!/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 "$@"
附件
deb32toall.tar.gz
解压缩后,给可执行权限,双击执行
(1.68 KiB) 已下载 175 次
头像
jarlyyn
帖子: 4671
注册时间: 2006-04-12 18:54
联系:

Re: [gui]debian/ubuntu下转换限定32位的deb为所有平台的脚本。

#2

帖子 jarlyyn » 2011-08-19 14:27

不能上传文件……

下次搞个google code的download链接算了
头像
qy117121
论坛版主
帖子: 50587
注册时间: 2007-12-14 13:40
系统: Winbuntu
来自: 志虚国乌由市
联系:

Re: [gui]debian/ubuntu下转换限定32位的deb为所有平台的脚本。

#3

帖子 qy117121 » 2011-08-19 14:29

压缩了就能上传了 :em11
渠月 · QY   
本人只会灌水,不负责回答问题
无聊可以点一下→ http://u.nu/ubuntu

邮箱 chuan@ubuntu.org.cn
头像
jarlyyn
帖子: 4671
注册时间: 2006-04-12 18:54
联系:

Re: [gui]debian/ubuntu下转换限定32位的deb为所有平台的脚本。

#4

帖子 jarlyyn » 2011-08-19 14:34

qy117121 写了:压缩了就能上传了 :em11
果然
头像
月下叹逍遥
论坛版主
帖子: 33994
注册时间: 2010-10-07 14:23
系统: Archdows10
来自: 某系某星某洲某国某省某市
联系:

Re: [gui]debian/ubuntu下转换限定32位的deb为所有平台的脚本。

#5

帖子 月下叹逍遥 » 2011-08-19 14:34

jarlyyn 写了:
qy117121 写了:压缩了就能上传了 :em11
果然
:em06
浮生七十今三十,从此凄惶未可知
autocup
帖子: 408
注册时间: 2010-01-23 20:36

Re: [gui]debian/ubuntu下转换限定32位的deb为所有平台的脚本。

#6

帖子 autocup » 2011-11-03 21:21

:em06 这么的东西要大力推广呀
ubuntu
tusooa
帖子: 6548
注册时间: 2008-10-31 22:12
系统: 践兔
联系:

Re: [gui]debian/ubuntu下转换限定32位的deb为所有平台的脚本。

#7

帖子 tusooa » 2011-11-14 17:27

s/depand/depend/g

代码: 全选

] ls -ld //
Points
帖子: 83
注册时间: 2010-02-19 16:13

Re: [gui]debian/ubuntu下转换限定32位的deb为所有平台的脚本。

#8

帖子 Points » 2012-04-10 15:11

这个要标记。。谢谢分享。。
barrynick
帖子: 8
注册时间: 2012-04-14 9:43

Re: [gui]debian/ubuntu下转换限定32位的deb为所有平台的脚本。

#9

帖子 barrynick » 2012-12-20 23:22

在64位的debian系统中安装说缺少libdirectfd-extra,这个问题怎么解决?
头像
fuhaoyun
帖子: 526
注册时间: 2009-05-08 14:12
来自: http://weibo.com/u/2201287863

Re: [gui]debian/ubuntu下转换限定32位的deb为所有平台的脚本。

#10

帖子 fuhaoyun » 2013-01-26 22:04

:em11 好东西

只用Ubuntu/Unity:安全、高效、自由、简洁!
http://weibo.com/u/2201287863
----------------------------------------------------
用了4年Ubuntu,发现离开windows也可以活得很好
看球赛、炒股、聊天、office等等都不算问题了
一切都是习惯,困难解决了就好

回复