-
Notifications
You must be signed in to change notification settings - Fork 1
/
check_package
executable file
·74 lines (61 loc) · 2.11 KB
/
check_package
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
#!/bin/bash
# A script to help manage the openSUSE:Tumbleweed project
# (C) 2010 Greg Kroah-Hartman <gregkh@suse.de>
# Released under the GPL v2.
#
# This script checks the links that are set up for a single Tumbleweed package.
# Tumbleweed works either by having packages submitted to it, or by linking to
# a "known stable" repository in the build service. This script checks the
# repo and package name requested on the command line and verifies that they
# are up to date. If they are not up to date, the proper 'osc' command is
# printed to output to be run by hand if necessary.
#
# If the package is not in the Tumbleweed repo, the proper 'osc' command
# to add it is printed out if you wish to run it.
#
# Any questions/comments/patches are gladly welcome, just send to:
# Greg Kroah-Hartman <gregkh@suse.de>
#
# Main Tumbleweed repository location
TUMBLE_REPO="openSUSE:Tumbleweed"
# expects:
# $PACKAGE to be set to the package name to be checked
# $REPO to be set to the base repo name
compare_version() {
BASE_LINK=`osc log --csv $REPO/$PACKAGE 2> /dev/null | head -n 1 | cut -f 4 -d '|'`
#echo $BASE_LINK
if [ "$BASE_LINK" = "" ]
then
echo "There is no such package as $REPO/$PACKAGE."
exit 1
fi
EXIST=`osc ls $TUMBLE_REPO | grep $PACKAGE`
if [ "$EXIST" = "" ]
then
echo "# $PACKAGE is not in Tumbleweed, add it by doing:"
else
TUMBLE_LINK=`osc cat $TUMBLE_REPO/$PACKAGE/_link 2> /dev/null | grep rev | cut -f 4 -d ' ' | cut -f 2 -d '=' | cut -f 1 -d '=' | sed -e 's/\"//g'`
#echo $TUMBLE_LINK
if [ "$TUMBLE_LINK" = "" ]
then
echo "# $PACKAGE is not a linked package in Tumbleweed, to overwrite the link, do:"
fi
fi
if [ "$BASE_LINK" = "$TUMBLE_LINK" ]
then
echo "# $PACKAGE is up to date."
else
echo "osc linkpac -f -r $BASE_LINK $REPO $PACKAGE $TUMBLE_REPO"
fi
}
if [ $# -ne 1 ]; then
echo -e "Usage:\t $0 repo/packagename\ne.g.\t $0 Kernel:stable/kernel-source"
exit 1
fi
FULL_PACKAGE=$1
# I'm sure that bash regex can do this better, but hey, this works...
REPO=`echo $FULL_PACKAGE | cut -f 1 -d '/'`
PACKAGE=`echo $FULL_PACKAGE | cut -f 2 -d '/'`
#echo $REPO
#echo $PACKAGE
compare_version