-
Notifications
You must be signed in to change notification settings - Fork 24
/
update_packages.sh
executable file
·61 lines (51 loc) · 1.79 KB
/
update_packages.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
#!/bin/bash
set +e
ensure_program() {
package=${2:-$1}
if ! (program_exists "$1"); then
echo "$1 is not installed - you can install it with"
echo "sudo yum install $package"
exit 1
fi
}
program_exists() {
which "$@" &> /dev/null
}
ensure_program rpmspec rpm-build
bump_spec() {
#Set pkg with the 1st argument from cli
pkg=$1
#Set NEW_VERSION with the 2nd argument from cli
NEW_VERSION=$2
NEW_VR=$NEW_VERSION
#Set the Spec path with the pkg name
SPEC_FILE="packages/python-$pkg/python-$pkg.spec"
# Store the packaged version of the lib
rpm_version=$(rpmspec -q --queryformat='%{version}' packages/python-"$pkg"/python-"$pkg".spec --srpm)
# Diff the new version and the packaged version
rpmdev-vercmp "$rpm_version" "$NEW_VERSION"
# Stores the exit_code from vercmp
exit_code=$?
if [ 12 -eq $exit_code ];
then
echo "RPM for Package $pkg needs to be updated from $rpm_version to $NEW_VERSION"
TARBALL_TO_REMOVE=$(spectool --list-files "$SPEC_FILE" | cut -d' ' -f2 | grep http | xargs --no-run-if-empty -n 1 basename)
git rm packages/python-"$pkg"/"$TARBALL_TO_REMOVE"
rpmdev-bumpspec --comment "- Update to ${NEW_VERSION}" --new "${NEW_VR}" "$SPEC_FILE"
git add "$SPEC_FILE"
spectool --get-files "$SPEC_FILE" -C packages/python-"$pkg"
TARBALL_ADDED=$(spectool --list-files "$SPEC_FILE" | cut -d' ' -f2 | grep http | xargs --no-run-if-empty -n 1 basename)
git annex add packages/python-"$pkg"/"$TARBALL_ADDED"
fi
if [ 0 -eq $exit_code ];
then
echo "Package $pkg version is the same as the packaged RPM"
exit 0
fi
if [ 11 -eq $exit_code ];
then
echo "Packaged $pkg RPM is newer than version in requirements"
exit 0
fi
}
bump_spec "$@"