#!/bin/sh # # Functions taken from protopkg by David Cantrell # # stripeverything() # Goes through the package tree and strips all ELF stuff (binaries, # libraries, and so on). # # Parameters: $1 The package tree. # stripeverything() { cd $1 STATIC_DONE=n # strip shared libraries and binaries if [ ! "$STRIPLIB" = "n" -o ! "$STRIPBIN" = "n" ] then msgOut=n for testname in `find . -type f` do islib="`file $testname | grep ELF | \ grep 'shared object' | \ grep 'not stripped'`" isprog="`file $testname | grep ELF | \ grep executable | \ grep 'not stripped'`" isstatic="`file $testname | grep 'current ar archive'`" # strip binaries if the user so desires if [ ! "$isprog" = "" -a "$STRIPBIN" = "y" ] then if [ "$msgOut" = "n" ] then echo echo "Stripping ELF objects, generating static library indexes..." msgOut=y fi echo " --> strip $testname" strip -p --strip-unneeded $testname 2>/dev/null 1>/dev/null fi # strip libraries if the user so desires if [ ! "$islib" = "" -a "$STRIPLIB" = "y" ] then if [ "$msgOut" = "n" ] then echo echo "Stripping ELF objects, generating static library indexes..." msgOut=y fi echo " --> strip $testname" strip -p --strip-unneeded $testname 2>/dev/null 1>/dev/null fi # run ranlib on static libraries if [ ! "$isstatic" = "" ] then STATIC_DONE=y echo " --> ranlib $testname" ranlib $testname 2>/dev/null 1>/dev/null fi done if [ "$msgOut" = "y" ] then echo fi fi if [ "$STATIC_DONE" = "n" ] then # ranlib static libraries msgOut=n for libname in `find . -name *.a -type f` do if [ ! "`file $libname | grep 'current ar archive'`" = "" ] then if [ "$msgOut" = "n" ] then echo echo "Generating static library indexes..." msgOut=y fi echo " --> $libname" ranlib $libname 2>/dev/null 1>/dev/null fi done fi } # # permissionize() # Called by protopkg() to fix permissions on the temporary package build # directory. It sets all bin and sbin stuff to root.bin, chmod'ed 755. # After that it runs the ownerships and permissions functions from the # package prototype file (to set any special permissions the package # maintainer wants). # # Parameters: $1 The package tree. # permissionize() { cd $1 # default system-wide permissions find . -exec chown root.root {} \; 1>/dev/null 2>/dev/null find . -type d -exec chmod 755 {} \; 1>/dev/null 2>/dev/null find . -type d -exec chown root.root {} \; 1>/dev/null 2>/dev/null # default bin and sbin permissions (root.bin, 755) for d in usr/bin usr/sbin usr/X11R6/bin bin sbin usr/local/bin usr/local/sbin do chown -R root.bin $1/$d 2>/dev/null chmod -R 755 $1/$d 2>/dev/null done # default include permissions find usr/include -name *.h -exec chmod 644 {} \; 1>/dev/null 2>/dev/null find usr/X11R6/include -name *.h -exec chmod 644 {} \; 1>/dev/null 2>/dev/null # default man and info page permissions find usr/man -type f -exec chmod 644 {} \; 1>/dev/null 2>/dev/null find usr/X11R6/man -type f -exec chmod 644 {} \; 1>/dev/null 2>/dev/null find usr/info -type f -exec chmod 644 {} \; 1>/dev/null 2>/dev/null # default /usr/doc permissions and ownerships find . | grep "usr/doc" | xargs chown root.root 1>/dev/null 2>/dev/null find . -type f | grep "usr/doc" | xargs chmod 644 1>/dev/null 2>/dev/null find . -type d | grep "usr/doc" | xargs chmod 755 1>/dev/null 2>/dev/null } # # compressdocs() # Compresses all man pages and info files in a package tree. # # Parameters: $1 The package tree. # compressdocs() { dir1=`pwd` cd $1 for dn in usr \ usr/local \ 'opt/*' \ usr/X11R6 \ usr/openwin do # adapted by Jasper Huijsmans to repair broken links # and to also gzip the originally installed file for dn2 in man share/man info share/info do for file in `find $dn/$dn2 -type f 2>/dev/null` do gzip -9f $1/$file /$file 2>/dev/null done for link in `find $dn/$dn2 -type l 2>/dev/null` do relink_docs $1/$link 2>/dev/null relink_docs /$link 2>/dev/null done done done cd $dir1 } # # relink_docs() # repair broken links to docs cause by gzipping # added by Jasper Huijsmans # # Parameters: $1 The symbolic link file # relink_docs() { LINKGOESIN=`dirname $1` LINKNAMEIS=`basename $1` LINKPOINTSTO=`ls -l $1 | cut -b50- | cut -f 3 -d ' '` rm $1 # Here comes the trick: just add .gz to every name ( cd $LINKGOESIN; ln -s $LINKPOINTSTO.gz $LINKNAMEIS.gz ) } if [ ! "$1" = "" ] then stripeverything $1 permissionize $1 compressdocs $1 fi