old-2-new-db 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. #!/bin/sh
  2. #convert the old package database format used in Puppy 'packages.txt',
  3. #'livepackages.txt' and 'alienpackages.txt' to the new Woof standardised format.
  4. export LANG=C #fast.
  5. cat ${1} | tr '\t' ' ' | tr -s ' ' | sed -e 's%\\$%%' |
  6. while read ONELINE
  7. do
  8. #old ex: "abiword-2.6.3" "abiword 2.6.3: wordprocessor" ONOFF "Document +fribidi,+gtk+,+goffice,+wv,+enchant 7556K"
  9. #new: pkgname|nameonly|version|pkgrelease|category|size|path|fullfilename|dependencies|description|
  10. #ex: abiword-1.2.4|abiword|1.2.4|5|Document|999K|slackware/ab|abiword-1.2.4-5-i486.tgz|+aiksausus,+gtk2|a nice wordprocessor|
  11. #optionally on the end: compileddistro|compiledrelease|repo| (fields 11,12,13)
  12. #ex: slackware|12.2|official|
  13. #this is not normally needed, as the name of the file holding the database info, for ex
  14. #'Packages-slackware-12.2-official' identifies this extra information.
  15. #can't automatically separate pkgrelease numbering...
  16. DB_pkgname="`echo -n "$ONELINE" | cut -f 2 -d '"'`" #'geany
  17. DB_nameonly="`echo -n "$ONELINE" | cut -f 4 -d '"' | cut -f 1 -d ' '`" #'geany
  18. DB_pkgrelease=""
  19. DB_fullfilename="${DB_pkgname}.pet"
  20. DB_repo="`echo -n "$1" | rev | cut -f 1 -d '-' | rev`" #extract from filename, ex 'packages-pet-4'.
  21. DB_path="pet_packages-${DB_repo}"
  22. DB_version="`echo -n "$ONELINE" | cut -f 4 -d '"' | cut -f 2 -d ' ' | cut -f 1 -d ':'`" #'geany
  23. DB_description="`echo -n "$ONELINE" | cut -f 4 -d '"' | cut -f 3-19 -d ' '`" #'geany
  24. DB_category="`echo -n "$ONELINE" | cut -f 6 -d '"' | cut -f 1 -d ' ' | cut -f 1 -d ':'`" #'geany
  25. if [ "`echo -n "$ONELINE" | cut -f 6 -d '"' | cut -f 2 -d ' ' | grep '\+'`" != "" ];then #'geany
  26. DB_dependencies="`echo -n "$ONELINE" | cut -f 6 -d '"' | cut -f 2 -d ' '`" #'geany
  27. DB_size="`echo -n "$ONELINE" | cut -f 6 -d '"' | cut -f 3 -d ' '`" #'geany
  28. else
  29. DB_dependencies=""
  30. DB_size="`echo -n "$ONELINE" | cut -f 6 -d '"' | cut -f 2 -d ' '`" #'geany
  31. fi
  32. #any extra info... ex old format:
  33. #"seamonkey-1.1.14-no_mailnews" "seamonkey 1.1.14-no_mailnews: browser suite" ONOFF "Internet:ubuntu:intrepid +nspr,+nss 27896K"
  34. if [ "`echo -n "$ONELINE" | cut -f 6 -d '"' | cut -f 1 -d ' ' | grep ':'`" != "" ];then #'geany
  35. DB_compileddistro="`echo -n "$ONELINE" | cut -f 6 -d '"' | cut -f 1 -d ' ' | cut -f 2 -d ':'`" #'geany
  36. DB_compiledrelease="`echo -n "$ONELINE" | cut -f 6 -d '"' | cut -f 1 -d ' ' | cut -f 3 -d ':'`" #'geany
  37. echo "$DB_pkgname|$DB_nameonly|$DB_version|$DB_pkgrelease|$DB_category|$DB_size|$DB_path|$DB_fullfilename|$DB_dependencies|$DB_description|$DB_compileddistro|$DB_compiledrelease|$DB_repo|"
  38. else
  39. echo "$DB_pkgname|$DB_nameonly|$DB_version|$DB_pkgrelease|$DB_category|$DB_size|$DB_path|$DB_fullfilename|$DB_dependencies|$DB_description|"
  40. fi
  41. done