LinuxSir.cn,穿越时空的Linuxsir!

 找回密码
 注册
搜索
热搜: shell linux mysql
查看: 1233|回复: 8

[Call for testing] ibus 的 SlackBuild

[复制链接]
发表于 2009-5-17 15:22:31 | 显示全部楼层 |阅读模式
比较受不了 SCIM,于是折腾了一中午 ibus,终于整的差不多了…… SlackBuild 是根据官方里 scim 的改写而成,还需要很多的测试。比如我不用 csh, XFce, 就没有办法测试它在那些环境下的应用情况…… 所以我就把自己写的 SlackBuild 发上来供大家测试吧~ 欢迎提意见和补丁~;)

1.2 版和 1.1 版的依赖貌似是一样的,所以就干脆写了 1.2 的脚本~


  1. #!/bin/sh

  2. # Slackware build script for ibus

  3. # Written by Grissiom chaos.proton@gmail.com

  4. # If you want to use ibus as your primary input method, you'd better uninstall
  5. # scim package.

  6. # This SlackBuild is modified from Eric Hameleers's SlackBuild for scim. It has
  7. # not been finished porting but works for me. So more testing and debugging is
  8. # needed. If you see "SCIM" or commented out blocks in this script, that means
  9. # I don't know the corresponding part in ibus or I don't have the debugging
  10. # environment(e.g., I don't use csh and XFce).Feel free to mail me if you have
  11. # brilliant idea or suggestions.
  12. # Thanks in advance!

  13. PRGNAM=ibus
  14. VERSION=${VERSION:-1.2.0.20090828}
  15. ARCH=${ARCH:-i486}
  16. BUILD=${BUILD:-1}
  17. TAG=${TAG:-_SBo}

  18. if [ "$ARCH" = "i486" ]; then
  19.   SLKCFLAGS="-O2 -march=i486 -mtune=i686"
  20.   LIBDIRSUFFIX=""
  21. elif [ "$ARCH" = "x86_64" ]; then
  22.   SLKCFLAGS="-O2 -fPIC"
  23.   LIBDIRSUFFIX="64"
  24. fi

  25. CWD=$(pwd)
  26. TMP=${TMP:-/tmp/SBo}
  27. PKG=$TMP/package-$PRGNAM
  28. OUTPUT=${OUTPUT:-/tmp}

  29. rm -rf $PKG
  30. mkdir -p $TMP $PKG $OUTPUT
  31. cd $TMP
  32. rm -rf ${PRGNAM}-${VERSION}
  33. tar -xvf $CWD/${PRGNAM}-${VERSION}.tar.gz
  34. cd ${PRGNAM}-${VERSION} || exit 1
  35. chown -R root:root .
  36. find . \
  37.   \( -perm 777 -o -perm 775 -o -perm 711 -o -perm 555 -o -perm 511 \) \
  38.   -exec chmod 755 {} \; -o \
  39.   \( -perm 666 -o -perm 664 -o -perm 600 -o -perm 444 -o -perm 440 -o -perm 400 \) \
  40.   -exec chmod 644 {} \;

  41. CFLAGS="$SLKCFLAGS" \
  42. CXXFLAGS="$SLKCFLAGS" \
  43. ./configure --prefix=/usr \
  44.             --libdir=/usr/lib${LIBDIRSUFFIX} \
  45.             --sysconfdir=/etc \
  46.             --localstatedir=/var \
  47.             --with-html-dir=/usr/doc/$PRGNAM-$VERSION \
  48.             --program-prefix= \
  49.             --program-suffix= \
  50.             --build=$ARCH-slackware-linux

  51. make
  52. make DESTDIR=$PKG install || exit 1

  53. # Add a profile script that sets up the environment:
  54. mkdir -p $PKG/etc/profile.d

  55. cat <<EOT > $PKG/etc/profile.d/ibus.sh.new
  56. #!/bin/sh

  57. # ibus - Intelligent Input Bus for Linux / Unix OS. This is used to support the
  58. # entering of text in non-US-English languages.

  59. # For SCIM to work, you need to use a UTF-8 locale.  Make sure it ends on
  60. # ".UTF-8", not "utf-8"!  As an example, you would need to use en_US.UTF-8
  61. # for a US locale (export LANG=en_US.UTF-8), not en_US.
  62. #
  63. # The locale (LANG variable) is set in /etc/profile.d/lang.sh.

  64. if [ -x /usr/bin/ibus-daemon ]; then
  65.   # Enable legacy X applications to use ibus:
  66.   export XMODIFIERS="@im=ibus"
  67.   # Enable Qt/KDE applications to use ibus. qt4 immodule hasn't finished
  68.   # working yet, so Qt programs could only use ibus through xim. In this
  69.   # manner, make sure you start ibus-daemon with --xim(or -x) option.
  70.   export QT_IM_MODULE="xim"
  71.   # Enable GTK applications to use ibus:
  72.   export GTK_IM_MODULE="ibus"
  73.   # Make ibus start automatically if the "magic key" Ctrl-Space is pressed:
  74.   export XIM_PROGRAM="/usr/bin/ibus-daemon -xdrt"
  75. fi

  76. # GTK+ environments such as XFce should support SCIM automatically, BUT
  77. # if the first app you run is a Qt one, you'll run into problems.  This
  78. # can be avoided by going into Menu -> Settings -> Autostarted Applications
  79. # and adding SCIM:  /usr/bin/scim -d

  80. # KDE will not start ibus automatically, so you will need a script such as
  81. # this one in your $HOME/.kde/Autostart:

  82. #!/bin/bash
  83. #if [ -x /usr/bin/ibus-daemon]; then
  84. #  /usr/bin/ibus-daemon -xdrt
  85. #fi

  86. # Obviously, uncomment all but the first line.  :-)

  87. EOT

  88. #cat <<EOT > $PKG/etc/profile.d/scim.csh.new
  89. ##!/bin/csh
  90. #
  91. ## SCIM (Smart Common Input Method platform).  This is used to support the
  92. ## entering of text in non-US-English languages.
  93. #
  94. ## For SCIM to work, you need to use a UTF-8 locale.  Make sure it ends on
  95. ## ".UTF-8", not "utf-8"!  As an example, you would need to use en_US.UTF-8
  96. ## for a US locale (setenv LANG en_US.UTF-8), not en_US.
  97. ##
  98. ## The locale (LANG variable) is set in /etc/profile.d/lang.csh.
  99. #
  100. #[ -x /usr/bin/scim ]
  101. #if (\$status == 0) then
  102. #  # Enable legacy X applications to use scim:
  103. #  setenv XMODIFIERS "@im=SCIM"
  104. #  ## Enable Qt/KDE applications to use scim (does not work for kde4):
  105. #  #setenv QT_IM_MODULE "scim"
  106. #  # Make scim start automatically if the "magic key" Ctrl-Space is pressed:
  107. #  setenv XIM_PROGRAM "/usr/bin/scim -d"
  108. #endif
  109. #
  110. #[ -x /usr/bin/scim-bridge ]
  111. #if (\$status == 0) then
  112. #  # Let GTK applications like Firefox/Thunderbird use scim-bridge as
  113. #  # default immodule:
  114. #  setenv GTK_IM_MODULE "scim-bridge"
  115. #  # Enable Qt4/KDE4 applications to use scim:
  116. #  setenv QT_IM_MODULE "scim-bridge"
  117. #endif
  118. #
  119. ## This ensures scim starts when you logon.
  120. ## This will only work if you login through runlevel 4 (graphical login)!!!
  121. ## Better is to have it start through Ctrl-Space like configured higher up ^^.
  122. ##[ ! \`ls /tmp/scim-socket*\` ]
  123. ##if (\$status == 0) then
  124. ##  /usr/bin/scim -d
  125. ##endif
  126. #
  127. ## GTK+ environments such as XFce should support SCIM automatically, BUT
  128. ## if the first app you run is a Qt one, you'll run into problems.  This
  129. ## can be avoided by going into Menu -> Settings -> Autostarted Applications
  130. ## and adding SCIM:  /usr/bin/scim -d
  131. #
  132. ## KDE will not start SCIM automatically, so you will need a script such as
  133. ## this one in your $HOME/.kde/Autostart:
  134. #
  135. ##!/bin/csh
  136. ##[ -x /usr/bin/scim ]
  137. ##if (\$status == 0) then
  138. ##  /usr/bin/scim -d &
  139. ##endif
  140. #
  141. ## Obviously, uncomment all but the first line.  :-)
  142. #
  143. #EOT

  144. chmod 755 $PKG/etc/profile.d/ibus.sh.new

  145. # Protect config files from being overwritten:
  146. #mv $PKG/etc/gconf/schemas/ibus.schemas{,.new}

  147. # Add this to the doinst.sh
  148. mkdir -p $PKG/install
  149. cat <<EOINS >> $PKG/install/doinst.sh

  150. # Handle the incoming configuration files:
  151. config() {
  152.   for infile in \$1; do
  153.     NEW="\$infile"
  154.     OLD="\$(dirname \$NEW)/\$(basename \$NEW .new)"
  155.     # If there's no config file by that name, mv it over:
  156.     if [ ! -r \$OLD ]; then
  157.       mv \$NEW \$OLD
  158.     elif [ "\$(cat \$OLD | md5sum)" = "\$(cat \$NEW | md5sum)" ]; then
  159.       # toss the redundant copy
  160.       rm \$NEW
  161.     fi
  162.     # Otherwise, we leave the .new copy for the admin to consider...
  163.   done
  164. }

  165. # Prepare the new configuration files
  166. for file in etc/profile.d/ibus.sh.new etc/profile.d/ibus.csh.new ; do
  167.   if [ -e \$(dirname \$file)/\$(basename \$file .new) -a -x \$(dirname \$file)/\$(basename \$file .new) ]; then
  168.     chmod 755 \$file
  169.   else
  170.     chmod 644 \$file
  171.   fi
  172.   config \$file
  173. done

  174. # Run gtk-query-immodules so that "ibus" will appear under Imput Method
  175. # when you right- click your mouse in a text box.
  176. if [ -x /usr/bin/update-gtk-immodules ]; then
  177.   /usr/bin/update-gtk-immodules --verbose
  178. fi

  179. EOINS

  180. # Add documentation:
  181. cp -a \
  182.   ABOUT-NLS AUTHORS COPYING ChangeLog NEWS README \
  183.   $PKG/usr/doc/$PRGNAM-$VERSION

  184. # Strip binaries:
  185. find $PKG | xargs file | grep -e "executable" -e "shared object" \
  186.   | grep ELF | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null

  187. # Add a package description:
  188. mkdir -p $PKG/install
  189. cat $CWD/slack-desc > $PKG/install/slack-desc

  190. # Build the package:
  191. cd $PKG
  192. /sbin/makepkg --prepend --linkadd y --chown n $OUTPUT/${PRGNAM}-${VERSION}-${ARCH}-${BUILD}.${PKGTYPE:-tgz}
