public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
* [gentoo-commits] proj/gentoo-mate:1.18-bump commit in: scripts/bin/
@ 2017-03-15 14:17 Ettore Di Giacinto
  0 siblings, 0 replies; only message in thread
From: Ettore Di Giacinto @ 2017-03-15 14:17 UTC (permalink / raw
  To: gentoo-commits

commit:     d7c42726a371b3c60d7e0075015ae162e615d6ce
Author:     Ettore Di Giacinto <mudler <AT> gentoo <DOT> org>
AuthorDate: Wed Mar 15 14:14:15 2017 +0000
Commit:     Ettore Di Giacinto <mudler <AT> gentoo <DOT> org>
CommitDate: Wed Mar 15 14:14:15 2017 +0000
URL:        https://gitweb.gentoo.org/proj/gentoo-mate.git/commit/?id=d7c42726

scripts: add version_bump helper script

 scripts/bin/version_bump | 104 +++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 104 insertions(+)

diff --git a/scripts/bin/version_bump b/scripts/bin/version_bump
new file mode 100755
index 0000000..f6d046d
--- /dev/null
+++ b/scripts/bin/version_bump
@@ -0,0 +1,104 @@
+#!/usr/bin/perl
+# version-bump - utility to bump a set of packages from their -9999 version.
+# Usage: from the root of the overlay
+# version-bump version input_file.txt
+# <mudler@gentoo.org>
+
+use Cwd;
+
+my $VERSION       = $ARGV[0];           # Version to bump to
+my $PACKAGES_LIST = $ARGV[1];
+my $COMMIT_MSG    = $ENV{COMMIT_MSG};
+my $BUGZ          = $ENV{BUGZ};
+
+my $CWD = getcwd;
+my @FAILED;
+
+# print helpers
+
+sub say { print join( "\n", @_ ) . "\n"; }
+
+sub err { say "\e[31m@_ \e[0m"; }
+
+sub fatal { err @_; exit 1; }
+
+sub ok { say "\e[1;34m@_ \e[0m"; }
+
+sub info { say "\e[1;37m@_ \e[0m"; }
+
+# deadly checks
+
+if ( !@ARGV or $VERSION eq "-h" or $VERSION eq "--help" or !$PACKAGES_LIST ) {
+    say "You must feed me with at least a package version", "",
+        "e.g. $0 package",        "",
+        "ENV variables options:", "",
+        " COMMIT_MSG \t\t default commit message",
+        " BUGZ \t\t Gentoo Bugzilla id, if any e.g. 596998",
+        exit 1;
+}
+
+if ( -e "${CWD}/Manifest" ) {
+    fatal "You are running me from the wrong folder, don't you?",
+        "I need to be executed from the root of the overlay!";
+}
+
+open FILE, "<$PACKAGES_LIST" or fatal "Can't open $PACKAGES_LIST : $!";
+my @LIST = <FILE>;
+close FILE;
+chomp(@LIST);
+
+# Cycle packages that need to be manipulated
+# Here it's being used $_, that contains strings in the following format:  category/package
+for (@LIST) {
+    my ( $current_cat, $current_package ) = /(.?)\/(.*)$/;
+    my $local_package = $current_package . "-" . $VERSION . ".ebuild";
+    my $live_package  = $current_package . "-9999" . ".ebuild";
+    info "===" x 16, "\nBumping $local_package from $live_package";
+    if ( -d $_ ) {
+        chdir($_);    # entering in the directory
+    }
+    else {
+        fatal "$_ directory doesn't exists";
+    }
+
+    # Checking if ebuild we want to keyword is there
+    if ( !-e $local_package ) {
+        info("Inside -> $CWD/$_");
+        system("cp -rfv $live_package $local_package");
+        system("ebuild $local_package digest");
+
+        my $LOCAL_COMMIT_MSG = $COMMIT_MSG;
+
+        # if no COMMIT_MSG is supplied, we generate it
+        if ( !$COMMIT_MSG ) {
+            $LOCAL_COMMIT_MSG = "Version bump to $VERSION";
+            $LOCAL_COMMIT_MSG .= " bug \#${BUGZ}" if $BUGZ;
+        }
+
+        system("git add $local_package");
+        system("git add Manifest");
+        system("repoman commit -m '$_: $LOCAL_COMMIT_MSG'");
+        if ( $? >> 8 != 0 ) {
+            fatal
+                "Meh. we got errors. before going on, i want you to fix those by hand.";
+            push( @FAILED, $local_package );
+        }
+        else {
+            ok "Done for $_ [$local_package]";
+        }
+    }
+
+    else {
+        # errors, the ebuild cannot be found
+            err "/!\\ $local_package found in $_, operation failed!";
+        push( @FAILED, $local_package );
+    }
+    chdir($CWD);
+}
+
+info "Finished";
+
+if ( @FAILED > 0 ) {
+        err "Operation failed for the following ebuilds:";
+    say "> " . $_ for @FAILED;
+}


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2017-03-15 14:17 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-03-15 14:17 [gentoo-commits] proj/gentoo-mate:1.18-bump commit in: scripts/bin/ Ettore Di Giacinto

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox