Advertisement
s243a

move-source

May 12th, 2019
306
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.34 KB | None | 0 0
  1. #!/bin/bash
  2. #written by s243a (John Creighton)
  3.  
  4. close_fds(){
  5.     exec 10>&-
  6.     rm -rf /tmp/move-source
  7. }
  8. trap close_fds EXIT
  9. trap close_fds SIGKILL
  10. trap close_fds SIGTERM
  11. curdir=`pwd`
  12. _(){ #Can use this function to safely quote things.
  13.   echo "$*"
  14. }
  15. s_root="`realpath "$curdir"`"
  16. mkdir -p ../tazpup-builder-source
  17. d_root=`realpath ../tazpup-builder-source`
  18. mkdir -p /tmp/move-source
  19. exec 10<> /tmp/move-source/fd_10
  20.  
  21. for adir in build-scripts pkgs tazpup-core-files; do
  22. #  for afile in "`find "./$adir" -name '*'`" ; do
  23.    while IFS=$'\0' read -r -d $'\0' -u10 afile; do
  24.     afile="${afile#'./'}"
  25.     if [ -d "$s_root/$afile" ]; then
  26.       adir2="$afile"
  27.     else
  28.       adir2="$(basename "$afile")"        
  29.     fi
  30.     if [ -d "$s_root/$afile" ]; then
  31.       cd "$s_root"
  32.       echo ./$adir2 | cpio -pd $d_root    
  33.     elif [[ `file -i "$s_root/$afile" | cut -d' ' -f2` = text/* ]] &&
  34.        [[ $afile != *.log ]]; then
  35.       cd "$s_root"
  36.       echo ./$afile | cpio -pd $d_root
  37.     else
  38.       if [ ! -d $d_root/$dir2 ]; then
  39.         cd $s_root
  40.         echo "./$adir2" | cpio -pd $d_root
  41.       fi
  42.       echo "\
  43. filename=$(basename "$afile")
  44. size=$(du "$afile")
  45. checksum.md5=$(md5sum "$afile")
  46. checksum.sha256=$(sha256sum "$afile")">$d_root/$afile.binary.meta
  47.     fi
  48.   done 10< <( find "./$adir" -name '*' -print0 )
  49. done
  50. exec 10>&-
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement