3mergepets 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187
  1. #!/bin/sh
  2. #sept 2011. creating wary 5.2pre, with new pkgs compiled in t2, need to upgrade all the existing ones.
  3. #note, i previously setup woof for building a t2 system and ran 0pre, 0setup, 2compat2pets, and 2createpackages,
  4. #which created 'packages-t2test' (the same thing as 'packages-wary'). the t2 setup also created 'Packages-t2-9-official'.
  5. #then ran 3builddistro, then 3compat2pets, got all T2 pkgs converted to pets in dir 'new-pets'
  6. #and dbs in file 'z-new-pets-db'.
  7. #now run '3mergepets' to merge pets in 'new-pets' into those in ../pet-construction/pet_packages-wary5-WARY52,
  8. #(pet_packages-wary5-WARY52 is a copy of pet_packages-wary5)
  9. #note, earlier scripts are usable to convert any compat-distro pkgs to pets, but this one is
  10. #specific to wary, needs mods to work for other compat-distro.
  11. echo "This script will merge imported pets in dir 'new-pets' into dir"
  12. echo "'pet_packages-wary5-WARY5' (which is a copy of pet_packages-wary5)."
  13. echo -n "Press ENTER to continue: "
  14. read yesgo
  15. if [ ! -f z-new-pets-db ];then
  16. echo "ERROR: file 'z-new-pets-db' does not exist. Aborting."
  17. exit
  18. fi
  19. if [ ! -d new-pets ];then
  20. echo "ERROR: dir 'new-pets' does not exist. Aborting."
  21. exit
  22. fi
  23. #echo -n "" > Packages-puppy-wary5-official-WARY52
  24. cp -f Packages-puppy-wary5-official Packages-puppy-wary5-official-WARY52
  25. rm -f MERGEPETS_ERROR_MERGE 2>/dev/null
  26. rm -f MERGEPETS_WARNING_OLD_VERSIONS 2>/dev/null
  27. echo "Need to manually check contents against originals..." > MERGEPETS_WARNING_NEW_VERSIONS
  28. echo
  29. echo "deleting any prior ../pet-construction/pet_packages-wary5-WARY52 ..."
  30. rm -rf ../pet-construction/pet_packages-wary5-WARY52 2>/dev/null
  31. sync
  32. echo "...done"
  33. mkdir -p ../pet-construction/pet_packages-wary5-WARY52
  34. echo "Copying all old wary pkgs to ../pet-construction/pet_packages-wary5-WARY52 ..."
  35. cp -a ../pet-construction/pet_packages-wary5/* ../pet-construction/pet_packages-wary5-WARY52/
  36. sync
  37. rm -f ../pet-construction/pet_packages-wary5-WARY52/*.pet
  38. rm -f ../pet-construction/pet_packages-wary5-WARY52/nohup.out 2>/dev/null
  39. sync
  40. echo "...done"
  41. #db fields: pkgname|nameonly|version|pkgrelease|category|size|path|fullfilename|dependencies|description|compileddistro|compiledrelease|repo|
  42. cat z-new-pets-db |
  43. while read ALINE
  44. do
  45. DB_pkgname1="`echo -n "$ALINE" | cut -f 1 -d '|'`"
  46. DB_nameonly1="`echo -n "$ALINE" | cut -f 2 -d '|'`"
  47. DB_version1="`echo -n "$ALINE" | cut -f 3 -d '|'`"
  48. DB_fullfilename1="`echo -n "$ALINE" | cut -f 8 -d '|'`"
  49. nPTN1="|${DB_nameonly1}|"
  50. DB_version2="`grep "$nPTN1" Packages-puppy-wary5-official | tail -n 1 | cut -f 3 -d '|'`"
  51. [ "$DB_version2" = "" ] && DB_version2='0.0.0.1'
  52. NAMEONLY="$DB_nameonly1"
  53. NEWNAME="$DB_pkgname1"
  54. NEWVERSION="${DB_version1}"
  55. NEWNAMEONLY="${NAMEONLY}"
  56. NEWPET="${DB_fullfilename1}"
  57. DB_fullfilenamex="`grep "$nPTN1" Packages-puppy-wary5-official | tail -n 1 | cut -f 8 -d '|' | sed -e 's%\.pet$%%'`"
  58. if [ -d new-pets/${DB_pkgname1} -a "$DB_fullfilenamex" ];then
  59. if [ -d ../pet-construction/pet_packages-wary5/${DB_fullfilenamex} ];then
  60. echo "$NAMEONLY"
  61. #truncate versions to same length...
  62. DB_version2x="`echo -n "$DB_version2" | cut -f 1 -d '-' | cut -f 1 -d '_'`"
  63. DB_version1x="`echo -n "$DB_version1" | cut -f 1 -d '-' | cut -f 1 -d '_'`"
  64. if vercmp $DB_version1x eq $DB_version2x;then
  65. rm -rf ../pet-construction/pet_packages-wary5-WARY52/${NEWNAME} 2>/dev/null #precaution.
  66. mv -f ../pet-construction/pet_packages-wary5-WARY52/${DB_fullfilenamex} ../pet-construction/pet_packages-wary5-WARY52/${NEWNAME}
  67. #now copy the files from the t2 pkgs...
  68. sPTN="s%../pet-construction/pet_packages-wary5-WARY52/${NEWNAME}/%%"
  69. find ../pet-construction/pet_packages-wary5-WARY52/${NEWNAME} -mindepth 1 -type f | sed -e "$sPTN" |
  70. while read ONEFND
  71. do
  72. ONEDIR="`dirname "$ONEFND"`"
  73. if [ -f "new-pets/${DB_pkgname1}/${ONEFND}" ];then
  74. echo " ${ONEFND}"
  75. if [ -h "new-pets/${DB_pkgname1}/${ONEFND}" ];then
  76. echo "ERROR HYPERLINK, EXPECTED FILE: new-pets/${DB_pkgname1}/${ONEFND}"
  77. echo "ERROR HYPERLINK, EXPECTED FILE: new-pets/${DB_pkgname1}/${ONEFND}" >> MERGEPETS_ERROR_MERGE
  78. else
  79. cp -a -f --remove-destination "new-pets/${DB_pkgname1}/${ONEFND}" "../pet-construction/pet_packages-wary5-WARY52/${NEWNAME}/${ONEDIR}/"
  80. fi
  81. else
  82. echo "ERROR MISSING FILE: new-pets/${DB_pkgname1}/${ONEFND}"
  83. echo "ERROR MISSING FILE: new-pets/${DB_pkgname1}/${ONEFND}" >> MERGEPETS_ERROR_MERGE
  84. fi
  85. done
  86. #fix pet.specs...
  87. #db fields: pkgname|nameonly|version|pkgrelease|category|size|path|fullfilename|dependencies|description|compileddistro|compiledrelease|repo|
  88. #the t2 spec is $ALINE, however, get it from old wary...
  89. OLDSPEC="`grep "$nPTN1" Packages-puppy-wary5-official | tail -n 1`"
  90. DB_category="`echo -n "$OLDSPEC" | cut -f 5 -d '|'`"
  91. DB_size="`echo -n "$ALINE" | cut -f 6 -d '|'`"
  92. DB_dependencies="`echo -n "$OLDSPEC" | cut -f 9 -d '|'`"
  93. DB_description="`echo -n "$OLDSPEC" | cut -f 10 -d '|'`"
  94. NEWSPECS="${NEWNAME}|${NEWNAMEONLY}|${NEWVERSION}||${DB_category}|${DB_size}||${NEWPET}|${DB_dependencies}|${DB_description}|puppy|wary5||"
  95. grep -v "$nPTN1" Packages-puppy-wary5-official-WARY52 > /tmp/ppwo52
  96. mv -f /tmp/ppwo52 Packages-puppy-wary5-official-WARY52
  97. echo "$NEWSPECS" >> Packages-puppy-wary5-official-WARY52
  98. echo "$NEWSPECS" > ../pet-construction/pet_packages-wary5-WARY52/${NEWNAME}/pet.specs
  99. #extra checking...
  100. ePTN="s%new-pets/${DB_pkgname1}/%%"
  101. find new-pets/${DB_pkgname1} -mindepth 1 | sed -e "$ePTN" |
  102. while read ONEFND
  103. do
  104. if [ ! -e ../pet-construction/pet_packages-wary5-WARY52/${NEWNAME}/${ONEFND} ];then
  105. case $NEWNAME in
  106. *_DEV-*)
  107. if [ -h ../pet-construction/pet_packages-wary5-WARY52/${NEWNAME}/${ONEFND} ];then
  108. [ "`echo -n "$ONEFND" | rev | cut -c 1,2,3 | rev`" = ".so" ] && continue
  109. fi
  110. ;;
  111. esac
  112. echo "WARNING, DOES NOT EXIST IN TARGET: new-pets/${DB_pkgname1}/${ONEFND}"
  113. echo "WARNING, DOES NOT EXIST IN TARGET: new-pets/${DB_pkgname1}/${ONEFND}" >> MERGEPETS_ERROR_MERGE
  114. fi
  115. done
  116. else
  117. if vercmp $DB_version1x gt $DB_version2x;then
  118. echo "UPDATED PKG: ${NEWNAME}"
  119. echo "PKG:${NAMEONLY} NEW:${DB_version1x} OLD:${DB_version2x}" >> MERGEPETS_WARNING_NEW_VERSIONS
  120. #copy the t2 pkg to a new place...
  121. mv -f ../pet-construction/pet_packages-wary5-WARY52/${DB_fullfilenamex} ../pet-construction/pet_packages-wary5-WARY52/${DB_fullfilenamex}OLDWARY5PKG #rename the old one. kept for manual comparison.
  122. rm -rf ../pet-construction/pet_packages-wary5-WARY52/${DB_pkgname1} 2>/dev/null #precaution
  123. cp -a new-pets/${DB_pkgname1} ../pet-construction/pet_packages-wary5-WARY52/
  124. #db fields: pkgname|nameonly|version|pkgrelease|category|size|path|fullfilename|dependencies|description|compileddistro|compiledrelease|repo|
  125. #the t2 spec is $ALINE, however, get it from old wary...
  126. OLDSPEC="`grep "$nPTN1" Packages-puppy-wary5-official | tail -n 1`"
  127. DB_category="`echo -n "$OLDSPEC" | cut -f 5 -d '|'`"
  128. DB_size="`echo -n "$ALINE" | cut -f 6 -d '|'`"
  129. DB_dependencies="`echo -n "$OLDSPEC" | cut -f 9 -d '|'`"
  130. DB_description="`echo -n "$OLDSPEC" | cut -f 10 -d '|'`"
  131. NEWSPECS="${NEWNAME}|${NEWNAMEONLY}|${NEWVERSION}||${DB_category}|${DB_size}||${NEWPET}|${DB_dependencies}|${DB_description}|puppy|wary5||"
  132. grep -v "$nPTN1" Packages-puppy-wary5-official-WARY52 > /tmp/ppwo52
  133. mv -f /tmp/ppwo52 Packages-puppy-wary5-official-WARY52
  134. echo "$NEWSPECS" >> Packages-puppy-wary5-official-WARY52
  135. echo "$NEWSPECS" > ../pet-construction/pet_packages-wary5-WARY52/${NEWNAME}/pet.specs
  136. else
  137. echo "WARNING: ${DB_pkgname1} older version, not merged."
  138. echo "WARNING: ${DB_pkgname1} older version, not merged." >> MERGEPETS_WARNING_OLD_VERSIONS
  139. fi
  140. fi
  141. else
  142. #does not exist in pet_packages-wary5-WARY52, just copy it straight through...
  143. echo "Straight thru: ${DB_pkgname1}"
  144. rm -rf ../pet-construction/pet_packages-wary5-WARY52/${DB_pkgname1} 2>/dev/null #precaution
  145. cp -a new-pets/${DB_pkgname1} ../pet-construction/pet_packages-wary5-WARY52/
  146. grep -v "$nPTN1" Packages-puppy-wary5-official-WARY52 > /tmp/ppwo52
  147. mv -f /tmp/ppwo52 Packages-puppy-wary5-official-WARY52
  148. cat new-pets/${DB_pkgname1}/pet.specs >> Packages-puppy-wary5-official-WARY52
  149. fi
  150. else
  151. #does not exist in pet_packages-wary5-WARY52, just copy it straight through...
  152. echo "Straight thru: ${DB_pkgname1}"
  153. rm -rf ../pet-construction/pet_packages-wary5-WARY52/${DB_pkgname1} 2>/dev/null #precaution
  154. cp -a new-pets/${DB_pkgname1} ../pet-construction/pet_packages-wary5-WARY52/
  155. grep -v "$nPTN1" Packages-puppy-wary5-official-WARY52 > /tmp/ppwo52
  156. mv -f /tmp/ppwo52 Packages-puppy-wary5-official-WARY52
  157. cat new-pets/${DB_pkgname1}/pet.specs >> Packages-puppy-wary5-official-WARY52
  158. fi
  159. sync
  160. done
  161. sort Packages-puppy-wary5-official-WARY52 > /tmp/ppwo52
  162. mv -f /tmp/ppwo52 Packages-puppy-wary5-official-WARY52
  163. ###END###