Parsing .change files


/ Published in: Bash
Save to your folder(s)

This script goes through .change files in the current directory and copies all the files listed to a different directory. It skips the _sources.change files as well.

This is really written in plain bourne shell, but Smipple doesn't seem to support it directly.

The obvious use is to copy the files so we can use "reprepro processincoming" to save packages to a repository.

There are probably smarter ways to do this, but this is pretty portable as it only requires grep and cut, and very minimal functionality from them as well. And even grep is not needed if you want to copy everything.


Copy this code and paste it in your HTML
  1. #/bin/sh
  2. for CHANGEFILE in *.changes;
  3. do
  4. str=`echo $CHANGEFILE | grep -v "source.changes"`
  5. if [ -z "$str" ]; then
  6. continue
  7. fi
  8. found="0"
  9. while read line
  10. do
  11. if [ "$found" = "0" ] ; then
  12. if [ "$line" != "Files:" ]; then
  13. continue
  14. else
  15. found="1"
  16. continue
  17. fi
  18. fi
  19.  
  20. file=`echo $line | cut -d " " -f 5`
  21. cp $file $INCOMING_DIR
  22. done < $CHANGEFILE
  23. cp $CHANGEFILE $INCOMING_DIR
  24. done

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.