s243a

installpkg.sh (tahrpup) LN# 359-369 non PUPMODE 2 install

Apr 22nd, 2018
451
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 4.94 KB | None | 0 0
  1. # LN# 359 to 369 of /usr/local/petget/installpkg.sh (tahrpup) - http://www.pearltrees.com/s243a/installpkg-sh-usr-local-petget/id20402080/item224130677
  2. else #-- anything other than PUPMODE 2 (full install) --
  3.  
  4.     [ "$DL_SAVE_FLAG" != "true" ] &&  rm -f $DLPKG_BASE 2>/dev/null
  5.     rm -f $DLPKG_MAIN.tar.${EXT} 2>/dev/null #131122
  6.  
  7.     #pkgname.files may need to be fixed...
  8.     FIXEDFILES="`cat /root/.packages/${DLPKG_NAME}.files | grep -v '^\\./$'| grep -v '^/$' | sed -e 's%^\\.%%' -e 's%^%/%' -e 's%^//%/%'`"
  9.     echo "$FIXEDFILES" > /root/.packages/${DLPKG_NAME}.files
  10.  
  11.     #120102 install may have overwritten a symlink-to-dir...
  12.     #tar defaults to not following symlinks, for both dirs and files, but i want to follow symlinks
  13.     #for dirs but not for files. so, fix here... (note, dir entries in .files have / on end)
  14.     cat /root/.packages/${DLPKG_NAME}.files | grep '[a-zA-Z0-9]/$' | sed -e 's%/$%%' | grep -v '^/mnt' |
  15.     while read ONESPEC
  16.     do
  17.      if [ -d "${DIRECTSAVEPATH}${ONESPEC}" ];then
  18.       if [ ! -h "${DIRECTSAVEPATH}${ONESPEC}" ];then
  19.        DIRLINK=""
  20.        if [ -h "/initrd${PUP_LAYER}${ONESPEC}" ];then #120107
  21.         DIRLINK="`readlink -m "/initrd${PUP_LAYER}${ONESPEC}" | sed -e "s%/initrd${PUP_LAYER}%%"`" #PUP_LAYER: see /etc/rc.d/PUPSTATE. 120107
  22.         xDIRLINK="`readlink "/initrd${PUP_LAYER}${ONESPEC}"`" #120107
  23.        fi
  24.        if [ ! "$DIRLINK" ];then
  25.         if [ -h "/initrd${SAVE_LAYER}${ONESPEC}" ];then #120107
  26.          DIRLINK="`readlink -m "/initrd${SAVE_LAYER}${ONESPEC}" | sed -e "s%/initrd${SAVE_LAYER}%%"`" #SAVE_LAYER: see /etc/rc.d/PUPSTATE. 120107
  27.          xDIRLINK="`readlink "/initrd${SAVE_LAYER}${ONESPEC}"`" #120107
  28.         fi
  29.        fi
  30.        if [ "$DIRLINK" ];then
  31.         if [ -d "$DIRLINK"  ];then
  32.          if [ "$DIRLINK" != "${ONESPEC}" ];then #precaution.
  33.           mkdir -p "${DIRECTSAVEPATH}${DIRLINK}" #120107
  34.           cp -a -f --remove-destination ${DIRECTSAVEPATH}"${ONESPEC}"/* "${DIRECTSAVEPATH}${DIRLINK}/" #ha! fails if put double-quotes around entire expression.
  35.           rm -rf "${DIRECTSAVEPATH}${ONESPEC}"
  36.           if [ "$DIRECTSAVEPATH" = "" ];then
  37.            ln -s "$xDIRLINK" "${ONESPEC}"
  38.           else
  39.            DSOPATH="`dirname "${DIRECTSAVEPATH}${ONESPEC}"`"
  40.            DSOBASE="`basename "${DIRECTSAVEPATH}${ONESPEC}"`"
  41.            rm -f "${DSOPATH}/.wh.${DSOBASE}" #allow underlying symlink to become visible on top.
  42.           fi
  43.          fi
  44.         fi
  45.        fi
  46.       fi
  47.      fi
  48.     done
  49.  
  50.     #121217 it seems that this problem is occurring in other modes (13 reported)...
  51.     #121123 having a problem with multiarch symlinks in full-installation...
  52.     #it seems that the symlink is getting replaced by a directory.
  53.     if [ "$DISTRO_ARCHDIR" ];then #in /etc/rc.d/DISTRO_SPECS. 130112 change test from DISTRO_ARCHDIR. 130114 revert DISTRO_ARCHDIR_SYMLINKS==yes.
  54.       if [ -d /usr/lib/${DISTRO_ARCHDIR} ];then
  55.        if [ ! -h /usr/lib/${DISTRO_ARCHDIR} ];then
  56.         cp -a -f --remove-destination /usr/lib/${DISTRO_ARCHDIR}/* /usr/lib/
  57.         sync
  58.         rm -r -f /usr/lib/${DISTRO_ARCHDIR}
  59.         ln -s ./ /usr/lib/${DISTRO_ARCHDIR}
  60.        fi
  61.       fi
  62.       if [ -d /lib/${DISTRO_ARCHDIR} ];then
  63.        if [ ! -h /lib/${DISTRO_ARCHDIR} ];then
  64.         cp -a -f --remove-destination /lib/${DISTRO_ARCHDIR}/* /lib/
  65.         sync
  66.         rm -r -f /lib/${DISTRO_ARCHDIR}
  67.         ln -s ./ /lib/${DISTRO_ARCHDIR}
  68.        fi
  69.       fi
  70.       if [ -d /usr/bin/${DISTRO_ARCHDIR} ];then
  71.        if [ ! -h /usr/bin/${DISTRO_ARCHDIR} ];then
  72.         cp -a -f --remove-destination /usr/bin/${DISTRO_ARCHDIR}/* /usr/bin/
  73.         sync
  74.         rm -r -f /usr/bin/${DISTRO_ARCHDIR}
  75.         ln -s ./ /usr/bin/${DISTRO_ARCHDIR}
  76.        fi
  77.       fi
  78.     fi
  79.  
  80.     #flush unionfs cache, so files in pup_save layer will appear "on top"...
  81.     if [ "$DIRECTSAVEPATH" != "" ];then
  82.      #but first, clean out any bad whiteout files...
  83.      # 22sep10 shinobar: bugfix was not working clean out whiteout files
  84.      find /initrd/pup_rw -mount -type f -name .wh.\*  -printf '/%P\n'|
  85.      while read ONEWHITEOUT
  86.      do
  87.       ONEWHITEOUTFILE="`basename "$ONEWHITEOUT"`"
  88.       ONEWHITEOUTPATH="`dirname "$ONEWHITEOUT"`"
  89.       if [ "$ONEWHITEOUTFILE" = ".wh.__dir_opaque" ];then
  90.        [ "`grep "$ONEWHITEOUTPATH" /root/.packages/${DLPKG_NAME}.files`" != "" ] && rm -f "/initrd/pup_rw/$ONEWHITEOUT"
  91.        continue
  92.       fi
  93.       ONEPATTERN="`echo -n "$ONEWHITEOUT" | sed -e 's%/\\.wh\\.%/%'`"'/*'   ;#echo "$ONEPATTERN" >&2
  94.       [ "`grep -x "$ONEPATTERN" /root/.packages/${DLPKG_NAME}.files`" != "" ] && rm -f "/initrd/pup_rw/$ONEWHITEOUT"
  95.      done
  96.      #111229 /usr/local/petget/removepreview.sh when uninstalling a pkg, may have copied a file from sfs-layer to top, check...
  97.      cat /root/.packages/${DLPKG_NAME}.files |
  98.      while read ONESPEC
  99.      do
  100.       [ "$ONESPEC" = "" ] && continue #precaution.
  101.       if [ ! -d "$ONESPEC" ];then
  102.        [ -e "/initrd/pup_rw${ONESPEC}" ] && rm -f "/initrd/pup_rw${ONESPEC}"
  103.       fi
  104.      done
  105.      #now re-evaluate all the layers...
  106.      busybox mount -t aufs -o remount,udba=reval unionfs / #remount with faster evaluation mode.
  107.      [ $? -ne 0 ] && logger -s -t "installpkg.sh" "Failed to remount aufs / with udba=reval"
  108.  
  109.      sync
  110.     fi
  111.  
  112. fi
Advertisement
Add Comment
Please, Sign In to add comment