复制代码


依赖:GConf, pyxdg, 这两个都能从 SBo 里找到~ 再有,ibus 只是输入法引擎,不带词库,不过词库的打包脚本很好写。附件是拼音的 SlackBuild~

1.2 版的有 ibus-qt 这个 qt-immodule,比较适合在 qt4 环境下使用,这个是 SlackBuild:

  1. #!/bin/sh

  2. # Slackware build script for ibus-qt

  3. # Written by Grissiom <chaos.proton@gmail.com>

  4. PRGNAM=ibus-qt
  5. VERSION=${VERSION:-1.2.0.20090822}
  6. ARCH=${ARCH:-i486}
  7. BUILD=${BUILD:-1}
  8. TAG=${TAG:-_SBo}

  9. CWD=$(pwd)
  10. TMP=${TMP:-/tmp/SBo}
  11. PKG=$TMP/package-$PRGNAM
  12. OUTPUT=${OUTPUT:-/tmp}

  13. if [ "$ARCH" = "i486" ]; then
  14.   SLKCFLAGS="-O2 -march=i486 -mtune=i686"
  15.   LIBDIRSUFFIX=""
  16. elif [ "$ARCH" = "i686" ]; then
  17.   SLKCFLAGS="-O2 -march=i686 -mtune=i686"
  18.   LIBDIRSUFFIX=""
  19. elif [ "$ARCH" = "x86_64" ]; then
  20.   SLKCFLAGS="-O2 -fPIC"
  21.   LIBDIRSUFFIX="64"
  22. fi

  23. set -e

  24. rm -rf $PKG
  25. mkdir -p $TMP $PKG $OUTPUT
  26. cd $TMP
  27. rm -rf $PRGNAM-$VERSION-Source
  28. # how could the tarball have a "Source" suffix?...
  29. tar xvf $CWD/$PRGNAM-$VERSION-Source.tar.gz
  30. cd $PRGNAM-$VERSION-Source
  31. chown -R root:root .
  32. find . \
  33. \( -perm 777 -o -perm 775 -o -perm 711 -o -perm 555 -o -perm 511 \) \
  34. -exec chmod 755 {} \; -o \
  35. \( -perm 666 -o -perm 664 -o -perm 600 -o -perm 444 -o -perm 440 -o -perm 400 \) \
  36. -exec chmod 644 {} \;

  37. mkdir build
  38. cd build
  39. cmake -DCMAKE_CXXFLAGS="$SLKCFLAGS" \
  40.       -DCMAKE_INSTALL_PREFIX=/usr \
  41.       -DCMAKE_BUILD_TYPE=Release \
  42.       -DLIBDIR=lib${LIBDIRSUFFIX} \
  43.       -DDOCDIR=/usr/doc/$PRGNAM-$VERSION \
  44.       ..

  45. make
  46. make install DESTDIR=$PKG

  47. ( cd $PKG
  48.   find . | xargs file | grep "executable" | grep ELF | cut -f 1 -d : | \
  49.     xargs strip --strip-unneeded 2> /dev/null || true
  50.   find . | xargs file | grep "shared object" | grep ELF | cut -f 1 -d : | \
  51.     xargs strip --strip-unneeded 2> /dev/null
  52. )

  53. cd -
  54. cp -a \
  55.   COPYING \
  56.   $PKG/usr/doc/$PRGNAM-$VERSION
  57. cat $CWD/$PRGNAM.SlackBuild > $PKG/usr/doc/$PRGNAM-$VERSION/$PRGNAM.SlackBuild

  58. mkdir -p $PKG/install
  59. cat $CWD/slack-desc > $PKG/install/slack-desc

  60. cd $PKG
  61. /sbin/makepkg -l y -c n $OUTPUT/$PRGNAM-$VERSION-$ARCH-$BUILD$TAG.${PKGTYPE:-tgz}
