-
Notifications
You must be signed in to change notification settings - Fork 5
/
releng-rpm
executable file
·130 lines (100 loc) · 3.84 KB
/
releng-rpm
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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
#!/usr/bin/env perl
#
# Cisco libfabric package builder script for release engineering
#
# This script makes RPMs, and understands the following OSs:
# RHEL 6.x, 7.x
# SLES 12.x
#
use strict;
use warnings;
use Cwd;
use File::Basename;
use Data::Dumper;
use Getopt::Long;
# Load the common functionality
use lib dirname($0);
use Cisco::usnic_releng_common;
use Cisco::libusnic_verbs_noop;
#--------------------------------------------------------------------------
# Simplification for use below
sub do_command {
Cisco::usnic_releng_common::do_command(@_);
}
#--------------------------------------------------------------------------
Cisco::libusnic_verbs_noop::sanity_check();
my $data = Cisco::libusnic_verbs_noop::parse_argv();
my $start_dir = getcwd();
# Values from files
my $git_id = Cisco::libusnic_verbs_noop::read_upstream_version("UPSTREAM_VERSION");
my ($cisco_version, $cisco_build_id) =
Cisco::libusnic_verbs_noop::read_cisco_version("version.sh");
my $distro = Cisco::usnic_releng_common::find_distro();
Cisco::libusnic_verbs_noop::update_git($git_id);
Cisco::libusnic_verbs_noop::make_tarball($cisco_version,
"libusnic_verbs.spec.in");
#--------------------------------------------------------------------------
# Apply local patches
Cisco::usnic_releng_common::apply_local_patches("../patches");
#--------------------------------------------------------------------------
# Don't let rpmbuild complain about rpaths. rpmbuild on releng
# machines seems to complain about rpaths to absolute directories that
# don't exist during the rpmbuild process (!), such as
# /opt/cisco/openmpi/lib. This seems like a broken check, because
# installing the RPM will create these directories. It feels like
# their check is targeted towards checking against library directories
# that should already exists (e.g., /usr/lib).
$ENV{QA_RPATHS} = "0xffff";
#--------------------------------------------------------------------------
# Make our own $HOME/.rpmmacros file.
print "=== Creating RPMS:\n";
print "*** Making $ENV{HOME}/.rpmmacros\n";
# Make $rpmbuilddir tree if it doesn't already exist
my $rpmbuilddir = "$start_dir/rpmbuild";
do_command("rm -rf $rpmbuilddir");
print "*** Making $rpmbuilddir tree\n";
mkdir("$rpmbuilddir");
mkdir("$rpmbuilddir/BUILD");
mkdir("$rpmbuilddir/BUILDROOT");
mkdir("$rpmbuilddir/RPMS");
mkdir("$rpmbuilddir/SOURCES");
mkdir("$rpmbuilddir/SPECS");
mkdir("$rpmbuilddir/SRPMS");
# Copy the files to the right places
do_command("cp libusnic_verbs-$cisco_version.tar.bz2 $rpmbuilddir/SOURCES");
do_command("cp libusnic_verbs.spec $rpmbuilddir/SPECS/libusnic_verbs.spec");
#------------------------------------------------------------------------
# Build the SRPM
my $rpmbuild_options;
print " = Building SRPM\n";
$rpmbuild_options =
'--define "_topdir ' . $rpmbuilddir . '" ' .
'--define "_vendorinfo Cisco Systems, Inc." ' .
'--define "_packager Cisco Systems, Inc." ' .
'--define "_distribution www.cisco.com"';
do_command("rpmbuild $rpmbuild_options -bs $rpmbuilddir/SPECS/libusnic_verbs.spec",
"rpmbuild-bs");
# Build the RPM
print " = Building RPM\n";
do_command("rpmbuild $rpmbuild_options -bb $rpmbuilddir/SPECS/libusnic_verbs.spec",
"rpmbuild-bb");
# Restore configure.ac
chdir($start_dir);
do_command("git checkout configure.ac");
#------------------------------------------------------------------------
# Success!
print "=== Success:\n";
my $tardir = $start_dir;
print " = Tarballs in $tardir:\n";
chdir($tardir);
system("ls -1 libusnic_verbs*$cisco_version*");
my $srpmdir = "$rpmbuilddir/SRPMS";
print " = SRPM in $srpmdir:\n";
chdir($srpmdir);
system("ls -1 libusnic_verbs-$cisco_version*.src.rpm");
my $rpmdir = "$rpmbuilddir/RPMS/x86_64";
print " = RPMs in $rpmdir:\n";
chdir($rpmdir);
system("ls -1 libusnic_verbs*$cisco_version*.rpm");
# All done
exit(0);