forked from kszaq/LibreELEC.tv
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrepo-tool
executable file
·196 lines (179 loc) · 5.1 KB
/
repo-tool
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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
#!/bin/bash
################################################################################
# This file is part of LibreELEC - https://libreelec.tv
# Copyright (C) 2009-2016 Lukas Rusak ([email protected])
#
# LibreELEC is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.
#
# LibreELEC is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with LibreELEC. If not, see <http://www.gnu.org/licenses/>.
################################################################################
. config/options
update_addons_xml() {
echo "[*] cleanup addons ..."
olddir=""
find target/addons/$ADDON_VERSION -iname 'changelog*.txt' | sort -rV | while read line ; do
dir=$(dirname $line)
if [ "$olddir" = "$dir" ] ; then
rm -f $line
fi
olddir=$dir
done
olddir=""
find target/addons/$ADDON_VERSION -iname '*.zip' | sort -rV | while read line ; do
dir=$(dirname $line)
if [ "$olddir" = "$dir" ] ; then
rm -f $line
fi
olddir=$dir
done
echo "[*] updating addons.xml* ..."
rm -rf .addons
pwd=`pwd`
find target/addons/$ADDON_VERSION -iname addons.xml | while read line ; do
localdir=`echo $line | sed s/addons.xml//g`
echo " [*] updating $line..."
echo '<?xml version="1.0" encoding="UTF-8"?>
<addons>
' > $line.tmp
for zip in $localdir/*/*.zip ; do
mkdir -p ".addons/$localdir"
unzip $zip "*/addon.xml" -d ".addons/$localdir" &>/dev/null
done
find .addons/$localdir -iname addon.xml | grep -v resources/ | while read xml ; do
cat $xml | grep -v "<?" >> $line.tmp
done
echo '
</addons>' >> $line.tmp
mv $line.tmp $line
cd $localdir
md5sum addons.xml > addons.xml.md5
cd $pwd
done
rm -rf .addons
}
touch_addons_xml() {
for PROJECT in $(ls -1 projects); do
for archfile in projects/$PROJECT/linux/linux.*.conf ; do
ARCH=`echo $archfile | sed -n '$s/\.conf//;$s/.*\.//p'`
if [ ! -d target/addons/$ADDON_VERSION/$PROJECT/$ARCH ]; then
break
fi
if [ ! -f target/addons/$ADDON_VERSION/$PROJECT/$ARCH/addons.xml ]; then
touch target/addons/$ADDON_VERSION/$PROJECT/$ARCH/addons.xml
fi
done
done
}
upload() {
if [ -f .work/repoconfig ] ; then
. .work/repoconfig
fi
if [ -z "$RSYNC_REPO" ] ; then
echo "*** ERROR: \$RSYNC_REPO not set. see .work/repoconfig ***"
exit 0
fi
touch_addons_xml
update_addons_xml
rsync -av --progress --delete target/addons/$ADDON_VERSION $RSYNC_REPO
}
build() {
for PROJECT in $2; do
for archfile in projects/$PROJECT/linux/linux.*.conf ; do
ARCH=`echo $archfile | sed -n '$s/\.conf//;$s/.*\.//p'`
for package in $(find $1 -iname package.mk) ; do
(
. $package
if [ "$PKG_IS_ADDON" = "yes" ] ; then
ADDON=$PKG_NAME
PROJECT=$PROJECT ARCH=$ARCH ./scripts/create_addon $ADDON
fi
)
done
done
done
}
update_revision() {
for package in $(find packages/addons -iname package.mk) ; do
(
. $package
if [ "$PKG_IS_ADDON" = "yes" ] ; then
sed -i -e "s|PKG_REV=.*|PKG_REV=\"$((PKG_REV+1))\"|" $package
fi
)
done
}
update_repo_version() {
for package in $(find packages/addons -iname package.mk) ; do
(
. $package
if [ "$PKG_IS_ADDON" = "yes" ] ; then
sed -i -e "s|PKG_ADDON_REPOVERSION=.*|PKG_ADDON_REPOVERSION=\"$ADDON_VERSION\"|" $package
sed -i -e "s|PKG_REV=.*|PKG_REV=\"100\"|" $package
changelog="$(echo $package | sed 's/package.mk/changelog.txt/')"
sed -i "1i${ADDON_VERSION}.100\n- Update for LibreELEC ${ADDON_VERSION}\n" $changelog
fi
)
done
}
usage() {
echo " usage: $0 -u to upload"
echo " $0 -b binary|official|all [project-name] to build [for a single project]"
echo " $0 -ru to update PKG_REV"
echo " $0 -rv to update PKG_ADDON_REPOVERSION"
echo " $0 -xml to update the addons.xml"
}
if [ "$1" = "-b" -a -z "$2" ]; then
usage
exit 0
elif [ "$1" = "-b" -a -n "$2" ]; then
case $2 in
binary)
repo="packages/mediacenter/kodi-binary-addons"
;;
official)
repo="packages/addons"
;;
all)
repo="packages/addons packages/mediacenter/kodi-binary-addons"
;;
*)
usage
exit 0
;;
esac
project="$(ls -1 projects)"
if [ -n "$3" ]; then
project="$3"
fi
fi
case $1 in
-b)
build "$repo" "$project"
;;
-u)
upload
;;
-ru)
update_revision
;;
-rv)
update_repo_version
;;
-xml)
touch_addons_xml
update_addons_xml
;;
*)
usage
exit 0
;;
esac