复制代码


不过这个依赖 icu4c ……(ibus 怎么这么多依赖呢?……)

欢迎提意见~

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有帐号?注册

x
发表于 2009-5-17 15:58:22 | 显示全部楼层
看不懂,支持
回复 支持 反对

使用道具 举报

发表于 2009-5-17 16:37:57 | 显示全部楼层
昨天刚在zenwalk上装了,默认安装的zenwalk还缺一个包iso-codes。
回复 支持 反对

使用道具 举报

发表于 2009-5-17 17:16:44 | 显示全部楼层
关于ibus-pinyin的slackbuild,建议你把http://ibus.googlecode.com/files/pinyin-database-0.1.10.6.tar.bz2先下回来,在slackbuild里加一句(红色那行):
  1. tar xvf $CWD/$PRGNAM-$VERSION.tar.gz
  2. [color="Red"]ln -s $CWD/pinyin-database-0.1.10.6.tar.bz2 $TMP/$PRGNAM-$VERSION/engine/[/color]
  3. cd $PRGNAM-$VERSION
  4. chown -R root:root .
  5. find . \
  6. \( -perm 777 -o -perm 775 -o -perm 711 -o -perm 555 -o -perm 511 \) \
  7. -exec chmod 755 {} \; -o \
  8. \( -perm 666 -o -perm 664 -o -perm 600 -o -perm 444 -o -perm 440 -o -perm 400 \) \
  9. -exec chmod 644 {} \;
  10. CFLAGS="$SLKCFLAGS" \
  11. CXXFLAGS="$SLKCFLAGS" \
  12. ./configure \
  13.   --prefix=/usr \
  14.   --libdir=/usr/lib${LIBDIRSUFFIX} \
  15.   --sysconfdir=/etc \
  16.   --localstatedir=/var \
  17.   --mandir=/usr/man \
  18.   --docdir=/usr/doc/$PRGNAM-$VERSION \
  19.   --build=$ARCH-slackware-linux
