-
Notifications
You must be signed in to change notification settings - Fork 2
/
build_common.sh
105 lines (97 loc) · 2.29 KB
/
build_common.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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
f_ssh_rbrepo() {
ssh -q -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no [email protected] "$@"
}
f_rsync_repo() {
local LIST="$@"
rsync -av -e "ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no" ${LIST} [email protected]:/repos/ng/latest/rhel/9/x86_64/
}
f_rsync_repo_SRPMS() {
local LIST="$@"
rsync -av -e "ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no" ${LIST} [email protected]:/repos/ng/latest/rhel/9/SRPMS/
}
f_rsync_iso() {
local LIST="$@"
rsync -av -e "ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no" ${LIST} [email protected]:/isos/ng/latest/rhel/9/x86_64/
}
f_updaterepo() {
local REPODIR=$1
local count ret
echo "Updating repo ${REPODIR}"
count=300
ret=0
while : ;do
if [ ! -e /var/lock/rbrepo_createrepo ]; then
# No lock file, go on
break
else
count=$(($count-1))
if [ $count -eq 0 ]; then
# reached final count
ret=1
break
fi
fi
# waiting 1 second (max 5 minutes)
sleep 1
done
if [ $ret -eq 0 ]; then
# it is time to update repo
touch /var/lock/rbrepo_createrepo
createrepo ${REPODIR}
rm -f /var/lock/rbrepo_createrepo
else
echo "Error updating repo ${REPODIR}"
fi
return $ret
}
f_rupdaterepo() {
local REPODIR=$1
local count ret
echo "Updating repo ${REPODIR}"
count=300
ret=0
while : ;do
f_ssh_rbrepo test -e /var/lock/rbrepo_createrepo
if [ $? -ne 0 ]; then
# No lock file, go on
break
else
count=$(($count-1))
if [ $count -eq 0 ]; then
# reached final count
ret=1
break
fi
fi
# waiting 1 second (max 5 minutes)
sleep 1
done
if [ $ret -eq 0 ]; then
# it is time to update repo
f_ssh_rbrepo touch /var/lock/rbrepo_createrepo
f_ssh_rbrepo createrepo --update ${REPODIR}
f_ssh_rbrepo rm -f /var/lock/rbrepo_createrepo
else
echo "Error updating repo ${REPODIR}"
fi
return $ret
}
f_check() {
# need to check if the packages exist
local list_of_packages="$@"
local create_rpms=0
for package in ${list_of_packages}; do
f_ssh_rbrepo test -e ${package}
if [ $? -eq 0 ]; then
f_ssh_rbrepo file --mime-type -b ${package} | grep -q "application/x-rpm"
if [ $? -ne 0 ]; then
create_rpms=1
break
fi
else
create_rpms=1
break
fi
done
return ${create_rpms}
}