2compat2pets 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. #!/bin/sh
  2. #BK sept 2011
  3. #this script is used in conjunction with '3compat2pets'
  4. #run this script before '2createpackages'.
  5. #then run, in this order: 2createpackages, 3builddistro, 3compat2pets
  6. #120719 support raspbian.
  7. #121102 file DISTRO_SPECS has new variable DISTRO_DB_SUBNAME. ex: for 14.0-based slacko, DISTRO_DB_SUBNAME=slacko14
  8. #130306 arch linux: gz now xz.
  9. if [ ! -f 2createpackages ];then
  10. echo "Must be run from the Woof project directory. Exiting."
  11. exit
  12. fi
  13. . ./DISTRO_SPECS
  14. [ ! "$DISTRO_DB_SUBNAME" ] && DISTRO_DB_SUBNAME="$DISTRO_COMPAT_VERSION" #121102 fallback if DISTRO_DB_SUBNAME not defined in file DISTRO_SPECS.
  15. if [ "${DISTRO_BINARY_COMPAT}" == "puppy" ];then
  16. echo "DISTRO_BINARY_COMPAT='${DISTRO_BINARY_COMPAT}'. Incorrect usage, aborting."
  17. exit
  18. fi
  19. if [ ! -f DISTRO_PKGS_SPECS-${DISTRO_BINARY_COMPAT}-${DISTRO_COMPAT_VERSION} ];then #130306
  20. if [ ! -f DISTRO_PKGS_SPECS-${DISTRO_BINARY_COMPAT} ];then
  21. echo "File DISTRO_PKGS_SPECS-${DISTRO_BINARY_COMPAT}-${DISTRO_COMPAT_VERSION}"
  22. echo "or DISTRO_PKGS_SPECS-${DISTRO_BINARY_COMPAT}"
  23. echo "does not exist. Aborting."
  24. fi
  25. exit
  26. fi
  27. if [ -f DISTRO_PKGS_SPECS-${DISTRO_BINARY_COMPAT}-${DISTRO_COMPAT_VERSION} ];then #130306
  28. . ./DISTRO_PKGS_SPECS-${DISTRO_BINARY_COMPAT}-${DISTRO_COMPAT_VERSION}
  29. DPSFILE="DISTRO_PKGS_SPECS-${DISTRO_BINARY_COMPAT}-${DISTRO_COMPAT_VERSION}"
  30. else
  31. . ./DISTRO_PKGS_SPECS-${DISTRO_BINARY_COMPAT}
  32. DPSFILE="DISTRO_PKGS_SPECS-${DISTRO_BINARY_COMPAT}"
  33. fi
  34. BINARIES='deb' #get them from packages-deb.
  35. [ "$DISTRO_BINARY_COMPAT" = "t2" ] && BINARIES="bz2" #get them from packages-bz2-${DISTRO_COMPAT_VERSION}.
  36. [ "$DISTRO_BINARY_COMPAT" = "slackware" ] && BINARIES="tgz_txz" #100617 download to packages-tgz_txz-${DISTRO_COMPAT_VERSION}.
  37. [ "$DISTRO_BINARY_COMPAT" = "debian" ] && BINARIES="deb" #download to packages-deb-${DISTRO_COMPAT_VERSION}.
  38. [ "$DISTRO_BINARY_COMPAT" = "arch" ] && BINARIES="tar_xz" #download to packages-tar_xz-${DISTRO_COMPAT_VERSION}. 130306
  39. [ "$DISTRO_BINARY_COMPAT" = "puppy" ] && BINARIES="pet" #w018 built entirely from pet pkgs.
  40. [ "$DISTRO_BINARY_COMPAT" = "scientific" ] && BINARIES="rpm" #110523 Iguleder: download to packages-rpm-${DISTRO_COMPAT_VERSION}.
  41. [ "$DISTRO_BINARY_COMPAT" = "mageia" ] && BINARIES="rpm" #110615
  42. [ "$DISTRO_BINARY_COMPAT" = "raspbian" ] && BINARIES="deb_raspbian" #download to packages-deb_raspbian-${DISTRO_COMPAT_VERSION}.
  43. BINARIES="${BINARIES}-${DISTRO_COMPAT_VERSION}" #w478
  44. if [ ! -d packages-${BINARIES} ];then
  45. echo "Directory packages-${BINARIES} does not exist. Aborting."
  46. exit
  47. fi
  48. #110908 remove comments from PKGS_SPECS_TABLE... make sure '|' on end... get rid of old |+udev,+whatever on end...
  49. PKGS_SPECS_TABLE="`echo "$PKGS_SPECS_TABLE" | grep -v '^#' | grep -v '^$' | tr '\t' ' ' | tr -s ' ' | tr '+' '&' | sed -e 's%|&.*%%' | tr '&' '+' | sed -e 's% #.*%%' -e 's% $%%' -e 's%$%|%' -e 's%||$%|%'`"
  50. #110908 go the whole hog, convert every compat-pkg to a pet...
  51. echo
  52. echo "This script is used in conjunction with 3compat2pets."
  53. echo "The default is to only convert compat-pkgs that have a 'yes' entry in"
  54. echo "variable PKGS_SPECS_TABLE (in file ${DPSFILE})"
  55. echo "Just press ENTER key to accept default."
  56. echo "Or, if you would like in addition to convert every single package in"
  57. echo "directory packages-${BINARIES} into a PET pkg, press any printable"
  58. echo "key then ENTER."
  59. echo "NOTICE: if you choose to convert all compat-pkgs, file"
  60. echo " ${DPSFILE}"
  61. echo " will be modified and the original copied with -ORIG appended."
  62. echo " You will probably want to restore the original file after this exercise."
  63. echo -n "Type ENTER or any printable-char then ENTER: "
  64. read extraflag
  65. if [ "$extraflag" = "" ];then
  66. echo "...ok, 'yes' pkgs only"
  67. echo "Leaving file ${DPSFILE} as-is."
  68. extraPST=""
  69. else
  70. echo "...ok, convert everything."
  71. extraPST="`ls -1 packages-${BINARIES} | sed -e 's%\.tar\.bz2$%%' -e 's%\.rpm$%%' -e 's%\.tgz$%%' -e 's%\.txz$%%' -e 's%\.deb$%%' | sed -e 's%\-[0-9].*$%%' | sed -r -e 's%(.*)%\1|\1%' | sed -e 's%^%yes|%' -e 's%$%|exe,dev,doc,nls|%'`"
  72. xPKGS_SPECS_TABLE="${PKGS_SPECS_TABLE}
  73. ${extraPST}"
  74. zPKGS_SPECS_TABLE="`echo "$xPKGS_SPECS_TABLE" | grep '^yes' | sort --field-separator="|" --key=2,3 -u`"
  75. #maybe duplicate conflicting entries...
  76. DUPLICATES="`echo "$zPKGS_SPECS_TABLE" | cut -f 2 -d '|' | sort | uniq -d | sort -u | tr '\n' ' '`" #-d option, return duplicates only.
  77. for ONEDUP in $DUPLICATES
  78. do
  79. nPTN="yes|${ONEDUP}|"
  80. extraPST="`echo "$extraPST" | grep -v "$nPTN"`"
  81. done
  82. xPKGS_SPECS_TABLE="${PKGS_SPECS_TABLE}
  83. ${extraPST}"
  84. PKGS_SPECS_TABLE="`echo "$xPKGS_SPECS_TABLE" | grep '^yes' | sort --field-separator="|" --key=2,3 -u`"
  85. yesdoit=""
  86. if [ -f ${DPSFILE}-ORIG ];then
  87. echo
  88. echo "File ${DPSFILE} ${DPSFILE}-ORIG"
  89. echo "already exists. Overwrite it?"
  90. echo -n "ENTER only for yes: "
  91. read yesdoit
  92. fi
  93. if [ "$yesdoit" = "" ];then
  94. mv -f ${DPSFILE} ${DPSFILE}-ORIG
  95. fi
  96. echo "FALLBACKS_COMPAT_VERSIONS='${FALLBACKS_COMPAT_VERSIONS}'" > ${DPSFILE}
  97. echo "PKGS_SPECS_TABLE='${PKGS_SPECS_TABLE}'" >> ${DPSFILE}
  98. echo "Modified ${DPSFILE}"
  99. fi
  100. echo
  101. echo "Done. Now run 2createpackages, 3builddistro, 3compat2pets"
  102. ###END###