Advertisement
s243a

pkg-list-aliases

Sep 14th, 2019
552
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 17.91 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. #==================  setup script vars  =====================#
  4.  
  5. APPNAME="Pkg"
  6. APPVER="1.9.22"
  7. APPTITLE="$APPNAME $APPVER"
  8. list_deps_count=0 #Keeps track of the number of instances of the function list_deps(). Cleanup will be done when the last instance exists.
  9. dep_id=0 #
  10. # get current locale settings
  11. USER_LANG=$LANG
  12. USER_LC_ALL=$LC_ALL
  13.  
  14. SELF=$(basename $0)        # this script
  15. QTAG=''                    # gets set to (y/n) if ASK=-true
  16. LANG=C                     # speed up
  17. LC_ALL=C                   # speed up
  18. EDITOR=${EDITOR:-vi}       # just in case
  19. PAGER=${PAGER:-less}       # just in case
  20. CURDIR="${PWD}"            # get current dir, before cd to WORKDIR
  21. whoami=$(whoami)           # s243a copied from below. See issue: http://murga-linux.com/puppy/viewtopic.php?p=1030838#1030838
  22. TMPDIR=/tmp/pkg/${whoami}  # set the tmp dir
  23.  
  24. # set colours true by default
  25. green="\e[32m"; red="\e[91m"; magenta="\e[95m"; lightblue="\e[36m"; yellow="\e[93m"; bold="\e[1m"; endcolour="\e[0m"
  26.  
  27. # ENVIRONMENT VARS, which may be overridden later
  28. [ -z "$PKGRC" ] && export PKGRC=${HOME}/.pkg/pkgrc      # config file for this script
  29. [ -z "$ASK"   ] && ASK=false                            # if true, ask user before doing stuff. Overridden by --ask
  30. [ -z "$QUIET" ] && QUIET=false                          # if true, hide output that doesnt log well in Xdialog, Gtkdialog, etc
  31. [ -z "$FORCE" ] && FORCE=false                          # if true, force (re)install/remove pkgs. Overridden by --force
  32. [ -z "$HIDE_INSTALLED" ] && export HIDE_INSTALLED=false # if true, hide installed pkgs from pkg searches (-n, -na, -ss, -ssa)
  33. [ -z "$HIDE_BUILTINS"  ] && export HIDE_BUILTINS=true   # if true, remove builtins pkgs from dep lists, dont download/install them
  34. [ -z "$HIDE_USER_PKGS" ] && export HIDE_USER_PKGS=true  # if true, hide user installed pkgs from dep lists, dont download/install them
  35. [ -z "$NO_ALIASES"     ] && export NO_ALIASES=false     # if true, skip searching pkg alias names for pkg alternatives
  36. [ -z "$NO_INSTALL"     ] && export NO_INSTALL=false     # if true, skip installing of pkgs
  37. [ -z "$PKG_NO_COLOURS" ] && export PKG_NO_COLOURS=false # if true, disable coloured output or not
  38. [ -z "$PKG_CONFIGURE"  ] && export PKG_CONFIGURE=''     # reset
  39. [ -z "$PKG_CFLAGS"     ] && export PKG_CFLAGS=''        # reset
  40.  
  41. [ -z "$PKGS_DIR" ] && export PKGS_DIR="$(realpath "${HOME}/.packages")"
  42. #These are files of the form
  43. #[ -z "$PET_SPEC_DIR_ROOT" ] && PET_SPEC_DIR_ROOT="$PKGS_DIR"
  44. if [ -z "$REPO_DB_FILE_DIR" ]; then
  45.   if [ -d "$PKGS_DIR/repo" ]; then #This imples mistfires ppm3 is installed
  46.     export REPO_DB_FILE_DIR="$(realpath "$PKGS_DIR/repo")"
  47.   else
  48.     export REPO_DB_FILE_DIR="$PKGS_DIR"
  49.   fi
  50. fi
  51. if [ -z "$PACKAGE_FILE_LIST_DIR" ]; then
  52.   if [ -d "$PKGS_DIR/package-files" ]; then #This imples mistfires ppm3 is installed
  53.     export PACKAGE_FILE_LIST_DIR="$(realpath "$PKGS_DIR/package-files")"
  54.   else
  55.     export PACKAGE_FILE_LIST_DIR="$(realpath "$PKGS_DIR")"
  56.   fi
  57. fi
  58. [ -z "$BUILTIN_FILE_LIST_DIR" ] && BUILTIN_FILE_LIST_DIR="$PKGS_DIR/builtin_files"
  59. #[ -z "$PET_SPEC_DIR_BUILTIN" ] && PET_SPEC_DIR_BUILTIN=\
  60. #  "$(realpath "$PKGS_DIR/builtin_files")"
  61. #
  62. #[ -z "$PET_SPEC_DIR_USR_INST" ] && PET_SPEC_DIR_USR_INST="$PKGS_DIR"
  63.  
  64.  
  65. #mk_spec_file_list_arry(){
  66.  [declare -p $SPEC_DB_PATHS ] || declare -ga SPEC_DB_PATHS=()
  67.  #Can't put the loop in the loop in a pipeline if you want to assign array values:
  68.  #https://stackoverflow.com/questions/13091700/why-is-my-array-gone-after-exiting-loop  
  69.  #find / -wholename "$PKGS_DIR"/'*-installed-packages' |
  70.  while read SPEC_FILE; do
  71.    bname="`basename "$SPEC_FILE"`"
  72.    case "$bname" in #Consider lowering case
  73.    "layers-installed-packages")
  74.      #Do Nothing
  75.      export LAYER_INST_PKGS_FILE="$SPEC_FILE" ;;
  76.    "woof-installed-packages")
  77.      export WOOF_INST_PKGS_FILE="$SPEC_FILE" ;;
  78.    "user-installed-packages")
  79.      export USER_INST_PKGS_FILE="$SPEC_FILE" ;;
  80.    "devx-only-installed-packages")
  81.      export DEVX_INST_PKGS_FILE="$SPEC_FILE" ;;    
  82.    *)
  83.      SPEC_DB_PATHS+=( "$SPEC_FILE" ) ;;
  84.    esac
  85.    #s243a: We don't need realpath for the next four vars but it will provide usefull debugging information.
  86.    #s243a: TODO search for the following files if they don't exist.
  87.    [ -z "$USER_INST_PKGS_FILE" ] && \
  88.      USER_INST_PKGS_FILE="$PKGS_DIR/user-installed-packages"
  89.    [ -z "$WOOF_INST_PKGS_FILE" ] && \
  90.      WOOF_INST_PKGS_FILE="$PKGS_DIR/woof-installed-packages"
  91.    [ -z "$LAYER_INST_PKGS_FILE" ] && \
  92.      LAYER_INST_PKGS_FILE="$PKGS_DIR/layers-installed packages"
  93.    [ -z "$DEVX_INST_PKGS_FILE" ] && \
  94.      DEVX_INST_PKGS_FILE="$PKGS_DIR/devx-only-installed-packages"
  95.    SPEC_DB_PATHS=( "$USER_INST_PKGS_FILE" "$WOOF_INST_PKGS_FILE" "${SPEC_DB_PATHS[@]}" )
  96.  done < <( find "$PKGS_DIR" -name '*-installed-packages' )
  97. #}  
  98. #mk_spec_file_list_arry
  99. #echo "SPEC_DB_PATHS=${SPEC_DB_PATHS[@]}"
  100.  
  101. #mk_all_repo_file_list_arry(){
  102.  declare -gA ALL_REPO_DB_PATHS=()
  103.  #ALL_REPO_DB_PATHS=()
  104.  bname=''
  105.  
  106.  #Can't put the loop in the loop in a pipeline if you want to assign array values:
  107.  #https://stackoverflow.com/questions/13091700/why-is-my-array-gone-after-exiting-loop
  108.  #find / -wholename "$REPO_DB_FILE_DIR"/'Packages-*' |
  109.  while read REPO_FILE; do
  110.      #s243a: I was thinking of using realpath but it might cause issues.
  111.      #REPO_FILE="$(realpath "$REPO_FILE")"
  112.      bname="$(basename "$REPO_FILE")"  
  113.      ALL_REPO_DB_PATHS+=( ["$bname"]="$REPO_FILE" )
  114.      #echo "ALL_REPO_DB_PATHS=${ALL_REPO_DB_PATHS[@]}"
  115.      #echo "ALL_REPO_DB_PATHS=${ALL_REPO_DB_PATHS[@]}"
  116.  done < <( find "$REPO_DB_FILE_DIR" -name 'Packages-*' )
  117. #}  
  118. #mk_all_repo_file_list_arry
  119. #echo "exited: mk_all_repo_file_list_arry()"
  120. #echo "ALL_REPO_DB_PATHS=${ALL_REPO_DB_PATHS[@]}"
  121.  
  122. #Moved after the function repo_file_list
  123. #mk_repo_file_list_arry
  124. # but disable colours if called as gpkg, or the ENV variable PKG_NO_COLOURS is true
  125. if [ "`basename $0`" != "pkg" -o "$PKG_NO_COLOURS" = true ]; then
  126.   green='' red='' magenta='' lightblue='' yellow='' bold='' endcolour=''
  127. fi
  128.  
  129. # report errors better than just echo
  130. error(){
  131.   echo -e 1>&2 "${red}Error:${endcolour} $1"
  132. }
  133.  
  134. #run as root only
  135. whoami=$(whoami) #s243a Copied to before line #40. See issue: http://murga-linux.com/puppy/viewtopic.php?p=1030838#1030838
  136. [ "$whoami" != "root" ] && echo "You must be root to run Pkg." && exit 1
  137.  
  138. #080413 make sure all config files are present, copy from /etc if need be
  139. if [ ! -f ${PKGRC} ]; then
  140.   echo "Restoring default settings from /etc/pkg"
  141.   [ ! -d /etc/pkg/ ] && error "Default config files  in /etc/pkg/ not found." && exit 3
  142.   mkdir -p "$HOME/.pkg"
  143.   [ ! -d "$HOME/.pkg" ] && error "Default user config dir '$HOME/.pkg/' could not be created." && exit 3
  144.   cp --force -a /etc/pkg/* "$HOME/.pkg/" || exit 3
  145. fi
  146.  
  147. # get puppy distro env vars
  148. [ -f /etc/rc.d/PUPSTATE ]                   && . /etc/rc.d/PUPSTATE                    #this has PUPMODE and SAVE_LAYER.
  149. [ -f /etc/DISTRO_SPECS ]                    && . /etc/DISTRO_SPECS                     #has DISTRO_BINARY_COMPAT, DISTRO_COMPAT_VERSION
  150. [ -f /etc/rc.d/BOOTCONFIG ]                 && . /etc/rc.d/BOOTCONFIG                  #has EXTRASFSLIST PREVUNIONRECORD, LASTUNIONRECORD (sfs stuff)
  151. [ -f /etc/xdg/menus/hierarchy ]             && . /etc/xdg/menus/hierarchy              #w478 has PUPHIERARCHY variable.
  152. [ -f $PKGS_DIR/DISTRO_PKGS_SPECS ]    && . $PKGS_DIR/DISTRO_PKGS_SPECS     #has lot sof essential info
  153. [ -f $PKGS_DIR/PKGS_MANAGEMENT ]      && . $PKGS_DIR/PKGS_MANAGEMENT       #has PKG_NAME_IGNORE, PKG_PET_THEN_BLACKLIST_COMPAT_KIDS, PKG_REPOS_ENABLED
  154. [ -f $PKGS_DIR/DISTRO_COMPAT_REPOS ]  && . $PKGS_DIR/DISTRO_COMPAT_REPOS   #has repo URL related vars
  155.  
  156. # set the package name suffix appended to combined pkgs (pkg+deps)
  157. CP_SUFFIX="WITHDEPS_${DISTRO_FILE_PREFIX}"
  158.  
  159. # set correct arch for repo URLs (used by some slack-pup repos)
  160. case "$DISTRO_TARGETARCH" in
  161.   x86)    DBIN_ARCH=i486                ;;
  162.   x86_64) DBIN_ARCH=x86_64 ; DSUFFIX=64 ;;
  163.   *)      DBIN_ARCH=i486                ;;
  164. esac
  165.  
  166. # needed for some debian based repos
  167. case $DISTRO_COMPAT_VERSION in
  168.   wheezy) DDB_COMP=bz2 ;; # older versions
  169.   *)      DDB_COMP=xz  ;;
  170. esac
  171.  
  172. # now create 'layers-installed': will contain builtins (and devx packages, if devx is loaded)
  173. #130511 need to include devx-only-installed-packages, if loaded...
  174. if which gcc &>/dev/null; then
  175.   [ ! -f /tmp/ppm-layers-installed-packages ] && cp -f "$WOOF_INST_PKGS_FILE" /tmp/ppm-layers-installed-packages &>/dev/null
  176.   cat "$PET_SPEC_DIR_DEFAULT/devx-only-installed-packages" >> /tmp/ppm-layers-installed-packages &>/dev/null
  177.   sort -u /tmp/ppm-layers-installed-packages > "$LAYER_INST_PKGS_FILE" &>/dev/null
  178. else
  179.   cp -f "$WOOF_INST_PKGS_FILE" "$LAYER_INST_PKGS_FILE" &>/dev/null
  180. fi
  181.  
  182. # set $DIRECTSAVEPATH (where we want to install pkgs)
  183. if [ $PUPMODE -eq 3 -o $PUPMODE -eq 7 -o $PUPMODE -eq 13 ]; then
  184.   DIRECTSAVEPATH="/initrd${SAVE_LAYER}" #SAVE_LAYER is in /etc/rc.d/PUPSTATE.
  185. elif [ "$PUPMODE" = "2" ]; then
  186.   DIRECTSAVEPATH=""
  187. fi
  188. # s243a: Need the real path to avoid overwriting sylinks. See:
  189. # http://murga-linux.com/puppy/viewtopic.php?p=1030958#1030958  
  190. # https://github.com/puppylinux-woof-CE/woof-CE/issues/1469#issuecomment-505706014
  191. [ -L "$DIRECTSAVEPATH" ] && DIRECTSAVEPATH="$(readlink "$DIRECTSAVEPATH")"
  192. # get repo details, workdir, search settings and so on.. you could
  193. # you can also add any ENVIRONMENT VARS above to PKGRC, to override the defaults
  194. . ${PKGRC}
  195.  
  196. # set and create workdir if no valid dir set
  197. [ ! -d "$WORKDIR" ] && mkdir -p "$WORKDIR"
  198. if [ ! -d "$WORKDIR" ]; then
  199.   error "Can't create $WORKDIR. Please create it."
  200.   exit 3
  201. fi
  202. WORKDIR=~/pkg
  203.  
  204. # add to tab completion settings to bashrc and print hint
  205. if [ -z "$PKG_TAB_COMPLETION" ]; then
  206.   if [ "$(grep 'export PKG_TAB_COMPLETION=true' ~/.bashrc)" = "" ]; then
  207.     # add to bashrc
  208.     echo "" >> ~/.bashrc
  209.     echo "# enable $APPNAME $APPVER TAB completion" >> ~/.bashrc
  210.     echo "export PKG_TAB_COMPLETION=true" >> ~/.bashrc
  211.     echo ". /etc/bash_completion.d/pkg 2>/dev/null" >> ~/.bashrc
  212.   fi
  213. fi
  214.  
  215. # make tmp dir writable by everyone if needed
  216. if [ ! -d "$TMPDIR" ]; then
  217.   mkdir -p "$TMPDIR" 2>/dev/null
  218.   chmod -R 1777 /tmp/pkg/ 2>/dev/null
  219. fi
  220.  
  221. # if no tmp dir created or accessible, exit
  222. [ ! -d "$TMPDIR" ] && error "Cannot create temp dir ${lightblue}$TMPDIR${endcolour}" && exit 3
  223.  
  224. # support aliases, create ALIASES tmp file
  225. PKG_NAME_ALIASES='mozilla-firefox,firefox gtk+,gtk2 gtk2,gtk+2 dirac,schroedinger hunspell,myspell mp,mped mplayer,mplayer_*,mplayer-*,mplayer2,smplayer,gmplayer mrxvt,rxvt-unicode,xterm,urxvt,urxvt-unicode cxxlibs,glibc*,libc-* glibc-solibs,glibcsolibs alsalib,alsa-lib,alsa-lib2* alsautils,alsa-utils,alsa_utils,alsa-utils2* libungif,libgif,giflib zip,infozip dbus,libdbus*,libdbus-glib* hal,libhal* mesa,mesa_*,libgl1-mesa*,mesa-common* libxcb,libxcb_base sane,sane-backends samba,samba-tng,samba_*,mountcifs SDL_*,libsdl_* SDL,libsdl skype,skype_static util_linux_ng,util-linux-ng,util-linux,util_linux,utillinuxng vlc,vlc-nogui,vlc_nogui,VLC_Plus_Extras xf86-video-ati,xf86-video-ati-*,ati_fglrx xfdiff,xfdiff-cut xorg_base,xorg_base_t2,x11-common,x-dev,xorg,xorg73_base_t2 acl,libacl* xdg_puppy,xdg-utils perl_tiny,perl-base,perl-modules,perlapi* xorg-util-macros,util-macros portaudio,libportaudio jack-audio-connection-kit,libjack libjasper,jasper imlib2,libimlib2 imlib,libimlib'
  226. [ ! -f "$TMPDIR/pkg_aliases" ] && echo "$PKG_NAME_ALIASES" | tr ' ' '\n' > $TMPDIR/pkg_aliases
  227.  
  228. # remove error code flag if we got here
  229. rm -f /tmp/pkg/error130 &>/dev/null
  230.  
  231. # if not first run, and no options given, print the help
  232. [ ! -f ~/.pkg/firstrun -a "$1" = "" ] && $SELF -H && exit 1 #200913 more help by default
  233.  
  234. #==================  setup script vars  =====================#
  235.  
  236. set -a
  237.  
  238. list_all_aliases_set_verify(){
  239.       local verify
  240.       declare -a verify_actions
  241.       if [[ $2 = -* ]]; then
  242.         verify=0 #Don't Verify aliases
  243.         #echo "first if"
  244.        #shift 1
  245.       elif [[ -z "$2" ]]; then
  246.         verify=0 #Don't Verify aliases
  247.          #echo "second if"      
  248.       else
  249.         verify=$2
  250.         #echo "else"
  251.         #shift 2
  252.       fi
  253.       #echo "exited if"
  254.       case "$verify" in
  255.         true|yes|1) verify=1; ;;
  256.         false|no|0) verify=0; ;;
  257.         fist|2) verify=2; ;; #Verify untill we know the version
  258.         *)
  259.           verify=3 #Specify the verify action.
  260.           verify_actions=( ${2//;/ } ) #TODO maybe use a more robust method here: https://stackoverflow.com/questions/918886/how-do-i-split-a-string-on-a-delimiter-in-bash
  261.           #shift 2
  262.           ;;
  263.       esac
  264.        
  265.       echo $verify
  266.      if [ declare -p verify_actions ]; then
  267.        for action in verify_actions; do
  268.          echo "$action"
  269.        done
  270.      fi
  271. }
  272.  
  273. # utility funcs
  274. #set -- gtk
  275. list_all_aliases(){
  276.   # support pkg name aliases in finding packages
  277.         #case "$i" in
  278.         #1) subdep2="subdep"
  279.         #2)
  280.         #  subdep2="$(echo subdep | sed -e 's/++/+++/g' -e 's/+[a-z0-9].*//g')"
  281.         #  if [ "$subdep" = "$subdep2" ]; then
  282.         #  
  283.         #  fi
  284.   echo "$subdep2"
  285.   #local ALIAS_LIST; local ALIAS; local ALIAS_RES; local subdep
  286.   #local subdep_version; local subdep2; local subdep_stripped
  287.   #local verify; local no_alias
  288.   declare -a options="$(getopt -o v:l:p --long version:,list:,package:,verify::,no-alias -- $@)"
  289.   eval set -- "$options"
  290.   while true; do
  291.     case $1 in
  292.     -v|--version)
  293.       subdep_version=${2:-'%{version}'}; shift 2 ;;  
  294.    -l|--list)
  295.      ALIAS_LIST="2"; shift 2; ;;
  296.    -p|--package)
  297.      subdep="$2"; shift 2; ;;
  298.    --verify)
  299.      while aResult in list_all_aliases_set_verify "$1" "$2"; do
  300.        verify_actions=("aResult")
  301.      done
  302.      verify=${verify_actions[0]};
  303.      #echo "WTF!"
  304.      unset 'verify_actions[0]'
  305.      shift 1; [[ "$1" = -* ]] && shift 1
  306.  ;;
  307.    #--verify-type)
  308.    --no-alias)  
  309.      if [[ $2 = -* ]] || [ -z "$2" ]; then
  310.        no_alias=1; shift 1;      
  311.      else
  312.        no_alias=$2; shift 2;    
  313.      fi
  314.      {
  315.      case "$no_alias" in
  316.        true|yes|1) no_alias=1; ;;
  317.        false|no|0) no_alias=0; ;;
  318.        default|2) no_alias=2; ;;
  319.      esac
  320.      } ;;
  321.    --)
  322.      shift
  323.      break; ;;
  324.    -*|--*) #This should never happen
  325.       echo "list_all_aliases(): unkown option '$1' '$2' "
  326.       shift 2; ;;      
  327.    *) #This should never happen
  328.       echo "list_all_aliases(): unkown paramater '$1' " 1>&2
  329.       shift 1; ;;
  330.    esac
  331.  done
  332.  
  333.  if [ -z "$subdep" ]; then
  334.    subdep="$1"; shift
  335.  fi
  336.  if [ -z "$subdep_version" ]; then
  337.    subdep_version=${1:-'%{version}'}; shift
  338.  fi
  339.  if [ -z "$ALIAS_LIST" ]; then
  340.    ALIAS_LIST="$1"; shift
  341.  fi
  342.  [ -z "$verify" ] && verify=0
  343.  if [ -z "$no_alias" ] || [ $no_alias -eq 2 ]; then
  344.    if [ ! -z "$NO_ALIASES" ]; then
  345.      case "$NO_ALIASES"  in
  346.      true) no_alias=1 ;;
  347.      false) no_alias=0 ;;
  348.      esac
  349.    else
  350.      no_alias=0;
  351.    fi
  352.  fi
  353.  if [ -z "$ALIAS_LIST" ]; then
  354.    if [ -f ${TMPDIR}/pkg_aliases ]; then
  355.      ALIAS_LIST="${TMPDIR}/pkg_aliases"
  356.    else
  357.      ALIAS_LIST="$PKG_NAME_ALIASES"
  358.    fi
  359.  fi
  360.  if [ -e "$ALIAS_LIST" ]; then #ALIAS_LIST is a file
  361.       ALIAS_LIST=( `grep -E "$subdep"'([,]|$)' "$ALIAS_LIST"  2>/dev/null | tr ',' ' '` )
  362.  else #[[ "$ALIAS_LIST" = *,* ]]; then #ALIAS_LIST is string
  363.    ALIAS_LIST=( $(echo "$ALIAS_LIST" | tr ' ' '\n' | grep -E "$subdep"'([,]|$)'  2>/dev/null | tr ',' '\n') )
  364.  fi
  365.    
  366.  subdep_stripped="$(echo "$subdep" | sed -e 's/++/+++/g' -e 's/+[a-z0-9].*//g')"
  367.  if [ "$subdep_stripped" = "$sudep" ]; then
  368.    supdep2="$subdep$subdep_version"
  369.  else
  370.    supbdep2="$subdep_stripped"
  371.  fi
  372.  declare -A result
  373.  if [ $no_alias = 1 ]; then
  374.    result[0]="$subdep"
  375.    result[1]="$subdep2"
  376.  elif [ $no_alias = 0 ]; then
  377.    
  378.    # if we have some results to parse
  379.  
  380.    # get the list of aliases
  381.    #ALIAS_LIST="`grep -m1 "$1" $TMPDIR/pkg_aliases  2>/dev/null | tr ',' ' '`";
  382.    # for each alias
  383.    while read ALIAS
  384.    do
  385.      [ "$ALIAS" = '' ] && continue
  386.      # get the match from the current repo (if any)
  387.      if [ $verify -eq 1 ]; then
  388.        ALIAS_RES="`LANG=C cut -f1 -d'|' "$REPO_DB_FILE_DIR/${REPOFILE}" 2>/dev/null | grep  "^$ALIAS"`" #'
  389.         [ ! "$ALIAS_RES" ] && ALIAS_RES="`LANG=C cut -f2 -d'|' "$REPO_DB_FILE_DIR/${REPOFILE}" 2>/dev/null | grep "^$ALIAS"`" #'
  390.         # if the repo match was found in the search results
  391.         if [ "$ALIAS_RES" != "" ]; then
  392.           # add the alias results to the search results
  393.           echo "$ALIAS_RES" #>> $TMPDIR/pkglist
  394.         fi
  395.         ##########
  396.         #For info on AWK regular expressions see: https://www.gnu.org/software/gawk/manual/html_node/Regexp.html
  397.         #For info on
  398.         if [ -z "$subdep_version" ]; then
  399.         AWK_PRG=\
  400.         "BEGIN{FS=\"|\"}
  401.        {
  402.           a=gensub(\$2,/([:alpha:]*)([:digit:]?)/,matches)
  403.           if length(matches) > 0 ) {
  404.             if ( matches[1] = \"$stripped\" and \$3 = \"$subdep_version\" ) {
  405.               print
  406.             }
  407.           }
  408.        }"
  409.         else
  410.         AWK_PRG=\          
  411.         "BEGIN{FS=\"|\"}
  412.        {
  413.          a=gensub(\$2,/([:alpha:]*)([:digit:]?)/,matches)
  414.           if length(matches) > 0 ) {
  415.             if ( matches[1] = \"$stripped\" ) {
  416.               print
  417.             }
  418.           }
  419.        }"          
  420.         fi
  421.         for aRepoDB in "$REPO_DB_FILE_DIR/${REPOFILE}"; do
  422.           awk_result=echo aRepoDB | awk "$AWK_PRG"
  423.           if [ -z "$awk_result" ]; then
  424.             if [ -z "$version" ]; then
  425.               version="${awk_result[3]}"
  426.               version="${version%%.*}"
  427.              
  428.             fi
  429.             break
  430.           fi
  431.          done
  432.          
  433.       fi
  434.       key=`md5sum < <( echo "$ALIAS" ) | cut -f1 -d' '`
  435.       result[$key]="$ALIAS"
  436.     done < <( echo $ALIAS_LIST )
  437.   fi
  438.  
  439.   for aKey in ${!result[@]}; do
  440.     echo "akey=$aKey"
  441.     echo "${result[$aKey]}"
  442.   done #| sort  
  443.    
  444. }
  445. list_all_aliases "$@"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement