Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100755 120 lines (101 sloc) 3.48 kb
cc6df46 Greg Kroah-Hartman added check_package
authored
1 #!/bin/bash
2
3 # A script to help manage the openSUSE:Tumbleweed project
4 # (C) 2010 Greg Kroah-Hartman <gregkh@suse.de>
5 # Released under the GPL v2.
6 #
11881ec Greg Kroah-Hartman fix scripts to handle packages that are not in the repo better
authored
7 # This script checks the links that are set up for a single Tumbleweed package.
8 # Tumbleweed works either by having packages submitted to it, or by linking to
9 # a "known stable" repository in the build service. This script checks the
10 # repo and package name requested on the command line and verifies that they
11 # are up to date. If they are not up to date, the proper 'osc' command is
12 # printed to output to be run by hand if necessary.
cc6df46 Greg Kroah-Hartman added check_package
authored
13 #
11881ec Greg Kroah-Hartman fix scripts to handle packages that are not in the repo better
authored
14 # If the package is not in the Tumbleweed repo, the proper 'osc' command
15 # to add it is printed out if you wish to run it.
cc6df46 Greg Kroah-Hartman added check_package
authored
16 #
17 # Any questions/comments/patches are gladly welcome, just send to:
18 # Greg Kroah-Hartman <gregkh@suse.de>
19 #
20
05f9652 check_package*: support overriding osc API
Jiri Slaby authored
21 OSC_API="https://api.opensuse.org"
22
a928629 check_package*: allow prepending to REPO
Jiri Slaby authored
23 PREPEND=""
24
cc6df46 Greg Kroah-Hartman added check_package
authored
25 # Main Tumbleweed repository location
26 TUMBLE_REPO="openSUSE:Tumbleweed"
27
c17674a Greg Kroah-Hartman check_package: add repo command line options
authored
28 # some other repos we like to use for stuff
29 TESTING_REPO="openSUSE:Tumbleweed:Testing"
30 GNOME_REPO="openSUSE:Tumbleweed:GNOME"
31 KDE_REPO="openSUSE:Tumbleweed:KDE"
cdbd418 added xfce repo
Greg KH authored
32 XFCE_REPO="openSUSE:Tumbleweed:xfce"
5f08cc8 Greg Kroah-Hartman check_package(s): add libreoffice subproject
authored
33 LIBREOFFICE_REPO="openSUSE:Tumbleweed:Libreoffice"
cc6df46 Greg Kroah-Hartman added check_package
authored
34
35 # expects:
36 # $PACKAGE to be set to the package name to be checked
37 # $REPO to be set to the base repo name
38 compare_version() {
39
05f9652 check_package*: support overriding osc API
Jiri Slaby authored
40 # BASE_LINK=`osc -A "$OSC_API" log --csv $REPO/$PACKAGE 2> /dev/null | head -n 1 | cut -f 4 -d '|'`
41 BASE_LINK=`osc -A "$OSC_API" api /source/${REPO}/${PACKAGE}?expand=1 | sed -n 's@^.*directory.*srcmd5="\([0-9a-f]*\)".*$@\1@ p'`
bc291bf Greg Kroah-Hartman check_package: use the source link instead for packages
authored
42 #echo $BASE_LINK
cc6df46 Greg Kroah-Hartman added check_package
authored
43
139ec24 Greg Kroah-Hartman check_package: handle when projects are not present or are not links
authored
44 if [ "$BASE_LINK" = "" ]
45 then
b966f04 Greg Kroah-Hartman check_package: proper comment the "There is no package" line
authored
46 echo "# There is no such package as $REPO/$PACKAGE."
139ec24 Greg Kroah-Hartman check_package: handle when projects are not present or are not links
authored
47 exit 1
48 fi
cc6df46 Greg Kroah-Hartman added check_package
authored
49
05f9652 check_package*: support overriding osc API
Jiri Slaby authored
50 #TUMBLE_LINK=`osc -A "$OSC_API" 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'`
51 TUMBLE_LINK=`osc -A "$OSC_API" cat $TUMBLE_REPO/$PACKAGE/_link 2> /dev/null | sed -n 's@^.*package.*rev="\([0-9a-f]*\)".*$@\1@ p'`
9b511c6 Greg Kroah-Hartman speed up check_package by about a second per call for the common case.
authored
52 #echo $TUMBLE_LINK
53 if [ "$TUMBLE_LINK" = "" ]
11881ec Greg Kroah-Hartman fix scripts to handle packages that are not in the repo better
authored
54 then
05f9652 check_package*: support overriding osc API
Jiri Slaby authored
55 EXIST=`osc -A "$OSC_API" ls $TUMBLE_REPO | grep "^${PACKAGE}$"`
9b511c6 Greg Kroah-Hartman speed up check_package by about a second per call for the common case.
authored
56 if [ "$EXIST" = "" ]
139ec24 Greg Kroah-Hartman check_package: handle when projects are not present or are not links
authored
57 then
9b511c6 Greg Kroah-Hartman speed up check_package by about a second per call for the common case.
authored
58 echo "# $PACKAGE is not in $TUMBLE_REPO, add it by doing:"
05f9652 check_package*: support overriding osc API
Jiri Slaby authored
59 echo "osc -A "$OSC_API" linkpac -f -r $BASE_LINK $REPO $PACKAGE $TUMBLE_REPO"
9b511c6 Greg Kroah-Hartman speed up check_package by about a second per call for the common case.
authored
60 else
61 echo "# $PACKAGE is not a linked package in $TUMBLE_REPO, to overwrite the link, do:"
139ec24 Greg Kroah-Hartman check_package: handle when projects are not present or are not links
authored
62 fi
11881ec Greg Kroah-Hartman fix scripts to handle packages that are not in the repo better
authored
63 fi
64
139ec24 Greg Kroah-Hartman check_package: handle when projects are not present or are not links
authored
65 if [ "$BASE_LINK" = "$TUMBLE_LINK" ]
cc6df46 Greg Kroah-Hartman added check_package
authored
66 then
67 echo "# $PACKAGE is up to date."
68 else
05f9652 check_package*: support overriding osc API
Jiri Slaby authored
69 #echo "osc -A "$OSC_API" linkpac -f -r $BASE_LINK $REPO $PACKAGE $TUMBLE_REPO"
70 echo "osc -A "$OSC_API" setlinkrev -r $BASE_LINK $TUMBLE_REPO $PACKAGE"
cc6df46 Greg Kroah-Hartman added check_package
authored
71 fi
72 }
73
c17674a Greg Kroah-Hartman check_package: add repo command line options
authored
74
75 #FULL_PACKAGE=$1
76
77 if [ $# -lt 1 ]; then
cc6df46 Greg Kroah-Hartman added check_package
authored
78 echo -e "Usage:\t $0 repo/packagename\ne.g.\t $0 Kernel:stable/kernel-source"
79 exit 1
80 fi
81
c17674a Greg Kroah-Hartman check_package: add repo command line options
authored
82 while [ "$1" != "" ]; do
83 case $1 in
84 --repo ) shift
85 TUMBLE_REPO=$1
86 ;;
87 --kde ) TUMBLE_REPO=$KDE_REPO
88 ;;
89 --gnome ) TUMBLE_REPO=$GNOME_REPO
90 ;;
cdbd418 added xfce repo
Greg KH authored
91 --xfce ) TUMBLE_REPO=$XFCE_REPO
92 ;;
c17674a Greg Kroah-Hartman check_package: add repo command line options
authored
93 --testing ) TUMBLE_REPO=$TESTING_REPO
94 ;;
5f08cc8 Greg Kroah-Hartman check_package(s): add libreoffice subproject
authored
95 --libreoffice ) TUMBLE_REPO=$LIBREOFFICE_REPO
96 ;;
05f9652 check_package*: support overriding osc API
Jiri Slaby authored
97 --api ) shift
98 OSC_API="$1"
99 ;;
a928629 check_package*: allow prepending to REPO
Jiri Slaby authored
100 --prepend ) shift
101 PREPEND="$1"
102 ;;
c17674a Greg Kroah-Hartman check_package: add repo command line options
authored
103 * ) FULL_PACKAGE=$1
104 ;;
105 esac
106 shift
107 done
108
109 #echo "# TUMBLE_REPO = '$TUMBLE_REPO'"
110 #echo "# FULL_PACKAGE = '$FULL_PACKAGE'"
cc6df46 Greg Kroah-Hartman added check_package
authored
111
112
113 # I'm sure that bash regex can do this better, but hey, this works...
a928629 check_package*: allow prepending to REPO
Jiri Slaby authored
114 REPO=$PREPEND`echo $FULL_PACKAGE | cut -f 1 -d '/'`
cc6df46 Greg Kroah-Hartman added check_package
authored
115 PACKAGE=`echo $FULL_PACKAGE | cut -f 2 -d '/'`
116 #echo $REPO
117 #echo $PACKAGE
118
119 compare_version
Something went wrong with that request. Please try again.