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", "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", "webmin_search.cgi" );
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",
70 "bacula-backup", "ldap-server",
73 @dirlist = ( "Webmin" );
75 if (-d "/usr/local/webadmin") {
76 chdir("/usr/local/webadmin");
77 system("./koi8-to-cp1251.pl");
78 system("./make-small-icons.pl /usr/local/webadmin");
80 $dir = "webmin-$vers";
81 system("rm -rf $tardir/$dir");
82 mkdir("$tardir/$dir", 0755);
84 # Copy top-level files to directory
85 print "Adding top-level files\n";
86 $flist = join(" ", @files);
87 system("cp -r -L $flist $tardir/$dir");
88 system("touch $tardir/$dir/install-type");
89 system("echo $vers > $tardir/$dir/version");
91 system("touch $tardir/$dir/minimal-install");
96 print "Adding module $m\n";
97 mkdir("$tardir/$dir/$m", 0755);
100 foreach $f (readdir(DIR)) {
101 if ($f =~ /^\./ || $f eq "test" || $f =~ /\.bak$/ ||
102 $f =~ /\.tmp$/ || $f =~ /\.site$/) { next; }
106 system("cp -r -L $flist $tardir/$dir/$m");
109 # Remove files that shouldn't be publicly available
110 system("rm -rf $tardir/$dir/status/mailserver*");
112 # Add other directories
113 foreach $d (@dirlist) {
114 print "Adding directory $d\n";
115 system("cp -r $d $tardir/$dir");
118 # Update module.info and theme.info files with depends and version
119 opendir(DIR, "$tardir/$dir");
120 while($d = readdir(DIR)) {
121 # set depends in module.info to this version
122 local $minfo = "$tardir/$dir/$d/module.info";
123 local $tinfo = "$tardir/$dir/$d/theme.info";
126 &read_file($minfo, \%minfo);
127 $minfo{'depends'} = join(" ", split(/\s+/, $minfo{'depends'}),
129 $minfo{'version'} = $vers;
130 &write_file($minfo, \%minfo);
134 &read_file($tinfo, \%tinfo);
135 $tinfo{'depends'} = join(" ", split(/\s+/, $tinfo{'depends'}),
137 $tinfo{'version'} = $vers;
138 &write_file($tinfo, \%tinfo);
143 # Remove useless .bak, test and other files, and create the tar.gz file
144 print "Creating webmin-$vfile.tar.gz\n";
145 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");
146 system("cd $tardir ; tar cvhf - $dir 2>/dev/null | gzip -c >webmin-$vfile.tar.gz");
148 if (!$min && -d $zipdir) {
149 # Create a .zip file too
150 print "Creating webmin-$vfile.zip\n";
151 system("rm -rf $zipdir/webmin");
152 system("mkdir $zipdir/webmin");
153 system("cp -rp $tardir/$dir/* $zipdir/webmin");
154 system("rm -rf $zipdir/webmin/{fdisk,exports,bsdexports,hpuxexports,sgiexports,zones,rbac}");
155 system("rm -rf $zipdir/webmin/acl/Authen-SolarisRBAC-0.1/*");
156 system("rm -f $zipdir/webmin/software/msi-lib.pl");
157 system("echo zip >$zipdir/webmin/install-type");
158 open(FIND, "find $zipdir/webmin -name '*\\**' |");
162 ($nw = $orig) =~ s/\*/ALL/g;
168 unlink("$zipdir/webmin-$vfile.zip");
169 system("cd $zipdir && zip -r webmin-$vfile.zip webmin >/dev/null 2>&1");
172 if (!$min && -d "modules") {
173 # Create per-module .wbm files
174 print "Creating modules\n";
175 opendir(DIR, "$tardir/$dir");
176 while($d = readdir(DIR)) {
177 # create the module.wbm file
178 local $minfo = "$tardir/$dir/$d/module.info";
179 next if (!-r $minfo);
180 unlink("modules/$d.wbm", "modules/$d.wbm.gz");
181 system("(cd $tardir/$dir ; tar chf - $d | gzip -c) >modules/$d.wbm.gz");
186 # Create the signature file
188 unlink("sigs/webmin-$vfile.tar.gz-sig.asc");
189 system("gpg --armor --output sigs/webmin-$vfile.tar.gz-sig.asc --default-key jcameron\@webmin.com --detach-sig $tardir/webmin-$vfile.tar.gz");
192 # Create a change log for this version
193 if (-d "/home/jcameron/webmin.com") {
194 $lastvers = sprintf("%.2f0", $vers - 0.005); # round down to last stable
195 if ($lastvers == $vers) {
196 # this is a new full version, so round down to the previous full version
197 $lastvers = sprintf("%.2f0", $vers-0.006);
199 system("./showchangelog.pl --html $lastvers >/home/jcameron/webmin.com/changes-$vers.html");
203 # Delete the tarball directory
204 system("rm -rf $tardir/$dir");
207 # read_file(file, &assoc, [&order])
208 # Fill an associative array with name=value pairs from a file
211 open(ARFILE, $_[0]) || return 0;
214 if (!/^#/ && /^([^=]+)=(.*)$/) {
223 # write_file(file, array)
224 # Write out the contents of an associative array as name=value lines
229 open(ARFILE, "> $_[0]");
230 foreach $k (keys %$arr) {
231 print ARFILE "$k=$$arr{$k}\n";
238 die "usage: makedist.pl [-minimal] <version>";