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