1 |
commit: 6962c13ed198140830fac97d818f0df22adff2c8 |
2 |
Author: mudler <mudler <AT> sabayon <DOT> org> |
3 |
AuthorDate: Thu Oct 13 20:20:07 2016 +0000 |
4 |
Commit: Ettore Di Giacinto <mudler <AT> sabayonlinux <DOT> org> |
5 |
CommitDate: Thu Oct 13 20:20:07 2016 +0000 |
6 |
URL: https://gitweb.gentoo.org/proj/gentoo-mate.git/commit/?id=6962c13e |
7 |
|
8 |
scripts: add keyword-mate script to automatically handle gentoo-mate stabilization processes |
9 |
|
10 |
scripts/bin/keyword-mate | 63 ++++++++++++++++++++++++++++++++++++++++++++++++ |
11 |
1 file changed, 63 insertions(+) |
12 |
|
13 |
diff --git a/scripts/bin/keyword-mate b/scripts/bin/keyword-mate |
14 |
new file mode 100755 |
15 |
index 0000000..43a2f29 |
16 |
--- /dev/null |
17 |
+++ b/scripts/bin/keyword-mate |
18 |
@@ -0,0 +1,63 @@ |
19 |
+#!/usr/bin/perl |
20 |
+# keyword-mate - utility to generate package lists, |
21 |
+# used also to call keyword-helper automatically to handle stabilizations. |
22 |
+# Given a list of packages in input and a MAJOR_VERSION, |
23 |
+# it returns the minimum version of the package if there are more ebuilds with the same MAJOR_VERSION |
24 |
+# Usage: from the root of the overlay |
25 |
+# MAJOR_VERSION=1.12 keyword-mate mate-base/mate |
26 |
+# <mudler@×××××××.org> |
27 |
+ |
28 |
+my @PKGLIST = @ARGV; |
29 |
+my $MAJOR_V = $ENV{MAJOR_VERSION}; |
30 |
+my $EXCLUSION_LIST = $ENV{EXCLUSION_LIST}; |
31 |
+my $AUTO = $ENV{AUTO} // 0; |
32 |
+my $LOCAL_MATCH = $ENV{LOCAL_MATCH} // "min"; |
33 |
+ |
34 |
+sub natural_order { |
35 |
+ my @a = @_; |
36 |
+ return @a[ |
37 |
+ map { unpack "N", substr( $_, -4 ) } |
38 |
+ sort |
39 |
+ map { |
40 |
+ my $key = $a[$_]; |
41 |
+ $key =~ s[(\d+)][ pack "N", $1 ]ge; |
42 |
+ $key . pack "CNN", 0, 0, $_ |
43 |
+ } 0 .. $#a |
44 |
+ ]; |
45 |
+} |
46 |
+ |
47 |
+print |
48 |
+ "You are running me from the wrong folder, don't you?\nI need to be executed from the root of the overlay!\n" |
49 |
+ and exit 1 |
50 |
+ if ( -e "Manifest" ); |
51 |
+ |
52 |
+print |
53 |
+ "I need a MAJOR_VERSION as environment variable, otherwise i can't find the local minimum among the ebuilds\n" |
54 |
+ and exit 1 |
55 |
+ if ( !$MAJOR_V ); |
56 |
+ |
57 |
+if ( !@ARGV or $ARGV[0] eq "-h" or $ARGV[0] eq "--help" ) { |
58 |
+ print "You must feed me with at least a package, without version!\n\n"; |
59 |
+ print "e.g. $0 package package1 package2\n\n"; |
60 |
+ print "ENV variables options:\n"; |
61 |
+ print " MAJOR_V \t Major version to check\n"; |
62 |
+ print " AUTO \t Automatically calls keyword-helper\n"; |
63 |
+ print " EXCLUSION_LIST \t Supply an list of packages to be excluded\n"; |
64 |
+ print " LOCAL_MATCH \t Can be 'min' or 'max', indicates local minimum or maximum\n"; |
65 |
+ |
66 |
+ exit 1; |
67 |
+} |
68 |
+ |
69 |
+for (@PKGLIST) { |
70 |
+ next if $EXCLUSION_LIST =~ /$_/; |
71 |
+ exit 1 unless -d $_; |
72 |
+ my @EBUILDS = <$_/*.ebuild>; |
73 |
+ my $wanted_version = ( natural_order( grep {/$MAJOR_V/} @EBUILDS ) ) |
74 |
+ [ $LOCAL_MATCH eq "max" ? -1 : 0 ]; |
75 |
+ my $package = ( $wanted_version =~ /(.*)\.ebuild/ )[0]; |
76 |
+ my @path = split( /\//, $package ); |
77 |
+ next unless @path > 0; |
78 |
+ $package = $path[0] . "/" . $path[2]; |
79 |
+ print "$package\n"; |
80 |
+ system("./scripts/bin/keyword-helper $package") if ( $AUTO == 1 ); |
81 |
+} |