-
Notifications
You must be signed in to change notification settings - Fork 5
/
releng-deb
executable file
·123 lines (94 loc) · 3.74 KB
/
releng-deb
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
#!/usr/bin/env perl
#
# Cisco libusnic_verbs package builder script for release engineering
#
# This script makes Debian packages, and understands the following OSs:
# Ubuntu 14.04.2 LTS
#
use strict;
use warnings;
use Cwd;
use File::Basename;
use Data::Dumper;
use Getopt::Long;
use POSIX qw(strftime);
# 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(@_);
}
sub read_mod_write {
Cisco::usnic_releng_common::read_mod_write(@_);
}
sub modify_file_contents {
Cisco::libusnic_verbs_noop::modify_file_contents(@_);
}
#--------------------------------------------------------------------------
Cisco::libusnic_verbs_noop::sanity_check();
my $data = Cisco::libusnic_verbs_noop::parse_argv();
my $cisco_maintainer = $data->{maintainer};
my $cisco_maintainer_email = $data->{maintainer_email};
my $start_dir = getcwd();
# Values from files
my $git_id = Cisco::libusnic_verbs_noop::read_upstream_version("UPSTREAM_VERSION");
my ($src_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);
my $prefix = "/";
my $configure_args =
" --libdir=/usr/lib" .
" --libexecdir=/usr/lib";
my $pkg_version = "$src_version-$cisco_build_id.$distro";
my $pkg_release = $cisco_build_id;
Cisco::libusnic_verbs_noop::modify_file_contents_setup($src_version,
$pkg_version,
$pkg_release,
$cisco_maintainer,
$cisco_maintainer_email,
$configure_args);
Cisco::libusnic_verbs_noop::make_tarball($src_version);
#--------------------------------------------------------------------------
# Apply local patches
Cisco::usnic_releng_common::apply_local_patches("patches");
#------------------------------------------------------------------------
# Make a new tree to do the debian builds, and copy the perfect
# tarball there (name it ".orig.", per Debian requirements.
print "=== Setting up expected Debian directory structure...\n";
do_command("rm -rf debian-build");
mkdir("debian-build");
do_command("cp libusnic_verbs-$src_version.tar.bz2 debian-build/libusnic-verbs_$src_version.orig.tar.bz2");
chdir("debian-build");
my $debian_buildtop = getcwd();
# Expand the tarball, and copy the debian directory to the top-level
# expanded tarball dir, per Debian requirements.
do_command("tar xf libusnic-verbs_$src_version.orig.tar.bz2");
do_command("mv libusnic_verbs-$src_version libusnic-verbs-$src_version-1");
my $src_dir = "..";
my $dest_dir = "libusnic-verbs-$src_version-1";
do_command("cp -rp $src_dir/debian $dest_dir");
# Replace @TOKENS@ in some of the debian/ files
my $outdir = "$dest_dir/debian";
foreach my $file (qw/control changelog rules/) {
read_mod_write("$outdir/$file", "$outdir/$file", \&modify_file_contents);
}
#------------------------------------------------------------------------
# Make the debian source package
print "=== Building deb source package\n";
do_command("dpkg-source -b libusnic-verbs-$src_version-1");
# Build the debian binary package
print "=== Building deb binary package\n";
chdir("libusnic-verbs-$src_version-1");
do_command("dpkg-buildpackage -us -uc -j32");
#------------------------------------------------------------------------
# Success!
print "=== Success\n";
print " = Files in $debian_buildtop:\n";
chdir($debian_buildtop);
system("ls -1 libusnic-verbs_$src_version*");
# All done
exit(0);