-
Notifications
You must be signed in to change notification settings - Fork 0
/
.doit
executable file
·183 lines (176 loc) · 4.65 KB
/
.doit
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
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
#!/usr/bin/perl
# Copyright (c) 2000 SuSE GmbH Nuernberg, Germany. All rights reserved.
#
# Author: Marcus Schaefer <[email protected]>, 2005
# Build script for qbiff with SVN access
#
# Syntax:
# -------
# doit --prepare [ --tag <tag> ] [ --branch <branch> ]
# [ --sourcelevel <n> ]
#
# tag or branch specifiy the subversion location where a tag
# or a branch source is stored.
# ---
#
use strict;
use Getopt::Long;
use Env;
#=====================================
# Globals...
#-------------------------------------
my $Prepare;
my $Tag;
my $Branch;
my $SourceList;
my $LocalSource;
my $Clean;
#----[ main ]-----------------#
sub main {
#-----------------------------------------------
# main routine to prepare for all the
# package and version stuff
#
my $result = GetOptions(
"tag|t=s" => \$Tag,
"branch|r=s" => \$Branch,
"prepare|p" => \$Prepare,
"sourcelevel=i" => \$SourceList,
"local|L" => \$LocalSource,
"clean|c" => \$Clean,
"help|h" => \&usage,
"<>" => \&usage
);
if ( $result != 1 ) {
usage();
}
#==============================================
# Check user privileges...
#----------------------------------------------
if (! defined $Prepare) {
usage();
}
#==============================================
# Setup subversion path for checkout...
#----------------------------------------------
my $tagsID;
my $treeID;
if (defined $Branch) {
$tagsID = $Branch;
$treeID = "qbiff-branches";
}
if (defined $Tag) {
$tagsID = $Tag;
$treeID = "qbiff-tags";
}
#==============================================
# Checkout source
#----------------------------------------------
my $pacdir = checkout (
$tagsID,$treeID,$SourceList,$LocalSource
);
#==============================================
# Cleanup
#----------------------------------------------
my $host = qx (hostname);
chomp ($host);
print 'Retrieve archive with: ';
print '[ scp -r root@'.$host.':'.$pacdir." . ]\n";
}
#---[ checkout ]-----#
sub checkout {
#-------------------------------------------------
# checkout sources and create a package directory
# ready to go to /work/src/done
#
qx (./.changes);
my $pacdir = svnup (@_);
chdir $pacdir;
qx( mv qbiff/rpm/* . );
qx( rm -rf ./qbiff.changeref );
chdir "./qbiff";
qx (./.archive);
chdir $pacdir;
qx( mv qbiff/*.bz2 . );
qx( rm -rf qbiff );
return $pacdir;
}
#----[ svnup ]----------------#
sub svnup {
#-----------------------------------------------
# checkout qbiff source according to an optional
# tag and return the pathname of the temp directory
# where the new sources are located
#
my $tagName = $_[0];
my $treeID = $_[1];
my $slevel = $_[2];
my $local = $_[3];
#===========================================
# set SVN path to repository and branch/tag
#-------------------------------------------
my $svnPath = "svn.berlios.de/svnroot/repos/qbiff/qbiff-head";
if (defined $tagName) {
$svnPath = "svn.berlios.de/svnroot/repos/qbiff/".$treeID."/".$tagName;
}
#===========================================
# create tmp directory and change into it
#-------------------------------------------
my $parent = qx ( pwd );
my $tmpdir = qx (
mktemp -q -d /tmp/gitqbiff.XXXXXX
);
chomp $parent;
chomp $tmpdir;
chdir $tmpdir
|| die "Could not create temp dir: $!";
#===========================================
# use local source if defined
#-------------------------------------------
if (defined $local) {
print "Checkout source level [local]...\n";
chdir $parent
|| die "Could not change dir: $parent:$!";
qx (mkdir -p $tmpdir/qbiff && cp -a . $tmpdir/qbiff);
chdir $tmpdir
|| die "Could not create temp dir: $!";
return $tmpdir;
}
#===========================================
# checkout source at given level or HEAD
#-------------------------------------------
if (defined $slevel) {
print "Checkout source level [$slevel]...\n";
qx (svn co -r $slevel http://$svnPath qbiff 2>&1 );
} else {
my $location = "HEAD";
if ( defined $Branch ) {
$location = "BRANCH: $Branch";
}
if ( defined $Tag ) {
$location = "TAG: $Tag";
}
print "Checkout source level [$location]...\n";
qx ( svn co http://$svnPath qbiff 2>&1 );
}
my $error = $? >> 8;
if ($error > 0) {
die "checkout failed: $!";
}
return $tmpdir;
}
#----[ usage ]------------#
sub usage {
#----------------------------------------
# give me a usage message
#
print "usage: doit [ options ]\n";
print "options:\n";
print "[ -p | --prepare [ --tag | --branch <name> ] ]\n";
print " prepare package for build. Use sources as specified\n";
print " by tag or branch. If no tag is given the head will\n";
print " be used\n";
print "--\n";
exit (0);
}
main();