#!/bin/sh ###################################################################### url="http://www.h5l.org/dist/src/heimdal-1.5.3.tar.gz ftp://plamo.linet.gr.jp/pub/Plamo-src.new/plamo/01_minimum/network.txz/heimdal/heimdal-1.5.3-texinfo_fix.patch" pkgbase=heimdal vers=1.5.3 arch=`uname -m` build=P2 src=$pkgbase-$vers patchfiles="heimdal-1.5.3-texinfo_fix.patch" OPT_CONFIG="--prefix=/usr/heimdal --infodir=/usr/share/info --mandir=/usr/share/man --with-sqlite3=/usr LIBS=-pthread" DOCS="ChangeLog* LICENSE NEWS README TODO" ###################################################################### fscheck() { PANGRAM="The quick brown fox jumps over the lazy dog." echo -n "Checking for the filesystem ... " mkdir pangram ; ( cd pangram ; touch $PANGRAM ) mv pangram pangram~ ; mkdir pangram ; touch -r pangram~ pangram tar cpf pangram.tar pangram ; rmdir pangram ; mv pangram~ pangram for i in $PANGRAM ; do tar rpf pangram.tar pangram/$i ; done touch -t `date '+%m%d0900'` pangram.tar ; gzip pangram.tar touch pangram.tar.gz ; mv pangram.tar.gz pangram1.tgz tar cpf pangram.tar pangram touch -t `date '+%m%d0900'` pangram.tar ; gzip pangram.tar touch pangram.tar.gz ; mv pangram.tar.gz pangram2.tgz if cmp -s pangram1.tgz pangram2.tgz ; then echo "OK" rm -rf pangram pangram1.tgz pangram2.tgz else echo "NG" cat <<- "EOF" Hmm, packaging may not be done properly on this filesystem. Would you please try again on a default filesystem, thanks! Happy packaging!! Quitting... EOF exit fi } install2() { install -d ${2%/*} ; install -m 644 $1 $2 } strip_bindir() { echo "compressing in $1" if [ -d $1 ] ; then ( shopt -s nullglob cd $1 for i in * ; do echo "$i" if [ -h $i ] ; then continue ; fi if [ -n "`file $i | grep "not stripped"`" ] ; then echo "stripping -p $i" strip -p $i fi done ) fi } strip_libdir() { echo "compressing in $1" if [ -d $1 ] ; then ( shopt -s nullglob cd $1 for i in *.so *.so.* *.a ; do echo "$i" if [ -h $i ] ; then continue ; fi if [ -n "`nm -a $i | grep " a "`" ] ; then if [ $i != ${i%.a} ] ; then echo -n "ranlib and " touch -r $i $i.mt ; ranlib $i ; touch -r $i.mt $i ; rm $i.mt fi echo "stripping -gp $i" strip -gp $i fi done ) fi } gzip_dir() { echo "compressing in $1" if [ -d $1 ] ; then ( cd $1 files=`ls -f --indicator-style=none | sed '/^\.\{1,2\}$/d'` 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() { for i in {$P,$P/usr}/{sbin,bin} ; do strip_bindir $i ; done for i in {$P,$P/usr}/$libdir ; do strip_libdir $i ; done if [ -f $infodir/dir ] ; then rm -f $infodir/dir ; fi gzip_dir $infodir for i in `seq 9` n ; do gzip_dir $mandir/man$i ; done } prune_symlink() { echo "pruning symlink in $1" if [ -d $1 ] ; then ( cd $P rm -f /tmp/iNsT-a.$$ ; touch /tmp/iNsT-a.$$ for i in `find ${1#$P/} -type l` ; do target=`readlink $i` echo "$i -> $target" echo $i$'\n'$target >> /tmp/iNsT-a.$$ done COUNT=1 LINE=`sed -n "${COUNT}p" /tmp/iNsT-a.$$` while [ -n "$LINE" ] ; do LINKGOESIN=`dirname $LINE` LINKNAMEIS=`basename $LINE` COUNT=$(($COUNT + 1)) LINKPOINTSTO=`sed -n "${COUNT}p" /tmp/iNsT-a.$$` if [ ! -d install ] ; then mkdir install ; fi cat <<- EOF >> install/doinst.sh ( cd $LINKGOESIN ; rm -rf $LINKNAMEIS ) ( cd $LINKGOESIN ; ln -sf $LINKPOINTSTO $LINKNAMEIS ) EOF rm -rf $LINE ; touch -t `date '+%m%d0900'` install/doinst.sh $LINE COUNT=$(($COUNT + 1)) LINE=`sed -n "${COUNT}p" /tmp/iNsT-a.$$` done rm -f /tmp/iNsT-a.$$ ) fi } convert() { for i in {$P,$P/usr}/{sbin,bin} ; do prune_symlink $i ; done for i in {$P,$P/usr}/$libdir ; do prune_symlink $i ; done prune_symlink $infodir for i in `seq 9` n ; do prune_symlink $mandir/man$i ; done } fscheck W=`pwd` for i in `seq 0 $((${#src[@]} - 1))` ; do S[$i]=$W/${src[$i]} ; B[$i]=$W/build`test ${#src[@]} -eq 1 || echo $i` done P=$W/work ; C=$W/pivot infodir=$P/usr/share/info mandir=$P/usr/share/man docdir=$P/usr/share/doc myname=`basename $0` pkg=$pkgbase-$vers-$arch-$build case $arch in x86_64) libdir=lib64 ;; *) libdir=lib ;; esac if [ $# -eq 0 ] ; then opt_download=1 ; 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 ; j=${i%.*} for sig in asc sig{,n} {sha{256,1},md5}{,sum} ; do if wget --spider $i.$sig ; then wget $i.$sig ; break ; fi if wget --spider $j.$sig ; then case ${i##*.} in gz) gunzip -c ${i##*/} > ${j##*/} ;; bz2) bunzip2 -c ${i##*/} > ${j##*/} ;; xz) unxz -c ${i##*/} > ${j##*/} ;; esac touch -r ${i##*/} ${j##*/} ; i=$j ; wget $i.$sig ; break fi done if [ -f ${i##*/}.$sig ] ; then case $sig in asc|sig|sign) gpg2 --verify ${i##*/}.$sig ;; sha256|sha1|md5) ${sig}sum -c ${i##*/}.$sig ;; *) $sig -c ${i##*/}.$sig ;; esac if [ $? -ne 0 ] ; then echo "archive verify failed" ; exit ; fi fi fi done for i in $url ; do case ${i##*.} in tar) tar xvpf ${i##*/} ;; gz|tgz) tar xvpzf ${i##*/} ;; bz2|tbz) tar xvpjf ${i##*/} ;; xz|txz) 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 for i in `seq 0 $((${#B[@]} - 1))` ; do cd ${B[$i]} for j in ${patchfiles[$i]} ; do case ${j##*.} in gz) gunzip -c $W/$j | patch -Np1 -i - ;; bz2) bunzip2 -c $W/j | patch -Np1 -i - ;; xz) unxz -c $W/$j | patch -Np1 -i - ;; *) patch -Np1 -i $W/$j ;; esac done done cd $B cp -p krb5.conf{,.orig} sed -i '/default_realm/s@^ *@\t@' krb5.conf for i in `seq 0 $((${#B[@]} - 1))` ; do cd ${B[$i]} if [ -f Makefile ] ; then make clean fi if [ -f config.log ] ; then rm -rf config.cache config.log fi if [ -x configure ] ; then ./configure --prefix=/usr --sysconfdir=/etc --localstatedir=/var \ --libdir='${exec_prefix}'/$libdir --infodir='${prefix}'/share/info \ --mandir='${prefix}'/share/man ${OPT_CONFIG[$i]} fi done fi if [ $opt_build -eq 1 ] ; then for i in `seq 0 $((${#B[@]} - 1))` ; do cd ${B[$i]} if [ -f Makefile ] ; then make 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]} if [ -f Makefile ] ; then make install DESTDIR=$P fi done mkdir $P/usr/heimdal/heimdal.tmp mv $P/usr/heimdal/{{{,s}bin,libexec,$libdir,include},heimdal.tmp} mv $P/usr/heimdal{/heimdal.tmp/{{,s}bin,libexec,$libdir,include},} rmdir $P/usr/heimdal/heimdal.tmp install -d $P/usr/$libdir/pkgconfig ln -sf /usr/heimdal/$libdir/pkgconfig/heimdal-gssapi.pc \ $P/usr/$libdir/pkgconfig ln -sf mech.5 $mandir/man5/qop.5 install -d $P/etc install -m 644 krb5.conf $P/etc install -m 644 etc/services.append $P/etc/services.append-kerberos install -d $P/etc/profile.d cat <<- "EOF" > $P/etc/profile.d/heimdal.sh # add /usr/heimdal/bin to $PATH for bash heimdal=/usr/heimdal if [ -n "$PATH" ] ; then PATH=$PATH:$heimdal/bin else PATH=/bin:/usr/bin:$heimdal/bin fi if [ `id -u` = 0 ] ; then PATH=$PATH:$heimdal/sbin fi export PATH EOF cat <<- "EOF" > $P/etc/profile.d/heimdal.csh # add /usr/heimdal/bin to $PATH for tcsh set heimdal=/usr/heimdal if ($?PATH) then setenv PATH $PATH:$heimdal/bin else setenv PATH /bin:/usr/bin:$heimdal/bin endif if (`id -u` == 0) then setenv PATH $PATH:$heimdal/sbin endif EOF install -d $P/etc/rc.d/init.d cat <<- "EOF" > $P/etc/rc.d/init.d/heimdal #!/bin/sh -f # # description: The Heimdal Kerberos5 KDC Master server and its administration # daemons. # processname: heimdal # chkconfig: 2345 11 89 # # Creation: 1997-04-10 # Auther: JuK # HISTORY # 2006-01-02 JuK port to Heimdal on Plamo Linux # 2001-10-01 JuK port to RH7.1 # KDC=/usr/heimdal/libexec/kdc kdcdaemon="heimdal (Kerberos 5 KDC)" KADMIND=/usr/heimdal/libexec/kadmind kdmdaemon="kadmind (Kerberos DB admin. daemon)" KPASSWDD=/usr/heimdal/libexec/kpasswdd kpwdaemon="kpasswdd (Kerberos password daemon)" kdcpid=`ps ax | grep $KDC | grep -v grep | sed -e 's/^ *//' -e 's/ .*//'` kdmpid=`ps ax | grep $KADMIND | grep -v grep | sed -e 's/^ *//' -e 's/ .*//'` kpwpid=`ps ax | grep $KPASSWDD | grep -v grep | sed -e 's/^ *//' -e 's/ .*//'` # # start or stop kdc (KDC) # start or stop kadmind (Kerberos DB admin. daemon) # start or stop kpasswdd (Kerberos password daemon) # case $1 in start) if [ -f $KDC ] ; then if [ -z "$kdcpid" ] ; then $KDC & echo "$0: $kdcdaemon started." kdcpid=`ps ax | grep $KDC | grep -v grep | sed -e 's/^ *//' -e 's/ .*//'` echo "$0: Proccess ID = $kdcpid" else echo "$0: $kdcdaemon is ALREADY running (PID = $kdcpid)." fi else echo "$0: $KDC does NOT exist." exit 1 fi if [ -f $KADMIND ] ; then if [ -z "$kdmpid" ] ; then $KADMIND & echo "$0: $kdmdaemon started." kdmpid=`ps ax | grep $KADMIND | grep -v grep | sed -e 's/^ *//' -e 's/ .*//'` echo "$0: Proccess ID = $kdmpid" else echo "$0: $kdmdaemon is ALREADY running (PID = $kdmpid)." fi else echo "$0: $KADMIND does NOT exist." exit 1 fi if [ -f $KPASSWDD ] ; then if [ -z "$kpwpid" ] ; then $KPASSWDD & echo "$0: $kpwdaemon started." kpwpid=`ps ax | grep $KPASSWDD | grep -v grep | sed -e 's/^ *//' -e 's/ .*//'` echo "$0: Proccess ID = $kpwpid" else echo "$0: $kpwdaemon is ALREADY running (PID = $kpwpid)." fi else echo "$0: $KPASSWDD does NOT exist." exit 1 fi ;; stop) if [ -f $KDC ] ; then if [ -n "$kdcpid" ] ; then kill $kdcpid echo "$0: $kdcdaemon has been killed." else echo "$0: $kdcdaemon is NOT running." fi fi if [ -f $KADMIND ] ; then if [ -n "$kdmpid" ] ; then kill $kdmpid echo "$0: $kdmdaemon has been killed." else echo "$0: $kdmdaemon is NOT running." fi fi if [ -f $KPASSWDD ] ; then if [ -n "$kpwpid" ] ; then kill $kpwpid echo "$0: $kpwdaemon has been killed." else echo "$0: $kpwdaemon is NOT running." fi fi ;; *) echo "usage: $0 {start|stop}" # check kdc if [ -n "$kdcpid" ] ; then echo "$0: $kdcdaemon is ALREADY running (PID = $kdcpid)." else echo "$0: $kdcdaemon is NOT running." fi # check kadmind if [ -n "$kdmpid" ] ; then echo "$0: $kdmdaemon is ALREADY running (PID = $kdmpid)." else echo "$0: $kdmdaemon is NOT running." fi # check kpasswdd if [ -n "$kpwpid" ] ; then echo "$0: $kpwdaemon is ALREADY running (PID = $kpwpid)." else echo "$0: $kpwdaemon is NOT running." fi exit 1 ;; esac exit 0 EOF touch $W/i.et cd $W find $P ! -type l -newer i.st ! -newer i.et \ -exec touch -t `date '+%m%d0900'` {} \; compress strip_bindir $P/usr/heimdal/bin strip_bindir $P/usr/heimdal/sbin strip_bindir $P/usr/heimdal/libexec/heimdal strip_bindir $P/usr/heimdal/libexec strip_libdir $P/usr/heimdal/$libdir 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 touch -t `date '+%m%d0900'` $docdir/$src/$myname 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 prune_symlink $P/usr/heimdal convert touch -t `date '+%m%d0900'` \ $P/usr/heimdal/{{,s}bin,libexec{,/heimdal},$libdir} tar cvpf $pkg.tar -C $P usr/heimdal tar rvpf $pkg.tar -C $P `cd $P ; find etc -type f` tar rvpf $pkg.tar -C $P `cd $P ; find usr/share/info | 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 `cd $P ; find usr/share/man/man3 | tail -n+2` tar rvpf $pkg.tar -C $P `cd $P ; find usr/share/man/man5 | tail -n+2` tar rvpf $pkg.tar -C $P `cd $P ; find usr/share/man/man8 | tail -n+2` tar rvpf $pkg.tar -C $P usr/share/doc/$src tar rvpf $pkg.tar -C $P install/doinst.sh touch -t `date '+%m%d0900'` $pkg.tar ; xz $pkg.tar ; touch $pkg.tar.xz mv $pkg.tar.xz $pkg.txz read -p "Do you want to keep work files? [y/N] " ans if [ "x$ans" != "xY" -a "x$ans" != "xy" ] ; then rm -rf $P $C i.[se]t ; fi fi