quixadhal

mkgit.sh NakedMUD version

Feb 8th, 2013
225
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 2.90 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. echo "--- Analyzing archive data ---"
  4.  
  5. mkdir -p open
  6. cd open
  7. for i in ../archive/*.tar.gz; do
  8.     echo -n " unpacking..."
  9.     VERSION=`echo $i | awk -F/ '{print $NF}' | cut -d- -f 2 | cut -d. -f -3`
  10.     echo -n " $VERSION..."
  11.  
  12.     mkdir -p $VERSION
  13.     cd $VERSION
  14.     tar -x --strip-components=1 -f../$i
  15.  
  16.     echo -n " cleaning..."
  17.     # Clean out cruft
  18.     for j in .DS_Store ._.DS_Store .gdb_history .depend; do
  19.         find . -name "$j" -print0 | xargs -0 rm -f
  20.     done
  21.     find . -type l -print0 | xargs -0 rm -f
  22.  
  23.     cd ..
  24.  
  25.     echo -n " permisioning..."
  26.     find "$VERSION" -type d -print0 | xargs -0 chmod 755
  27.     find "$VERSION" -type f -print0 | xargs -0 chmod 644
  28.     for j in `find "$VERSION" -type f`; do
  29.         FILETYPE=`file -nNk $j | grep -i 'executable'`
  30.         if [ -n "$FILETYPE" ]; then
  31.             chmod 755 "$j"
  32.         fi
  33.     done
  34.     #for j in `find "$VERSION" -type f -print0 | xargs -0 file -nNk | grep -i 'executable' | awk -F: '{print $1}'`; do
  35.     #    chmod 755 "$j"
  36.     #done
  37.  
  38.     echo -n " unemptying..."
  39.     RECENT=`find "$VERSION" -type f -printf '%TY-%Tm-%Td %TT %p\n' | grep -v .git | colrm 20 | sort -r | head -1`
  40.     touch -d "$RECENT" "$VERSION"
  41.     for j in `find "$VERSION" -type d -empty`; do
  42.         touch -d "$RECENT" "$j/.gitignore"
  43.     done
  44.  
  45.     echo -n " stamping..."
  46.     echo -en "$VERSION\t$RECENT\n" >"$VERSION/VERSION"
  47.     touch -d "$RECENT" "$VERSION/VERSION"
  48.  
  49.     echo "done."
  50. done
  51. cd ..
  52.  
  53. DIRS=`ls -d1 open/v* | awk -F/ '{print $NF}' | sort -n`
  54. TOTAL=`echo $DIRS | wc -w`
  55.  
  56. exit 1
  57.  
  58. echo "--- Creating git repository ---"
  59.  
  60. mkdir -p nakedmud
  61. cd nakedmud
  62. git init >../git_checkin.log 2>../git_error.log
  63.  
  64. DIRS=`ls -d1 ../open/v* | awk -F/ '{print $NF}' | sort -n`
  65. COUNT=0
  66. TOTAL=`echo $DIRS | wc -w`
  67. for i in $DIRS; do
  68.     COUNT=$[ $COUNT + 1 ]
  69.     echo -n "$i ($COUNT of $TOTAL) versioning..."
  70.  
  71.     git ls-files -z | xargs -0 rm -f
  72.     find . -maxdepth 1 -type d -print0 | grep -z '^./[a-zA-Z0-9_]' | xargs -0 rm -rf
  73.     cp -rp ../open/$i/* .
  74.     cp -rp ../addons .
  75.     cp -rp ../manuals .
  76.  
  77.     if [ -f "VERSION" ]; then
  78.         RECENT=`cat "VERSION"  | cut -f 2-`
  79.     else
  80.         RECENT=`find "../open/$i" -type f -printf '%TY-%Tm-%Td %TT %p\n' | grep -v .git | colrm 20 | sort -r | head -1`
  81.     fi
  82.     export GIT_AUTHOR_DATE="$RECENT"
  83.     export GIT_COMMITTER_DATE="$RECENT"
  84.     git add -A >>../git_checkin.log 2>>../git_error.log
  85.     git commit -m $i >>../git_checkin.log 2>>../git_error.log
  86.     git tag $i >>../git_checkin.log 2>>../git_error.log
  87.  
  88.     echo " done."
  89. done
  90. cd ..
  91.  
  92. if [ -f git_error.log -a ! -s git_error.log ]; then
  93.     rm git_error.log
  94. fi
  95.  
  96. # If that looks like it worked properly...
  97. # git config --global user.name "Dread Quixadhal"
  98. # git config --global user.email [email protected]
  99. # git remote add origin [email protected]:quixadhal/nakedmud.git
  100. # git push --all
  101. # git push --tags
Advertisement
Add Comment
Please, Sign In to add comment