#!/usr/local/bin/perl # Build an RPM package of Webmin if (-d "$ENV{'HOME'}/redhat") { $base_dir = "$ENV{'HOME'}/redhat"; } elsif (-d "$ENV{'HOME'}/rpmbuild") { $base_dir = "$ENV{'HOME'}/rpmbuild"; } else { $base_dir = "/usr/src/redhat"; $< && die "makerpm.pl must be run as root"; } $spec_dir = "$base_dir/SPECS"; $source_dir = "$base_dir/SOURCES"; $rpms_dir = "$base_dir/RPMS/noarch"; $srpms_dir = "$base_dir/SRPMS"; if ($ARGV[0] eq "--nosign" || $ARGV[0] eq "-nosign") { $nosign = 1; shift(@ARGV); } $ver = $ARGV[0] || die "usage: makerpm.pl [--nosign] [release]"; $rel = $ARGV[1] || "1"; $oscheck = <) { chop; next if (/^Generic\s+Linux/i); if (/^([^\t]+)\t+([^\t]+)\t+([^\t]+)\t+([^\t]+)\t*(.*)$/ && $5) { $if = $count++ == 0 ? "if" : "elsif"; $oscheck .= "$if ($5) {\n". " print \"oscheck='$1'\\n\";\n". " }\n"; } } close(OS); $oscheck =~ s/\\/\\\\/g; $oscheck =~ s/`/\\`/g; $oscheck =~ s/\$/\\\$/g; open(TEMP, "maketemp.pl"); while() { $maketemp .= $_; } close(TEMP); $maketemp =~ s/\\/\\\\/g; $maketemp =~ s/`/\\`/g; $maketemp =~ s/\$/\\\$/g; if ($rel && $rel > 1) { $makerel = "echo $rel >%{buildroot}/usr/libexec/webmin/release"; } else { $makerel = "rm -f %{buildroot}/usr/libexec/webmin/release"; } if ($rel > 1 && -r "tarballs/webmin-$ver-$rel.tar.gz") { $tarfile = "webmin-$ver-$rel.tar.gz"; } else { $tarfile = "webmin-$ver.tar.gz"; } system("cp tarballs/$tarfile $source_dir"); open(SPEC, ">$spec_dir/webmin-$ver.spec"); print SPEC <%{buildroot}/usr/libexec/webmin/install-type $makerel %clean #%{rmDESTDIR} [ "%{buildroot}" != "/" ] && rm -rf %{buildroot} %files %defattr(-,root,root) /usr/libexec/webmin /usr/bin/webmin %config /etc/pam.d/webmin %pre perl <$tempdir/\$\$.check </dev/null 2>&1 \$tempdir/webmin-setup.out 2>&1 chmod 600 \$tempdir/webmin-setup.out rm -f /var/lock/subsys/webmin cd /usr/libexec/webmin if [ "\$inetd" != "1" ]; then if [ "\$1" == 1 ]; then /etc/webmin/start >/dev/null 2>&1 /dev/null 2>&1 /dev/null 2>&1 /dev/null 2>&1 /etc/webmin/uninstall.sh </dev/null 2>/dev/null if [ "\$?" = "0" ]; then sslmode=1 fi fi musthost=`grep musthost= /etc/webmin/miniserv.conf | sed -e 's/musthost=//'` if [ "$musthost" != "" ]; then host=$musthost fi if [ "\$1" == 1 ]; then if [ "\$sslmode" = "1" ]; then echo "Webmin install complete. You can now login to https://\$host:\$port/" >>\$tempdir/webmin-setup.out 2>&1 else echo "Webmin install complete. You can now login to http://\$host:\$port/" >>\$tempdir/webmin-setup.out 2>&1 fi echo "as root with your root password." >>\$tempdir/webmin-setup.out 2>&1 fi /bin/true %preun if [ "\$1" = 0 ]; then grep root=/usr/libexec/webmin /etc/webmin/miniserv.conf >/dev/null 2>&1 if [ "\$?" = 0 ]; then # RPM is being removed, and no new version of webmin # has taken it's place. Run uninstalls and stop the server /etc/webmin/stop >/dev/null 2>&1 /dev/null 2>&1 /dev/null 2>&1 if [ "\$?" = 0 ]; then # RPM is being removed, and no new version of webmin # has taken it's place. Rename away the /etc/webmin directory rm -rf /etc/webmin.rpmsave mv /etc/webmin /etc/webmin.rpmsave rm -rf /var/webmin fi fi /bin/true %triggerpostun -- webmin if [ ! -d /var/webmin -a "\$1" = 2 ]; then mkdir /var/webmin fi if [ ! -r /etc/webmin/miniserv.conf -a -d /etc/.webmin-backup -a "\$1" = 2 ]; then rm -rf /etc/.webmin-broken mv /etc/webmin /etc/.webmin-broken mv /etc/.webmin-backup /etc/webmin if [ -r /etc/webmin/.post-install ]; then /etc/webmin/.post-install >/dev/null 2>&1