Advertisement
tolikpunkoff

undeb

Jan 10th, 2017
492
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.08 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. DATADIR="./data"
  4. CONTROLDIR="./control"
  5. CURDIR=""
  6.  
  7. if [ "$1" == "-h" ]; then #print help
  8.     echo "Unpacking all *.deb packages in current directory"
  9.     echo "use" `basename "$0"` "[-c]"
  10.     echo "-c - delete files in out-dirs"
  11.     exit
  12. fi
  13.  
  14. echo "Unpacking all *.deb packages in current directory"
  15.  
  16. echo "Making out-dirs... $DATADIR $CONTROLDIR"
  17. mkdir $DATADIR
  18. mkdir $CONTROLDIR
  19.  
  20. if [ "$1" == "-c" ]; then
  21.     echo "Clear out-dirs..."
  22.     CURDIR=`pwd`
  23.     cd $DATADIR
  24.     rm *
  25.     cd $CURDIR
  26.     cd $CONTROLDIR
  27.     rm *
  28.     cd $CURDIR
  29. fi
  30.  
  31. echo "Processing:"
  32. F=`find . -name "*.deb" -type f`
  33.  
  34. for FILE in $F
  35. do
  36.    
  37.     DATAPKG=`ar t ${FILE}|grep "data"`
  38.     CONTROLPKG=`ar t ${FILE}|grep "control"`
  39.     BASENAME=`basename -s ".deb" ${FILE}`
  40.     EXTDATA=`echo $DATAPKG|sed 's/data//g'`
  41.     EXTCONTROL=`echo $CONTROLPKG|sed 's/control//g'`
  42.     echo "${FILE} : $DATAPKG, $CONTROLPKG"
  43.    
  44.     #razbor paketa
  45.     ar -p "$BASENAME.deb" $DATAPKG > "$DATADIR/$BASENAME$EXTDATA"
  46.     ar -p "$BASENAME.deb" $CONTROLPKG > "$CONTROLDIR/$BASENAME$EXTCONTROL"
  47. done
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement