s243a

installpkg.sh LN# 215-299 Install?

Apr 22nd, 2018
409
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 3.68 KB | None | 0 0
  1. cd "$DLPKG_PATH" # LN# 215-299 of /usr/local/petget/installpkg.sh (tahrpup) - http://www.pearltrees.com/s243a/installpkg-sh-usr-local-petget/id20402080/item224129810
  2.  
  3. case $DLPKG_BASE in
  4.  *.pet)
  5.   DLPKG_MAIN="`basename $DLPKG_BASE .pet`"
  6.   pet2tgz $DLPKG_BASE || exit 1
  7.   tarball=$(echo ${DLPKG_MAIN}.tar.[gx]z)
  8.   PETFILES="$(tar --list -a -f $tarball)" || exit 1
  9.   #check for renamed pets. Will produce an empty ${DLPKG_NAME}.files file
  10.   PETFOLDER=$(echo "${PETFILES}" | cut -f 2 -d '/' | head -n 1)
  11.   [ "$PETFOLDER" = "" ] && PETFOLDER=$(echo "${PETFILES}" | cut -f 1 -d '/' | head -n 1)
  12.   if [ "${DLPKG_MAIN}" != "${PETFOLDER}" ]; then
  13.    pupkill $YAFPID1
  14.    LANG=$LANG_USER
  15.    if [ "$DISPLAY" ]; then
  16.     . /usr/lib/gtkdialog/box_ok "$(gettext 'Puppy Package Manager')" error "<b>${DLPKG_MAIN}.pet</b> $(gettext 'is named') <b>${PETFOLDER}</b> $(gettext 'inside the pet file. Will not install it!')"
  17.    else
  18.     . dialog --msgbox "$DLPKG_MAIN.pet $(gettext 'is named') $PETFOLDER $(gettext 'inside the pet file. Will not install it!')" 0 0
  19.    fi
  20.    exit 1
  21.   fi
  22.   if [ "`echo "$PETFILES" | grep -m1 '^\\./'`" != "" ];then
  23.    #ttuuxx has created some pets with './' prefix...
  24.    pPATTERN="s%^\\./${DLPKG_NAME}%%"
  25.    echo "$PETFILES" | sed -e "$pPATTERN" > /root/.packages/${DLPKG_NAME}.files
  26.    install_path_check
  27.    tar -a -x --strip=2 --directory=${DIRECTSAVEPATH}/ -f ${tarball} #120102. 120107 remove --unlink-first
  28.   else
  29.    #new2dir and tgz2pet creates them this way...
  30.    pPATTERN="s%^${DLPKG_NAME}%%"
  31.    echo "$PETFILES" | sed -e "$pPATTERN" > /root/.packages/${DLPKG_NAME}.files
  32.    install_path_check
  33.    tar -a -x --strip=1 --directory=${DIRECTSAVEPATH}/ -f ${tarball} #120102. 120107. 131122
  34.   fi
  35.   rm -f "${tarball}"
  36.   [ $? -ne 0 ] && clean_and_die
  37.  ;;
  38.  *.deb)
  39.   DLPKG_MAIN="`basename $DLPKG_BASE .deb`"
  40.   PFILES="`dpkg-deb --contents $DLPKG_BASE | tr -s ' ' | cut -f 6 -d ' '`"
  41.   [ $? -ne 0 ] && exit 1
  42.   echo "$PFILES" > /root/.packages/${DLPKG_NAME}.files
  43.   install_path_check
  44.   # Workaround to avoid overwriting the $DISTRO_ARCHDIR symlink.  
  45.   if [ "$DISTRO_ARCHDIR" != "" -a "$(echo "$PFILES" | grep "$DISTRO_ARCHDIR")" != "" ]; then
  46.        mkdir -p /tmp/$DLPKG_BASE
  47.        rm -rf /tmp/$DLPKG_BASE/*
  48.        dpkg-deb -x $DLPKG_BASE /tmp/$DLPKG_BASE/
  49.        for f in $(find /tmp/$DLPKG_BASE \( -type f -o -type l \))
  50.     do
  51.        xpath=$(echo $f |  cut  -f 4-30 -d "/" | sed "s/$DISTRO_ARCHDIR\///")
  52.        mkdir -p /$(dirname $xpath)
  53.        cp -a $f /$(dirname $xpath)/
  54.     done
  55.        rm -rf /tmp/$DLPKG_BASE
  56.   else
  57.        dpkg-deb -x $DLPKG_BASE ${DIRECTSAVEPATH}/
  58.   fi
  59.   [ $? -ne 0 ] && clean_and_die
  60.   [ -d /DEBIAN ] && rm -rf /DEBIAN #130112 precaution.
  61.   dpkg-deb -e $DLPKG_BASE /DEBIAN #130112 extracts deb control files to dir /DEBIAN. may have a post-install script, see below.
  62.  ;;
  63.  *.tgz|*.txz|*.tar.gz|*.tar.xz|*.tar.bz2) #slackware, arch, etc..
  64.   DLPKG_MAIN="`basename $DLPKG_BASE`" #remove directory - filename only
  65.   DLPKG_MAIN=${DLPKG_MAIN%*.tar.*}    #remove .tar.xx extension
  66.   DLPKG_MAIN=${DLPKG_MAIN%.t[gx]z}    #remove .t[gx]z extension
  67.   PFILES="`tar --list -a -f $DLPKG_BASE`" || exit 1
  68.   echo "$PFILES" > /root/.packages/${DLPKG_NAME}.files
  69.   install_path_check
  70.   tar -a -x --directory=${DIRECTSAVEPATH}/ -f $DLPKG_BASE #120102. 120107
  71.   [ $? -ne 0 ] && clean_and_die
  72.  ;;
  73.  *.rpm) #110523
  74.   DLPKG_MAIN="`basename $DLPKG_BASE .rpm`"
  75.   busybox rpm -qp $DLPKG_BASE > /dev/null 2>&1
  76.   [ $? -ne 0 ] && exit 1
  77.   PFILES="`busybox rpm -qpl $DLPKG_BASE`"
  78.   [ $? -ne 0 ] && exit 1
  79.   echo "$PFILES" > /root/.packages/${DLPKG_NAME}.files
  80.   install_path_check
  81.   #110705 rpm -i does not work for mageia pkgs...
  82.   exploderpm -i $DLPKG_BASE
  83.   [ $? -ne 0 ] && clean_and_die
  84.  ;;
  85. esac
Add Comment
Please, Sign In to add comment