Advertisement
s243a

petget LN#117-162 Get package info from file name

Apr 20th, 2018
241
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 2.46 KB | None | 0 0
  1. # Lines 117 to 162 of /usr/sbin/petget (tahrpup) - https://www.pearltrees.com/s243a/source-petget-usr-sbin/id20395775/item224036691
  2. #split PKGMAIN, ex: FULLPKGNAME=xvidtune-1.0.1-i486-1.tgz has PKGNAME=xvidtune-1.0.1
  3. case $EXT in
  4.   .deb)
  5.    #deb ex: xsltproc_1.1.24-1ubuntu2_i386.deb  xserver-common_1.5.2-2ubuntu3_all.deb
  6.    DB_nameonly="`echo -n "$PKGMAIN" | cut -f 1 -d '_'`"
  7.    DB_pkgrelease="`echo -n "$PKGMAIN" | rev | cut -f 2 -d '_' | cut -f 1 -d '-' | rev`"
  8.    prPATTERN="s%\\-${DB_pkgrelease}.*%%"
  9.    PKGNAME="`echo -n "$PKGMAIN" | sed -e "$prPATTERN"`"
  10.    DB_version="`echo "$PKGNAME" | cut -f 2 -d '_'`"
  11.   ;;
  12.   .pet)
  13.    PKGNAME="$PKGMAIN"
  14.    DB_version="`echo -n "$PKGNAME" | grep -o '\\-[0-9].*' | sed -e 's%^\-%%'`"
  15.    xDB_version="`echo -n "$DB_version" | sed -e 's%\\-%\\\\-%g' -e 's%\\.%\\\\.%g'`"
  16.    xPATTERN="s%${xDB_version}%%"
  17.    DB_nameonly="`echo -n "$PKGNAME" | sed -e "$xPATTERN" -e 's%\\-$%%'`"
  18.    DB_pkgrelease=""
  19.   ;;
  20.   .tgz|.txz)
  21.    #slack ex: xvidtune-1.0.1-i486-1.tgz  printproto-1.0.4-noarch-1.tgz
  22.    PKGNAME="`echo -n "$PKGMAIN" | sed -e 's%\\-i[3456]86.*%%' -e 's%\\-noarch.*%%'`"
  23.    DB_version="`echo -n "$PKGNAME" | grep -o '\\-[0-9].*' | sed -e 's%^\\-%%'`"
  24.    xDB_version="`echo -n "$DB_version" | sed -e 's%\\-%\\\\-%g' -e 's%\\.%\\\\.%g'`"
  25.    xPATTERN="s%${xDB_version}%%"
  26.    DB_nameonly="`echo -n "$PKGNAME" | sed -e "$xPATTERN" -e 's%\-$%%'`"
  27.    DB_pkgrelease="`echo -n "$PKGMAIN" | sed -e 's%.*\\-i[3456]86%%' -e 's%.*\\-noarch%%' -e 's%^\\-%%'`"
  28.   ;;
  29.   .tar.gz)
  30.    #arch ex: xproto-7.0.14-1-i686.pkg.tar.gz  trapproto-3.4.3-1.pkg.tar.gz
  31.    PKGNAME="`echo -n "$PKGMAIN" | sed -e 's%\\-i[3456]86.*%%' -e 's%\\.pkg$%%' | rev | cut -f 2-9 -d '-' | rev`"
  32.    DB_version="`echo -n "$PKGNAME" | grep -o '\\-[0-9].*' | sed -e 's%^\\-%%'`"
  33.    xDB_version="`echo -n "$DB_version" | sed -e 's%\\-%\\\\-%g' -e 's%\\.%\\\\.%g'`"
  34.    xPATTERN="s%${xDB_version}%%"
  35.    DB_nameonly="`echo -n "$PKGNAME" | sed -e "$xPATTERN" -e 's%\\-$%%'`"
  36.    DB_pkgrelease="`echo -n "$PKGMAIN" | sed -e 's%\\-i[3456]86.*%%' -e 's%\\.pkg$%%' | rev | cut -f 1 -d '-' | rev`"
  37.   ;;
  38.   .rpm) #110523
  39.    #exs: hunspell-fr-3.4-1.1.el6.noarch.rpm
  40.    PKGNAME="$PKGMAIN"
  41.    DB_version="`echo -n "$PKGNAME" | grep -o '\\-[0-9].*' | sed -e 's%^\-%%'`"
  42.    xDB_version="`echo -n "$DB_version" | sed -e 's%\\-%\\\\-%g' -e 's%\\.%\\\\.%g'`"
  43.    xPATTERN="s%${xDB_version}%%"
  44.    DB_nameonly="`echo -n "$PKGNAME" | sed -e "$xPATTERN" -e 's%\\-$%%'`"
  45.    DB_pkgrelease=""
  46.   ;;
  47. esac
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement