Index: /trunk/DNSDB.pm
===================================================================
--- /trunk/DNSDB.pm	(revision 218)
+++ /trunk/DNSDB.pm	(revision 219)
@@ -147,5 +147,5 @@
   my $deferr = '';	# place to put error from default config file in case we can't find either one
 
-  my $configroot = '/etc/dnsdb';
+  my $configroot = "/etc/dnsdb";	##CFG_LEAF##
   $configroot = '' if $basename =~ m|^/|;
   $basename .= ".conf" if $basename !~ /\.conf$/;
Index: /trunk/INSTALL
===================================================================
--- /trunk/INSTALL	(revision 218)
+++ /trunk/INSTALL	(revision 219)
@@ -27,4 +27,5 @@
     - NetAddr::IP >= 4.x.  3.x may work, however 4.x has been out for
       more than 4 years.
+    - Frontier::Responder (only required if using dns-rpc.cgi)
 - tinydns - support for other DNS server software is planned
 
@@ -69,11 +70,9 @@
 shell> psql -U dnsdb dnsdb <dns.sql
 
-
-##work
 4) Configure your webserver to call the DNS Administrator scripts
-at an appropriate web path.  A webroot pointing to the HTML files
-(first level under the dnsadmin-#VERSION#/ tarball directory, or
-/usr/local/lib/dnsadmin-#VERSION#) should work fine;  a server
-alias under an existing virtual host should work as well.
+at an appropriate web path.  A webroot pointing to the unpacked tarball
+directory or the default install location /usr/local/lib/dnsadmin-#VERSION#
+should work fine;  a directory alias under an existing virtual host should
+work as well.
 
 The directory containing the HTML and scripts must have at least the
Index: /trunk/Makefile
===================================================================
--- /trunk/Makefile	(revision 218)
+++ /trunk/Makefile	(revision 219)
@@ -28,7 +28,23 @@
 DESTDIR =
 
+# flag to indicate if we install in a version-numbered location to
+# support parallel installs (packaged or otherwise) or if we're
+# installing to .../dnsdb/ (overwrite whatever was there last)
+PARA_VERSIONS = 0
+
+# also set the leaf directories we'll be putting things in
+PKG_LEAF = "dnsdb"
+CFG_LEAF = "dnsdb"
+
+# tweak the final leaf directories we install to if PARA_VERSIONS is set
+ifeq "$(PARA_VERSIONS)" "1"
+PKG_LEAF = "dnsdb-$(VERSION)"
+CFG_LEAF = "dnsdb/$(VERSION)"
+endif
+
 MANIFEST = \
-	INSTALL COPYING TODO Makefile new-dns.sql dns.sql dns.cgi dns-rpc.cgi DNSDB.pm \
-	vega-import.pl \
+	INSTALL COPYING TODO Makefile dnsadmin.spec \
+	\
+	new-dns.sql dns.sql dns.cgi dns-rpc.cgi DNSDB.pm vega-import.pl \
 	\
 	index.shtml \
@@ -83,22 +99,23 @@
 install:
 	@for i in $(IMAGES) $(TEMPLATES); do \
-		$(INSTALL_DATA) -D $$i $(DESTDIR)${datadir}/dnsdb-$(VERSION)/$$i ; \
+		$(INSTALL_DATA) -D $$i $(DESTDIR)${datadir}/$(PKG_LEAF)/$$i ; \
 	done
 	@# munge in necessary 'use lib ...' bits so scripts can find libs and config...
 	@# datadir is correct;  no arch-specific files
 	@for i in $(SCRIPTS) $(MODULES); do \
-		$(INSTALL_SCRIPT) -D $$i $(DESTDIR)${datadir}/dnsdb-$(VERSION)/$$i ; \
-		perl -pi -e 's|use lib '.';	##uselib##|use lib "${datadir}/dnsdb-$(VERSION)/";|;' $(DESTDIR)${datadir}/dnsdb-$(VERSION)/$$i ; \
-		perl -pi -e 's|use lib '.';	##uselib##|use lib "${datadir}/dnsdb-$(VERSION)/";|;' $(DESTDIR)${datadir}/dnsdb-$(VERSION)/$$i ; \
+		$(INSTALL_SCRIPT) -D $$i $(DESTDIR)${datadir}/$(PKG_LEAF)/$$i ; \
+		perl -pi -e 's|use lib '.';	##uselib##|use lib "${datadir}/$(PKG_LEAF)/";|;' $(DESTDIR)${datadir}/$(PKG_LEAF)/$$i ; \
+		perl -pi -e 's|use lib '.';	##uselib##|use lib "${datadir}/$(PKG_LEAF)/";|;' $(DESTDIR)${datadir}/$(PKG_LEAF)/$$i ; \
 	done
-	@$(INSTALL) -d $(DESTDIR)${sysconfdir}/dnsdb/
+	@$(INSTALL) -d $(DESTDIR)${sysconfdir}/$(CFG_LEAF)/
 	@# install an example config file with all known settings
 	@for i in $(CONFIGFILES) ; do \
-		if [ -e $(DESTDIR)${sysconfdir}/dnsdb/$$i ]; then \
+		if [ -e $(DESTDIR)${sysconfdir}/$(CFG_LEAF)/$$i ]; then \
 			echo "refusing to overwrite existing config file, created as $$i.new" ; \
-			$(INSTALL_DATA) $$i $(DESTDIR)${sysconfdir}/dnsdb/$$i.new ; \
+			$(INSTALL_DATA) $$i $(DESTDIR)${sysconfdir}/$(CFG_LEAF)/$$i.new ; \
 		else \
-			$(INSTALL_DATA) $$i $(DESTDIR)${sysconfdir}/dnsdb/ ; \
-		fi \
+			$(INSTALL_DATA) $$i $(DESTDIR)${sysconfdir}/$(CFG_LEAF)/ ; \
+		fi ; \
+		perl -pi -e 's|"/etc/dnsdb";	##CFG_LEAF##|"${sysconfdir}/$(CFG_LEAF)";|;' $(DESTDIR)${datadir}/$(PKG_LEAF)/DNSDB.pm ; \
 	done
 #	# and now munge MyDNSDB.pm so it can find the core library
@@ -113,5 +130,5 @@
 	mkdir $(PKGNAME)-$(VERSION)
 	tar cf - $(MANIFEST) | (cd $(PKGNAME)-$(VERSION); tar xf -)
-	#/usr/bin/perl -p -e 's/#VERSION#/$(VERSION)/;s/#RELEASE#/$(RELEASE)/;s/#BETA#//g' < $(PKGNAME).spec > $(PKGNAME)-$(VERSION)/$(PKGNAME).spec
+	/usr/bin/perl -p -e 's/#VERSION#/$(VERSION)/;s/#RELEASE#/$(RELEASE)/;s/#BETA#//g' < $(PKGNAME).spec > $(PKGNAME)-$(VERSION)/$(PKGNAME).spec
 	/usr/bin/perl -p -e 's/#VERSION#/$(VERSION)/;s/#RELEASE#/$(RELEASE)/;s/#BETA#//g' < INSTALL > $(PKGNAME)-$(VERSION)/INSTALL
 	perl -pi -e 's/[\d.]+;\s*##VERSION##/$(VERSION);/;' $(PKGNAME)-$(VERSION)/DNSDB.pm
Index: /trunk/dnsadmin.spec
===================================================================
--- /trunk/dnsadmin.spec	(revision 219)
+++ /trunk/dnsadmin.spec	(revision 219)
@@ -0,0 +1,103 @@
+# spec file for DNS Administrator
+# $Id$
+
+# A collection of magic for packaging with debbuild (https://secure.deepnet.cx/trac/debbuild
+# Sets the release "number" such that dist upgrades will upgrade in the right order.
+%if "%{debdist}" == "sarge"
+%define errata 0
+%endif
+%if "%{debdist}" == "dapper"
+%define errata 1
+%endif
+%if "%{debdist}" == "etch"
+%define errata 2
+%endif
+%if "%{debdist}" == "lenny"
+%define errata 3
+%endif
+%if "%{debdist}" == "squeeze"
+%define errata 4
+%endif
+%if %{?relnum:0}%{?!relnum:1}
+%define relnum 1
+%endif
+
+# redefine release only if debdist is defined
+%if %{?debdist:1}%{?!debdist:0}
+%define release %{relnum}.%{errata}%{debdist}
+%else
+%define release 1
+%endif
+
+# handle flag for parallel-versions installs.
+%if %{?para_versions:1}%{?!para_versions:0}
+%define pkg_leaf dnsdb-%{version}
+%define cfg_leaf dnsdb/%{version}
+%else
+%define pkg_leaf dnsdb
+%define cfg_leaf dnsdb
+%endif
+
+Summary: DeepNet DNS Administrator
+Name: dnsadmin
+Version: #VERSION#
+Release: %{release}
+Group: Applications/System
+Source: %{name}-%{version}.tar.gz
+Packager: Kris Deugau <kdeugau@deepnet.cx>
+BuildRoot: /var/tmp/%{name}-%{version}
+License: GPL 3+
+BuildArch: noarch
+
+# not absolutely required:
+Requires: perl(NetAddr::IP) >= 4
+
+# rpmbuild should fill in the rest of the deps.  Debian's tools aren't so friendly.  :/
+
+%if %{_vendor} == "debbuild"
+# ah, Debian, how we do *love* thee so...  *eyeroll*
+Requires: libfrontier-rpc-perl >= 0.07b4, perl(CGI::Simple), perl(HTML::Template), perl(Net::DNS)
+Requires: perl(CGI::Session), perl(Crypt::PasswdMD5), perl(Digest::MD5), perl(Net::Whois::Raw)
+%endif
+
+%description
+A web-based DNS management tool
+
+%prep
+%setup
+
+%build
+
+%install
+# le sigh.  rpm's makeinstall macro includes the buildroot in the dirs, so it will break here.  :/
+make \
+        prefix=%{_prefix} \
+        exec_prefix=%{_exec_prefix} \
+        bindir=%{_bindir} \
+        sbindir=%{_sbindir} \
+        sysconfdir=%{_sysconfdir} \
+        datadir=%{_datadir} \
+        includedir=%{_includedir} \
+        libdir=%{_libdir} \
+        libexecdir=%{_libexecdir} \
+        localstatedir=%{_localstatedir} \
+        sharedstatedir=%{_sharedstatedir} \
+        mandir=%{_mandir} \
+        infodir=%{_infodir} \
+  install DESTDIR=$RPM_BUILD_ROOT PARA_VERSIONS=%{?para_versions:1}%{?!para_versions:0}
+
+%clean
+if [ "$RPM_BUILD_ROOT" != "/" ]; then
+  rm -rf $RPM_BUILD_ROOT
+fi
+
+%files
+%{_datadir}/%{pkg_leaf}
+%attr(-,-,0755) %{_datadir}/%{pkg_leaf}/*.cgi
+%attr(-,-,0755) %{_datadir}/%{pkg_leaf}/*.pl
+%{_sysconfdir}/%{cfg_leaf}
+%config %{_sysconfdir}/%{cfg_leaf}/dnsdb.conf
+
+%changelog
+* Fri Jan 13 2012  Kris Deugau <kdeugau@deepnet.cx> 1.0-1
+- Initial package
