SHARE
TWEET

Draft: testcat

s243a Dec 11th, 2019 (edited) 101 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #!/bin/ash
  2. outfile=~/testcat.in
  3. #cat_file=/usr/local/petget/categories.dat
  4. cat_file=~/cat_test_cat.dat
  5. . ~/build_cannonical
  6.             awk -v PKGOS="$distro" -v PKGOSVER="$distro_ver" -v CATFILE="$cat_file" -v ALIASFILE="$alias_file" \
  7. 'function fixdepends(s,   p,a,sout) {
  8.     split(s,a,",")
  9.     for (p in a) {
  10.         sout = sout ",+" a[p]
  11.     }
  12.     sub(/^,/,"",sout) ; return sout;
  13. }
  14. function parse_pkg_name(s,        txz_split,arch_build){
  15.     match(s,/^([^\-]*)(\-.*)(\.([^\-]+))$/,txz_split)
  16.  
  17.     PKG=txz_split[1]
  18.     split(txz_split[2],ver_arch_build,"-") 
  19.     PKGVER=ver_arch_build[2]
  20.  
  21.     len=length(ver_arch_build)
  22.    if (len == 4){
  23.         BUILD_NO=ver_arch_build[4]
  24.         ARCH=ver_arch_build[3]
  25.    }
  26.    else if(len == 3){
  27.       if (ver_arch_build[len-1] ~ /^[0-9]+$/){
  28.         BUILD_NO=ver_arch_build[2]
  29.        }
  30.        else{
  31.            ARCH=ver_arch_build[3]
  32.       }
  33.    }  
  34.    
  35. }
  36. function maybe_parse_dec(s,        line_split){
  37.  if( PARSE_DEC_FLAG == 1){
  38.     match($0,/(\S+):\s+(.*)$/,line_split)
  39.     if(length(line_split) > 0){
  40.       if (line_split[1] == PKG){
  41.         PKGINFO=substr(line_split[2],1,200)
  42.         PARSE_DEC_FLAG=0
  43.       }
  44.    }
  45.  }
  46. }
  47. function cat_fallback(s){
  48.     switch(s){
  49.         case /vcs.*/:
  50.           return "Utility;development"
  51.           break
  52.         case /doc.*/:
  53.           return "Help"
  54.           break
  55.         case /admin.*/:
  56.           return "Setup"
  57.           break
  58.         case /games.*/:
  59.           return "Fun"
  60.           break
  61.         case /.{7,}/:
  62.           return "science"
  63.           break
  64.       default:
  65.          return "BuildingBlock"
  66.          break
  67.  
  68.    }
  69. }
  70.  
  71. function parse_cats(s){
  72.  i=index(s,"=")
  73.  if (i>0){
  74.     #catagory=( package1 package2 ... packageN)  
  75.    category=substr(s,i-1)
  76.    sub(/PKGCAT_/,"",category) #e.g. category=PKGCAT_Utility => category=Utility
  77.    sub(/_/,";",category) #e.g. category=Filesystem_filemanager => category=Filesystem;filemanager
  78.    
  79.    #e.g catagory=( package1 package2 ... packageN) => package1 package2 ... packageN
  80.    gensub(/^([^=]+="\s)(.*)(\s*"\s*)$/,"\\2","g",s)
  81.    
  82.    split(s,pkg_names" ")
  83.    for (pkg in pkg_names){
  84.      pkg_categories[pkg]=category
  85.     }  
  86.  }
  87. }'\
  88. "$ALIAS_FNS"\
  89. 'BEGIN { init_CANONICAL_ARY() #MAPS a PKG NAME to a canonical name
  90.       }
  91. FILENAME = ALIASFILE {
  92. FILENAME = CATFILE {parse_cats($0)
  93.                     next} #https://www3.physnet.uni-hamburg.de/physnet/Tru64-Unix/HTML/APS32DTE/WKXXXXXX.HTM
  94.                        
  95. /^PACKAGE NAME:/     { sub(/^PACKAGE NAME:\s*/,""); PKGFILE=$0; parse_pkg_name($0); }
  96. /^PACKAGE LOCATION:/     { sub(/^PACKAGE LOCATION:\s*/,""); sub(/^(.\/)?/,""); PKGPATH=$0; }
  97. /^PACKAGE SIZE \(uncompressed\):/ { sub(/^PACKAGE SIZE \(uncompressed\):\s*/,""); sub(/\s/,""); PKGSIZE=$0; }
  98. /^PACKAGE DESCRIPTION:/ { PARSE_DEC_FLAG=1}
  99. /^PACKAGE REQUIRED:/ { sub(/^PACKAGE REQUIRED:\s*/,"");     PKGDEP=fixdepends($0); }
  100. {maybe_parse_dec($0)}                      
  101. /^$/            {
  102.     if (length(PKG)>1){
  103.     print PKG "_" PKGVER "|" PKG "|" PKGVER "|"  BUILD_NO "|" PKGSECTION "|" PKGSIZE "|" PKGPATH "|" PKGFILE  "|" PKGDEP "|" PKGINFO "|" PKGOS "|" PKGOSVER  "|"
  104.     };
  105.    
  106.                  PKG=""; PKGVER=""; PKGSECTION="CATEGORY"; PKGSIZE=""; PKGFILE=""; PKGPATH=""; PKGDEP=""; PKGINFO=""; PKGPRIO="";   BUILD_NO="";  ARCH=""; PARSE_DEC_FLAG=0; }
  107. ' "$alias_file" "$cat_file"
  108. #cat "$cat_file"
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top