-
Notifications
You must be signed in to change notification settings - Fork 2
/
ifad-private-repo-update
executable file
·42 lines (32 loc) · 1.19 KB
/
ifad-private-repo-update
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
# Check the last modified file in $REPODIR - if it is the repomd.xml file,
# then no changes occurred. Otherwise, run createrepo to regenerate it.
#
# - a.dellaera@ifad.org Fri Dec 12 12:02:00 CET 2013
# - m.barnaba@ifad.org Sun Dec 15 21:32:26 CET 2013
# - m.barnaba@ifad.org Sat Dec 28 21:13:20 CET 2013
# - m.barnaba@ifad.org Thu Jun 21 10:02:13 CEST 2018
REPODIR=/srv/opensuse/repositories/ifad-private
ARCHIVE=_archive
FILELIST=$REPODIR/.filelist
TMPLIST=$REPODIR/.filelist.tmp
if [ -f "$TMPLIST" ]; then
# Another process is running, do not overlap.
echo "RPM update started on `stat -c %y "$TMPLIST"` is not completed yet as of `date --rfc-3339=ns`"
exit 1
fi
touch $TMPLIST
find $REPODIR -name "*.rpm" -not -path "*/$ARCHIVE/*" -type f | sort | tr '\n' '\0' | xargs -0 sha1sum > $TMPLIST
diff=`diff -u $FILELIST $TMPLIST`
if test -n "$diff"; then
echo -e "Updating RPM repository due to file changes.\n"
createrepo --exclude "$ARCHIVE/*" --update $REPODIR
rm $REPODIR/repodata/repomd.xml.asc
gpg -a --detach-sign $REPODIR/repodata/repomd.xml
echo -e "\nChanges:\n$diff"
echo -e "\nCurrent files list:"
cat $TMPLIST
mv $TMPLIST $FILELIST
else
rm $TMPLIST
fi
exit 0