-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy path.functions.subr
90 lines (75 loc) · 1.96 KB
/
.functions.subr
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
# Sanity checks
#
if [ `id -u` -eq 0 ]; then
echo "Please do not run this as root. Use the 'mirror' user."
exit -1
fi
# Create lockfile
#
create_lock() {
LOCK=/var/lock/`basename $0`.lock
if ! lockfile -l 14400 -r 0 $LOCK; then
echo "Another process is already running. Aborting."
exit 1
fi
}
# Remove lockfile
#
remove_lock() {
rm -f $LOCK
}
# Create filter rules from the VERSIONS config variable. Follows the
# OpenSuSE repositories semantics.
#
create_filter_suse() {
FILTER=`mktemp`
_filter="include update/\ninclude distribution/\ninclude leap/\n"
for ver in $VERSIONS; do
_filter="${_filter}include update/${ver}\n"
_filter="${_filter}exclude update/${ver}/*_debug\n"
_filter="${_filter}include update/${ver}/**\n"
_filter="${_filter}include distribution/${ver}\n"
_filter="${_filter}include distribution/${ver}/repo\n"
_filter="${_filter}include distribution/${ver}/repo/**\n"
done
echo -ne $_filter > $FILTER
}
# Create filter rules from the VERSIONS config variable. Follows the
# Percona repositories semantics.
#
create_filter_percona() {
FILTER=`mktemp`
_filter="include PERCONA-PACKAGING-KEY\ninclude RPM-GPG-KEY-Percona\ninclude release\n"
for ver in $VERSIONS; do
_filter="${_filter}include release/${ver}\n"
_filter="${_filter}include release/${ver}*\n"
_filter="${_filter}exclude release/${ver}/SRPMS\n"
_filter="${_filter}exclude *MongoDB*\n"
_filter="${_filter}include release/${ver}/**\n"
done
echo -ne $_filter > $FILTER
}
# Remove the filter temp file
#
remove_filter() {
[ -n "$FILTER" ] && rm -f $FILTER
}
# Housekeeping
#
_cleanup() {
remove_lock
remove_filter
}
trap '_cleanup' 'EXIT'
# Update URIs in .repo files with $LOCAL_HOST
#
replace_repo_uris() {
find $1 -name \*.repo -user $LOGNAME -print0 | \
xargs -0 sed -Ei "s#https?://download.opensuse.org/#https://$LOCAL_HOST/#"
}
# Path to rsync binary
#
RSYNC=/usr/bin/rsync
# Path to wget binary
#
WGET=/usr/bin/wget