复制代码
这样做的目的有三个:
1、某些用户从googlecode下载文件速度非常慢,提前下载好方便打包。
2、防止有人在无网络环境时打包失败。
3、据我所知pinyin-database不会经常更新,从去年8月至今只更新过一次。大多数情况下主程序更新时pinyin-database都没变。所以,事先下载好可以避免每当ibus-pinyin发布新版后,在打包时把一模一样的文件重新下载一次。

另外还有个建议你可以参考一下(意义不是很大):
将make install DESTDIR=$PKG替换为make NO_INDEX=true install DESTDIR=$PKG,在doinst.sh加入以下内容:
  1. cd /usr/share/ibus-pinyin/engine
  2.     python -c "import pysqlitedb; db = pysqlitedb.PYSQLiteDB (filename='py.db'); db.create_indexes ();"
复制代码
这样只有一个作用,就是打出来的包体积可以减少50%以上(你可以分别打包两次做对比),不过总体消耗时间没变,只是将create index的步骤放到了安装的时候,安装后的体积也没变。
回复 支持 反对

使用道具 举报

 楼主| 发表于 2009-5-17 21:02:10 | 显示全部楼层
Post by 狱卒;1988244
关于ibus-pinyin的slackbuild,建议你把http://ibus.googlecode.com/files/pinyin-database-0.1.10.6.tar.bz2先下回来,在slackbuild里加一句(红色那行):
  1. tar xvf $CWD/$PRGNAM-$VERSION.tar.gz
  2. [color="Red"]ln -s $CWD/pinyin-database-0.1.10.6.tar.bz2 $TMP/$PRGNAM-$VERSION/engine/[/color]
  3. cd $PRGNAM-$VERSION
  4. chown -R root:root .
  5. find . \
  6. \( -perm 777 -o -perm 775 -o -perm 711 -o -perm 555 -o -perm 511 \) \
  7. -exec chmod 755 {} \; -o \
  8. \( -perm 666 -o -perm 664 -o -perm 600 -o -perm 444 -o -perm 440 -o -perm 400 \) \
  9. -exec chmod 644 {} \;

  10. CFLAGS="$SLKCFLAGS" \
  11. CXXFLAGS="$SLKCFLAGS" \
  12. ./configure \
  13.   --prefix=/usr \
  14.   --libdir=/usr/lib${LIBDIRSUFFIX} \
  15.   --sysconfdir=/etc \
  16.   --localstatedir=/var \
  17.   --mandir=/usr/man \
  18.   --docdir=/usr/doc/$PRGNAM-$VERSION \
  19.   --build=$ARCH-slackware-linux
