feeds.sh 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  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, space separated
  8. # $2 -> other options (not used yet)
  9. #
  10. # Note : we do not yet resolve package name conflicts
  11. #
  12. # Directories
  13. FEEDS_DIR=$TOPDIR/feeds
  14. PACKAGE_DIR=$TOPDIR/package
  15. # We work in the TOPDIR as defined in the caller Makefile
  16. cd $TOPDIR
  17. # This directory will be structured this way : feeds/feed-name
  18. [ -d $FEEDS_DIR ] || mkdir -p $FEEDS_DIR
  19. # Some functions we might call several times a run
  20. delete_symlinks() {
  21. find $1 -type l | xargs -r rm -f
  22. }
  23. setup_symlinks() {
  24. # We assume that feeds do reproduce the hierarchy : section/package
  25. # so that we can make this structure be flat in $PACKAGE_DIR
  26. for dir in $(ls $1/)
  27. do
  28. ln -s $1/$dir/*/* $2/
  29. done
  30. }
  31. checkout_feed() {
  32. # We ensure the feed has not already been checked out, if so, we just update the source feed
  33. if [ -d $FEEDS_DIR/$2 ]; then
  34. svn up $FEEDS_DIR/$2
  35. echo "Updated to revision $(LANG=C svn info $FEEDS_DIR/$2 | awk '/^Revision:/ { print $2 }' )";
  36. # Otherwise, we have to checkout in the $FEEDS_DIR
  37. else
  38. svn co $1 $FEEDS_DIR/$2
  39. echo "Checked out revision $(LANG=C svn info $FEEDS_DIR/$2 | awk '/^Revision:/ { print $2 }' )";
  40. fi
  41. }
  42. extract_feed_name() {
  43. # We extract the last name of the URL, maybe we should rename this as domain.tld.repository.name
  44. echo "$(echo $1 | sed -e "s/[^A-Za-z\.]\+/_/g")"
  45. }
  46. # We can delete symlinks every time we start this script, since modifications have been made in the $FEEDS_DIR anyway
  47. delete_symlinks "$PACKAGE_DIR"
  48. # Now let's checkout feeds
  49. for feed in $1
  50. do
  51. name=$(extract_feed_name "$feed")
  52. checkout_feed "$feed" "$name"
  53. done
  54. # Finally setup symlinks
  55. setup_symlinks "$FEEDS_DIR" "$PACKAGE_DIR"