-
Notifications
You must be signed in to change notification settings - Fork 1
/
check_package
executable file
·102 lines (86 loc) · 2.68 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
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
#!/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"
# some other repos we like to use for stuff
TESTING_REPO="openSUSE:Tumbleweed:Testing"
GNOME_REPO="openSUSE:Tumbleweed:GNOME"
KDE_REPO="openSUSE:Tumbleweed:KDE"
XFCE_REPO="openSUSE:Tumbleweed:xfce"
# 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
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
EXIST=`osc ls $TUMBLE_REPO | grep $PACKAGE`
if [ "$EXIST" = "" ]
then
echo "# $PACKAGE is not in $TUMBLE_REPO, add it by doing:"
else
echo "# $PACKAGE is not a linked package in $TUMBLE_REPO, 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
}
#FULL_PACKAGE=$1
if [ $# -lt 1 ]; then
echo -e "Usage:\t $0 repo/packagename\ne.g.\t $0 Kernel:stable/kernel-source"
exit 1
fi
while [ "$1" != "" ]; do
case $1 in
--repo ) shift
TUMBLE_REPO=$1
;;
--kde ) TUMBLE_REPO=$KDE_REPO
;;
--gnome ) TUMBLE_REPO=$GNOME_REPO
;;
--xfce ) TUMBLE_REPO=$XFCE_REPO
;;
--testing ) TUMBLE_REPO=$TESTING_REPO
;;
* ) FULL_PACKAGE=$1
;;
esac
shift
done
#echo "# TUMBLE_REPO = '$TUMBLE_REPO'"
#echo "# FULL_PACKAGE = '$FULL_PACKAGE'"
# 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