feeds.sh 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. #!/bin/sh
  2. # Copyright (C) 2006 OpenWrt.org
  3. #
  4. # This is free software, licensed under the GNU General Public License v2.
  5. # See /LICENSE for more information.
  6. #
  7. # Usage : $1 -> source feeds
  8. # $2 -> other options
  9. #
  10. # Note : we do not yet resolve package name conflicts
  11. #
  12. #
  13. FEEDS_DIR=$TOPDIR/feeds
  14. PACKAGE_DIR=$TOPDIR/package
  15. cd $TOPDIR
  16. # This directory will be structured this way : feeds/feed-name
  17. [ -d $FEEDS_DIR ] || mkdir -p $FEEDS_DIR
  18. # Some functions we might call several times a run
  19. delete_symlinks() {
  20. find $PACKAGE_DIR -type l | xargs rm -f
  21. }
  22. setup_symlinks() {
  23. # We assume that feeds do reproduce the hierarchy : section/package
  24. for dir in $(ls $FEEDS_DIR/)
  25. do
  26. ln -s $FEEDS_DIR/$dir/*/* $PACKAGE_DIR/
  27. done
  28. }
  29. checkout_feed() {
  30. # We ensure the feed has not already been checkout, if so, just update the source feed
  31. if [ -d $FEEDS_DIR/$2 ]; then
  32. svn update $FEEDS_DIR/$2
  33. echo "Updated to revision $(LANG=C svn info $FEEDS_DIR/$2 | awk '/^Revision:/ { print $2 }' )";
  34. # Otherwise, we have to checkout in the
  35. else
  36. svn co $1 $FEEDS_DIR/$2
  37. echo "Checked out revision $(LANG=C svn info $FEEDS_DIR/$2 | awk '/^Revision:/ { print $2 }' )";
  38. fi
  39. }
  40. extract_feed_name() {
  41. echo "$(echo $1 | awk -F/ '{ print $NF}')"
  42. }
  43. # We can delete symlinks every time we start this script, since modifications have been made anyway
  44. delete_symlinks ""
  45. # Now let's checkout feeds
  46. for feed in $1
  47. do
  48. name=$(extract_feed_name "$feed")
  49. checkout_feed "$feed" "$name"
  50. done
  51. # Finally setup symlinks
  52. setup_symlinks ""