2compat2pets 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  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" = "slackware64" ] && BINARIES="tgz_txz" #100617 download to packages-tgz_txz-${DISTRO_COMPAT_VERSION}.
  38. [ "$DISTRO_BINARY_COMPAT" = "debian" ] && BINARIES="deb" #download to packages-deb-${DISTRO_COMPAT_VERSION}.
  39. [ "$DISTRO_BINARY_COMPAT" = "arch" ] && BINARIES="tar_xz" #download to packages-tar_xz-${DISTRO_COMPAT_VERSION}. 130306
  40. [ "$DISTRO_BINARY_COMPAT" = "puppy" ] && BINARIES="pet" #w018 built entirely from pet pkgs.
  41. [ "$DISTRO_BINARY_COMPAT" = "scientific" ] && BINARIES="rpm" #110523 Iguleder: download to packages-rpm-${DISTRO_COMPAT_VERSION}.
  42. [ "$DISTRO_BINARY_COMPAT" = "mageia" ] && BINARIES="rpm" #110615
  43. [ "$DISTRO_BINARY_COMPAT" = "raspbian" ] && BINARIES="deb_raspbian" #download to packages-deb_raspbian-${DISTRO_COMPAT_VERSION}.
  44. BINARIES="${BINARIES}-${DISTRO_COMPAT_VERSION}" #w478
  45. if [ ! -d packages-${BINARIES} ];then
  46. echo "Directory packages-${BINARIES} does not exist. Aborting."
  47. exit
  48. fi
  49. #110908 remove comments from PKGS_SPECS_TABLE... make sure '|' on end... get rid of old |+udev,+whatever on end...
  50. 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%||$%|%'`"
  51. #110908 go the whole hog, convert every compat-pkg to a pet...
  52. echo
  53. echo "This script is used in conjunction with 3compat2pets."
  54. echo "The default is to only convert compat-pkgs that have a 'yes' entry in"
  55. echo "variable PKGS_SPECS_TABLE (in file ${DPSFILE})"
  56. echo "Just press ENTER key to accept default."
  57. echo "Or, if you would like in addition to convert every single package in"
  58. echo "directory packages-${BINARIES} into a PET pkg, press any printable"
  59. echo "key then ENTER."
  60. echo "NOTICE: if you choose to convert all compat-pkgs, file"
  61. echo " ${DPSFILE}"
  62. echo " will be modified and the original copied with -ORIG appended."
  63. echo " You will probably want to restore the original file after this exercise."
  64. echo -n "Type ENTER or any printable-char then ENTER: "
  65. read extraflag
  66. if [ "$extraflag" = "" ];then
  67. echo "...ok, 'yes' pkgs only"
  68. echo "Leaving file ${DPSFILE} as-is."
  69. extraPST=""
  70. else
  71. echo "...ok, convert everything."
  72. 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|%'`"
  73. xPKGS_SPECS_TABLE="${PKGS_SPECS_TABLE}
  74. ${extraPST}"
  75. zPKGS_SPECS_TABLE="`echo "$xPKGS_SPECS_TABLE" | grep '^yes' | sort --field-separator="|" --key=2,3 -u`"
  76. #maybe duplicate conflicting entries...
  77. DUPLICATES="`echo "$zPKGS_SPECS_TABLE" | cut -f 2 -d '|' | sort | uniq -d | sort -u | tr '\n' ' '`" #-d option, return duplicates only.
  78. for ONEDUP in $DUPLICATES
  79. do
  80. nPTN="yes|${ONEDUP}|"
  81. extraPST="`echo "$extraPST" | grep -v "$nPTN"`"
  82. done
  83. xPKGS_SPECS_TABLE="${PKGS_SPECS_TABLE}
  84. ${extraPST}"
  85. PKGS_SPECS_TABLE="`echo "$xPKGS_SPECS_TABLE" | grep '^yes' | sort --field-separator="|" --key=2,3 -u`"
  86. yesdoit=""
  87. if [ -f ${DPSFILE}-ORIG ];then
  88. echo
  89. echo "File ${DPSFILE} ${DPSFILE}-ORIG"
  90. echo "already exists. Overwrite it?"
  91. echo -n "ENTER only for yes: "
  92. read yesdoit
  93. fi
  94. if [ "$yesdoit" = "" ];then
  95. mv -f ${DPSFILE} ${DPSFILE}-ORIG
  96. fi
  97. echo "FALLBACKS_COMPAT_VERSIONS='${FALLBACKS_COMPAT_VERSIONS}'" > ${DPSFILE}
  98. echo "PKGS_SPECS_TABLE='${PKGS_SPECS_TABLE}'" >> ${DPSFILE}
  99. echo "Modified ${DPSFILE}"
  100. fi
  101. echo
  102. echo "Done. Now run 2createpackages, 3builddistro, 3compat2pets"
  103. ###END###