复制代码

这样做的目的有三个:
1、某些用户从googlecode下载文件速度非常慢,提前下载好方便打包。
2、防止有人在无网络环境时打包失败。
3、据我所知pinyin-database不会经常更新,从去年8月至今只更新过一次。大多数情况下主程序更新时pinyin-database都没变。所以,事先下载好可以避免每当ibus-pinyin发布新版后,在打包时把一模一样的文件重新下载一次。

多谢~;)

另外还有个建议你可以参考一下(意义不是很大):
将make install DESTDIR=$PKG替换为make NO_INDEX=true install DESTDIR=$PKG,在doinst.sh加入以下内容:
  1. cd /usr/share/ibus-pinyin/engine
  2.     python -c "import pysqlitedb; db = pysqlitedb.PYSQLiteDB (filename='py.db'); db.create_indexes ();"
复制代码


嗯,这条命令会不会产生新的文件呢?
回复 支持 反对

使用道具 举报

发表于 2009-5-17 22:34:05 | 显示全部楼层
Post by grissiom;1988319
嗯,这条命令会不会产生新的文件呢?

不会。创建索引只是对py.db这个文件进行操作,只会改变py.db的大小,不会生成新文件。

简单的说一下原理,在打包时用make NO_INDEX=true install是为了让make不执行创建索引这一步,也就是说在打包时py.db还未创建索引,但不创建索引,数据文件就没法用,而slackware为我们提供了doinst.sh机制,所以我们把创建索引的步骤丢给doinst.sh脚本,就可以在安装后创建索引,在保证程序可用的基础上,达到减小二进制包体积的目的。

