Advertisement
s243a

installpkg.sh #LN301-357 - PUPMODE 2 Stuff

Apr 22nd, 2018
233
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 2.89 KB | None | 0 0
  1. if [ "$PUPMODE" = "2" ]; then #from BK's quirky6.1 #LN301-357 of /usr/local/petget/installpkg.sh (tahpup) - http://www.pearltrees.com/s243a/installpkg-sh-usr-local-petget/id20402080/item224130427
  2.     mkdir /audit/${DLPKG_NAME}DEPOSED
  3.     echo -n '' > /tmp/petget/FLAGFND
  4.     find ${DIRECTSAVEPATH}/ -mindepth 1 | sed -e "s%${DIRECTSAVEPATH}%%" |
  5.     while read AFILESPEC
  6.     do
  7.       if [ -f "$AFILESPEC" ];then
  8.        ADIR="$(dirname "$AFILESPEC")"
  9.        mkdir -p /audit/${DLPKG_NAME}DEPOSED/${ADIR}
  10.        cp -a -f "$AFILESPEC" /audit/${DLPKG_NAME}DEPOSED/${ADIR}/
  11.        echo -n '1' > /tmp/petget/FLAGFND
  12.       fi
  13.     done
  14.     sync
  15.     if [ -s /tmp/petget/FLAGFND ];then
  16.       [ -f /audit/${DLPKG_NAME}DEPOSED.sfs ] && rm -f /audit/${DLPKG_NAME}DEPOSED.sfs #precaution, should not happen, as not allowing duplicate installs of same pkg.
  17.       mksquashfs /audit/${DLPKG_NAME}DEPOSED /audit/${DLPKG_NAME}DEPOSED.sfs
  18.     fi
  19.     sync
  20.     rm -rf /audit/${DLPKG_NAME}DEPOSED
  21.     #now write temp-location to final destination...
  22.     cp -a -f --remove-destination ${DIRECTSAVEPATH}/* /  2> /tmp/petget/install-cp-errlog
  23.     sync
  24.     #can have a problem if want to replace a folder with a symlink. for example, got this error:
  25.     # cp: cannot overwrite directory '/usr/share/mplayer/skins' with non-directory
  26.     #3builddistro has this fix... which is a vice-versa situation...
  27.     #firstly, the vice-versa, source is a directory, target is a symlink...
  28.     CNT=0
  29.     while [ -s /tmp/petget/install-cp-errlog ];do
  30.       echo -n '' > /tmp/petget/install-cp-errlog2
  31.       echo -n '' > /tmp/petget/install-cp-errlog3
  32.       cat /tmp/petget/install-cp-errlog | grep 'cannot overwrite non-directory' | grep 'with directory' | tr '[`‘’]' "'" | cut -f 2 -d "'" |
  33.       while read ONEDIRSYMLINK #ex: /usr/share/mplayer/skins
  34.       do
  35.        if [ -h "${ONEDIRSYMLINK}" ];then #source is a directory, target is a symlink...
  36.         #adding that extra trailing / does the trick...
  37.         cp -a -f --remove-destination ${DIRECTSAVEPATH}"${ONEDIRSYMLINK}"/* "${ONEDIRSYMLINK}"/ 2>> /tmp/petget/install-cp-errlog2
  38.        else #source is a directory, target is a file...
  39.         rm -f "${ONEDIRSYMLINK}" #delete the file!
  40.         DIRPATH="$(dirname "${ONEDIRSYMLINK}")"
  41.         cp -a -f ${DIRECTSAVEPATH}"${ONEDIRSYMLINK}" "${DIRPATH}"/ 2>> /tmp/petget/install-cp-errlog2 #copy directory (and contents).
  42.        fi
  43.       done
  44.       cat /tmp/petget/install-cp-errlog2 >> /tmp/petget/install-cp-errlog3
  45.       cat /tmp/petget/install-cp-errlog3 > /tmp/petget/install-cp-errlog
  46.       sync
  47.       CNT=`expr $CNT + 1`
  48.       [ $CNT -gt 10 ] && break #something wrong, get out.
  49.     done
  50.     #end 131220
  51.  
  52.     rm -rf ${DIRECTSAVEPATH} #131229 131230
  53.     [ "$DL_SAVE_FLAG" != "true" ] && rm -f $DLPKG_BASE 2>/dev/null
  54.     rm -f $DLPKG_MAIN.tar.gz 2>/dev/null
  55.     #pkgname.files may need to be fixed...
  56.     FIXEDFILES="`cat /root/.packages/${DLPKG_NAME}.files | grep -v '^\\./$'| grep -v '^/$' | sed -e 's%^\\.%%' -e 's%^%/%' -e 's%^//%/%'`"
  57.     echo "$FIXEDFILES" > /root/.packages/${DLPKG_NAME}.files
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement