3compat2pets 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262
  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" = "slackware64" ] && BINARIES="tgz_txz" #100617 download to packages-tgz_txz-${DISTRO_COMPAT_VERSION}.
  52. [ "$DISTRO_BINARY_COMPAT" = "debian" ] && BINARIES="deb" #download to packages-deb-${DISTRO_COMPAT_VERSION}.
  53. [ "$DISTRO_BINARY_COMPAT" = "arch" ] && BINARIES="tar_xz" #download to packages-tar_gz-${DISTRO_COMPAT_VERSION}. 130306
  54. [ "$DISTRO_BINARY_COMPAT" = "puppy" ] && BINARIES="pet" #w018 built entirely from pet pkgs.
  55. [ "$DISTRO_BINARY_COMPAT" = "scientific" ] && BINARIES="rpm" #110523 Iguleder: download to packages-rpm-${DISTRO_COMPAT_VERSION}.
  56. [ "$DISTRO_BINARY_COMPAT" = "mageia" ] && BINARIES="rpm" #110615
  57. [ "$DISTRO_BINARY_COMPAT" = "raspbian" ] && BINARIES="deb_raspbian" #download to packages-deb_raspbian-${DISTRO_COMPAT_VERSION}.
  58. BINARIES="${BINARIES}-${DISTRO_COMPAT_VERSION}" #w478
  59. #110908 remove comments from PKGS_SPECS_TABLE... make sure '|' on end... get rid of old |+udev,+whatever on end...
  60. 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%||$%|%'`"
  61. echo "This script will convert the packages of ${DISTRO_BINARY_COMPAT} version ${DISTRO_COMPAT_VERSION}"
  62. echo "used to build Puppy, into PET packages. These will be placed in directory"
  63. echo "'new-pets'."
  64. echo
  65. echo "This script must be run after running '2createpackages' and '3builddistro'"
  66. echo
  67. echo "The objective is to be able to build a Puppy in Woof entirely from PET"
  68. echo "packages. As such, DISTRO_BINARY_COMPAT variable will become 'puppy'"
  69. echo "(it is currently '${DISTRO_BINARY_COMPAT}'), the DISTRO_COMPAT_VERSION"
  70. echo "variable will become something you choose to designate the generation of"
  71. echo "Puppy, for example 'wary5' (rather than a specific version number)"
  72. echo "(The current value of DISTRO_COMPAT_VERSION is '${DISTRO_COMPAT_VERSION}')"
  73. echo
  74. echo "Type a version/generation name for the proposed Puppy distro,"
  75. echo "this will be put into the 'pet.specs' file inside each PET pkg"
  76. echo "(the first and last chars will be appended onto the PET pkg names)"
  77. echo -n "example: 'wary5' : "
  78. read newDISTRO_COMPAT_VERSION
  79. newDISTRO_BINARY_COMPAT="puppy"
  80. CUT1="`echo -n "$newDISTRO_COMPAT_VERSION" | cut -c 1`"
  81. CUT2="`echo -n "$newDISTRO_COMPAT_VERSION" | rev | cut -c 1`"
  82. CUTnewDISTRO_COMPAT_VERSION="${CUT1}${CUT2}"
  83. #110908...
  84. echo
  85. echo "The PET packages will be created with '${CUTnewDISTRO_COMPAT_VERSION}' appended"
  86. echo "to their names, for example 'abiword-1.2.3-${CUTnewDISTRO_COMPAT_VERSION}.pet'"
  87. echo "If you are happy with this, just press ENTER, or, if you want an"
  88. echo "alternate string (ex: '${CUTnewDISTRO_COMPAT_VERSION}2'), then type the"
  89. echo -n "alternate string now then ENTER: "
  90. read altSTR
  91. [ "$altSTR" != "" ] && CUTnewDISTRO_COMPAT_VERSION="`echo -n "$altSTR" | sed -e 's%^-%%'`"
  92. rm -rf new-pets
  93. mkdir new-pets
  94. echo -n "" > z-new-pets-db
  95. #for checking files that are not really needed...
  96. mkdir layer_top
  97. LAYERFS="aufs"
  98. [ "`lsmod | grep '^unionfs'`" != "" ] && LAYERFS="unionfs"
  99. if [ "$LAYERFS" = "aufs" ];then
  100. mount -t aufs -o udba=reval,diropq=w,dirs=sandbox3/devx=rw:sandbox3/rootfs-complete=ro layerfs layer_top
  101. else
  102. mount -t unionfs -o dirs=sandbox3/devx=rw:sandbox3/rootfs-complete=ro layerfs layer_top
  103. fi
  104. #read PKGS_SPECS_TABLE to get all the package names to be converted...
  105. echo
  106. echo "Creating new PETS in new-pets directory..."
  107. #110908 need extra logic here, support optional |pet[:<repo>] or |compat[:<repo>] overrides...
  108. 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' ' '`"
  109. x2COMPAT_GENERIC_NAMES="`echo "$PKGS_SPECS_TABLE" | grep '|compat|$' | cut -f 2 -d '|' | tr '\n' ' '`"
  110. x3COMPAT_GENERIC_NAMES="`echo "$PKGS_SPECS_TABLE" | grep '|compat:' | cut -f 2 -d '|' | tr '\n' ' '`"
  111. COMPAT_GENERIC_NAMES="${x1COMPAT_GENERIC_NAMES} ${x2COMPAT_GENERIC_NAMES} ${x3COMPAT_GENERIC_NAMES}"
  112. for GENERICNAME in $COMPAT_GENERIC_NAMES #ex: 915resolution a52dec abiword ...
  113. do
  114. #110908 support/findpkgs (called from 2createpackages) has created this file...
  115. #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||
  116. gennamePTN=":${GENERICNAME}:" #a pkg may be shared by multiple generic names, ex: :gcc_lib::gcc_dev:|compat|... (ex from Slacko).
  117. FNDIT="`grep "$gennamePTN" status/findpkgs_FINAL_PKGS-${DISTRO_BINARY_COMPAT}-${DISTRO_COMPAT_VERSION} | tail -n 1`" #note, maybe more than one hit.
  118. UPKGVERSION="`echo -n "$FNDIT" | cut -f 6 -d '|'`"
  119. #overrides...
  120. case $GENERICNAME in
  121. x11proto|xorg_base*|xorg73_base*|xserver_xorg*)
  122. 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 '_'`"
  123. #...note, woof-installed-packages also in current dir.
  124. [ "$XORGVER" = "" ] && XORGVER="1.7" #precaution.
  125. UPKGVERSION="7.5"
  126. if vercmp $XORGVER lt 1.7;then
  127. UPKGVERSION="7.4"
  128. fi
  129. if vercmp $XORGVER lt 1.6;then
  130. UPKGVERSION="7.3"
  131. fi
  132. ;;
  133. esac
  134. for xLOOP in 1 2 3 4
  135. do
  136. [ "$xLOOP" == "1" ] && xDEV=""
  137. [ "$xLOOP" == "2" ] && xDEV="_DEV"
  138. [ "$xLOOP" == "3" ] && xDEV="_DOC"
  139. [ "$xLOOP" == "4" ] && xDEV="_NLS"
  140. [ ! -d packages-${DISTRO_FILE_PREFIX}/${GENERICNAME}${xDEV} ] && continue
  141. echo "${GENERICNAME}${xDEV}-${UPKGVERSION}"
  142. if [ -d new-pets/${GENERICNAME}${xDEV}-${UPKGVERSION}-${CUTnewDISTRO_COMPAT_VERSION} ];then
  143. #take care of odd situation, ex 'perl-html-parser' pkg...
  144. #cp -a -f --remove-destination packages-${DISTRO_FILE_PREFIX}/${GENERICNAME}${xDEV}/* new-pets/${GENERICNAME}${xDEV}-${UPKGVERSION}-${CUTnewDISTRO_COMPAT_VERSION}/
  145. continue
  146. else
  147. cp -a packages-${DISTRO_FILE_PREFIX}/${GENERICNAME}${xDEV} new-pets/${GENERICNAME}${xDEV}-${UPKGVERSION}-${CUTnewDISTRO_COMPAT_VERSION}
  148. fi
  149. if [ $? -ne 0 ];then
  150. echo " ...error, skipping"
  151. continue
  152. fi
  153. #create the 'pet.specs' file for each new PET package...
  154. #2createpackages also creates status/2createpackages_history_builds-${DISTRO_BINARY_COMPAT}-${DISTRO_COMPAT_VERSION}
  155. #each line has ${GENERICNAME}|${COMPATPKGNAME} (where COMPATPKGNAME is name of compat-distro pkg)
  156. COMPATPKGNAMES="`grep "$pGENERICNAME" status/2createpackages_history_builds-${DISTRO_BINARY_COMPAT}-${DISTRO_COMPAT_VERSION} | cut -f 2 -d '|'`"
  157. COMPATPKGNAME="`echo "$COMPATPKGNAMES" | head -n 1`"
  158. #file 'woof-installed-packages' has a database entry for COMPATPKGNAME...
  159. pCOMPATPKGNAME='|'"$COMPATPKGNAME"'|'
  160. COMPATDBENTRY="`grep "$pCOMPATPKGNAME" sandbox3/rootfs-complete/root/.packages/woof-installed-packages | head -n 1`"
  161. #pkgname|nameonly|version|pkgrelease|category|size|path|fullfilename|dependencies|description|compileddistro|compiledrelease|repo|
  162. #...'compileddistro|compiledrelease' (fields 11,12) identify where the package was compiled.
  163. DB_pkgname="`echo -n "$COMPATDBENTRY" | cut -f 1 -d '|'`"
  164. DB_nameonly="`echo -n "$COMPATDBENTRY" | cut -f 2 -d '|'`"
  165. DB_version="`echo -n "$COMPATDBENTRY" | cut -f 3 -d '|'`"
  166. DB_pkgrelease="`echo -n "$COMPATDBENTRY" | cut -f 4 -d '|'`"
  167. DB_category="`echo -n "$COMPATDBENTRY" | cut -f 5 -d '|'`"
  168. DB_size="`echo -n "$COMPATDBENTRY" | cut -f 6 -d '|'`"
  169. DB_path="`echo -n "$COMPATDBENTRY" | cut -f 7 -d '|'`"
  170. DB_fullfilename="`echo -n "$COMPATDBENTRY" | cut -f 8 -d '|'`"
  171. DB_dependencies="`echo -n "$COMPATDBENTRY" | cut -f 9 -d '|'`"
  172. DB_description="`echo -n "$COMPATDBENTRY" | cut -f 10 -d '|'`"
  173. DB_compileddistro="`echo -n "$COMPATDBENTRY" | cut -f 11 -d '|'`"
  174. DB_compiledrelease="`echo -n "$COMPATDBENTRY" | cut -f 12 -d '|'`"
  175. DB_repo="`echo -n "$COMPATDBENTRY" | cut -f 13 -d '|'`"
  176. #build modified pet.specs file...
  177. SIZEK="`du -s -k new-pets/${GENERICNAME}${xDEV}-${UPKGVERSION}-${CUTnewDISTRO_COMPAT_VERSION} | cut -f 1 | head -n 1`"
  178. #for ONECOMPAT in `echo "$COMPATPKGNAMES" | tr '\n' ' '`
  179. #do
  180. # #get all the dependencies...
  181. # pONECOMPAT='|'"$ONECOMPAT"'|'
  182. # ONEDEPS="`grep "$pONECOMPAT" sandbox3/rootfs-complete/root/.packages/woof-installed-packages | head -n 1 | cut -f 9 -d '|'`"
  183. # echo -n ""
  184. #done
  185. #100921 remove unecessary entries from DB_dependencies...
  186. 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'
  187. for ONEDEP in $LOWDEPS
  188. do
  189. ldP1=',+'"$ONEDEP"','
  190. ldP2=',+'"$ONEDEP"'$'
  191. ldP3='+'"$ONEDEP"','
  192. ldP4='+'"$ONEDEP"'$'
  193. P1="s%${ldP1}%,%"
  194. P2="s%${ldP2}%%"
  195. P3="s%${ldP3}%,%"
  196. P4="s%${ldP4}%%"
  197. DB_dependencies="`echo -n "$DB_dependencies" | sed -e "$P1" -e "$P2" -e "$P3" -e "$P4"`"
  198. done
  199. DB_dependencies="`echo -n "$DB_dependencies" | tr -s ',' | sed -e 's%,$%%' -e 's%^,%%'`"
  200. case $xDEV in
  201. _DEV) DB_dependencies="+${GENERICNAME}" ;;
  202. _DOC) DB_dependencies="" ;;
  203. _NLS) DB_dependencies="+${GENERICNAME}" ;;
  204. esac
  205. 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
  206. #100921 log db entries to a file...
  207. 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
  208. #remove files that will get deleted anyway...
  209. if [ "$xDEV" == "" -o "$xDEV" == "_DEV" ];then
  210. pFIX="s%new-pets/${GENERICNAME}${xDEV}-${UPKGVERSION}-${CUTnewDISTRO_COMPAT_VERSION}/%%"
  211. for ONESPEC in `find new-pets/${GENERICNAME}${xDEV}-${UPKGVERSION}-${CUTnewDISTRO_COMPAT_VERSION} -mindepth 2 | tr '\n' ' '`
  212. do
  213. [ ! -e $ONESPEC ] && continue
  214. DOWNSPEC="`echo -n "$ONESPEC" | sed -e "$pFIX"`"
  215. if [ ! -e layer_top/${DOWNSPEC} ];then
  216. echo "Deleting new-pets/${GENERICNAME}${xDEV}-${UPKGVERSION}-${CUTnewDISTRO_COMPAT_VERSION}/${DOWNSPEC}"
  217. rm -rf new-pets/${GENERICNAME}${xDEV}-${UPKGVERSION}-${CUTnewDISTRO_COMPAT_VERSION}/${DOWNSPEC}
  218. fi
  219. done
  220. fi
  221. cd new-pets
  222. sync
  223. dir2tgz ${GENERICNAME}${xDEV}-${UPKGVERSION}-${CUTnewDISTRO_COMPAT_VERSION}
  224. tgz2pet ${GENERICNAME}${xDEV}-${UPKGVERSION}-${CUTnewDISTRO_COMPAT_VERSION}.tar.gz
  225. cd ..
  226. #rm -rf new-pets/${GENERICNAME}${xDEV}-${UPKGVERSION}-${CUTnewDISTRO_COMPAT_VERSION}
  227. done
  228. done
  229. echo
  230. sync
  231. umount layer_top
  232. rmdir layer_top
  233. ###END###