forked from openwrt-xiaomi/builder
-
Notifications
You must be signed in to change notification settings - Fork 0
/
xupdate.sh
executable file
·89 lines (73 loc) · 2.08 KB
/
xupdate.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
#!/bin/bash
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
export XDIR=$SCRIPT_DIR
export XADDONSDIR=$XDIR/package/addons
FEEDSDIR=$XDIR/package/feeds
ADDONSCFG=$XDIR/_addons.config
. ./xcommon.sh
OPT_FULL_UPDATE=false
while getopts "f" opt; do
case $opt in
f) OPT_FULL_UPDATE=true;;
esac
done
[ ! -d "$FEEDSDIR" ] && OPT_FULL_UPDATE=true
rm -rf tmp
if [ "$OPT_FULL_UPDATE" = "true" ]; then
rm -rf feeds/luci.tmp
rm -rf feeds/packages.tmp
#rm -rf feeds
#rm -rf package/feeds
rm -rf staging_dir/packages
rm -rf $XADDONSDIR
fi
git reset --hard HEAD
git fetch
[ "$?" != "0" ] && die "Can't fetch current repository"
git pull --force "origin" &> /dev/null
#[ "$?" != "0" ] && die "Can't pull current repository"
CUR_BRANCH=$( git rev-parse --abbrev-ref HEAD )
git reset --hard origin/$CUR_BRANCH
[ "$?" != "0" ] && die "Can't reset current repository"
rm -f feeds.conf
cp -f feeds.conf.default feeds.conf
feed_lst=$( get_cfg_feed_lst "$ADDONSCFG" )
for feed in $feed_lst; do
value=$( get_cfg_feed_url "$ADDONSCFG" $feed )
#echo "$feed = '$value'"
echo "src-git $feed $value" >> feeds.conf
done
if [ "$OPT_FULL_UPDATE" = "true" ]; then
./scripts/feeds update -a
./scripts/feeds install -a
fi
CLONE_ADDONS=true
if [ "$CLONE_ADDONS" = "true" ]; then
mkdir $XADDONSDIR
pkg_lst=$( get_cfg_expkg_lst "$ADDONSCFG" )
for pkg in $pkg_lst; do
value=$( get_cfg_expkg_url "$ADDONSCFG" $pkg )
#echo "$pkg = '$value'"
url=$( echo "$value" | cut -d " " -f 1 )
branch=$( echo "$value" | cut -d " " -f 2 )
#echo "'$url' / '$branch'"
if [ ! -d "$XADDONSDIR/$pkg" ]; then
git clone $url -b $branch $XADDONSDIR/$pkg
[ "$?" != "0" ] && die "Can't clone repository '$url'"
fi
done
if [ "$OPT_FULL_UPDATE" = "true" ]; then
./scripts/feeds install -a
fi
fi
if [ "$OPT_FULL_UPDATE" = "true" ]; then
if [ -f "$XDIR/vermagic_update.sh" ]; then
./vermagic_update.sh ipq806x generic
./vermagic_update.sh ramips mt7621
./vermagic_update.sh mediatek mt7622
fi
fi
if [ -f "$XDIR/luci_dispatcher.sh" ]; then
./luci_dispatcher.sh
fi
echo "All git sources updated!"