Advertisement
gur111

MtmEx3 AutoPacker Dep Handler

Jun 24th, 2020
1,796
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.85 KB | None | 0 0
  1. #!/bin/bash
  2. set -e -o pipefail
  3.  
  4. function cleanup {
  5.     EXIT_CODE=$?
  6.     set +e # disable termination on error
  7.     if ls -a1 | grep $TMP_DIR ; then
  8.         rm -Rf $TMP_DIR
  9.         echo "deleted dir $TMP_DIR"
  10.     fi
  11.     cd $orig_dir
  12.     exit $EXIT_CODE
  13. }
  14.  
  15. trap cleanup EXIT
  16.  
  17. orig_dir=$(pwd)
  18. TMP_DIR=.tmp_sub
  19. mkdir -p $TMP_DIR
  20.  
  21. # Replace include from parent to local
  22. for folder in $(ls -1 | grep "^part.$") ; do
  23.     echo dir is $TMP_DIR/$folder
  24.     mkdir -p $TMP_DIR/$folder
  25.     for file in $(ls -1 $folder | grep "\.h\|\.cpp") ; do
  26.         sed 's/\.\.\/part.\///g' $folder/$file > $TMP_DIR/$folder/$file
  27.     done
  28.  
  29.     # Add dependencies
  30.     for dep in $(grep -roh $folder/ -e ".*\.\./part./\w*\.h" | grep -v "//" | grep -oh -e "part./\w*\.") ; do
  31.         echo "Copying dep $dep*"
  32.         cp $dep* $TMP_DIR/$folder
  33.     done
  34. done
  35.  
  36. cd $TMP_DIR
  37. t=$(date "+%H:%M:%S")
  38. zip ../sub_$t.zip ./*
  39. cd -
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement