vcs-workarounds 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. #!/bin/sh
  2. #BK nov. 2011
  3. [ ! -d woof-code ] && exit
  4. echo
  5. echo "You don't need to run this script.
  6. I ran it once, which should be enough. It applies workarounds for a VCS to the
  7. 'woof-code' directory -- see more explanation in 'merge-arch_code_distro-2-out'
  8. script."
  9. echo -n "Press 'c' key to continue, ENTER key only to quit: "
  10. read goforit
  11. [ "$goforit" != "c" ] && exit
  12. echo
  13. echo "Creating file 'EMPTYDIRMARKER' in empty directories..."
  14. for ONEDIR in `find woof-code -type d`
  15. do
  16. [ ! -d $ONEDIR ] && continue #catch dirs with spaces.
  17. if [ "`ls $ONEDIR`" = "" ];then
  18. echo " $ONEDIR/EMPTYDIRMARKER"
  19. touch $ONEDIR/EMPTYDIRMARKER
  20. fi
  21. done
  22. echo
  23. echo "Rename [ and [[ files as LEFTSQBRACKETCHAR and DBLLEFTSQBRACKETCHAR..."
  24. for ONEBAD in `find woof-code -name \\[`
  25. do
  26. ONEDIR="`dirname "$ONEBAD"`"
  27. [ ! -e ${ONEDIR}/[ ] && continue #catch dirs with spaces
  28. echo " renaming ${ONEDIR}/[ to ${ONEDIR}/LEFTSQBRACKETCHAR"
  29. mv -f ${ONEDIR}/[ ${ONEDIR}/LEFTSQBRACKETCHAR
  30. done
  31. for ONEBAD in `find woof-code -name \\[\\[`
  32. do
  33. ONEDIR="`dirname "$ONEBAD"`"
  34. [ ! -e ${ONEDIR}/[[ ] && continue #catch dirs with spaces
  35. echo " renaming ${ONEDIR}/[[ to ${ONEDIR}/DBLLEFTSQBRACKETCHAR"
  36. mv -f ${ONEDIR}/[[ ${ONEDIR}/DBLLEFTSQBRACKETCHAR
  37. done
  38. echo
  39. echo "Convert 'dev' directories to DEVDIR.tar.gz tarballs..."
  40. if [ -d woof-code/rootfs-skeleton/dev ];then
  41. echo " woof-code/rootfs-skeleton/dev"
  42. cd woof-code/rootfs-skeleton
  43. tar -c -f DEVDIR.tar dev/
  44. gzip DEVDIR.tar
  45. mv -f DEVDIR.tar.gz ../../woof-arch/woof-code_rootfs-skeleton_DEVDIR.tar.gz
  46. echo -n 'woof-code_rootfs-skeleton_DEVDIR.tar.gz' > DEVDIRMARKER
  47. rm -rf dev
  48. cd ../../
  49. fi
  50. if [ -d woof-code/boot/initrd-tree0/dev ];then
  51. echo " woof-code/boot/initrd-tree0/dev"
  52. cd woof-code/boot/initrd-tree0
  53. tar -c -f DEVDIR.tar dev/
  54. gzip DEVDIR.tar
  55. mv -f DEVDIR.tar.gz ../../../woof-arch/woof-code_boot_initrd-tree0_DEVDIR.tar.gz
  56. echo -n 'woof-code_boot_initrd-tree0_DEVDIR.tar.gz' > DEVDIRMARKER
  57. rm -rf dev
  58. cd ../../../
  59. fi
  60. #echo "Move all image files from woof-code to woof-arch..."
  61. #rm -rf /tmp/vcs-workarounds 2>/dev/null
  62. #mkdir /tmp/vcs-workarounds
  63. #if [ -f woof-arch/woof-code-binary-images.tar.gz ];then #from previous time ran this script.
  64. # cd woof-arch
  65. # tar -zxf woof-code-binary-images.tar.gz
  66. # cp -a -f woof-code-binary-images/* /tmp/vcs-workarounds/
  67. # rm -rf woof-code-binary-images
  68. # rm -f woof-code-binary-images.tar.gz
  69. # cd ..
  70. #fi
  71. #for ONEFILE in `find woof-code -type f -iname '*.gif' -or -iname '*.png' -or -iname '*.jpg' -or -iname '*.jpeg' | sed -e 's% %SPACECHAR%g' | tr '\n' ' '`
  72. #do
  73. # ONEFILE="`echo -n "$ONEFILE" | sed -e 's%SPACECHAR% %g'`"
  74. # [ ! -e "$ONEFILE" ] && continue
  75. # ONENAME="`basename "$ONEFILE"`"
  76. # ONEPATH="`dirname "$ONEFILE"`"
  77. # echo "$ONEFILE" > ${ONEFILE}MARKER
  78. # mkdir -p "/tmp/vcs-workarounds/${ONEPATH}"
  79. # mv -f "$ONEFILE" "/tmp/vcs-workarounds/${ONEFILE}"
  80. #done
  81. #mv -f /tmp/vcs-workarounds woof-arch/woof-code-binary-images
  82. #cd woof-arch
  83. #dir2tgz woof-code-binary-images
  84. #cd ..
  85. #sync
  86. echo
  87. echo "Record special permissions/ownership in woof-code/VCSMETADATA..."
  88. #catch-22 situation, can only do this on the original 'woof-code', not a 'woof-code'
  89. #that is created from a VCS checkout. Assume such a checkout will also contain file
  90. #'VCSMETADATA'...
  91. if [ ! -f woof-code/VCSMETADATA ];then
  92. cd woof-code
  93. touch VCSMETADATA
  94. for ONESPEC in `find rootfs-skeleton -mindepth 1 | tr '\n' ' '`
  95. do
  96. [ ! -e $ONESPEC ] && continue
  97. FSTATS="`stat --format=%a:%U:%G $ONESPEC`"
  98. [ "$FSTATS" != "755:root:root" ] && [ "$FSTATS" != "644:root:root" ] && echo "${ONESPEC}:${FSTATS}" >> VCSMETADATA
  99. done
  100. for ONESPEC in `find packages-templates -mindepth 1 | tr '\n' ' '`
  101. do
  102. [ ! -e $ONESPEC ] && continue
  103. FSTATS="`stat --format=%a:%U:%G $ONESPEC`"
  104. [ "$FSTATS" != "755:root:root" ] && [ "$FSTATS" != "644:root:root" ] && echo "${ONESPEC}:${FSTATS}" >> VCSMETADATA
  105. done
  106. sort -u --key=1,1 --field-separator=: VCSMETADATA > /tmp/fossil-VCSMETADATA
  107. mv -f /tmp/fossil-VCSMETADATA VCSMETADATA
  108. if [ -s VCSMETADATA ];then
  109. echo "Written to VCSMATADATA:"
  110. cat VCSMETADATA
  111. fi
  112. cd ..
  113. else
  114. echo "NOTE: woof-code/VCSMETADATA already exists. This can only be edited manually
  115. if you want to add or modify any file/dir permissions/ownerhsip."
  116. fi
  117. echo "Finished"
  118. ###END###