-
Notifications
You must be signed in to change notification settings - Fork 75
/
.doit
executable file
·124 lines (118 loc) · 3.34 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
#!/usr/bin/perl
# Copyright (c) 2000 SuSE GmbH Nuernberg, Germany. All rights reserved.
#
# Author: Marcus Schaefer <ms@suse.de>, 2005
# Build script for kiwi RPM package(s)
#
# Syntax:
# -------
# doit -p | --prepare --local
#
# ---
#
use strict;
use Time::localtime;
use Time::Local;
use Getopt::Long;
use File::lchown qw( lutimes );
use POSIX qw( ENOENT );
use Env;
#=====================================
# Globals...
#-------------------------------------
my $Prepare;
my $LocalSource;
#----[ main ]-----------------#
sub main {
#-----------------------------------------------
# main routine to prepare for all the
# package and version stuff
#
my $result = GetOptions(
"prepare|p" => \$Prepare,
"local|L" => \$LocalSource,
"help|h" => \&usage,
"<>" => \&usage
);
if ( $result != 1 ) {
usage();
}
#==============================================
# Check user privileges...
#----------------------------------------------
if (! defined $Prepare) {
usage();
}
#==============================================
# Checkout source
#----------------------------------------------
my $pacdir = checkout ( $LocalSource );
#==============================================
# convert spec to utf8
#----------------------------------------------
qx (iconv -f ISO-8859-1 -t utf8 $pacdir/kiwi.spec > $pacdir/kiwi.spec.new);
qx (mv $pacdir/kiwi.spec.new $pacdir/kiwi.spec);
qx (iconv -f ISO-8859-1 -t utf8 $pacdir/kiwi.changes > $pacdir/kiwi.c.new);
qx (mv $pacdir/kiwi.c.new $pacdir/kiwi.changes);
#==============================================
# 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
#
my $pacdir = repoup (@_);
chdir $pacdir;
qx( cp -a -p kiwi/rpm/* . );
chdir "./kiwi";
qx (./.archive);
chdir $pacdir;
qx( mv kiwi/*.bz2 . );
qx( rm -rf kiwi );
return $pacdir;
}
#----[ repoup ]----------------#
sub repoup {
#-----------------------------------------------
# checkout kiwi source according to an optional
# tag and return the pathname of the temp directory
# where the new sources are located
#
#===========================================
# create tmp directory and change into it
#-------------------------------------------
my $parent = qx ( pwd );
my $tmpdir = qx (
mktemp -q -d /tmp/gitkiwi.XXXXXX
);
chomp $parent;
chomp $tmpdir;
chdir $tmpdir
|| die "Could not create temp dir: $!";
#===========================================
# pack up local source
#-------------------------------------------
print "Checkout source level [local]...\n";
qx( cp -a -p $parent/ $tmpdir/kiwi );
qx ($parent/.lutime $parent $tmpdir);
chdir $tmpdir
|| die "Could not create temp dir: $!";
return $tmpdir;
}
#----[ usage ]------------#
sub usage {
#----------------------------------------
# give me a usage message
#
print "usage: doit -p --local\n";
print "--\n";
exit (0);
}
main();