有的人觉得这样做很好,也有人不赞同。不赞同的人认为如果是自己打包,那么总体时间没变,只是调换步骤而已。如果打包给最终用户使用,用户在安装时需要等待创建索引,会增加安装所花费的时间。但另一方认为如果包的体积变大了,会增加用户的下载时间,所以很难说哪个更好。
回复 支持 反对

使用道具 举报

 楼主| 发表于 2009-5-17 22:55:38 | 显示全部楼层
Post by 狱卒;1988345
不会。创建索引只是对py.db这个文件进行操作,只会改变py.db的大小,不会生成新文件。

简单的说一下原理,在打包时用make NO_INDEX=true install是为了让make不执行创建索引这一步,也就是说在打包时py.db还未创建索引,但不创建索引,数据文件就没法用,而slackware为我们提供了doinst.sh机制,所以我们把创建索引的步骤丢给doinst.sh脚本,就可以在安装后创建索引,在保证程序可用的基础上,达到减小二进制包体积的目的。

有的人觉得这样做很好,也有人不赞同。不赞同的人认为如果是自己打包,那么总体时间没变,只是调换步骤而已。如果打包给最终用户使用,用户在安装时需要等待创建索引,会增加安装所花费的时间。但另一方认为如果包的体积变大了,会增加用户的下载时间,所以很难说哪个更好。


嗯~ 大概明白了~

刚才试了下,make index 的 tgz 包是 22.3M,not make index 的 tgz 是 14.4M,make index 的 txz 是 13.3M,not make index 的 txz 是 9.2M,所以还是差不多的……
回复 支持 反对

使用道具 举报

发表于 2009-5-18 02:57:24 | 显示全部楼层
Post by grissiom;1988349
嗯~ 大概明白了~

刚才试了下,make index 的 tgz 包是 22.3M,not make index 的 tgz 是 14.4M,make index 的 txz 是 13.3M,not make index 的 txz 是 9.2M,所以还是差不多的……


现在好像比以前小了,我记得以前帮arch维护ibus的时候,分别打包,不创建索引的包是二十多兆到三十兆的样子,而创建索引的包达到了五十兆之巨。
回复 支持 反对

使用道具 举报

 楼主| 发表于 2009-9-2 20:07:53 | 显示全部楼层
更新了脚本,增加了 ibus-qt.SlackBuild,欢迎使用~
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

快速回复 返回顶部 返回列表