-
Notifications
You must be signed in to change notification settings - Fork 0
/
smartbuildtmprpm
executable file
·57 lines (48 loc) · 1.53 KB
/
smartbuildtmprpm
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
#! /usr/bin/perl
#
# Checks out required revision from GIT (current directory) into temporary directory
# and:
# 1) Create temporaray version commit (new version) locally only
# 2) Build new RPM
#
# Can be for example be used for creating temporary builds for staging repo
#
# Examples:
#
# ./smartbuildtmprpm
# package top in current directory, use currently checked out revision
#
# ./smartbuildtmprpm FOO
# package top in current directory, use revision FOO (for example tag FOO)
#
# ./smartbuildtmprpm FOO BAR
# package top in directory BAR, use revision FOO (for example tag FOO)
#
use strict;
use File::Temp qw/tempdir/;
my $rev = "HEAD";
my $top_opt = ".";
if ($#ARGV == 0) {
$rev = $ARGV[0];
} elsif ($#ARGV == 1) {
$top_opt = "-C $ARGV[1]"
} elsif ($#ARGV > 1) {
die "No more than one argument expected";
}
my $build_top = tempdir(CLEANUP => 1);
my $build_dir = $build_top;
print("Build directory: $build_dir\n");
my $cmd = "git clone $top_opt $build_top";
print "Running: $cmd\n";
system($cmd) == 0 or die "Failed to run $cmd: $!";
unlink("$build_top/__source__.tar");
system("git -C $build_dir checkout $rev") == 0 or die "Failed to check out revision $rev";
my $rev_info=`git -C $build_dir show-ref $rev`;
chomp $rev_info;
my $msg = "Test version (GIT revision $rev_info)";
print "rev_info=$rev_info\n";
my $cmd = "( cd $build_dir && smartmkrelease \"$msg\" )";
system($cmd);
$cmd = "make -C $build_dir rpm";
print "Running: $cmd\n";
system($cmd) == 0 or die "Failed to build RPM package for revision $rev";