#!/bin/sh ############################################################## url='http://download.gimp.org/pub/gimp/v2.8/gimp-2.8.14.tar.bz2' pkgbase=gimp vers=2.8.14 arch=`uname -m` build=P2 src=gimp-2.8.14 OPT_CONFIG='' DOCS='AUTHORS COPYING ChangeLog ChangeLog.pre-1-0 ChangeLog.pre-1-2 ChangeLog.pre-2-0 ChangeLog.pre-2-2 ChangeLog.pre-2-4 ChangeLog.pre-2-6 HACKING INSTALL LICENSE NEWS NEWS.pre-2-0 NEWS.pre-2-2 NEWS.pre-2-4 NEWS.pre-2-6 README README.i18n authors.dtd authors.xml authors.xsl' patchfiles='' compress=txz ############################################################## install2() { install -d ${2%/*} ; install -m 644 $1 $2 } strip_all() { for chk in `find . ` ; do chk_elf=`file $chk | grep ELF` if [ "$chk_elf.x" != ".x" ]; then chk_lib=`echo $chk | grep lib` if [ "$chk_lib.x" != ".x" ]; then echo "stripping $chk with -g " strip -g $chk else echo "stripping $chk" strip $chk fi fi done } gzip_dir() { echo "compressing in $1" if [ -d $1 ] ; then ( cd $1 files=`ls -f --indicator-style=none | sed '/^\.\{1,2\}$/d'` # files=`ls -a --indicator-style=none | tail -n+3` for i in $files ; do echo "$i" if [ ! -f $i -a ! -h $i -o $i != ${i%.gz} ] ; then continue ; fi lnks=`ls -l $i | awk '{print $2}'` if [ $lnks -gt 1 ] ; then inum=`ls -i $i | awk '{print $1}'` for j in `find . -maxdepth 1 -inum $inum` ; do if [ ${j#./} == $i ] ; then gzip -f $i else rm -f ${j#./} ; ln $i.gz ${j#./}.gz fi done elif [ -h $i ] ; then target=`readlink $i` ; rm -f $i ; ln -s $target.gz $i.gz else gzip $i fi done for i in $files ; do mv ${i%.gz}.gz $C ; done for i in $files ; do mv $C/${i%.gz}.gz . ; done ) fi } gzip_one() { gzip $1 ; mv $1.gz $C ; mv $C/${1##*/}.gz ${1%/*} } compress_all() { cd $P strip_all } W=`pwd` WD=/tmp for i in `seq 0 $((${#src[@]} - 1))` ; do S[$i]=$W/${src[$i]} if [ $arch = "x86_64" ]; then B[$i]=$WD/build`test ${#src[@]} -eq 1 || echo $i` else B[$i]=$WD/build32`test ${#src[@]} -eq 1 || echo $i` fi done P=$W/work ; C=$W/pivot infodir=$P/usr/share/info mandir=$P/usr/share/man xmandir=$P/usr/X11R7/share/man docdir=$P/usr/share/doc myname=`basename $0` pkg=$pkgbase-$vers-$arch-$build if [ $arch = "x86_64" ]; then target="-m64" libdir="lib64" suffix="64" else target="-m32" libdir="lib" suffix="" fi if [ $# -eq 0 ] ; then opt_download=0 ; opt_config=1 ; opt_build=1 ; opt_package=1 else opt_download=0 ; opt_config=0 ; opt_build=0 ; opt_package=0 for i in $@ ; do case $i in download) opt_download=1 ;; config) opt_config=1 ;; build) opt_build=1 ;; package) opt_package=1 ;; esac done fi if [ $opt_download -eq 1 ] ; then for i in $url ; do if [ ! -f ${i##*/} ] ; then wget $i ; fi done for i in $url ; do case ${i##*.} in tar) tar xvpf ${i##*/} ;; gz) tar xvpzf ${i##*/} ;; bz2) tar xvpjf ${i##*/} ;; esac done fi if [ $opt_config -eq 1 ] ; then for i in `seq 0 $((${#B[@]} - 1))` ; do if [ -d ${B[$i]} ] ; then rm -rf ${B[$i]} ; fi ; cp -a ${S[$i]} ${B[$i]} done ###################################################################### # * ./configure を行う前に適用したい設定やパッチなどがある場合はここに # 記述します。 ###################################################################### for i in `seq 0 $((${#B[@]} - 1))` ; do cd ${B[$i]} for patch in $patchfiles ; do patch -p1 < $W/$patch done # if [ -f autogen.sh ] ; then # sh ./autogen.sh # fi if [ -x configure ] ; then export PKG_CONFIG_PATH=/usr/${libdir}/pkgconfig:/usr/share/pkgconfig:/opt/kde/${libdir}/pkgconfig export LDFLAGS='-Wl,--as-needed' export CC="gcc -isystem /usr/include $target" export CXX="g++ -isystem /usr/include $target " ./configure --prefix=/usr --libdir=/usr/${libdir} --sysconfdir=/etc --localstatedir=/var --mandir='${prefix}'/share/man ${OPT_CONFIG[$i]} fi if [ $? != 0 ]; then echo "configure error. $0 script stop" exit 255 fi done fi if [ $opt_build -eq 1 ] ; then for i in `seq 0 $((${#B[@]} - 1))` ; do cd ${B[$i]} if [ -f Makefile ] ; then export LDFLAGS='-Wl,--as-needed' make -j3 fi done fi if [ $opt_package -eq 1 ] ; then if [ `id -u` -ne 0 ] ; then read -p "Do you want to package as root? [y/N] " ans if [ "x$ans" == "xY" -o "x$ans" == "xy" ] ; then cd $W ; /bin/su -c "$0 package" ; exit fi fi if [ -d $P ] ; then rm -rf $P ; fi ; mkdir -p $P if [ -d $C ] ; then rm -rf $C ; fi ; mkdir -p $C touch $W/i.st ; sleep 1 for i in `seq 0 $((${#B[@]} - 1))` ; do cd ${B[$i]} for mk in `find . -name "[Mm]akefile" ` ; do sed -i -e 's|GCONFTOOL = /usr/bin/gconftool-2|GCONFTOOL = echo|' $mk done if [ -f Makefile ] ; then export LDFLAGS='-Wl,--as-needed' make install DESTDIR=$P fi done ###################################################################### # * make install でコピーされないファイルがある場合はここに記述します。 ###################################################################### mkdir -p $docdir/$src # remove locales except ja # for loc_dir in `find $P -name locale` ; do pushd $loc_dir for loc in * ; do if [ "$loc" != "ja" ]; then rm -rf $loc fi done popd done ###################################################################### # path に lib があるバイナリは strip -g, ないバイナリは strip する ###################################################################### cd $P compress_all if [ -d $P/usr/share/man ]; then for mdir in `find $P/usr/share/man -name man[0-9mno] -type d`; do gzip_dir $mdir done fi ###################################################################### # * compress 対象以外で圧縮したいディレクトリやファイルがある場合はここ # に記述します(strip_{bin,lib}dir や gzip_{dir,one} を使います)。 # * 他のアーカイブから追加したいファイルがある場合はここに記述します。 ###################################################################### cd $W for i in `seq 0 $((${#DOCS[@]} - 1))` ; do for j in ${DOCS[$i]} ; do for k in ${S[$i]}/$j ; do install2 $k $docdir/${src[$i]}/${k#${S[$i]}/} touch -r $k $docdir/${src[$i]}/${k#${S[$i]}/} gzip_one $docdir/${src[$i]}/${k#${S[$i]}/} done done if [ $i -eq 0 ] ; then install $myname $docdir/$src gzip_one $docdir/$src/$myname else ln $docdir/$src/$myname.gz $docdir/${src[$i]} fi ( cd $docdir ; find ${src[$i]} -type d -exec touch -r $W/{} {} \; ) done for patch in $patchfiles ; do cp $W/$patch $docdir/$src/$patch gzip_one $docdir/$src/$patch done ############################################################ # /usr/share/doc 以下には一般ユーザのIDのままのファイルが # 紛れこみがちなので ############################################################ chk_me=`whoami | grep root` if [ "$chk_me.x" != ".x" ]; then chown -R root.root $P/usr/share/doc fi ###################################################################### # * convert 対象以外で刈り取りたいシンボリックリンクがある場合はここに # 記述します(prune_symlink を使います)。 # * 完成した作業ディレクトリから tar イメージを作成する手順を以降に記述 # します(こだわりを求めないなら単に makepkg でも良いです)。 ###################################################################### # tar cvpf $pkg.tar -C $P `cd $P ; find usr/bin | tail -n+2` # tar rvpf $pkg.tar -C $P `cd $P ; find usr/share/man/man1 | tail -n+2` # tar rvpf $pkg.tar -C $P usr/share/doc/$src # touch -t `date '+%m%d0900'` $pkg.tar ; gzip $pkg.tar ; touch $pkg.tar.gz # mv $pkg.tar.gz $pkg.tgz cd $P /sbin/makepkg ../$pkg.$compress <