2 # Builds a tar.gz package of a specified Webmin version
4 @ARGV == 1 || @ARGV == 2 || usage();
5 if ($ARGV[0] eq "-minimal" || $ARGV[0] eq "--minimal") {
10 $vers =~ /^[0-9\.]+$/ || usage();
11 $tardir = $min ? "minimal" : "tarballs";
12 $vfile = $min ? "$vers-minimal" : $vers;
15 @files = ("config.cgi", "config-*-linux",
16 "config-solaris", "images", "index.cgi", "mime.types",
17 "miniserv.pl", "os_list.txt", "perlpath.pl", "setup.sh", "setup.pl",
18 "version", "web-lib.pl", "web-lib-funcs.pl", "README",
19 "config_save.cgi", "chooser.cgi", "miniserv.pem",
21 "newmods.pl", "copyconfig.pl", "config-hpux", "config-freebsd",
22 "changepass.pl", "help.cgi", "user_chooser.cgi",
23 "group_chooser.cgi", "config-irix", "config-osf1", "thirdparty.pl",
24 "oschooser.pl", "config-unixware",
25 "config-openserver", "switch_user.cgi", "lang", "lang_list.txt",
26 "webmin-init", "webmin-caldera-init", "webmin-daemon",
28 "config-macos", "LICENCE", "PATENTS",
29 "session_login.cgi", "referer_save.cgi", "acl_security.pl",
30 "defaultacl", "rpc.cgi", "date_chooser.cgi", "switch_skill.cgi",
31 "install-module.pl", "LICENCE.ja",
32 "favicon.ico", "config-netbsd", "fastrpc.cgi",
33 "defaulttheme", "feedback.cgi", "feedback_form.cgi",
34 "javascript-lib.pl", "webmin-pam", "maketemp.pl",
36 "webmin-gentoo-init", "run-postinstalls.pl",
37 "config-lib.pl", "entities_map.txt", "ui-lib.pl",
38 "password_form.cgi", "password_change.cgi", "pam_login.cgi",
39 "module_chooser.cgi", "config-windows", "xmlrpc.cgi",
40 "uptracker.cgi", "create-module.pl" );
42 # Only those required by others
43 @mlist = ("cron", "init", "inittab", "proc", "webmin", "acl", "servers",
49 ("cron", "dfsadmin", "dnsadmin", "exports", "inetd", "init",
50 "mount", "samba", "useradmin", "fdisk", "format", "proc", "webmin",
51 "quota", "software", "pap", "acl", "apache", "lpadmin", "bind8",
52 "sendmail", "squid", "bsdexports", "hpuxexports", "file",
53 "net", "dhcpd", "majordomo", "custom", "lilo", "telnet", "servers",
54 "time", "wuftpd", "syslog", "mysql", "man",
55 "inittab", "raid", "postfix", "webminlog", "postgresql", "xinetd",
56 "status", "cpan", "caldera", "pam", "nis", "shell", "grub",
57 "fetchmail", "passwd", "at", "proftpd", "sshd",
58 "heartbeat", "cluster-software", "cluster-useradmin", "qmailadmin",
59 "mon", "mscstyle3", "jabber", "stunnel", "burner", "usermin",
60 "fsdump", "lvm", "sentry", "cfengine", "pserver", "procmail",
61 "cluster-webmin", "firewall", "sgiexports", "vgetty", "openslp",
62 "webalizer", "shorewall", "adsl-client", "updown", "ppp-client",
63 "pptp-server", "pptp-client", "ipsec", "ldap-useradmin",
64 "change-user", "cluster-shell", "cluster-cron", "spam",
65 "htaccess-htpasswd", "logrotate", "cluster-passwd", "mailboxes",
66 "ipfw", "frox", "sarg", "bandwidth", "cluster-copy", "backup-config",
67 "smart-status", "idmapd", "krb5", "smf", "ipfilter", "rbac",
68 "tunnel", "zones", "cluster-usermin", "dovecot", "syslog-ng",
69 "mailcap", "blue-theme", "ldap-client", "phpini", "filter",
72 @dirlist = ( "Webmin" );
74 if (-d "/usr/local/webadmin") {
75 chdir("/usr/local/webadmin");
76 system("./koi8-to-cp1251.pl");
77 system("./make-small-icons.pl /usr/local/webadmin");
79 $dir = "webmin-$vers";
80 system("rm -rf $tardir/$dir");
81 mkdir("$tardir/$dir", 0755);
83 # Copy top-level files to directory
84 print "Adding top-level files\n";
85 $flist = join(" ", @files);
86 system("cp -r -L $flist $tardir/$dir");
87 system("touch $tardir/$dir/install-type");
88 system("echo $vers > $tardir/$dir/version");
90 system("touch $tardir/$dir/minimal-install");
95 print "Adding module $m\n";
96 mkdir("$tardir/$dir/$m", 0755);
99 foreach $f (readdir(DIR)) {
100 if ($f =~ /^\./ || $f eq "test" || $f =~ /\.bak$/ ||
101 $f =~ /\.tmp$/ || $f =~ /\.site$/) { next; }
105 system("cp -r -L $flist $tardir/$dir/$m");
108 # Remove files that shouldn't be publicly available
109 system("rm -rf $tardir/$dir/status/mailserver*");
111 # Add other directories
112 foreach $d (@dirlist) {
113 print "Adding directory $d\n";
114 system("cp -r $d $tardir/$dir");
117 # Update module.info and theme.info files with depends and version
118 opendir(DIR, "$tardir/$dir");
119 while($d = readdir(DIR)) {
120 # set depends in module.info to this version
121 local $minfo = "$tardir/$dir/$d/module.info";
122 local $tinfo = "$tardir/$dir/$d/theme.info";
125 &read_file($minfo, \%minfo);
126 $minfo{'depends'} = join(" ", split(/\s+/, $minfo{'depends'}),
128 $minfo{'version'} = $vers;
129 &write_file($minfo, \%minfo);
133 &read_file($tinfo, \%tinfo);
134 $tinfo{'depends'} = join(" ", split(/\s+/, $tinfo{'depends'}),
136 $tinfo{'version'} = $vers;
137 &write_file($tinfo, \%tinfo);
142 # Remove useless .bak, test and other files, and create the tar.gz file
143 print "Creating webmin-$vfile.tar.gz\n";
144 system("find $tardir/$dir -name '*.bak' -o -name test -o -name '*.tmp' -o -name '*.site' -o -name core -o -name .xvpics -o -name .svn | xargs rm -rf");
145 system("cd $tardir ; tar cvhf - $dir 2>/dev/null | gzip -c >webmin-$vfile.tar.gz");
147 if (!$min && -d $zipdir) {
148 # Create a .zip file too
149 print "Creating webmin-$vfile.zip\n";
150 system("rm -rf $zipdir/webmin");
151 system("mkdir $zipdir/webmin");
152 system("cp -rp $tardir/$dir/* $zipdir/webmin");
153 system("rm -rf $zipdir/webmin/{fdisk,exports,bsdexports,hpuxexports,sgiexports,zones,rbac}");
154 system("rm -rf $zipdir/webmin/acl/Authen-SolarisRBAC-0.1/*");
155 system("rm -f $zipdir/webmin/software/msi-lib.pl");
156 system("echo zip >$zipdir/webmin/install-type");
157 open(FIND, "find $zipdir/webmin -name '*\\**' |");
161 ($nw = $orig) =~ s/\*/ALL/g;
167 unlink("$zipdir/webmin-$vfile.zip");
168 system("cd $zipdir && zip -r webmin-$vfile.zip webmin >/dev/null 2>&1");
171 if (!$min && -d "modules") {
172 # Create per-module .wbm files
173 print "Creating modules\n";
174 opendir(DIR, "$tardir/$dir");
175 while($d = readdir(DIR)) {
176 # create the module.wbm file
177 local $minfo = "$tardir/$dir/$d/module.info";
178 next if (!-r $minfo);
179 unlink("modules/$d.wbm", "modules/$d.wbm.gz");
180 system("(cd $tardir/$dir ; tar chf - $d | gzip -c) >modules/$d.wbm.gz");
185 # Create the signature file
187 unlink("sigs/webmin-$vfile.tar.gz-sig.asc");
188 system("gpg --armor --output sigs/webmin-$vfile.tar.gz-sig.asc --default-key jcameron\@webmin.com --detach-sig $tardir/webmin-$vfile.tar.gz");
191 # Create a change log for this version
192 if (-d "/home/jcameron/webmin.com") {
193 $lastvers = sprintf("%.2f0", $vers - 0.005); # round down to last stable
194 if ($lastvers == $vers) {
195 # this is a new full version, so round down to the previous full version
196 $lastvers = sprintf("%.2f0", $vers-0.006);
198 system("./showchangelog.pl --html $lastvers >/home/jcameron/webmin.com/changes-$vers.html");
202 # Delete the tarball directory
203 system("rm -rf $tardir/$dir");
206 # read_file(file, &assoc, [&order])
207 # Fill an associative array with name=value pairs from a file
210 open(ARFILE, $_[0]) || return 0;
213 if (!/^#/ && /^([^=]+)=(.*)$/) {
222 # write_file(file, array)
223 # Write out the contents of an associative array as name=value lines
228 open(ARFILE, "> $_[0]");
229 foreach $k (keys %$arr) {
230 print ARFILE "$k=$$arr{$k}\n";
237 die "usage: makedist.pl [-minimal] <version>";