-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmake_package
executable file
·161 lines (145 loc) · 5.03 KB
/
make_package
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
#!/usr/local/bin/perl
#
# Automated processes to create SUN packages
# You can run this script after you did a 'make install' in the chrooted
# environment. Run it from the <whatever>/packagename-1.0/usr/local/ directory
#
# JA: 06-01-2000 Initial release
# JA: 25-01-2000 Beautified a little
# AH: 20-07-2000 Beautified a bit more
#
# Originally written in 2000 by Jasper Aukes.
$find = "/usr/bin/find";
$pkgproto = "/usr/bin/pkgproto";
$pkgmk = "/usr/bin/pkgmk";
$pkgtrans = "/usr/bin/pkgtrans";
$temp = "/tmp/prototype$$";
$prototype = "prototype";
$pkginfo = "pkginfo";
($gid ,$pkg ,$uid ,$userInfo ,$email ,$quota ,$group ,$passwd
,$category ,$userHome ,$vendor ,$loginShell ,$pstamp ,$basedir)=();
# Sanitycheck
$pwd = `pwd`;
if ($pwd =~ '\/usr\/local') {
$pwd = $`;
}
die "Wrong location, please cd to <PKGBASE>/usr/local/ and run again.\n"
if ($pwd eq "");
system ("$find . -print | $pkgproto > $temp");
open (PREPROTO,"<$temp") || die "Unable to read prototype information ($!)\n";
open (PROTO,">$prototype") || die "Unable to write file prototype ($!)\n";
print PROTO "i pkginfo=./$pkginfo\n";
@specials = ( "postinstall", "preremove", "postremove", "depend", "copyright" );
while ( $special = shift(@specials) ) {
if ( -f $special ) {
print PROTO "i ${special}=./${special}\n";
}
}
while (<PREPROTO>) {
# Read the prototype information from /tmp/prototype$$
chomp;
$thisline = $_;
if ($thisline =~ " prototype "
or $thisline =~ " depend "
or $thisline =~ " pkginfo "
or $thisline =~ " postinstall "
or $thisline =~ " preremove "
or $thisline =~ " postremove "
or $thisline =~ " copyright "
or $thisline =~ " usr "
or $thisline =~ " var "
or $thisline =~ " var/tmp ") {
# We don't need that line
} elsif ($thisline =~ "^[fd] ") {
# Change the ownership for files and directories
($dir, $none, $file, $mode, $user, $group) = split / /,$thisline;
# print PROTO "$dir $none $file $mode bin bin\n";
print PROTO "$dir $none $file $mode $user $group\n";
} else {
# Symlinks and other stuff should be printed as well ofcourse
print PROTO "$thisline\n";
}
}
close PROTO;
close PREPROTO;
# Clean up
unlink $temp || warn "Unable to remove tempfile ($!)\n";
# Now we can start building the package
#
# First get some info
$thispackage = `basename $pwd`;
if ($thispackage =~ '-') {
$default{"name"} = $PREMATCH;
$default{"version"} = $POSTMATCH;
chomp $default{"version"};
} else {
$default{"name"} = $thispackage;
chomp $default{"name"};
$default{"version"} = "1.0";
}
$default{"pkg"} = "DZL" . substr($default{"name"},0,4);
$default{"arch"} = `uname -m`;
chomp $default{"arch"};
$default{"category"} = "application";
$default{"vendor"} = "GNU";
$default{"email"} = "info@\gnu.org";
$login = getlogin();
($user, $passwd, $uid, $gid, $quota, $default{"pstamp"}, $userInfo,
$userHome, $loginShell) = getpwnam ($login);
$default{"pstamp"} = "Dano Carroll"
if ($default{"pstamp"} eq "");
$os = `uname -r`;
chomp $os;
$os =~ s/5\./sol2/;
$os =~ s/sol27/sol7/;
$os =~ s/sol28/sol8/;
$default{"basedir"} = "/";
# Check for correctness of guessed values by userinput
%questions = (
pkg => "Please give the name for this package",
name => "Now enter the real name for this package",
arch => "What architecture did you build the package on?",
version => "Enter the version number of the package",
category => "What category does this package belong to?",
vendor => "Who is the vendor of this package?",
email => "Enter the email adress for contact",
pstamp => "Enter your own name",
basedir => "What is the basedir this package will install into?",
packagename => "How should i call the packagefile?",
);
@vars = qw(pkg name arch version category vendor email pstamp basedir
packagename);
foreach $varname (@vars) {
$default{"$varname"} = "$name-$version-$os-$arch-local"
if ($varname eq "packagename");
getvar($varname);
}
$classes = "none";
# Create the pkginfo file
print "\nNow creating $pkginfo file\n";
open (PKGINFO,">$pkginfo") || die "Unable to open $pkginfo for writing ($!)\n";
print PKGINFO "PKG=\"$pkg\"\n";
print PKGINFO "NAME=\"$name\"\n";
print PKGINFO "ARCH=\"$arch\"\n";
print PKGINFO "VERSION=\"$version\"\n";
print PKGINFO "CATEGORY=\"$category\"\n";
print PKGINFO "VENDOR=\"$vendor\"\n";
print PKGINFO "EMAIL=\"$email\"\n";
print PKGINFO "PSTAMP=\"$pstamp\"\n";
print PKGINFO "BASEDIR=\"$basedir\"\n";
print PKGINFO "CLASSES=\"$classes\"\n";
close PKGINFO;
print "Done.\n";
# Build and zip the package
print "Building package\n";
system ("$pkgmk -o -r `pwd`");
system ("(cd /var/spool/pkg;$pkgtrans -s `pwd` /tmp/$packagename)");
# The subroutines
sub getvar {
my $questionname = "@_";
print "$questions{$questionname} [$default{\"$questionname\"}]: ";
my $answer = <STDIN>;
chomp $answer;
$$questionname = $answer;
$$questionname = $default{$questionname} if ($$questionname eq "");
}