mageia2ppm 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  1. #!/bin/ash
  2. #called from 0setup, either in Woof or /usr/local/petget/0setup in running Puppy.
  3. #(in Woof, this script is in support/, in running pup /usr/local/petget/mageia2ppm).
  4. #pass name of file on commandline, which is 'synthesis.hdlist' online (renamed to Packages-mageia-1-corepre|nonfreepre|taintedpre).
  5. #second param is Mageia release version number. ex: 1
  6. #110612 first release.
  7. #110613 sometimes comes up with a dep that is itself.
  8. #110615 determine online subdir.
  9. #120515 release 1 was all "mga1" in pkg name, but release 2 has mix of "mga1" and "mga2" pkgs. also pkgs can have "nonfree" or "tainted" in name.
  10. export LANG=C #faster.
  11. SYNTHHDLIST="$1"
  12. [ "$SYNTHHDLIST" = "" ] && exit 1
  13. [ ! -f "$SYNTHHDLIST" ] && exit 1
  14. MAGEIA_VERSION="$2"
  15. [ "$MAGEIA_VERSION" = "" ] && exit
  16. #110615 determine online subdir...
  17. SUBREPO="`echo "$SYNTHHDLIST" | rev | cut -f 1 -d '-' | rev | sed -e 's%pre$%%'`" #ex: core
  18. DB_path="${SUBREPO}/release"
  19. #ppm package database format, last 3 are optional...
  20. #pkgname|nameonly|version|pkgrelease|category|size|path|fullfilename|dependencies|description|compileddistro|compiledrelease|repo|
  21. #...'compileddistro|compiledrelease' identify where the package was compiled.
  22. echo
  23. #120515 the pkg name can now be mga1 or mga2, allow for the future, up to version 9...
  24. #120515 also, nonfree db can have pkg names ex: libopenmotif-devel-2.3.3-1.mga2.nonfree.i586.rpm
  25. # tainted db ex: audacious-adplug-3.2.1-1.mga2.tainted.i586.rpm
  26. #mgaPTN0="\\[== [^@]*\\.mga${MAGEIA_VERSION}\\]"
  27. #mgaPTN1="s%\\.mga${MAGEIA_VERSION}.*%%"
  28. mgaPTN0="\\[== [^@]*\\.mga[1-9]\\]"
  29. mgaPTN1="s%\\.mga[1-9].*%%"
  30. xmgaPTN0="\\[== [^@]*\\.mga[1-9]\\.nonfree\\]"
  31. ymgaPTN0="\\[== [^@]*\\.mga[1-9]\\.tainted\\]"
  32. echo -n "" > /tmp/mageia2ppm-ppm-temp1
  33. cat $SYNTHHDLIST |
  34. while read ONELINE
  35. do
  36. echo -n '.'
  37. case $ONELINE in
  38. @provides@*)
  39. DB_version="`echo -n "$ONELINE" | grep -o "$mgaPTN0" | cut -f 2 -d ' ' | rev | cut -f 2-9 -d '.' | rev | head -n 1 | cut -f 2 -d ':'`"
  40. [ "$DB_version" = "" ] && DB_version="`echo -n "$ONELINE" | grep -o "$xmgaPTN0" | cut -f 2 -d ' ' | rev | cut -f 3-9 -d '.' | rev | head -n 1 | cut -f 2 -d ':'`"
  41. [ "$DB_version" = "" ] && DB_version="`echo -n "$ONELINE" | grep -o "$ymgaPTN0" | cut -f 2 -d ' ' | rev | cut -f 3-9 -d '.' | rev | head -n 1 | cut -f 2 -d ':'`"
  42. [ "$DB_version" = "" ] && DB_version="0" #error condition.
  43. PROVIDES_SO=" `echo -n "$ONELINE" | tr '@' '\n' | tr -s '\n' | grep -E '\.so$|\.so\.[0-9]' | cut -f 1 -d '(' | sort -u | tr '\n' ' '`" #list of shared libs, space-delimited.
  44. ;;
  45. @conflicts@*)
  46. true
  47. ;;
  48. @requires@*)
  49. REQUIRES_SO=" `echo -n "$ONELINE" | tr '@' '\n' | tr -s '\n' | grep -E '\.so$|\.so\.[0-9]' | cut -f 1 -d '(' | sort -u | tr '\n' ' '`" #list of shared libs, space-delimited.
  50. REQUIRES_PKG=" `echo -n "$ONELINE" | tr '@' '\n' | tr -s '\n' | grep -v -E '\.so$|\.so\.[0-9]|/|requires|\(' | cut -f 1 -d '[' | sort -u | tr '\n' ' '`"
  51. ;;
  52. @summary@*)
  53. DB_description="`echo -n "$ONELINE" | cut -f 3 -d '@' | tr '[|<>]' ' '`"
  54. ;;
  55. @info@*)
  56. FULLNAME="`echo -n "$ONELINE" | cut -f 3 -d '@'`"
  57. DB_fullfilename="${FULLNAME}.rpm"
  58. DB_pkgname="`echo -n "$FULLNAME" | sed -e "$mgaPTN1"`"
  59. vPTN="s%\\-${DB_version}.*%%"
  60. DB_nameonly="`echo -n "$DB_pkgname" | sed -e "$vPTN"`"
  61. DB_compileddistro="mageia";DB_compiledrelease="$MAGEIA_VERSION"
  62. if [ "`echo -n "$FULLNAME" | grep '\.noarch$'`" != "" ];then
  63. DB_compileddistro=""
  64. DB_compiledrelease=""
  65. fi
  66. sizeBYTES=`echo -n "$ONELINE" | cut -f 5 -d '@'`
  67. DB_size=$(($sizeBYTES/1024))
  68. categoryORIG="`echo -n "$ONELINE" | cut -f 6 -d '@'`"
  69. #puppy categories are: Desktop, System, Setup, Utility, Filesystem, Graphic, Document, Business, Personal, Network, Internet, Multimedia, Fun, BuildingBlock, Help, Develop
  70. case $categoryORIG in
  71. Development*) DB_category="Development" ;;
  72. Archiving*|Sciences*|Monitoring*|Terminals*) DB_category="Utility" ;;
  73. System/Internationalization*|System/Font*) DB_category="System" ;;
  74. System/Configuration*) DB_category="Setup" ;;
  75. System*) DB_category="BuildingBlock" ;;
  76. Office*|Database*) DB_category="Business" ;;
  77. Networking/Other|Networking/Remote*|Communications*) DB_category="Network" ;;
  78. Networking*) DB_category="Internet" ;;
  79. *desktop*|Accessibility*) DB_category="Desktop" ;;
  80. Video*|Sound*) DB_category="Multimedia" ;;
  81. Graphics*) DB_category="Graphic" ;;
  82. Games*|Toys*) DB_category="Fun" ;;
  83. Text*|Publishing*|Education*|Editors*) DB_category="Document" ;;
  84. File*) DB_category="Filesystem" ;;
  85. Books*) DB_category="Help" ;;
  86. *) DB_category="BuildingBlock" ;;
  87. esac
  88. #3 fields on end are temporary...
  89. echo "$DB_pkgname|$DB_nameonly|$DB_version||$DB_category|${DB_size}K|$DB_path|$DB_fullfilename|$DB_dependencies|$DB_description|${DB_compileddistro}|${DB_compiledrelease}||${PROVIDES_SO}|${REQUIRES_SO}|${REQUIRES_PKG}|" >> /tmp/mageia2ppm-ppm-temp1
  90. PROVIDES_SO="";REQUIRES_SO="";REQUIRES_PKG="";FULLNAME="";DB_pkgname='';DB_nameonly='';DB_version='';DB_category='';DB_size='';DB_fullfilename='';DB_dependencies='';DB_description=''
  91. ;;
  92. esac
  93. done
  94. #want only DB_nameonly|PROVIDES_SO...
  95. echo
  96. cat /tmp/mageia2ppm-ppm-temp1 | cut -f 2,14 -d '|' > /tmp/mageia2ppm-ppm-temp2
  97. echo -n "" > /tmp/mageia2ppm-ppm-temp3
  98. cat /tmp/mageia2ppm-ppm-temp1 |
  99. while read ONELINE
  100. do
  101. echo -n '.'
  102. REQUIRES_SO="`echo -n "$ONELINE" | cut -f 15 -d '|'`"
  103. REQUIRES_PKG="`echo -n "$ONELINE" | cut -f 16 -d '|'`"
  104. DB_dependencies=""
  105. NAMEONLY="`echo -n "$ONELINE" | cut -f 2 -d '|'`" #110613
  106. for ONESO in $REQUIRES_SO
  107. do
  108. ONEDEP="`grep " ${ONESO} " /tmp/mageia2ppm-ppm-temp2 | cut -f 1 -d '|' | head -n 1`"
  109. if [ "$ONEDEP" ];then
  110. [ "$ONEDEP" = "$NAMEONLY" ] && continue #110613 sometimes comes up with a dep that is itself.
  111. [ "$ONEDEP" = "glibc" ] && continue #110613 leave these out.
  112. [ "$ONEDEP" = "pkgconfig" ] && continue #110613 leave these out.
  113. DB_dependencies="${DB_dependencies},+${ONEDEP}"
  114. fi
  115. done
  116. for ONEPKG in $REQUIRES_PKG
  117. do
  118. [ "$ONEPKG" = "$NAMEONLY" ] && continue #110613 sometimes comes up with a dep that is itself.
  119. [ "$ONEPKG" = "glibc" ] && continue #110613 leave these out.
  120. [ "$ONEPKG" = "pkgconfig" ] && continue #110613 leave these out.
  121. DB_dependencies="${DB_dependencies},+${ONEPKG}"
  122. done
  123. DB_dependencies="`echo -n "$DB_dependencies" | sed -e 's%^,%%' | tr ',' '\n' | sort -u | tr '\n' ',' | sed -e 's%,$%%'`"
  124. CUT1to8="`echo -n "$ONELINE" | cut -f 1-8 -d '|'`"
  125. CUT10to13="`echo -n "$ONELINE" | cut -f 10-13 -d '|'`"
  126. echo "${CUT1to8}|${DB_dependencies}|${CUT10to13}|" >> /tmp/mageia2ppm-ppm-temp3
  127. done
  128. sort --key=1 --field-separator="|" /tmp/mageia2ppm-ppm-temp3 > /tmp/mageia2ppm-ppm-temp4
  129. rm -f /tmp/mageia2ppm-ppm-temp3
  130. rm -f /tmp/mageia2ppm-ppm-temp1
  131. rm -f /tmp/mageia2ppm-ppm-temp2
  132. ###END###