3compat2pets 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261
  1. #!/bin/bash
  2. #(c) Copright Barry Kauler July 2010.
  3. #create PET packages of the compat-distro binary pkgs.
  4. #the scripts '2createpackages' and '3builddistro' must have been executed beforehand,
  5. #with the variables in file DISTRO_SPECS set to that of the compatible-distro, for
  6. #example DISTRO_BINARY_COMPAT='t2', DISTRO_FILE_PREFIX='wary', DISTRO_COMPAT_VERSION='8.0rcXorg7.3'.
  7. #after running this script, you will then be able to create a build entirely of
  8. #PET packages, in which case name these DISTRO_BINARY_COMPAT='puppy' and
  9. #DISTRO_COMPAT_VERSION='wary5' -- some generation designation, earlier puppies
  10. #had '3', '4', '5' for this variable.
  11. #100820 replace /var/cache/woof path with /var/local/woof
  12. #100921 remove unecessary entries from DB_dependencies. log db entries to a file.
  13. #110908 update for new woof with support/findpkgs.
  14. #111204 do not use /var/local/woof, instead 'status' directory (better for running from different save-files).
  15. #120719 support raspbian.
  16. #121102 file DISTRO_SPECS has new variable DISTRO_DB_SUBNAME. ex: for 14.0-based slacko, DISTRO_DB_SUBNAME=slacko14
  17. #130306 arch linux: gz now xz.
  18. if [ ! -f 2createpackages ];then
  19. echo "Must be run from the Woof project directory. Exiting."
  20. exit
  21. fi
  22. . ./DISTRO_SPECS
  23. [ ! "$DISTRO_DB_SUBNAME" ] && DISTRO_DB_SUBNAME="$DISTRO_COMPAT_VERSION" #121102 fallback if DISTRO_DB_SUBNAME not defined in file DISTRO_SPECS.
  24. if [ "${DISTRO_BINARY_COMPAT}" == "puppy" ];then
  25. echo "DISTRO_BINARY_COMPAT='${DISTRO_BINARY_COMPAT}'. Incorrect usage, aborting."
  26. exit
  27. fi
  28. if [ ! -f DISTRO_PKGS_SPECS-${DISTRO_BINARY_COMPAT}-${DISTRO_COMPAT_VERSION} ];then #130306
  29. if [ ! -f DISTRO_PKGS_SPECS-${DISTRO_BINARY_COMPAT} ];then
  30. echo "File DISTRO_PKGS_SPECS-${DISTRO_BINARY_COMPAT}-${DISTRO_COMPAT_VERSION}"
  31. echo "or DISTRO_PKGS_SPECS-${DISTRO_BINARY_COMPAT}"
  32. echo "does not exist. Aborting."
  33. fi
  34. exit
  35. fi
  36. if [ -f DISTRO_PKGS_SPECS-${DISTRO_BINARY_COMPAT}-${DISTRO_COMPAT_VERSION} ];then #130306
  37. . ./DISTRO_PKGS_SPECS-${DISTRO_BINARY_COMPAT}-${DISTRO_COMPAT_VERSION}
  38. DPSFILE="DISTRO_PKGS_SPECS-${DISTRO_BINARY_COMPAT}-${DISTRO_COMPAT_VERSION}"
  39. else
  40. . ./DISTRO_PKGS_SPECS-${DISTRO_BINARY_COMPAT}
  41. DPSFILE="DISTRO_PKGS_SPECS-${DISTRO_BINARY_COMPAT}"
  42. fi
  43. if [ ! -f status/findpkgs_FINAL_PKGS-${DISTRO_BINARY_COMPAT}-${DISTRO_COMPAT_VERSION} ];then #110908
  44. echo "File status/findpkgs_FINAL_PKGS-${DISTRO_BINARY_COMPAT}-${DISTRO_COMPAT_VERSION}"
  45. echo "does not exist. You have not yet run 2createpackages. Aborting."
  46. exit
  47. fi
  48. BINARIES='deb' #get them from packages-deb.
  49. [ "$DISTRO_BINARY_COMPAT" = "t2" ] && BINARIES="bz2" #get them from packages-bz2-${DISTRO_COMPAT_VERSION}.
  50. [ "$DISTRO_BINARY_COMPAT" = "slackware" ] && BINARIES="tgz_txz" #100617 download to packages-tgz_txz-${DISTRO_COMPAT_VERSION}.
  51. [ "$DISTRO_BINARY_COMPAT" = "debian" ] && BINARIES="deb" #download to packages-deb-${DISTRO_COMPAT_VERSION}.
  52. [ "$DISTRO_BINARY_COMPAT" = "arch" ] && BINARIES="tar_xz" #download to packages-tar_gz-${DISTRO_COMPAT_VERSION}. 130306
  53. [ "$DISTRO_BINARY_COMPAT" = "puppy" ] && BINARIES="pet" #w018 built entirely from pet pkgs.
  54. [ "$DISTRO_BINARY_COMPAT" = "scientific" ] && BINARIES="rpm" #110523 Iguleder: download to packages-rpm-${DISTRO_COMPAT_VERSION}.
  55. [ "$DISTRO_BINARY_COMPAT" = "mageia" ] && BINARIES="rpm" #110615
  56. [ "$DISTRO_BINARY_COMPAT" = "raspbian" ] && BINARIES="deb_raspbian" #download to packages-deb_raspbian-${DISTRO_COMPAT_VERSION}.
  57. BINARIES="${BINARIES}-${DISTRO_COMPAT_VERSION}" #w478
  58. #110908 remove comments from PKGS_SPECS_TABLE... make sure '|' on end... get rid of old |+udev,+whatever on end...
  59. 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%||$%|%'`"
  60. echo "This script will convert the packages of ${DISTRO_BINARY_COMPAT} version ${DISTRO_COMPAT_VERSION}"
  61. echo "used to build Puppy, into PET packages. These will be placed in directory"
  62. echo "'new-pets'."
  63. echo
  64. echo "This script must be run after running '2createpackages' and '3builddistro'"
  65. echo
  66. echo "The objective is to be able to build a Puppy in Woof entirely from PET"
  67. echo "packages. As such, DISTRO_BINARY_COMPAT variable will become 'puppy'"
  68. echo "(it is currently '${DISTRO_BINARY_COMPAT}'), the DISTRO_COMPAT_VERSION"
  69. echo "variable will become something you choose to designate the generation of"
  70. echo "Puppy, for example 'wary5' (rather than a specific version number)"
  71. echo "(The current value of DISTRO_COMPAT_VERSION is '${DISTRO_COMPAT_VERSION}')"
  72. echo
  73. echo "Type a version/generation name for the proposed Puppy distro,"
  74. echo "this will be put into the 'pet.specs' file inside each PET pkg"
  75. echo "(the first and last chars will be appended onto the PET pkg names)"
  76. echo -n "example: 'wary5' : "
  77. read newDISTRO_COMPAT_VERSION
  78. newDISTRO_BINARY_COMPAT="puppy"
  79. CUT1="`echo -n "$newDISTRO_COMPAT_VERSION" | cut -c 1`"
  80. CUT2="`echo -n "$newDISTRO_COMPAT_VERSION" | rev | cut -c 1`"
  81. CUTnewDISTRO_COMPAT_VERSION="${CUT1}${CUT2}"
  82. #110908...
  83. echo
  84. echo "The PET packages will be created with '${CUTnewDISTRO_COMPAT_VERSION}' appended"
  85. echo "to their names, for example 'abiword-1.2.3-${CUTnewDISTRO_COMPAT_VERSION}.pet'"
  86. echo "If you are happy with this, just press ENTER, or, if you want an"
  87. echo "alternate string (ex: '${CUTnewDISTRO_COMPAT_VERSION}2'), then type the"
  88. echo -n "alternate string now then ENTER: "
  89. read altSTR
  90. [ "$altSTR" != "" ] && CUTnewDISTRO_COMPAT_VERSION="`echo -n "$altSTR" | sed -e 's%^-%%'`"
  91. rm -rf new-pets
  92. mkdir new-pets
  93. echo -n "" > z-new-pets-db
  94. #for checking files that are not really needed...
  95. mkdir layer_top
  96. LAYERFS="aufs"
  97. [ "`lsmod | grep '^unionfs'`" != "" ] && LAYERFS="unionfs"
  98. if [ "$LAYERFS" = "aufs" ];then
  99. mount -t aufs -o udba=reval,diropq=w,dirs=sandbox3/devx=rw:sandbox3/rootfs-complete=ro layerfs layer_top
  100. else
  101. mount -t unionfs -o dirs=sandbox3/devx=rw:sandbox3/rootfs-complete=ro layerfs layer_top
  102. fi
  103. #read PKGS_SPECS_TABLE to get all the package names to be converted...
  104. echo
  105. echo "Creating new PETS in new-pets directory..."
  106. #110908 need extra logic here, support optional |pet[:<repo>] or |compat[:<repo>] overrides...
  107. x1COMPAT_GENERIC_NAMES="`echo "$PKGS_SPECS_TABLE" | grep '^yes|' | grep -v '||' | grep -v '|pet|$' | grep -v '|pet:' | grep -v '|compat|$' | grep -v '|compat:' | cut -f 2 -d '|' | tr '\n' ' '`"
  108. x2COMPAT_GENERIC_NAMES="`echo "$PKGS_SPECS_TABLE" | grep '|compat|$' | cut -f 2 -d '|' | tr '\n' ' '`"
  109. x3COMPAT_GENERIC_NAMES="`echo "$PKGS_SPECS_TABLE" | grep '|compat:' | cut -f 2 -d '|' | tr '\n' ' '`"
  110. COMPAT_GENERIC_NAMES="${x1COMPAT_GENERIC_NAMES} ${x2COMPAT_GENERIC_NAMES} ${x3COMPAT_GENERIC_NAMES}"
  111. for GENERICNAME in $COMPAT_GENERIC_NAMES #ex: 915resolution a52dec abiword ...
  112. do
  113. #110908 support/findpkgs (called from 2createpackages) has created this file...
  114. #ex: :a52dec:|compat|Packages-puppy-wary5-official|a52dec-0.7.4-w5|a52dec|0.7.4-w5||BuildingBlock|68K||a52dec-0.7.4-w5.pet||A free ATSC A52 stream decoder|puppy|wary5||
  115. gennamePTN=":${GENERICNAME}:" #a pkg may be shared by multiple generic names, ex: :gcc_lib::gcc_dev:|compat|... (ex from Slacko).
  116. FNDIT="`grep "$gennamePTN" status/findpkgs_FINAL_PKGS-${DISTRO_BINARY_COMPAT}-${DISTRO_COMPAT_VERSION} | tail -n 1`" #note, maybe more than one hit.
  117. UPKGVERSION="`echo -n "$FNDIT" | cut -f 6 -d '|'`"
  118. #overrides...
  119. case $GENERICNAME in
  120. x11proto|xorg_base*|xorg73_base*|xserver_xorg*)
  121. XORGVER="`grep '^xorg-server' sandbox3/rootfs-complete/root/.packages/woof-installed-packages | head -n 1 | cut -f 3 -d '|' | cut -f 1 -d '-' | cut -f 1 -d '_'`"
  122. #...note, woof-installed-packages also in current dir.
  123. [ "$XORGVER" = "" ] && XORGVER="1.7" #precaution.
  124. UPKGVERSION="7.5"
  125. if vercmp $XORGVER lt 1.7;then
  126. UPKGVERSION="7.4"
  127. fi
  128. if vercmp $XORGVER lt 1.6;then
  129. UPKGVERSION="7.3"
  130. fi
  131. ;;
  132. esac
  133. for xLOOP in 1 2 3 4
  134. do
  135. [ "$xLOOP" == "1" ] && xDEV=""
  136. [ "$xLOOP" == "2" ] && xDEV="_DEV"
  137. [ "$xLOOP" == "3" ] && xDEV="_DOC"
  138. [ "$xLOOP" == "4" ] && xDEV="_NLS"
  139. [ ! -d packages-${DISTRO_FILE_PREFIX}/${GENERICNAME}${xDEV} ] && continue
  140. echo "${GENERICNAME}${xDEV}-${UPKGVERSION}"
  141. if [ -d new-pets/${GENERICNAME}${xDEV}-${UPKGVERSION}-${CUTnewDISTRO_COMPAT_VERSION} ];then
  142. #take care of odd situation, ex 'perl-html-parser' pkg...
  143. #cp -a -f --remove-destination packages-${DISTRO_FILE_PREFIX}/${GENERICNAME}${xDEV}/* new-pets/${GENERICNAME}${xDEV}-${UPKGVERSION}-${CUTnewDISTRO_COMPAT_VERSION}/
  144. continue
  145. else
  146. cp -a packages-${DISTRO_FILE_PREFIX}/${GENERICNAME}${xDEV} new-pets/${GENERICNAME}${xDEV}-${UPKGVERSION}-${CUTnewDISTRO_COMPAT_VERSION}
  147. fi
  148. if [ $? -ne 0 ];then
  149. echo " ...error, skipping"
  150. continue
  151. fi
  152. #create the 'pet.specs' file for each new PET package...
  153. #2createpackages also creates status/2createpackages_history_builds-${DISTRO_BINARY_COMPAT}-${DISTRO_COMPAT_VERSION}
  154. #each line has ${GENERICNAME}|${COMPATPKGNAME} (where COMPATPKGNAME is name of compat-distro pkg)
  155. COMPATPKGNAMES="`grep "$pGENERICNAME" status/2createpackages_history_builds-${DISTRO_BINARY_COMPAT}-${DISTRO_COMPAT_VERSION} | cut -f 2 -d '|'`"
  156. COMPATPKGNAME="`echo "$COMPATPKGNAMES" | head -n 1`"
  157. #file 'woof-installed-packages' has a database entry for COMPATPKGNAME...
  158. pCOMPATPKGNAME='|'"$COMPATPKGNAME"'|'
  159. COMPATDBENTRY="`grep "$pCOMPATPKGNAME" sandbox3/rootfs-complete/root/.packages/woof-installed-packages | head -n 1`"
  160. #pkgname|nameonly|version|pkgrelease|category|size|path|fullfilename|dependencies|description|compileddistro|compiledrelease|repo|
  161. #...'compileddistro|compiledrelease' (fields 11,12) identify where the package was compiled.
  162. DB_pkgname="`echo -n "$COMPATDBENTRY" | cut -f 1 -d '|'`"
  163. DB_nameonly="`echo -n "$COMPATDBENTRY" | cut -f 2 -d '|'`"
  164. DB_version="`echo -n "$COMPATDBENTRY" | cut -f 3 -d '|'`"
  165. DB_pkgrelease="`echo -n "$COMPATDBENTRY" | cut -f 4 -d '|'`"
  166. DB_category="`echo -n "$COMPATDBENTRY" | cut -f 5 -d '|'`"
  167. DB_size="`echo -n "$COMPATDBENTRY" | cut -f 6 -d '|'`"
  168. DB_path="`echo -n "$COMPATDBENTRY" | cut -f 7 -d '|'`"
  169. DB_fullfilename="`echo -n "$COMPATDBENTRY" | cut -f 8 -d '|'`"
  170. DB_dependencies="`echo -n "$COMPATDBENTRY" | cut -f 9 -d '|'`"
  171. DB_description="`echo -n "$COMPATDBENTRY" | cut -f 10 -d '|'`"
  172. DB_compileddistro="`echo -n "$COMPATDBENTRY" | cut -f 11 -d '|'`"
  173. DB_compiledrelease="`echo -n "$COMPATDBENTRY" | cut -f 12 -d '|'`"
  174. DB_repo="`echo -n "$COMPATDBENTRY" | cut -f 13 -d '|'`"
  175. #build modified pet.specs file...
  176. SIZEK="`du -s -k new-pets/${GENERICNAME}${xDEV}-${UPKGVERSION}-${CUTnewDISTRO_COMPAT_VERSION} | cut -f 1 | head -n 1`"
  177. #for ONECOMPAT in `echo "$COMPATPKGNAMES" | tr '\n' ' '`
  178. #do
  179. # #get all the dependencies...
  180. # pONECOMPAT='|'"$ONECOMPAT"'|'
  181. # ONEDEPS="`grep "$pONECOMPAT" sandbox3/rootfs-complete/root/.packages/woof-installed-packages | head -n 1 | cut -f 9 -d '|'`"
  182. # echo -n ""
  183. #done
  184. #100921 remove unecessary entries from DB_dependencies...
  185. LOWDEPS='atk autoconf automake bash bigreqsproto bin86 binutils bison bzip2 cf cmake compositeproto coreutils cpio cups damageproto diffutils embutils expat file findutils fixesproto flex fontcacheproto fontconfig fontsproto freetype gawk gcc gettext giflib glade3 glib glibc glproto grep groff gzip hotplug++ imake inputproto intltool kbproto libdrm libexif libfontenc libice libidl libjpeg libpciaccess libpng libpthread-stubs librsvg libsm libtiff libtool libusb libx11 libxau libxaw libxcb libxcomposite libxcursor libxdamage libxdmcp libxevie libxext libxfixes libxfont libxfontcache libxft libxi libxinerama libxkbfile libxkbui libxmu libxp libxpm libxrandr libxprintapputil libxprintutil libxrender libxres libxscreensaver libxslt libxt libxtrap libtst libxv libxvmc libxxf86dga libxxf86misc libxxf86vm linux-header m4 make man mesa minised mkfontdir mkfontscale mkinitrd mktemp modutils nasm ncurses net-tools openssl pango panoramixproto patch patchutils pciutils pcre perl pixman pkgconfig popt printproto psmisc python randrproto readline recordproto renderproto resourceproto rman scrnsaverproto scrollkeeper sed shadow shared-mime-info subversion sysfiles sysfsutils t1lib tar texinfo trapproto udev usbutils util-linux valgrind videoproto wget xcmiscproto xextproto xf86bigfontproto xf86dgaproto xf86driproto xf86miscproto xf86rushproto xf86vidmodeproto xineramaproto xproto zlib'
  186. for ONEDEP in $LOWDEPS
  187. do
  188. ldP1=',+'"$ONEDEP"','
  189. ldP2=',+'"$ONEDEP"'$'
  190. ldP3='+'"$ONEDEP"','
  191. ldP4='+'"$ONEDEP"'$'
  192. P1="s%${ldP1}%,%"
  193. P2="s%${ldP2}%%"
  194. P3="s%${ldP3}%,%"
  195. P4="s%${ldP4}%%"
  196. DB_dependencies="`echo -n "$DB_dependencies" | sed -e "$P1" -e "$P2" -e "$P3" -e "$P4"`"
  197. done
  198. DB_dependencies="`echo -n "$DB_dependencies" | tr -s ',' | sed -e 's%,$%%' -e 's%^,%%'`"
  199. case $xDEV in
  200. _DEV) DB_dependencies="+${GENERICNAME}" ;;
  201. _DOC) DB_dependencies="" ;;
  202. _NLS) DB_dependencies="+${GENERICNAME}" ;;
  203. esac
  204. echo "${GENERICNAME}${xDEV}-${UPKGVERSION}-${CUTnewDISTRO_COMPAT_VERSION}|${GENERICNAME}${xDEV}|${UPKGVERSION}-${CUTnewDISTRO_COMPAT_VERSION}||${DB_category}|${SIZEK}K||${GENERICNAME}${xDEV}-${UPKGVERSION}-${CUTnewDISTRO_COMPAT_VERSION}.pet|${DB_dependencies}|${DB_description}|${newDISTRO_BINARY_COMPAT}|${newDISTRO_COMPAT_VERSION}||" > new-pets/${GENERICNAME}${xDEV}-${UPKGVERSION}-${CUTnewDISTRO_COMPAT_VERSION}/pet.specs
  205. #100921 log db entries to a file...
  206. echo "${GENERICNAME}${xDEV}-${UPKGVERSION}-${CUTnewDISTRO_COMPAT_VERSION}|${GENERICNAME}${xDEV}|${UPKGVERSION}-${CUTnewDISTRO_COMPAT_VERSION}||${DB_category}|${SIZEK}K||${GENERICNAME}${xDEV}-${UPKGVERSION}-${CUTnewDISTRO_COMPAT_VERSION}.pet|${DB_dependencies}|${DB_description}|${newDISTRO_BINARY_COMPAT}|${newDISTRO_COMPAT_VERSION}||" >> z-new-pets-db
  207. #remove files that will get deleted anyway...
  208. if [ "$xDEV" == "" -o "$xDEV" == "_DEV" ];then
  209. pFIX="s%new-pets/${GENERICNAME}${xDEV}-${UPKGVERSION}-${CUTnewDISTRO_COMPAT_VERSION}/%%"
  210. for ONESPEC in `find new-pets/${GENERICNAME}${xDEV}-${UPKGVERSION}-${CUTnewDISTRO_COMPAT_VERSION} -mindepth 2 | tr '\n' ' '`
  211. do
  212. [ ! -e $ONESPEC ] && continue
  213. DOWNSPEC="`echo -n "$ONESPEC" | sed -e "$pFIX"`"
  214. if [ ! -e layer_top/${DOWNSPEC} ];then
  215. echo "Deleting new-pets/${GENERICNAME}${xDEV}-${UPKGVERSION}-${CUTnewDISTRO_COMPAT_VERSION}/${DOWNSPEC}"
  216. rm -rf new-pets/${GENERICNAME}${xDEV}-${UPKGVERSION}-${CUTnewDISTRO_COMPAT_VERSION}/${DOWNSPEC}
  217. fi
  218. done
  219. fi
  220. cd new-pets
  221. sync
  222. dir2tgz ${GENERICNAME}${xDEV}-${UPKGVERSION}-${CUTnewDISTRO_COMPAT_VERSION}
  223. tgz2pet ${GENERICNAME}${xDEV}-${UPKGVERSION}-${CUTnewDISTRO_COMPAT_VERSION}.tar.gz
  224. cd ..
  225. #rm -rf new-pets/${GENERICNAME}${xDEV}-${UPKGVERSION}-${CUTnewDISTRO_COMPAT_VERSION}
  226. done
  227. done
  228. echo
  229. sync
  230. umount layer_top
  231. rmdir layer_top
  232. ###END###