# This file is part of the src2pkg program: # Copyright 2005-2009 Gilbert Ashley # src2pkg is released under the GNU General Public License Version 2 ### fix_pkg_perms fix_pkg_perms() { if [[ $ALLOW_USER_EXTENSIONS = "YES" ]] ; then # check if the user has any pre-execution extensions to this file and run them, if so. [[ -f "$HOME"/.src2pkg/extensions/09.pre ]] && . "$HOME"/.src2pkg/extensions/09.pre fi if [[ "$FAILED" = "" ]] && [[ ! $USER_CANCELLED ]] ; then if [[ ! $RESUME ]] || [[ $RESUME = $FUNCNAME ]] || [[ $HAVE_RESUMED ]] ; then [[ $RESUME = $FUNCNAME ]] && HAVE_RESUMED=1 && echo $CYAN"Notice - "$BLUE"Resuming build at: "$NORMAL "$FUNCNAME" if [[ $PAUSE = "BEFORE" ]] || [[ $PAUSE = $FUNCNAME ]] ; then echo $MAGENTA"Notice - "$BLUE"Pausing before: "$NORMAL" '$FUNCNAME' Press ENTER to continue" read fi echo $BLUE"Processing package content:"$NORMAL # create lists of the ELF-bin, ELF-libs, libtool-files and ar-archives cd "$PKG_DIR" ; [[ $DEBUG ]] && echo -n $BLUE"Building file lists: "$NORMAL find * -type f -name "*.la" -fprint $SRC_DIR/$NAME-la-files -o \ -name "*.a" -fprint $SRC_DIR/$NAME-a-files -o \ -print -exec file {} \; |grep ELF > $SRC_DIR/$NAME-elf-files # shared libs egrep '(shared object|relocatable)' $SRC_DIR/$NAME-elf-files |cut -f 1 -d : > $SRC_DIR/$NAME-ELF-libs if [[ -s $SRC_DIR/$NAME-ELF-libs ]] ; then [[ $DEBUG ]] && echo -n "ELF-libs " else rm -f $SRC_DIR/$NAME-ELF-libs fi # executable binaries egrep '(dynamically linked)' $SRC_DIR/$NAME-elf-files |cut -f 1 -d : > $SRC_DIR/$NAME-ELF-bins if [[ -s $SRC_DIR/$NAME-ELF-bins ]] ; then [[ $DEBUG ]] && echo -n "ELF-bins " else rm -f $SRC_DIR/$NAME-ELF-bins fi # libtool files while read line ; do file $line 2> /dev/null |grep 'libtool' |cut -f 1 -d : > $SRC_DIR/$NAME-libtool-files done < $SRC_DIR/$NAME-la-files if [[ -s $SRC_DIR/$NAME-libtool-files ]] ; then [[ $DEBUG ]] && echo -n "libtool-files " else rm -f $SRC_DIR/$NAME-libtool-files fi # ar archives (static libs) while read line ; do file $line 2> /dev/null |grep 'ar archive' |cut -f 1 -d : > $SRC_DIR/$NAME-static-libs done < $SRC_DIR/$NAME-a-files if [[ -s $SRC_DIR/$NAME-static-libs ]] ; then [[ $DEBUG ]] && echo -n "static-libs " else rm -f $SRC_DIR/$NAME-static-libs fi [[ $DEBUG ]] && echo rm -f $SRC_DIR/$NAME-la-files $SRC_DIR/$NAME-a-files if [[ "$CORRECT_PKG_PERMS" != "NO" ]] ; then echo -n $BLUE"Correcting package permissions - "$NORMAL # this is redundant, but won't hurt if [[ "$EUID" = "0" ]] ; then chown root:root "$PKG_DIR" else chown $OWNER:$GROUP "$PKG_DIR" fi ## Fix exceptions which are set to 1777 : drwxrwxrwt [[ -d "$PKG_DIR"/tmp ]] && chmod 1777 "$PKG_DIR"/tmp [[ -d "$PKG_DIR"/var/tmp ]] && chmod 1777 "$PKG_DIR"/var/tmp [[ -d "$PKG_DIR"/var/lock ]] && chmod 1777 "$PKG_DIR"/var/lock ## Fix exceptions which are set to 775 : drwxrwxr-x [[ -d "$PKG_DIR"/var/run ]] && chmod 775 "$PKG_DIR"/var/run # Fix common bin and sbin dirs for dir in $BIN_DIRS ; do if [[ -d "$PKG_DIR"/$dir ]] ; then if [[ "$EUID" = "0" ]] ; then chown -R root:root "$PKG_DIR"/$dir else chown -R $OWNER:$GROUP "$PKG_DIR"/$dir fi chmod -R 755 "$PKG_DIR"/$dir fi done for dir in $LIB_DIRS; do if [[ -d "$PKG_DIR"/$dir ]] ; then if [[ "$EUID" = "0" ]] ; then chown -R root:root "$PKG_DIR"/$dir chmod 755 $PKG_DIR/$dir find "$PKG_DIR"/$dir -type d -exec chown root:root {} \; find "$PKG_DIR"/$dir -type d -exec chmod 755 {} \; else chown -R $OWNER:$GROUP "$PKG_DIR"/$dir chmod 755 $PKG_DIR/$dir find "$PKG_DIR"/$dir -type d -exec chown $OWNER:$GROUP {} \; find "$PKG_DIR"/$dir -type d -exec chmod 755 {} \; fi fi done # chmod all ELF files 755 if [[ -f $SRC_DIR/$NAME-elf-files ]] ; then while read line ; do # $line is still a long line with lots of output -keep only left of first ':' chmod 755 $PKG_DIR/${line%%:*} 2> /dev/null done < $SRC_DIR/$NAME-elf-files # rm -f $SRC_DIR/$NAME-elf-files fi # chmod all libtool files 644 if [[ -f $SRC_DIR/$NAME-libtool-files ]] ; then while read line ; do chmod 644 $PKG_DIR/$line 2> /dev/null done < $SRC_DIR/$NAME-libtool-files fi # chmod all static libs 644 if [[ -f $SRC_DIR/$NAME-static-libs ]] ; then while read line ; do chmod 644 $PKG_DIR/$line 2> /dev/null done < $SRC_DIR/$NAME-static-libs fi # if [[ -d $PKG_DIR/etc/X11/app-defaults ]] ; then chmod 644 $PKG_DIR/etc/X11/app-defaults/* fi echo $GREEN"Done"$NORMAL fi if [[ $PAUSE = "AFTER" ]] || [[ $PAUSE = $FUNCNAME ]] ; then echo $MAGENTA"Notice - "$BLUE"Pausing after: "$NORMAL" '$FUNCNAME' Press ENTER to continue" read fi fi fi if [[ $ALLOW_USER_EXTENSIONS = "YES" ]] ; then # check if the user has any post-execution extensions to this file and run them, if so. [[ -f "$HOME"/.src2pkg/extensions/09.post ]] && . "$HOME"/.src2pkg/extensions/09.post fi } # end fix_source_perms