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",
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",
41 "webmin-search-lib.pl", "WebminCore.pm",
44 # Only those required by others
45 @mlist = ("cron", "init", "inittab", "proc", "webmin", "acl", "servers",
51 ("cron", "dfsadmin", "dnsadmin", "exports", "inetd", "init",
52 "mount", "samba", "useradmin", "fdisk", "format", "proc", "webmin",
53 "quota", "software", "pap", "acl", "apache", "lpadmin", "bind8",
54 "sendmail", "squid", "bsdexports", "hpuxexports", "file",
55 "net", "dhcpd", "majordomo", "custom", "lilo", "telnet", "servers",
56 "time", "wuftpd", "syslog", "mysql", "man",
57 "inittab", "raid", "postfix", "webminlog", "postgresql", "xinetd",
58 "status", "cpan", "caldera", "pam", "nis", "shell", "grub",
59 "fetchmail", "passwd", "at", "proftpd", "sshd",
60 "heartbeat", "cluster-software", "cluster-useradmin", "qmailadmin",
61 "mon", "mscstyle3", "jabber", "stunnel", "burner", "usermin",
62 "fsdump", "lvm", "sentry", "cfengine", "pserver", "procmail",
63 "cluster-webmin", "firewall", "sgiexports", "vgetty", "openslp",
64 "webalizer", "shorewall", "adsl-client", "updown", "ppp-client",
65 "pptp-server", "pptp-client", "ipsec", "ldap-useradmin",
66 "change-user", "cluster-shell", "cluster-cron", "spam",
67 "htaccess-htpasswd", "logrotate", "cluster-passwd", "mailboxes",
68 "ipfw", "frox", "sarg", "bandwidth", "cluster-copy", "backup-config",
69 "smart-status", "idmapd", "krb5", "smf", "ipfilter", "rbac",
70 "tunnel", "zones", "cluster-usermin", "dovecot", "syslog-ng",
71 "mailcap", "blue-theme", "ldap-client", "phpini", "filter",
72 "bacula-backup", "ldap-server", "exim", "tcpwrappers",
75 @dirlist = ( "Webmin" );
77 if (-d "/usr/local/webadmin") {
78 chdir("/usr/local/webadmin");
79 system("./koi8-to-cp1251.pl");
80 system("./make-small-icons.pl /usr/local/webadmin");
82 $dir = "webmin-$vers";
83 system("rm -rf $tardir/$dir");
84 mkdir("$tardir/$dir", 0755);
86 # Copy top-level files to directory
87 print "Adding top-level files\n";
88 $flist = join(" ", @files);
89 system("cp -r -L $flist $tardir/$dir");
90 system("touch $tardir/$dir/install-type");
91 system("echo $vers > $tardir/$dir/version");
93 system("touch $tardir/$dir/minimal-install");
98 print "Adding module $m\n";
99 mkdir("$tardir/$dir/$m", 0755);
102 foreach $f (readdir(DIR)) {
103 if ($f =~ /^\./ || $f eq "test" || $f =~ /\.bak$/ ||
104 $f =~ /\.tmp$/ || $f =~ /\.site$/) { next; }
108 system("cp -r -L $flist $tardir/$dir/$m");
111 # Remove files that shouldn't be publicly available
112 system("rm -rf $tardir/$dir/status/mailserver*");
113 system("rm -rf $tardir/$dir/file/plugin.jar");
115 # Add other directories
116 foreach $d (@dirlist) {
117 print "Adding directory $d\n";
118 system("cp -r $d $tardir/$dir");
121 # Update module.info and theme.info files with depends and version
122 opendir(DIR, "$tardir/$dir");
123 while($d = readdir(DIR)) {
124 # set depends in module.info to this version
125 local $minfo = "$tardir/$dir/$d/module.info";
126 local $tinfo = "$tardir/$dir/$d/theme.info";
129 &read_file($minfo, \%minfo);
130 $minfo{'depends'} = join(" ", split(/\s+/, $minfo{'depends'}),
132 $minfo{'version'} = $vers;
133 &write_file($minfo, \%minfo);
137 &read_file($tinfo, \%tinfo);
138 $tinfo{'depends'} = join(" ", split(/\s+/, $tinfo{'depends'}),
140 $tinfo{'version'} = $vers;
141 &write_file($tinfo, \%tinfo);
146 # Remove useless .bak, test and other files, and create the tar.gz file
147 print "Creating webmin-$vfile.tar.gz\n";
148 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");
149 system("cd $tardir ; tar cvhf - $dir 2>/dev/null | gzip -c >webmin-$vfile.tar.gz");
151 if (!$min && -d $zipdir) {
152 # Create a .zip file too
153 print "Creating webmin-$vfile.zip\n";
154 system("rm -rf $zipdir/webmin");
155 system("mkdir $zipdir/webmin");
156 system("cp -rp $tardir/$dir/* $zipdir/webmin");
157 system("rm -rf $zipdir/webmin/{fdisk,exports,bsdexports,hpuxexports,sgiexports,zones,rbac,Webmin}");
158 system("rm -rf $zipdir/webmin/acl/Authen-SolarisRBAC-0.1/*");
159 system("echo zip >$zipdir/webmin/install-type");
160 open(FIND, "find $zipdir/webmin -name '*\\**' |");
164 ($nw = $orig) =~ s/\*/ALL/g;
170 unlink("$zipdir/webmin-$vfile.zip");
171 system("cd $zipdir && zip -r webmin-$vfile.zip webmin >/dev/null 2>&1");
174 if (!$min && -d "modules") {
175 # Create per-module .wbm files
176 print "Creating modules\n";
177 opendir(DIR, "$tardir/$dir");
178 while($d = readdir(DIR)) {
179 # create the module.wbm file
180 local $minfo = "$tardir/$dir/$d/module.info";
181 next if (!-r $minfo);
182 unlink("modules/$d.wbm", "modules/$d.wbm.gz");
183 system("(cd $tardir/$dir ; tar chf - $d | gzip -c) >modules/$d.wbm.gz");
188 # Create the signature file
190 unlink("sigs/webmin-$vfile.tar.gz-sig.asc");
191 system("gpg --armor --output sigs/webmin-$vfile.tar.gz-sig.asc --default-key jcameron\@webmin.com --detach-sig $tardir/webmin-$vfile.tar.gz");
194 # Create a change log for this version
195 if (-d "/home/jcameron/webmin.com") {
196 $lastvers = sprintf("%.2f0", $vers - 0.005); # round down to last stable
197 if ($lastvers == $vers) {
198 # this is a new full version, so round down to the previous full version
199 $lastvers = sprintf("%.2f0", $vers-0.006);
201 system("./showchangelog.pl --html $lastvers >/home/jcameron/webmin.com/changes-$vers.html");
205 # Delete the tarball directory
206 system("rm -rf $tardir/$dir");
209 # read_file(file, &assoc, [&order])
210 # Fill an associative array with name=value pairs from a file
213 open(ARFILE, $_[0]) || return 0;
216 if (!/^#/ && /^([^=]+)=(.*)$/) {
225 # write_file(file, array)
226 # Write out the contents of an associative array as name=value lines
231 open(ARFILE, "> $_[0]");
232 foreach $k (keys %$arr) {
233 print ARFILE "$k=$$arr{$k}\n";
240 die "usage: makedist.pl [-minimal] <version>";