Anonymous avatar Anonymous committed 75f02e7

Packaging for Daybo Logic stuff

Comments (0)

Files changed (25)

+#!/bin/bash
+#
+# This bootstrap script is designed to initlaly populate, and later update
+# from the global skeleton, for a build of any package.
+#
+# It should be manually fetched and run by any programmer creating a package,
+# it should be able to run on CentOS and Debian platforms and should be
+# non-destructive.
+#
+#----------------------------------------------------------------------------
+function copy_skeleton
+{
+	echo 'Copying skeleton packaging tree from within build-scripts'
+	if [ -d '../shared/packaging' ]; then
+		/usr/bin/rsync --exclude=Bootstrap-pkg.sh --exclude=.svn -r -a -u -v -p ../shared/packaging/ .
+	else
+		echo 'Sorry, ../shared/packaging is not available'
+		exit 1;
+	fi
+}
+#----------------------------------------------------------------------------
+function download_skeleton
+{
+	echo "Since you're not building within the build-scripts tree, we need to access"
+	echo "sub-version, and perform an update from /tmp/, please enter your credentials"
+	echo "when prompted"
+	echo -e "\n"
+
+	old_dir=`pwd`
+
+	mkdir -p -m 0700 /tmp/`whoami`/Build.$$/ && \
+	cd /tmp/`whoami`/Build.$$/ && \
+	svn export https://svn.daybologic.co.uk/svn/packaging/trunk
+
+	cd $old_dir && \
+	/usr/bin/rsync --exclude=Bootstrap-pkg.sh -r -a -u -v -p /tmp/`whoami`/Build.$$/packaging/ . && \
+	rm -rv /tmp/`whoami`/Build.$$/packaging/ && \
+	rmdir -v /tmp/`whoami`/Build.$$/
+}
+#----------------------------------------------------------------------------
+function copy_skeleton_wrapper
+{
+	if [ -d '../shared/packaging' ]; then
+		copy_skeleton
+	else
+		download_skeleton
+	fi
+}
+#----------------------------------------------------------------------------
+function deps
+{
+	# You'll need Subversion for the skeleton package directory
+	if ! [ -x /usr/bin/svn ]; then
+		if [ -x /usr/bin/yum ]; then
+			sudo yum install subversion
+		else
+			sudo apt-get install subversion
+		fi
+	fi
+
+	# You'll need RSync for updating the skeleton
+	if ! [ -x /usr/bin/rsync ]; then
+		if [ -x /usr/bin/yum ]; then
+			sudo yum install rsync
+		else
+			sudo apt-get install rsync
+		fi
+	fi
+}
+#----------------------------------------------------------------------------
+function fixups
+{
+	# It's OK to refer to dl-generic's configure here, since that's part
+	# of the bootstrap distribution set.
+	base_path=./rpmbuild/SOURCES/dl-generic-0.1.0
+	x_script=("$base_path/configure" "dl-get_from_spec" "dl-rpm_to_deb" "dl-rules_hack")
+
+	for xscr in ${x_script[*]}
+	do
+		if [ -f "$xscr" ]; then
+			if ! [ -x "$xscr" ]; then
+				echo "Marking $xscr executable"
+				chmod +x "$xscr"
+			fi
+		else
+			echo "Error: Script not found - $xscr"
+			exit 1;
+		fi
+	done
+}
+#----------------------------------------------------------------------------
+# Die on unbound (uninitialised) varaible use.
+set -u
+
+deps -f 0
+copy_skeleton_wrapper -f 0
+fixups -f 0
+
+echo ''
+echo '*** INSTRUCTIONS ***'
+echo 'Please review the package skeleton, write the .spec or Debian rules, and then run ./Build'
+echo ''
+
+exit 0;
+#!/bin/bash
+
+do_time=0
+do_list=0
+do_clean=0
+this_host=`hostname -s`
+cc=${CC}
+#----------------------------------------------------------------------------
+function rpmbuild_link
+{
+	# Create a link like /home/palmer/rpmbuild to keep rpmbuild happy.
+	link=$HOME/rpmbuild
+	link_dest=`pwd`/rpmbuild
+	if [ -s "$link" ]; then
+		echo "Sorry, the symbolic link $link already exists, we need to link it to $link_dest"
+		exit 1;
+	fi
+	if ! [ -f "$link" ]; then
+		ln -s "$link_dest" "$link"
+	else
+		echo "Sorry, $link exists and is not a symbolic link, please check it and remove it"
+		exit 1;
+	fi
+}
+#----------------------------------------------------------------------------
+function rpmbuild_unlink
+{
+	# We will only remove ~/rpmbuild if it's a symlink to a directory.
+	link=$HOME/rpmbuild
+	if [ -d "$link" ]; then
+		if [ -s "$link" ]; then
+			echo "Removing symbolic link $link"
+			rm "$link"
+		fi
+	fi
+}
+#----------------------------------------------------------------------------
+function do_debian
+{
+	# For now, we're going to convert from the .rpm generated on CentOS
+	# using Alien, we will generate directly in a later revision of this
+	# script.
+
+	# Call dl_get_from_spec to get some important knowledge
+	specfile="./rpmbuild/SPECS/$1.spec"
+	buildarch=`./dl-get_from_spec -s $specfile -v BuildArch`
+	version=`./dl-get_from_spec -s $specfile -v Version`
+	pkgname=`./dl-get_from_spec -s $specfile -v Name`
+	rel=`./dl-get_from_spec -s $specfile -v Release`
+
+	rpmpath=./rpmbuild/RPMS/$buildarch/$pkgname-$version-$rel.$buildarch.rpm
+	debpath=`./dl-rpm_to_deb -m path -r $rpmpath`
+	debepath=`./dl-rpm_to_deb -m epath -r $rpmpath`
+	if [ "$?" -ne "0" ]; then
+		echo "Build: Cannot assure path for $rpmpath via support tool - dl-rpm_to_deb"
+		exit $?
+	fi
+	./dl-rpm_to_deb -m alien -r $rpmpath -b $debpath
+	if [ "$?" -ne "0" ]; then
+		echo "Build: Cannot generate .deb from .rpm via Alien (dl-rpm_to_deb)"
+		exit $?
+	fi
+
+	# We now have a directory created by Alien, suitable for passing through the standard Debian toolchain
+	# First we must change the rules slightly using a slight of hand.
+
+	tmp_rules=/tmp/Build-packaging.rules.`hostname -s`.$$
+	./dl-rules_hack -d -i $debepath/debian/rules -o $tmp_rules
+	if [ "$?" -ne "0" ]; then
+		if [ "$?" -eq "1" ]; then
+			echo "dl-rules_hack: Input error"
+			exit "$?"
+		fi
+		if [ "$?" -eq "2" ]; then
+			echo "dl-rules_hack: Output error"
+			exit "$?"
+		fi
+		if [ "$?" -eq "3" ]; then
+			echo "dl-rules_hack: Command-line syntax error"
+			exit "$?"
+		fi
+		echo "dl-rules_hack: Unknown error"
+		exit "$?"
+	fi
+
+	if [ -f $tmp_rules ]; then
+		diff -u $debepath/debian/rules $tmp_rules | patch -u $debepath/debian/rules
+		if [ "$?" -eq "0" ]; then
+			rm -v $tmp_rules
+			old_path=`pwd` && \
+			cd $debepath/ && dpkg-buildpackage && \
+			cd $old_path
+			echo "Converted $rpmpath to $debpath"
+		fi
+	fi
+}
+#----------------------------------------------------------------------------
+function do_centos
+{
+	if ! [ -x '/usr/bin/rpmbuild' ]; then
+		sudo yum -y install rpm-build
+	fi
+
+	if [ -x '/usr/bin/rpmbuild' ]; then
+		rpmbuild_link
+		old_dir=`pwd`
+		cd "$old_dir/rpmbuild/" && \
+		/bin/sh -x ./tar.sh $1 && \
+		rpmbuild -v -bb --clean "SPECS/$1.spec"
+		rpmbuild_unlink
+		if [ "$?" -ne "0" ]; then
+			echo "rpmbuild exited with status $?"
+			cd "$old_dir"
+			exit $?;
+		fi
+		cd "$old_dir"
+	else
+		echo "rpm-build is not installed."
+		exit 1;
+	fi
+}
+#----------------------------------------------------------------------------
+function do_list
+{
+	if ! [ -x './rpmbuild/tmp/spec_lister' ]; then
+		inst_cc -f 0
+		$cc -o ./rpmbuild/tmp/spec_lister ./rpmbuild/SOURCES/spec_lister.c
+	fi
+	if [ -x './rpmbuild/tmp/spec_lister' ]; then
+		./rpmbuild/tmp/spec_lister rpmbuild/SPECS
+	else
+		echo 'Helper program failed to build.'
+		exit 1;
+	fi
+	exit 0;
+}
+#----------------------------------------------------------------------------
+function do_clean_list
+{
+	if [ -f './rpmbuild/tmp/spec_lister' ]; then
+		rm -v ./rpmbuild/tmp/spec_lister
+	fi
+}
+#----------------------------------------------------------------------------
+function inst_cpp
+{
+	if ! [ -x '/usr/bin/g++' ]; then
+		if [ -x '/usr/bin/yum' ]; then
+			sudo /usr/bin/yum -y install 'gcc-c++'
+		else
+			sudo apt-get install 'g++'
+		fi
+	fi
+	if ! [ -x '/usr/bin/g++' ]; then
+		echo "Failed to install C++ compiler (g++)"
+		exit 2;
+	fi
+}
+#----------------------------------------------------------------------------
+function inst_cc
+{
+	if ! [ -x /usr/bin/cc ]; then
+		if [ -x /usr/bin/yum ]; then
+			sudo /usr/bin/yum -y install gcc
+		else
+			sudo apt-get install gcc
+		fi
+	fi
+	if ! [ -x /usr/bin/cc ]; then
+		echo "Failed to install C compiler (gcc)"
+		exit 2;
+	fi
+}
+#----------------------------------------------------------------------------
+if ! [ "$cc" ]; then
+	cc=cc
+fi
+
+if ! [ "$1" ]; then
+	echo "Specify package to build or --list to view packages, use --clean for cleanup"
+	exit 1;
+fi
+
+if [ "$1" = '--list' ]; then
+	do_list=1
+fi
+if [ "$1" = '-l' ]; then
+	do_list=1
+fi
+
+if [ "$1" = '--clean' ]; then
+	do_clean=1
+fi
+if [ "$1" = '-c' ]; then
+	do_clean=1
+fi
+
+if [ "$do_list" -eq "1" ]; then
+	do_list -f 0
+	exit 0;
+fi
+
+if [ "$do_clean" -eq "1" ]; then
+	do_clean_list -f 0
+	exit 0;
+fi
+
+if [ "$this_host" = "violet-club" ]; then
+	do_time=1
+elif [ "$this_host" = "runt" ]; then
+	do_time=1
+fi
+
+if [ "$do_time" -eq "1" ]; then
+	if ! [ -x '/usr/sbin/ntpdate' ]; then
+		sudo yum -y install ntp
+	fi
+	if [ -x '/usr/sbin/ntpdate' ]; then
+		sudo /usr/sbin/ntpdate ntp1.gradwell.net
+	fi
+fi
+
+# Install compilers and other tools configure will look for
+inst_cc -f 0
+inst_cpp -f 0
+if [ -f '/etc/debian_version' ]; then
+	do_debian $1
+else
+	do_centos $1
+fi
+
+exit 0;
+#----------------------------------------------------------------------------
+dl-generic (0.0.1) stable; urgency=low
+
+  * Initial release
+
+ -- David Palmer <palmer@overchat.org>  Fri, 19 Nov 2010 21:47:30 +0000
+Source: dl-generic
+Section: utils
+Priority: extra
+Maintainer: David Palmer <palmer@overchat.org>
+Build-Depends: debhelper (>= 7)
+Standards-Version: 3.7.3
+Homepage: http://www.daybologic.co.uk/
+
+Package: dl-generic
+Architecture: all
+Depends: ${shlibs:Depends}, ${misc:Depends}, ${perl:Depends}, perl
+Description: Generic Daybo Logic package (example)
+ This package is designed for basing more advanced packages from only,
+ it is not intended to be deployed or depended on, it is for copying and modfying.
+opt/voip/dl-generic
+#!/bin/sh
+
+set -e
+
+/bin/true
+if [ "$?" -ne "0" ]; then
+        echo "Not a standard system"
+        exit 1;
+fi
+exit 0;
+#!/bin/sh
+
+set -e
+
+/bin/true
+if [ "$?" -ne "0" ]; then
+	echo "Not a standard system"
+	exit 1;
+fi
+exit 0;
+#!/usr/bin/make -f
+# -*- makefile -*-
+# Sample debian/rules that uses debhelper.
+# This file was originally written by Joey Hess and Craig Small.
+# As a special exception, when this file is copied by dh-make into a
+# dh-make output file, you may use that output file without restriction.
+# This special exception was added by Craig Small in version 0.37 of dh-make.
+
+# Uncomment this to turn on verbose mode.
+#export DH_VERBOSE=1
+
+
+
+
+
+configure: configure-stamp
+configure-stamp:
+	dh_testdir
+	# Add here commands to configure the package.
+
+	touch configure-stamp
+
+
+build: build-stamp
+
+build-stamp: configure-stamp  
+	dh_testdir
+
+	# Add here commands to compile the package.
+	#$(MAKE)
+	#docbook-to-man debian/floatips.sgml > floatips.1
+
+	touch $@
+
+clean: 
+	dh_testdir
+	dh_testroot
+	rm -f build-stamp configure-stamp
+
+	# Add here commands to clean up after the build process.
+	#$(MAKE) clean
+
+	dh_clean 
+
+install: build
+	dh_testdir
+	dh_testroot
+	dh_clean -k 
+	dh_installdirs
+
+	# Add here commands to install the package into debian/dl-generic.
+	install -m 755 obj/dl-generic $(CURDIR)/debian/dl-generic/opt/dl-generic
+
+# Build architecture-independent files here.
+binary-indep: build install
+# We have nothing to do by default.
+
+# Build architecture-dependent files here.
+binary-arch: build install
+	dh_testdir
+	dh_testroot
+#	dh_installchangelogs 
+#	dh_installdocs
+#	dh_installexamples
+#	dh_install
+#	dh_installmenu
+#	dh_installdebconf	
+#	dh_installlogrotate
+#	dh_installemacsen
+#	dh_installpam
+#	dh_installmime
+#	dh_python
+#	dh_installinit
+#	dh_installcron
+#	dh_installinfo
+#	dh_installman
+#	dh_link
+#	dh_strip
+	dh_compress
+	dh_fixperms
+#	dh_perl
+#	dh_makeshlibs
+	dh_installdeb
+	dh_shlibdeps
+	dh_gencontrol
+	dh_md5sums
+	dh_builddeb
+
+binary: binary-indep binary-arch
+.PHONY: build clean binary-indep binary-arch binary install configure
+#!/usr/bin/perl -w
+#
+# This tool was intended to convert a .spec %changelog section into a Debian changelog,
+# however, Alien converts the first (latest) entry in the changelog when creating the
+# .deb and I think this is enough.
+#
+
+use strict;
+use Getopt::Std;
+
+use constant OPTS => ('r:b:dp:v:R:h');
+use constant EXIT_SUCCESS => (0);
+use constant EXIT_RPM_FILE => (1);
+use constant EXIT_DEB_FILE => (2);
+use constant EXIT_NO_DATA => (3);
+use constant EXIT_RPM_SYNTAX => (4);
+use constant EXIT_SYNTAX_CLI => (5);
+use constant EXIT_UNKNOWN => (6);
+#----------------------------------------------------------------------------
+sub Main();
+sub Syntax($);
+#----------------------------------------------------------------------------
+sub Main()
+{
+	my %opts = ( );
+	my $ret = EXIT_UNKNOWN();
+	return EXIT_SYNTAX_CLI() unless ( Getopt(\%opts, OPTS()) );
+
+	if ( $opts{'h'} ) {
+		Syntax(1);
+		return EXIT_SUCCESS();
+	}
+	return $ret;
+}
+#----------------------------------------------------------------------------
+sub Syntax($)
+{
+}
+#----------------------------------------------------------------------------
+exit Main(); # Entry point.
+#----------------------------------------------------------------------------
+#!/usr/bin/perl -w
+#
+# This Perl script is intended to recover various bits of information from the .spec file,
+# in the ultimate hope that we can maintain one .spec file, whilst simultaneously building
+# both a .rpm and a .deb file.  Various scripts will call us when creating a .deb, without
+# needing a copy of CentOS or rpm around.
+#
+# Eg. dl-get_from_spec BuildArch
+# may return the string 'noarch' and then the script will exit with code 0
+# Return code 1 means the string was not found
+# Return code 2 means that the .spec file itself did not exist, or there was a problem
+# reading it.
+#
+
+use strict;
+use Getopt::Std;
+#----------------------------------------------------------------------------
+use constant EXIT_SUCCESS => ( 0 );
+use constant EXIT_NO_MATCH => ( 1 );
+use constant EXIT_FILE_ERROR => ( 2 );
+use constant EXIT_SYNTAX => ( 3 );
+
+use constant OPTS => ( 's:v:d' );
+
+my $Debug = 0;
+my %GlobDefs = (
+	nil => '' # Special definition which is often used in RPMs
+); # Global definitions in .spec file.
+
+sub Main();
+sub DoParseOpen($$$);
+sub DoParseDecomment($$$$);
+sub DoParseReal($$$$);
+sub ResolveMacros($);
+sub ResolveShell($);
+sub DumpGlobDefs();
+#----------------------------------------------------------------------------
+sub Main()
+{
+	my $ret = EXIT_FILE_ERROR();
+	my @tmpArg;
+	my %opts = ( );
+	my @specFiles = (
+		"$ENV{HOME}/.rpmrc",
+		"$ENV{HOME}/.rpmmacros"
+	);
+
+	getopts(OPTS(), \%opts);
+	@tmpArg = split(':', OPTS());
+	foreach my $a ( @tmpArg ) {
+		# All arguments are mandatory (except d)
+		next if ( $a eq 'd' );
+		unless ( defined($opts{$a}) && length($opts{$a}) ) {
+			printf(STDERR "Error: -%s must be specified\n", $a);
+			return EXIT_SYNTAX();
+		}
+	}
+
+	$Debug = 1 if ( defined($opts{'d'}) );
+
+	push @specFiles, $opts{'s'};
+	foreach my $specFile ( @specFiles ) {
+		my $isSpecFile = 0;
+		$isSpecFile = 1 if ( $specFile =~ m/.spec$/ );
+		$ret = DoParseOpen($specFile, $opts{'v'}, $isSpecFile);
+		last if ( $ret == EXIT_SUCCESS() || $ret == EXIT_SYNTAX() );
+	}
+	return $ret;
+}
+#----------------------------------------------------------------------------
+sub DoParseOpen($$$)
+{
+	my $line;
+	my $ret;
+	my $output = undef;
+	my ( $Spec, $DefVar, $SpecMode ) = ( @_ );
+	my @specData = ( );
+	unless ( open(SPEC, '< ' . $Spec) ) {
+		printf(STDERR "Cannot read .spec file - %s\n", $Spec);
+		return EXIT_FILE_ERROR();
+	}
+
+	while ( $line = <SPEC> ) {
+		push @specData, $line;
+	}
+	close(SPEC);
+
+	$ret = DoParseDecomment(\@specData, $DefVar, \$output, $SpecMode);
+	print "$output\n" if ( $ret == EXIT_SUCCESS() );
+	DumpGlobDefs() if ( $Debug );
+	return $ret;
+}
+#----------------------------------------------------------------------------
+sub DoParseDecomment($$$$)
+{
+	my ( $SpecData, $DefVar, $Output, $SpecMode ) = @_;
+	my $ret = EXIT_NO_MATCH();
+
+	foreach my $line ( @$SpecData ) {
+		my $decomm = undef; # Decommented line
+		chomp($line);
+		my $rmkPos = index($line, '#');
+		if ( $rmkPos == 0 ) { # Comment is entire line?
+			$decomm = '';
+		} elsif ( $rmkPos == -1 ) { # No comment?
+			$decomm = $line;
+		} else {
+			$decomm = substr($line, 0, $rmkPos);
+		}
+
+		next unless ( defined($decomm) && length($decomm) );
+		$ret = DoParseReal($line, $DefVar, $Output, $SpecMode);
+		last if ( $ret == EXIT_SUCCESS() );
+	}
+	return $ret;
+}
+#----------------------------------------------------------------------------
+sub DoParseReal($$$$)
+{
+	my ( $Line, $DefVar, $Output, $SpecMode ) = ( @_ );
+
+	if ( $SpecMode ) { # We're looking at a Spec file?
+		if ( $Line =~ m/\%define\s+([a-zA-Z0-9_]+)\s+(.*)$/ ) { # Found macro definition
+			$GlobDefs{$1} = ResolveShell(ResolveMacros($2));
+		}
+
+		if ( $Line =~ m/([a-zA-Z]+)\:\s+(.*)$/ ) { # Found directive?
+			if ( $1 eq $DefVar ) {
+				$$Output = ResolveShell(ResolveMacros($2));
+				return EXIT_SUCCESS();
+			}
+		}
+	} else { # We're looking at a macro file only
+		if ( $Line =~ m/\%([a-zA-Z0-9_]+)\s+(.*)$/ ) { # Found macro definition
+			$GlobDefs{$1} = ResolveShell(ResolveMacros($2));
+		}
+	}
+	return EXIT_NO_MATCH();
+}
+#----------------------------------------------------------------------------
+sub ResolveMacros($)
+{
+	# You might get warnings here if you reference anything which isn't defined.
+	# There's no great way I can think of to avoid the warnings whilst at the same
+	# time keeping this code so elite.
+
+	my $Line = $_[0];
+	while ( $Line =~ s/\%\{([a-zA-Z0-9_]+)\}/$GlobDefs{$1}/ ) { }
+	return $Line;
+}
+#----------------------------------------------------------------------------
+sub ResolveShell($)
+{
+	# Warning, this is potentially risky!  Refuse to run as root.
+	my $Line = $_[0];
+	my $matches = 1;
+
+	if ( $> == 0 ) {
+		die 'Shell substitution detected within .spec, must not be performed as root';
+	}
+
+	while ( $matches ) {
+		my $start_idx;
+		if ( (( $start_idx = index($Line, '%(')) != -1 ) ) {
+			my $end_idx = index($Line, ')', $start_idx+1);
+			next if ( $start_idx >= $end_idx );
+			my $shellRepl = substr($Line, $start_idx+2, ($end_idx-$start_idx)-2);
+			my $shellOutput = `$shellRepl`;
+			chomp $shellOutput;
+			substr($Line, $start_idx, ($end_idx-$start_idx)+1, $shellOutput);
+		} else { $matches = 0; }
+	}
+	return $Line;
+}
+#----------------------------------------------------------------------------
+sub DumpGlobDefs()
+{
+	foreach my $g ( keys(%GlobDefs) ) {
+		printf("%s => %s\n", $g, $GlobDefs{$g});
+	}
+	return;
+}
+#----------------------------------------------------------------------------
+exit Main();
+#----------------------------------------------------------------------------
+#!/usr/bin/perl -w
+#
+# This Perl script functions as a wrapper for ALIEN(1p)
+#   alien - Convert or install an alien binary package
+#
+# We have two basic modes of operation:
+# -m path (Generate a path from a given .rpm path
+# -m alien (Run alien)
+# Additionally, a mode called epath will generate a different path
+# for expanded rpms.
+#
+# Additional flags:
+# -r <rpmpath> Specify path to .rpm file (always required)
+# -b <debpath> Specify path to .deb file (only required in alien mode)
+#
+# -d Debugging enabled
+# -h For help
+
+use strict;
+use Getopt::Std;
+use Data::Dumper;
+use File::Basename;
+#----------------------------------------------------------------------------
+# Exit codes for shell script
+use constant EXIT_SUCCESS => ( 0 ); # Operation completed successfully
+use constant EXIT_CLI => ( 1 ); # Command-line error (typically syntax, order of ops)
+use constant EXIT_RPM => ( 2 ); # Cannot access/read .rpm file, or the rpm file is unacceptable
+use constant EXIT_DEB => ( 3 ); # Path to .deb may not be acceptable
+use constant EXIT_ALIEN => ( 4 ); # Alien reported an error converting to .deb
+use constant EXIT_UNKNOWN => ( 5 );
+
+use constant OPTS => ( 'm:r:b:dh' );
+
+my $Debug = 0;
+my %FileExitMap = (
+	'rpm' => EXIT_RPM(),
+	'deb' => EXIT_DEB()
+);
+
+sub Main();
+sub Syntax($);
+sub SyntaxDetail($$);
+sub CheckMode($);
+sub DoSanity($$);
+sub OptSet($$$);
+sub CheckPaths($$);
+sub GetFileExtension($$);
+sub Process($);
+sub GenPath($$);
+sub GenEPath($$);
+sub DoAlien($$);
+sub FnRpmToDeb($);
+#----------------------------------------------------------------------------
+sub Main()
+{
+	my $errMsg = undef;
+	my $ret = EXIT_SUCCESS();
+	my %opts = ( );
+	my @specFiles = (
+		"$ENV{HOME}/.rpmrc",
+		"$ENV{HOME}/.rpmmacros"
+	);
+
+	getopts(OPTS(), \%opts);
+	if ( defined($opts{'h'}) ) {
+		Syntax(1);
+		return EXIT_SUCCESS();
+	}
+
+	$Debug = 1 if ( defined($opts{'d'}) );
+	$ret = DoSanity(\%opts, \$errMsg);
+	unless ( $ret == EXIT_SUCCESS() ) {
+		printf(STDERR "%s\n", $errMsg) if ( defined($errMsg) );
+		Syntax(0) if ( $ret == EXIT_CLI );
+		return $ret;
+	}
+
+	$ret = Process(\%opts);
+	return $ret;
+}
+#----------------------------------------------------------------------------
+sub Syntax($)
+{
+	my $DoBanner = $_[0];
+
+	my %args = (
+		'm' => 'mode',
+		'r' => 'rpmpath',
+		'b' => 'debpath'
+	);
+
+	if ( $DoBanner ) {
+		print("dl-rpm_to_deb; RPM to Debian Alien Wrapper for the Daybo Logic package system\n");
+		print("(c)Copyright 2010 Daybo Logic.  All rights reserved\n");
+		print("\n\n");
+	}
+
+	my $cmd = "$0 ";
+	my @o = split('', OPTS());
+	for ( my $i = 0; $i < scalar(@o); $i++ ) {
+		next if ( $o[$i] eq ':' );
+		$cmd .= '-' . $o[$i];
+		if ( $i != (scalar(@o)-1) && $o[$i+1] eq ':' ) {
+			# It's an option which takes an argument
+			if ( defined($args{$o[$i]}) ) {
+				$cmd .= ' <' . $args{$o[$i]} . '>';
+			} else {
+				die "-$o[$i] needs an argument, but none is known in the code, add to args hash;\n" .
+				sprintf(Dumper \%args);
+			}
+		}
+		$cmd .= ' ' unless ( $i == (scalar(@o)-1) );
+	}
+	$cmd .= "\n";
+
+	print $cmd; # The basic syntax line
+
+	# This function is long enough now, pass to a SyntaxDetail function for a complete listing
+	SyntaxDetail(\@o, \%args);
+	return;
+}
+#----------------------------------------------------------------------------
+sub SyntaxDetail($$)
+{
+	my ( $Opts, $Args ) = @_;
+	my %detail = (
+		'm' => "Mode of operation, \'path\' produces a .deb path from an .rpm path, \'alien\' converts between the two",
+		'h' => "This help/syntax report",
+		'r' => 'Path to input RPM file, directory components may be changed, this is always mandatory',
+		'b' => 'Path to output DEB file, the path must exist and be writable, only accepted in alien mode',
+		'd' => 'Debug at critical sections to trace logic decisions'
+	);
+
+	foreach my $o ( @$Opts ) {
+		next if ( $o eq ':' ); # Ignore Getopt-speak
+		my $a = ''; # Argument to option
+		my $d = 'No help provided ;('; # Detail
+		$a = '<' . $Args->{$o} . '>' if ( defined($Args->{$o}) );
+		$d = $detail{$o} if ( defined($detail{$o}) );
+		printf("-%s %s\n\t%s\n", $o, $a, $d);
+	}
+	return;
+}
+#----------------------------------------------------------------------------
+sub CheckMode($)
+{
+	my $m;
+	my $Opts = $_[0];
+	die 'Assertion failed' unless ( $Opts );
+	$m = $Opts->{'m'};
+	if ( defined($m) ) {
+		return 1 if ( $m eq 'alien' || $m eq 'path' || $m eq 'epath' );
+	}
+	return 0;
+}
+#----------------------------------------------------------------------------
+sub DoSanity($$)
+{
+	my %pathsToCheck = ( );
+	my ( $Opts, $ErrMsg ) = @_;
+	unless ( CheckMode($Opts) ) {
+		$$ErrMsg = 'Error, -m must specify a valid mode' if ( $ErrMsg );
+		return EXIT_CLI();
+	}
+
+	if ( $Opts->{'m'} eq 'path' || $Opts->{'m'} eq 'epath' ) { # In path mode we need rpm but not deb
+		unless ( OptSet($Opts, 'r', 1) && !OptSet($Opts, 'b', 1) ) {
+			$$ErrMsg = '-r must be specified, but not -b in -m path or -m epath mode' if ( $ErrMsg );
+			return EXIT_CLI();
+		}
+	} elsif ( $Opts->{'m'} eq 'alien' ) { # In alien mode, both the rpm and the deb need to be specified
+		unless ( OptSet($Opts, 'r', 1) && OptSet($Opts, 'b', 1) ) {
+			$$ErrMsg = 'Need both -r and -b in -m alien mode' if ( $ErrMsg );
+			return EXIT_CLI();
+		}
+		$pathsToCheck{$Opts->{'b'}} = 'deb';
+	}
+
+	$pathsToCheck{$Opts->{'r'}} = 'rpm';
+	return CheckPaths(\%pathsToCheck, $ErrMsg);
+}
+#----------------------------------------------------------------------------
+sub OptSet($$$)
+{
+	my ( $Opts, $Opt, $Contents ) = @_;
+	my $ok = 0;
+	return $ok unless ( $Opts && defined($Opt) && length($Opt) == 1 );
+	return $ok unless ( defined($Opts->{$Opt}) );
+	$ok = 1 unless ( $Contents );
+	unless ( $ok ) {
+		$ok = 1 if ( length($Opts->{$Opt}) );
+	}
+	return $ok;
+}
+#----------------------------------------------------------------------------
+sub CheckPaths($$)
+{
+	my ( $Paths, $ErrMsg ) = @_;
+	my $ret = EXIT_SUCCESS();
+
+	die 'Assertion failed' unless ( $Paths );
+	print Dumper $Paths if ( $Debug );
+	foreach my $p ( keys(%$Paths) ) {
+		my $fe;
+		die 'Assertion failed, no value for path $p'
+			unless ( defined($Paths->{$p}) && length($Paths->{$p}) );
+
+		if ( $Paths->{$p} ne 'deb' && $Paths->{$p} ne 'rpm' ) {
+			die 'Assertion failed - unrecognised path type, not rpm or deb for $p (has been set to $Paths->{$p})';
+		}
+
+		# Sanity check the paths, rpm has an rpm extensions etc
+		unless ( GetFileExtension($p, \$fe) eq $Paths->{$p} ) {
+			$$ErrMsg = sprintf(
+				'%s file %s does not have the correct extension (%s)',
+				$Paths->{$p}, $p, $Paths->{$p}
+			) if ( $ErrMsg );
+			return $FileExitMap{$Paths->{$p}};
+		}
+
+		if ( $Paths->{$p} eq 'rpm' ) { # The RPM must exist
+			unless ( -f $p ) {
+				$$ErrMsg = sprintf('%s file - %s is not a normal file', $Paths->{$p}, $p) if ( $ErrMsg );
+				return $FileExitMap{$Paths->{$p}};
+			}
+		}
+
+		if ( $Paths->{$p} eq 'deb' ) { # The directory to contain the .deb must exist
+			my $d = dirname($p);
+			unless ( -d $d ) {
+				$$ErrMsg = sprintf(
+					'Directory %s does not exist for writing %s file',
+					$d, $Paths->{$p}
+				) if ( $ErrMsg );
+				return $FileExitMap{$Paths->{$p}};
+			}
+		}
+	}
+
+	return $ret;
+}
+#----------------------------------------------------------------------------
+sub GetFileExtension($$)
+{
+	my $c;
+	my @parts;
+	my ( $Path, $ExtOut ) = ( @_ );
+	die 'Assertion failed' unless ( $ExtOut );
+	$$ExtOut = '';
+	return $$ExtOut unless ( defined($Path) && length($Path) );
+	@parts = split('\.', $Path);
+	$c = scalar(@parts);
+	return $$ExtOut unless ( $c >= 2 );
+	$$ExtOut = $parts[$c-1];
+	return $$ExtOut;
+}
+#----------------------------------------------------------------------------
+sub Process($)
+{
+	my $ret = EXIT_UNKNOWN();
+	my $Opts = $_[0];
+	my $m = $Opts->{'m'};
+	my $debPath = undef;
+
+	if ( $m eq 'path' ) {
+		$ret = GenPath($Opts->{'r'}, \$debPath);
+	} elsif ( $m eq 'epath' ) {
+		$ret = GenEPath($Opts->{'r'}, \$debPath);
+	} elsif ( $m eq 'alien' ) {
+		$ret = DoAlien($Opts->{'r'}, $Opts->{'b'});
+	}
+
+	if ( $ret == EXIT_SUCCESS() && defined($debPath) ) {
+		print "$debPath\n";
+	}
+	return $ret;
+}
+#----------------------------------------------------------------------------
+sub GenPath($$)
+{
+	# A possible improvement to this code would be to ask the caller about the
+	# name of the package, to avoid assumptions and nasty regexes.
+
+	my $c;
+	my @tmpd;
+	my $fn;
+	my $ret = EXIT_SUCCESS();
+	my ( $Rpm, $Deb ) = ( @_ );
+	$$Deb = $Rpm;
+	$$Deb =~ s/RPMS/DEBS/g;
+	@tmpd = split(m%/%, $$Deb);
+	$c = scalar(@tmpd);
+	$fn = $tmpd[$c-1];
+	printf(STDERR "Filename for path re-generation is \'%s\'\n", $fn) if ( $Debug );
+	$fn = FnRpmToDeb($fn);
+	printf(STDERR "Filename transformation is \'%s\'\n", $fn) if ( $Debug );
+	$tmpd[$c-1] = $fn;
+	$$Deb = join('/', @tmpd);
+	printf(STDERR "Path returned from GenPath is \'%s\'\n", $$Deb) if ( $Debug );
+	return $ret;
+}
+#----------------------------------------------------------------------------
+sub GenEPath($$)
+{
+	my $ret = EXIT_SUCCESS();
+	my ( $Rpm, $Deb ) = ( @_ );
+	my $fn;
+	my $c;
+	my ( @tmpd, @tmpd2 );
+	my $pkg;
+	my $ver;
+
+	$$Deb = $Rpm;
+	@tmpd = split(m%/%, $$Deb);
+	$c = scalar(@tmpd);
+	return EXIT_RPM() unless ( $c >= 2 );
+	$fn = $tmpd[$c-1];
+	return EXIT_RPM() unless ( FnInfoFromRpm($fn, \$pkg, \$ver) );
+
+	@tmpd2 = ( );
+	foreach my $d ( @tmpd ) {
+		push(@tmpd2, $d);
+		last if ( $d eq 'rpmbuild' );
+	}
+	@tmpd = @tmpd2;
+	push(@tmpd, ('BUILD', $pkg . '-' . $ver));
+	$$Deb = join('/', @tmpd);
+	return $ret;
+}
+#----------------------------------------------------------------------------
+sub DoAlien($$)
+{
+	my $rpm_m; # RPM with modified path (local)
+	my $old_dir = undef;
+	my $ret = EXIT_ALIEN();
+	my ( $Rpm, $Deb ) = ( @_ );
+	my $acmd = 'fakeroot alien -d -c -g -s -v -k -T'; # FIXME: Generates dir in wrong place.
+	my @parts = split(m%\s+%, $acmd);
+
+	$rpm_m = '../../' . $Rpm;
+	push @parts, $rpm_m;
+	$old_dir=`pwd`;
+	if ( chdir('./rpmbuild/BUILD/') ) {
+		printf("Running: %s\n", join(' ', @parts));
+		my $retcode = system(@parts);
+		$ret = EXIT_SUCCESS() if ( $retcode == 0 );
+		chdir($old_dir);
+	} else {
+		printf(STDERR "Cannot change directory to $old_dir/rpmbuild/BUILD in DoAlien()\n");
+	}
+	return $ret;
+}
+#----------------------------------------------------------------------------
+sub FnRpmToDeb($)
+{
+	# Convert from dl-generic-0.1.0-1.noarch.rpm
+	# to dl-generic_0.1.0-1_all.deb
+
+	my $Rpm = $_[0];
+	my $deb = '';
+	my ( $pkg, $ver, $rev, $arch );
+
+	if ( $Rpm =~ m/^([a-z][a-z-]*)\-(\d+\.\d+.\d+)\-(\d+)\.(\w+)\.rpm$/ ) {
+		$pkg = $1;
+		$ver = $2;
+		$rev = $3;
+		$arch = $4;
+	}
+
+	$arch = 'all' if ( $arch eq 'noarch' ); # Slightly different terminology
+	$deb = $pkg . '_' . $ver . '-' . $rev . '_' . $arch . '.deb';
+	return $deb;
+}
+#----------------------------------------------------------------------------
+sub FnInfoFromRpm($$$)
+{
+	# Acquire package name and version number from dl-generic-0.1.0-1.noarch.rpm
+
+	my ( $Rpm, $Pkg, $Ver ) = @_;
+	
+	if ( $Rpm =~ m/^([a-z][a-z-]*)\-(\d+\.\d+.\d+)\-(\d+)\.(\w+)\.rpm$/ ) {
+		$$Pkg = $1;
+		$$Ver = $2;
+		return 1;
+	}
+	return 0;
+}
+#----------------------------------------------------------------------------
+exit Main();
+#----------------------------------------------------------------------------
+#!/usr/bin/perl -w
+#
+# Daybo Logic rules hack script.
+# (post-alien processor).
+#
+
+use strict;
+use Getopt::Std;
+
+use constant OPTS => ('i:o:dh');
+use constant EXIT_SUCCESS => (0);
+use constant EXIT_INPUT => (1);
+use constant EXIT_OUTPUT => (2);
+use constant EXIT_SYNTAX_CLI => (3);
+use constant EXIT_UNKNOWN => (4);
+
+use constant SCRIPT_VERSION => ('0.0.1');
+#----------------------------------------------------------------------------
+my $Debug = 0;
+
+sub Main();
+sub Syntax($$);
+sub CheckOpts($);
+sub ReadInput($$);
+sub WriteOutput($$);
+sub Process($$);
+sub Uncomment($$);
+#----------------------------------------------------------------------------
+sub Main()
+{
+	my %opts = ( );
+	my $ret = EXIT_UNKNOWN();
+	return EXIT_SYNTAX_CLI() unless ( getopts(OPTS(), \%opts) );
+
+	if ( $opts{'h'} ) {
+		Syntax(1,1);
+		return EXIT_SUCCESS();
+	}
+	if ( CheckOpts(\%opts) ) {
+		my @data = ( );
+		my $lines = 0;
+		return EXIT_INPUT() unless ( $lines = ReadInput(\@data, $opts{'i'}) );
+		printf("Processing %u lines\n", $lines) if ( $Debug );
+		return $ret unless ( Process(\@data, $lines) );
+		return EXIT_OUTPUT() unless ( WriteOutput(\@data, $opts{'o'}) == $lines );
+		$ret = EXIT_SUCCESS();
+	} else {
+		Syntax(0,0);
+		$ret = EXIT_SYNTAX_CLI();
+	}
+
+	printf(STDERR "%s script exiting with code %u\n", $0, $ret) if ( $Debug );
+	return $ret;
+}
+#----------------------------------------------------------------------------
+sub Syntax($$)
+{
+	my %opt_desc_map = ( # Human-readable
+		'o' => 'Output file (stdout will be used if not specified)',
+		'i' => 'Input file (stdin will be used if not specified)',
+		'h' => 'This help text',
+		'd' => 'Enable verbose debug output on stderr'
+	);
+
+	my %opt_arg_map = (
+		'o' => 'output',
+		'i' => 'input'
+	);
+
+	my ( $DoBanner, $DoDetail ) = ( @_ );
+	if ( $DoBanner ) {
+		printf("dl-rules-hack script %s\n", SCRIPT_VERSION());
+		print("(c)2010 Daybo Logic, all rights reserved.\n\n");
+	}
+
+	my $cli = $0;
+	my @allArgs = split(//, OPTS());
+	for ( my $i = 0; $i < scalar(@allArgs); $i++ ) {
+		my $a = $allArgs[$i];
+		next if ( $a eq ':' );
+		$cli .= ' -' . $a;
+		if ( ($i < scalar(@allArgs)-1) && $allArgs[$i+1] eq ':' ) {
+			$cli .= ' <' . $opt_arg_map{$a} . '>';
+		}
+	}
+	print("$cli\n\n");
+
+	return unless ( $DoDetail );
+	for ( my $i = 0; $i < scalar(@allArgs); $i++ ) {
+		my $a = $allArgs[$i];
+		next if ( $a eq ':' );
+		printf(
+			"-%s %s\n\t%s\n",
+			$a,
+			(exists($opt_arg_map{$a})) ? ('<' . $opt_arg_map{$a} . '>') : (''),
+			$opt_desc_map{$a}
+		);
+	}
+	print("\n");
+
+	return;
+}
+#----------------------------------------------------------------------------
+sub CheckOpts($)
+{
+	my $ret = 0;
+	my $Opts = $_[0];
+	return $ret unless ( $Opts );
+	foreach my $a ( keys(%$Opts) ) {
+		if ( $a eq 'd' ) {
+			$Debug = 1;
+			print(STDERR "Debugging mode enabled.\n");
+		}
+	}
+	$ret = 1; # It's legal to specify nothing for now.
+
+	printf(STDERR "Debug command line: %s %s\n", $0, join(' ', @ARGV)) if ( $Debug );
+	print(STDERR "Command-line error\n") unless ( $ret );
+	return $ret;
+}
+#----------------------------------------------------------------------------
+sub ReadInput($$)
+{
+	my $nextLine;
+	my $fileOpen = 0;
+	my $inHandle = undef;
+	my $readLines = 0;
+	my ( $Lines, $InFile ) = ( @_ );
+	if ( $InFile ) {
+		if ( open(INFILE, '< ' . $InFile) ) {
+			$inHandle = *INFILE;
+			$fileOpen = 1;
+		} else {
+			printf(STDERR "Error opening %s - %s\n", $InFile, $!) if ( $Debug );
+			return 0;
+		}
+	} else {
+		$inHandle = *STDIN;
+	}
+
+	while ( $nextLine = <$inHandle> ) {
+		chomp($nextLine);
+		push @$Lines, $nextLine;
+		$readLines++;
+	}
+
+	close($inHandle) if ( $fileOpen );
+	return $readLines;
+}
+#----------------------------------------------------------------------------
+sub WriteOutput($$)
+{
+	my $doneVerbose = 0;
+	my $fileOpen = 0;
+	my $outHandle = undef;
+	my $writtenLines = 0;
+	my ( $Lines, $OutFile ) = ( @_ );
+	if ( $OutFile ) {
+		if ( open(OUTFILE, '> ' . $OutFile) ) {
+			$outHandle = *OUTFILE;
+			$fileOpen = 1;
+		} else {
+			printf(STDERR "Error opening %s - %s\n", $OutFile, $!) if ( $Debug );
+			return 0;
+		}
+	} else {
+		$outHandle = *STDOUT;
+	}
+
+	foreach my $nextLine ( @$Lines ) {
+		$nextLine .= "\n";
+		if ( print($outHandle $nextLine) ) {
+			$writtenLines++;
+		} elsif ( $Debug && !$doneVerbose ) {
+			printf(STDERR "Error writing output to %s - %s\n", $OutFile, $!);
+			$doneVerbose = 1;
+		}
+	}
+
+	close($outHandle) if ( $fileOpen );
+	return $writtenLines;
+}
+#----------------------------------------------------------------------------
+sub Process($$)
+{
+	my $processedCount = 0;
+	my ( $LinesPtr, $LineCount ) = ( @_ );
+	die 'Internal error' unless ( $LinesPtr );
+	my ( $Real, $Remark ) = ( undef, undef );
+	for ( my $linei = 0; $linei < $LineCount; $linei++ ) {
+		( $Real, $Remark ) = split('#', $LinesPtr->[$linei]);
+		if ( defined($Remark) ) {
+			my $remark = '';
+			if ( $Debug ) {
+				printf(
+				  STDERR
+				  "The following was recognised as a remark at line %u/%u: %s\n",
+				  $linei + 1, $LineCount, '#' . $Remark
+				);
+			}
+			if ( Uncomment($Remark, \$remark) ) {
+				$Real .= $Remark; # Uncomment
+				printf(STDERR "Uncommented line %u\n", $linei+1);
+				$LinesPtr->[$linei] = $Real;
+			}
+		}
+
+		if ( defined($Real) && length($Real) ) {
+			$processedCount++;
+		}
+	}
+	return $processedCount;
+}
+#----------------------------------------------------------------------------
+sub Uncomment($$)
+{
+	my @uncomment_me = (
+		'export DH_VERBOSE=1',
+		'dh_fixperms'
+	);
+
+	my ( $In, $Out ) = ( @_ );
+	my $uncommented = 0;
+	foreach my $u ( @uncomment_me ) {
+		if ( index($In, $u) > -1 ) {
+			$$Out = $u;
+			$uncommented = 1;
+			last;
+		}
+	}
+	return $uncommented;
+}
+#----------------------------------------------------------------------------
+exit Main(); # Entry point.
+#----------------------------------------------------------------------------
+#!/bin/sh
+#
+# install - install a program, script, or datafile
+#
+# This originates from X11R5 (mit/util/scripts/install.sh), which was
+# later released in X11R6 (xc/config/util/install.sh) with the
+# following copyright and license.
+#
+# Copyright (C) 1994 X Consortium
+#
+# Permission is hereby granted, free of charge, to any person obtaining a copy
+# of this software and associated documentation files (the "Software"), to
+# deal in the Software without restriction, including without limitation the
+# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+# sell copies of the Software, and to permit persons to whom the Software is
+# furnished to do so, subject to the following conditions:
+#
+# The above copyright notice and this permission notice shall be included in
+# all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
+# X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+# AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNEC-
+# TION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+#
+# Except as contained in this notice, the name of the X Consortium shall not
+# be used in advertising or otherwise to promote the sale, use or other deal-
+# ings in this Software without prior written authorization from the X Consor-
+# tium.
+#
+#
+# FSF changes to this file are in the public domain.
+#
+# Calling this script install-sh is preferred over install.sh, to prevent
+# `make' implicit rules from creating a file called install from it
+# when there is no Makefile.
+#
+# This script is compatible with the BSD install script, but was written
+# from scratch.  It can only install one file at a time, a restriction
+# shared with many OS's install programs.
+
+
+# set DOITPROG to echo to test this script
+
+# Don't use :- since 4.3BSD and earlier shells don't like it.
+doit="${DOITPROG-}"
+
+
+# put in absolute paths if you don't have them in your path; or use env. vars.
+
+mvprog="${MVPROG-mv}"
+cpprog="${CPPROG-cp}"
+chmodprog="${CHMODPROG-chmod}"
+chownprog="${CHOWNPROG-chown}"
+chgrpprog="${CHGRPPROG-chgrp}"
+stripprog="${STRIPPROG-strip}"
+rmprog="${RMPROG-rm}"
+mkdirprog="${MKDIRPROG-mkdir}"
+
+transformbasename=""
+transform_arg=""
+instcmd="$mvprog"
+chmodcmd="$chmodprog 0755"
+chowncmd=""
+chgrpcmd=""
+stripcmd=""
+rmcmd="$rmprog -f"
+mvcmd="$mvprog"
+src=""
+dst=""
+dir_arg=""
+
+while [ x"$1" != x ]; do
+    case $1 in
+	-c) instcmd="$cpprog"
+	    shift
+	    continue;;
+
+	-d) dir_arg=true
+	    shift
+	    continue;;
+
+	-m) chmodcmd="$chmodprog $2"
+	    shift
+	    shift
+	    continue;;
+
+	-o) chowncmd="$chownprog $2"
+	    shift
+	    shift
+	    continue;;
+
+	-g) chgrpcmd="$chgrpprog $2"
+	    shift
+	    shift
+	    continue;;
+
+	-s) stripcmd="$stripprog"
+	    shift
+	    continue;;
+
+	-t=*) transformarg=`echo $1 | sed 's/-t=//'`
+	    shift
+	    continue;;
+
+	-b=*) transformbasename=`echo $1 | sed 's/-b=//'`
+	    shift
+	    continue;;
+
+	*)  if [ x"$src" = x ]
+	    then
+		src=$1
+	    else
+		# this colon is to work around a 386BSD /bin/sh bug
+		:
+		dst=$1
+	    fi
+	    shift
+	    continue;;
+    esac
+done
+
+if [ x"$src" = x ]
+then
+	echo "install:	no input file specified"
+	exit 1
+else
+	true
+fi
+
+if [ x"$dir_arg" != x ]; then
+	dst=$src
+	src=""
+	
+	if [ -d $dst ]; then
+		instcmd=:
+		chmodcmd=""
+	else
+		instcmd=mkdir
+	fi
+else
+
+# Waiting for this to be detected by the "$instcmd $src $dsttmp" command
+# might cause directories to be created, which would be especially bad 
+# if $src (and thus $dsttmp) contains '*'.
+
+	if [ -f $src -o -d $src ]
+	then
+		true
+	else
+		echo "install:  $src does not exist"
+		exit 1
+	fi
+	
+	if [ x"$dst" = x ]
+	then
+		echo "install:	no destination specified"
+		exit 1
+	else
+		true
+	fi
+
+# If destination is a directory, append the input filename; if your system
+# does not like double slashes in filenames, you may need to add some logic
+
+	if [ -d $dst ]
+	then
+		dst="$dst"/`basename $src`
+	else
+		true
+	fi
+fi
+
+## this sed command emulates the dirname command
+dstdir=`echo $dst | sed -e 's,[^/]*$,,;s,/$,,;s,^$,.,'`
+
+# Make sure that the destination directory exists.
+#  this part is taken from Noah Friedman's mkinstalldirs script
+
+# Skip lots of stat calls in the usual case.
+if [ ! -d "$dstdir" ]; then
+defaultIFS=' 	
+'
+IFS="${IFS-${defaultIFS}}"
+
+oIFS="${IFS}"
+# Some sh's can't handle IFS=/ for some reason.
+IFS='%'
+set - `echo ${dstdir} | sed -e 's@/@%@g' -e 's@^%@/@'`
+IFS="${oIFS}"
+
+pathcomp=''
+
+while [ $# -ne 0 ] ; do
+	pathcomp="${pathcomp}${1}"
+	shift
+
+	if [ ! -d "${pathcomp}" ] ;
+        then
+		$mkdirprog "${pathcomp}"
+	else
+		true
+	fi
+
+	pathcomp="${pathcomp}/"
+done
+fi
+
+if [ x"$dir_arg" != x ]
+then
+	$doit $instcmd $dst &&
+
+	if [ x"$chowncmd" != x ]; then $doit $chowncmd $dst; else true ; fi &&
+	if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dst; else true ; fi &&
+	if [ x"$stripcmd" != x ]; then $doit $stripcmd $dst; else true ; fi &&
+	if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dst; else true ; fi
+else
+
+# If we're going to rename the final executable, determine the name now.
+
+	if [ x"$transformarg" = x ] 
+	then
+		dstfile=`basename $dst`
+	else
+		dstfile=`basename $dst $transformbasename | 
+			sed $transformarg`$transformbasename
+	fi
+
+# don't allow the sed command to completely eliminate the filename
+
+	if [ x"$dstfile" = x ] 
+	then
+		dstfile=`basename $dst`
+	else
+		true
+	fi
+
+# Make a temp file name in the proper directory.
+
+	dsttmp=$dstdir/#inst.$$#
+
+# Move or copy the file name to the temp name
+
+	$doit $instcmd $src $dsttmp &&
+
+	trap "rm -f ${dsttmp}" 0 &&
+
+# and set any options; do chmod last to preserve setuid bits
+
+# If any of these fail, we abort the whole thing.  If we want to
+# ignore errors from any of these, just make sure not to ignore
+# errors from the above "$doit $instcmd $src $dsttmp" command.
+
+	if [ x"$chowncmd" != x ]; then $doit $chowncmd $dsttmp; else true;fi &&
+	if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dsttmp; else true;fi &&
+	if [ x"$stripcmd" != x ]; then $doit $stripcmd $dsttmp; else true;fi &&
+	if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dsttmp; else true;fi &&
+
+# Now rename the file to the real destination.
+
+	$doit $rmcmd -f $dstdir/$dstfile &&
+	$doit $mvcmd $dsttmp $dstdir/$dstfile 
+
+fi &&
+
+
+exit 0
+#! /bin/sh
+# Common stub for a few missing GNU programs while installing.
+# Copyright (C) 1996, 1997, 1999, 2000, 2002 Free Software Foundation, Inc.
+# Originally by Fran,cois Pinard <pinard@iro.umontreal.ca>, 1996.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+# 02111-1307, USA.
+
+# As a special exception to the GNU General Public License, if you
+# distribute this file as part of a program that contains a
+# configuration script generated by Autoconf, you may include it under
+# the same distribution terms that you use for the rest of that program.
+
+if test $# -eq 0; then
+  echo 1>&2 "Try \`$0 --help' for more information"
+  exit 1
+fi
+
+run=:
+
+# In the cases where this matters, `missing' is being run in the
+# srcdir already.
+if test -f configure.ac; then
+  configure_ac=configure.ac
+else
+  configure_ac=configure.in
+fi
+
+case "$1" in
+--run)
+  # Try to run requested program, and just exit if it succeeds.
+  run=
+  shift
+  "$@" && exit 0
+  ;;
+esac
+
+# If it does not exist, or fails to run (possibly an outdated version),
+# try to emulate it.
+case "$1" in
+
+  -h|--h|--he|--hel|--help)
+    echo "\
+$0 [OPTION]... PROGRAM [ARGUMENT]...
+
+Handle \`PROGRAM [ARGUMENT]...' for when PROGRAM is missing, or return an
+error status if there is no known handling for PROGRAM.
+
+Options:
+  -h, --help      display this help and exit
+  -v, --version   output version information and exit
+  --run           try to run the given command, and emulate it if it fails
+
+Supported PROGRAM values:
+  aclocal      touch file \`aclocal.m4'
+  autoconf     touch file \`configure'
+  autoheader   touch file \`config.h.in'
+  automake     touch all \`Makefile.in' files
+  bison        create \`y.tab.[ch]', if possible, from existing .[ch]
+  flex         create \`lex.yy.c', if possible, from existing .c
+  help2man     touch the output file
+  lex          create \`lex.yy.c', if possible, from existing .c
+  makeinfo     touch the output file
+  tar          try tar, gnutar, gtar, then tar without non-portable flags
+  yacc         create \`y.tab.[ch]', if possible, from existing .[ch]"
+    ;;
+
+  -v|--v|--ve|--ver|--vers|--versi|--versio|--version)
+    echo "missing 0.4 - GNU automake"
+    ;;
+
+  -*)
+    echo 1>&2 "$0: Unknown \`$1' option"
+    echo 1>&2 "Try \`$0 --help' for more information"
+    exit 1
+    ;;
+
+  aclocal*)
+    if test -z "$run" && ($1 --version) > /dev/null 2>&1; then
+       # We have it, but it failed.
+       exit 1
+    fi
+
+    echo 1>&2 "\
+WARNING: \`$1' is missing on your system.  You should only need it if
+         you modified \`acinclude.m4' or \`${configure_ac}'.  You might want
+         to install the \`Automake' and \`Perl' packages.  Grab them from
+         any GNU archive site."
+    touch aclocal.m4
+    ;;
+
+  autoconf)
+    if test -z "$run" && ($1 --version) > /dev/null 2>&1; then
+       # We have it, but it failed.
+       exit 1
+    fi
+
+    echo 1>&2 "\
+WARNING: \`$1' is missing on your system.  You should only need it if
+         you modified \`${configure_ac}'.  You might want to install the
+         \`Autoconf' and \`GNU m4' packages.  Grab them from any GNU
+         archive site."
+    touch configure
+    ;;
+
+  autoheader)
+    if test -z "$run" && ($1 --version) > /dev/null 2>&1; then
+       # We have it, but it failed.
+       exit 1
+    fi
+
+    echo 1>&2 "\
+WARNING: \`$1' is missing on your system.  You should only need it if
+         you modified \`acconfig.h' or \`${configure_ac}'.  You might want
+         to install the \`Autoconf' and \`GNU m4' packages.  Grab them
+         from any GNU archive site."
+    files=`sed -n 's/^[ ]*A[CM]_CONFIG_HEADER(\([^)]*\)).*/\1/p' ${configure_ac}`
+    test -z "$files" && files="config.h"
+    touch_files=
+    for f in $files; do
+      case "$f" in
+      *:*) touch_files="$touch_files "`echo "$f" |
+				       sed -e 's/^[^:]*://' -e 's/:.*//'`;;
+      *) touch_files="$touch_files $f.in";;
+      esac
+    done
+    touch $touch_files
+    ;;
+
+  automake*)
+    if test -z "$run" && ($1 --version) > /dev/null 2>&1; then
+       # We have it, but it failed.
+       exit 1
+    fi
+
+    echo 1>&2 "\
+WARNING: \`$1' is missing on your system.  You should only need it if
+         you modified \`Makefile.am', \`acinclude.m4' or \`${configure_ac}'.
+         You might want to install the \`Automake' and \`Perl' packages.
+         Grab them from any GNU archive site."
+    find . -type f -name Makefile.am -print |
+	   sed 's/\.am$/.in/' |
+	   while read f; do touch "$f"; done
+    ;;
+
+  autom4te)
+    if test -z "$run" && ($1 --version) > /dev/null 2>&1; then
+       # We have it, but it failed.
+       exit 1
+    fi
+
+    echo 1>&2 "\
+WARNING: \`$1' is needed, and you do not seem to have it handy on your
+         system.  You might have modified some files without having the
+         proper tools for further handling them.
+         You can get \`$1Help2man' as part of \`Autoconf' from any GNU
+         archive site."
+
+    file=`echo "$*" | sed -n 's/.*--output[ =]*\([^ ]*\).*/\1/p'`
+    test -z "$file" && file=`echo "$*" | sed -n 's/.*-o[ ]*\([^ ]*\).*/\1/p'`
+    if test -f "$file"; then
+	touch $file
+    else
+	test -z "$file" || exec >$file
+	echo "#! /bin/sh"
+	echo "# Created by GNU Automake missing as a replacement of"
+	echo "#  $ $@"
+	echo "exit 0"
+	chmod +x $file
+	exit 1
+    fi
+    ;;
+
+  bison|yacc)
+    echo 1>&2 "\
+WARNING: \`$1' is missing on your system.  You should only need it if
+         you modified a \`.y' file.  You may need the \`Bison' package
+         in order for those modifications to take effect.  You can get
+         \`Bison' from any GNU archive site."
+    rm -f y.tab.c y.tab.h
+    if [ $# -ne 1 ]; then
+        eval LASTARG="\${$#}"
+	case "$LASTARG" in
+	*.y)
+	    SRCFILE=`echo "$LASTARG" | sed 's/y$/c/'`
+	    if [ -f "$SRCFILE" ]; then
+	         cp "$SRCFILE" y.tab.c
+	    fi
+	    SRCFILE=`echo "$LASTARG" | sed 's/y$/h/'`
+	    if [ -f "$SRCFILE" ]; then
+	         cp "$SRCFILE" y.tab.h
+	    fi
+	  ;;
+	esac
+    fi
+    if [ ! -f y.tab.h ]; then
+	echo >y.tab.h
+    fi
+    if [ ! -f y.tab.c ]; then
+	echo 'main() { return 0; }' >y.tab.c
+    fi
+    ;;
+
+  lex|flex)
+    echo 1>&2 "\
+WARNING: \`$1' is missing on your system.  You should only need it if
+         you modified a \`.l' file.  You may need the \`Flex' package
+         in order for those modifications to take effect.  You can get
+         \`Flex' from any GNU archive site."
+    rm -f lex.yy.c
+    if [ $# -ne 1 ]; then
+        eval LASTARG="\${$#}"
+	case "$LASTARG" in
+	*.l)
+	    SRCFILE=`echo "$LASTARG" | sed 's/l$/c/'`
+	    if [ -f "$SRCFILE" ]; then
+	         cp "$SRCFILE" lex.yy.c
+	    fi
+	  ;;
+	esac
+    fi
+    if [ ! -f lex.yy.c ]; then
+	echo 'main() { return 0; }' >lex.yy.c
+    fi
+    ;;
+
+  help2man)
+    if test -z "$run" && ($1 --version) > /dev/null 2>&1; then
+       # We have it, but it failed.
+       exit 1
+    fi
+
+    echo 1>&2 "\
+WARNING: \`$1' is missing on your system.  You should only need it if
+	 you modified a dependency of a manual page.  You may need the
+	 \`Help2man' package in order for those modifications to take
+	 effect.  You can get \`Help2man' from any GNU archive site."
+
+    file=`echo "$*" | sed -n 's/.*-o \([^ ]*\).*/\1/p'`
+    if test -z "$file"; then
+	file=`echo "$*" | sed -n 's/.*--output=\([^ ]*\).*/\1/p'`
+    fi
+    if [ -f "$file" ]; then
+	touch $file
+    else
+	test -z "$file" || exec >$file
+	echo ".ab help2man is required to generate this page"
+	exit 1
+    fi
+    ;;
+
+  makeinfo)
+    if test -z "$run" && (makeinfo --version) > /dev/null 2>&1; then
+       # We have makeinfo, but it failed.
+       exit 1
+    fi
+
+    echo 1>&2 "\
+WARNING: \`$1' is missing on your system.  You should only need it if
+         you modified a \`.texi' or \`.texinfo' file, or any other file
+         indirectly affecting the aspect of the manual.  The spurious
+         call might also be the consequence of using a buggy \`make' (AIX,
+         DU, IRIX).  You might want to install the \`Texinfo' package or
+         the \`GNU make' package.  Grab either from any GNU archive site."
+    file=`echo "$*" | sed -n 's/.*-o \([^ ]*\).*/\1/p'`
+    if test -z "$file"; then
+      file=`echo "$*" | sed 's/.* \([^ ]*\) *$/\1/'`
+      file=`sed -n '/^@setfilename/ { s/.* \([^ ]*\) *$/\1/; p; q; }' $file`
+    fi
+    touch $file
+    ;;
+
+  tar)
+    shift
+    if test -n "$run"; then
+      echo 1>&2 "ERROR: \`tar' requires --run"
+      exit 1
+    fi
+
+    # We have already tried tar in the generic part.
+    # Look for gnutar/gtar before invocation to avoid ugly error
+    # messages.
+    if (gnutar --version > /dev/null 2>&1); then
+       gnutar "$@" && exit 0
+    fi
+    if (gtar --version > /dev/null 2>&1); then
+       gtar "$@" && exit 0
+    fi
+    firstarg="$1"
+    if shift; then
+	case "$firstarg" in
+	*o*)
+	    firstarg=`echo "$firstarg" | sed s/o//`
+	    tar "$firstarg" "$@" && exit 0
+	    ;;
+	esac
+	case "$firstarg" in
+	*h*)
+	    firstarg=`echo "$firstarg" | sed s/h//`
+	    tar "$firstarg" "$@" && exit 0
+	    ;;
+	esac
+    fi
+
+    echo 1>&2 "\
+WARNING: I can't seem to be able to run \`tar' with the given arguments.
+         You may want to install GNU tar or Free paxutils, or check the
+         command line arguments."
+    exit 1
+    ;;
+
+  *)
+    echo 1>&2 "\
+WARNING: \`$1' is needed, and you do not seem to have it handy on your
+         system.  You might have modified some files without having the
+         proper tools for further handling them.  Check the \`README' file,
+         it often tells you about the needed prerequirements for installing
+         this package.  You may also peek at any GNU archive site, in case
+         some other package would contain this missing \`$1' program."
+    exit 1
+    ;;
+esac
+
+exit 0
+#! /bin/sh
+# mkinstalldirs --- make directory hierarchy
+# Author: Noah Friedman <friedman@prep.ai.mit.edu>
+# Created: 1993-05-16
+# Public domain
+
+# $Id: mkinstalldirs,v 1.2 2002/02/10 21:13:52 jbj Exp $
+
+errstatus=0
+
+for file
+do
+   set fnord `echo ":$file" | sed -ne 's/^:\//#/;s/^://;s/\// /g;s/^#/\//;p'`
+   shift
+
+   pathcomp=
+   for d
+   do
+     pathcomp="$pathcomp$d"
+     case "$pathcomp" in
+       -* ) pathcomp=./$pathcomp ;;
+     esac
+
+     if test ! -d "$pathcomp"; then
+        echo "mkdir $pathcomp"
+
+        mkdir "$pathcomp" || lasterr=$?
+
+        if test ! -d "$pathcomp"; then
+  	  errstatus=$lasterr
+        fi
+     fi
+
+     pathcomp="$pathcomp/"
+   done
+done
+
+exit $errstatus
+
+# mkinstalldirs ends here

rpmbuild/SOURCES/dl-generic-0.1.0/Makefile.in

+#!/usr/bin/make
+#
+# Please note that the Makefile should only be modified when it has the name
+# Makefile.in, Makefile, depending on the project, is likely to be overwritten
+# by GNU configure, or a custom configure script, built by the local developer.
+#
+# This per-package Makefile shall build under CentOS or Debian and shall not rely
+# on any specific package names, nor shall it attempt to install any packages,
+# or check out anything from any repositories.  All of this must be performed by
+# the package maintainer.
+#
+# -- David Palmer <palmer@overchat.org>
+#
+
+# The application we are building.
+EXE=dl-generic
+
+HOSTNAME_SHORT=@HOSTNAME_SHORT@
+BSD_INSTALL=/usr/bin/install
+LOG_DIR=@LOG_DIR@
+
+# You might want to override this somewhere else (ie. with configure),
+# this will determine who the code is installed as.  Typically root,
+# but we're trying to get away from that.
+INST_USER=root
+INST_GROUP=root
+
+# Inclusion paths for libraries
+MYSQL_INC=-I/usr/include/mysql -I/usr/include/mysql++
+SQLITE_INC=-I/opt/include
+
+# Library paths (when linking)
+SQLITE_LIBPATH=-L/opt/lib
+
+# Example only: Decide which SQlite library to link against
+#ifeq ($(SQLITE_MAJOR),3)
+#  SQLITE_LIB=-lsqlite3
+#else
+#  SQLITE_LIB=-lsqlite
+#endif
+
+# You may want different menthods for installing different scripts / binaries.
+INSTBIN=$(BSD_INSTALL)
+INSTINIT=$(BSD_INSTALL)
+
+# Override permissions only if we're root (not when building a package).
+ifeq ($(UID),0)
+	INSTBIN=$(BSD_INSTALL) -o $(INST_USER) -g $(INST_GROUP)
+	INSTINIT=$(BSD_INSTALL) -o $(INST_USER) -g $(INST_GROUP)
+endif
+
+# Hint: Prefix is normally set to opt/voip by configure
+ifeq ($(DESTDIR),)
+	DESTDIR=/
+endif
+REALDESTDIR := $(DESTDIR)/@PREFIX@
+LOCAL_STATE_DIR := @LOCAL_STATE_DIR@
+
+# These warnings are useful for C++ code, if you're using Perl, or another language,
+# you can ignore these
+CPP_WARNINGS= \
+ -Wall -W -Wcast-qual -Wcast-align \
+ -Wpointer-arith -Winline \
+ -Wredundant-decls -Wwrite-strings -Wformat=2 \
+ -Wformat-security -Wformat-nonliteral -Wundef -Wredundant-decls \
+ -Wunknown-pragmas
+
+# Some warnings don't mean anything in C, and vice-versa, so use these when compiling C
+# code.
+C_WARNINGS= \
+  -Wmissing-prototypes -Wstrict-prototypes \
+  -Wbad-function-cast -Wnested-externs \
+  -Wmissing-declarations
+
+# This is a list of C warnings it's nice to use,
+# aggregates is an inefficient C++ return value, and shadowing is overwriting a variable with your
+# current scope.  You'll want to know about this, but some code is ugly and needs these removed,
+# so just move these under C_WARNINGS or CPP_WARNINGS if you can.
+DISABLED_WARNINGS= \
+  -Wshadow -Waggregate-return
+
+# This is just an example.
+CFLAGS=-g $(MYSQL_INC) $(SQLITE_INC) -DVARDIR=\"/$(LOCAL_STATE_DIR)\" -DHAVE_CONFIG_H=1 \
+  -ansi $(WARNINGS) -DNDEBUG=1
+CC=g++ $(CFLAGS)
+LIBS=
+
+# This fetches your username from the environment, this is because you might need to override it.
+PERSON=$(USER)
+
+# The CHECKOUTS variable defines where source code will be copied in under the build tree.
+# Your tree.txt source (not destination) directory is relevative to this,
+# you need this to be right, or the whole maketree system will break.
+CHECKOUTS=$(PWD)/../../..
+
+# Stop lazy attempting to build as root, it's evil.
+ifeq ($(PERSON),root)
+	PERSON=nobody
+	echo 'Sorry, you should not be building this package as root'
+	cd /tmp/$(PERSON)/`hostid`/do_not_run_as_root
+endif
+
+# List all of your objects here
+OBJS=obj/$(EXE).o
+
+SOURCES=src/$(EXE).c
+
+# Default rule
+all : object_dir $(EXE)
+
+$(EXE) : $(OBJS)
+	$(CC) -o $(EXE) $(OBJS) $(LIBS)
+
+obj/$(EXE).o : src/$(EXE).c
+	$(CC) -c -o obj/$(EXE).o src/$(EXE).c
+
+test : all
+	./$(EXE)
+
+debug : all
+	gdb ./$(EXE)
+
+clean :
+	rm -f $(OBJS) $(EXE)
+	rmdir obj/
+
+# Cannot rely on __HOSTNAME_SHORT_, as that is set by configure,
+# and configure has run run as make tree time =(
+tree:
+	chmod +x ./maketree.pl
+	CHECKOUTS=$(CHECKOUTS) ./maketree.pl < tree.txt
+
+cleantree:
+	chmod +x ./maketree.pl
+	./maketree.pl clean < tree.txt
+
+# The object directory might already exist, that's OK.
+object_dir:
+	mkdir -p obj/
+
+# You'll need to go over exactly what you need here with a fine-tooth comb.
+install : all
+	-mkdir -p $(REALDESTDIR)/bin/
+	$(INSTBIN) $(EXE) $(REALDESTDIR)/bin
+
+# Initial init.d scripts
+#install_init:
+#	-mkdir -p $(DESTDIR)/etc/init.d/
+#	$(INSTINIT) etc/init.d/voxsci-inbound-copier $(DESTDIR)/etc/init.d/

rpmbuild/SOURCES/dl-generic-0.1.0/conf.pl

+#!/usr/bin/perl -w
+#
+# This script should be called by the configure shell script.  If you are using GNU autoconf,
+# or some other mechanism to configure your tree, just use that, and ignore this script.
+# the bootstrap will keep re-creating it, as an essential tool, but you can ignore that,
+# and/or never check it in, because it will stay in shared/packaging in the build-tools
+# repository.
+#
+#----------------------------------------------------------------------------
+use strict;
+use Data::Dumper;
+
+sub Parser($);
+sub RawSubst($);
+sub SubstHostnameShort();
+sub SubstLogDir();
+sub SubstPrefix();
+sub SubstLocalStateDir();
+sub ProcessArgs();
+sub ProcessArg($$);
+sub CheckArgs();
+#----------------------------------------------------------------------------
+my %Params = (
+	'prefix' => { arg_mandatory => 1, val_mandatory => 1, val_default => '/opt', val_numeric => undef }
+);
+#----------------------------------------------------------------------------
+ProcessArgs();
+
+foreach my $line ( <STDIN> ) {
+	$line = Parser($line);
+	print $line;
+}
+
+exit 0;
+#----------------------------------------------------------------------------
+sub Parser($)
+{
+	my $Line = $_[0];
+	if ( $Line =~ m/\@(.*)\@/ ) {
+		my $variable = $1;
+		my $parsedVar = RawSubst($variable);
+		if ( defined($parsedVar) ) {
+			my $idx = index($Line, '@' . $variable . '@');
+			substr($Line, $idx, length($variable)+2, $parsedVar);
+		}
+	}
+	return $Line;
+}
+#----------------------------------------------------------------------------
+sub RawSubst($)
+{
+	my %substTable = (
+		'HOSTNAME_SHORT' => \&SubstHostnameShort,
+		'LOG_DIR' => \&SubstLogDir,
+		'PREFIX' => \&SubstPrefix,
+		'LOCAL_STATE_DIR' => \&SubstLocalStateDir
+	);
+
+	my $Variable = $_[0];
+	die unless ( defined($Variable) );
+	unless ( defined($substTable{$Variable}) ) {
+		return ''; # Undefined variable
+	}
+
+	return $substTable{$Variable}->(); # Call the substitution function
+}
+#----------------------------------------------------------------------------
+sub SubstHostnameShort()
+{
+	my $hn = `hostname -s`;
+	chomp($hn);
+	return $hn;
+}
+#----------------------------------------------------------------------------
+sub SubstLogDir()
+{
+	return '';
+}
+#----------------------------------------------------------------------------
+sub SubstPrefix()
+{
+	my $Param = 'prefix';
+	if ( $Params{$Param}->{is_set} ) {
+		return $Params{$Param}->{value};
+	} else {
+		return '';
+	}
+}
+#----------------------------------------------------------------------------
+sub SubstLocalStateDir()
+{
+	return '/var';
+}
+#----------------------------------------------------------------------------
+sub ProcessArgs()
+{
+	foreach my $a ( @ARGV ) {
+		if ( index($a, '--') == 0 ) {
+			my $argName = substr($a, 2);
+			next unless length($argName);
+
+			my @paramParts = split('=', $argName);
+			if ( scalar(@paramParts) >= 2 ) {
+				ProcessArg($paramParts[0], $paramParts[1]);
+			} else {
+				ProcessArg($argName, undef);
+			}
+		}
+	}
+
+	CheckArgs();
+}
+#----------------------------------------------------------------------------
+sub ProcessArg($$)
+{
+	my ( $ArgName, $ArgVal ) = @_;
+
+	#printf("Called with %s equals %s\n", $ArgName, ($ArgVal) ? ($ArgVal) : ('(undef)'));
+	#print Dumper \%Params;
+
+	die unless( defined($ArgName) && length($ArgName) );
+	unless ( defined($Params{$ArgName}) ) {
+		printf(STDERR "Sorry, --%s is not a recognised parameter\n", $ArgName);
+		exit 1;
+	}
+
+	# Check for mandatory values for arguments
+	if ( !defined($ArgVal) && $Params{$ArgName}->{val_mandatory} ) {
+		my $optional = ' and the argument must be numeric';
+		printf(
+                  STDERR "Sorry, --%s requires a value in the form --%s=(value)%s\n",
+		  $ArgName, $ArgName, ($Params{$ArgName}->{val_numeric}) ? ($optional) : ('')
+		);
+		exit 1;
+	}
+
+	# Check for values which, if specified must be numeric
+	if ( defined($ArgVal) && $Params{$ArgName}->{val_numeric} ) {
+		unless ( $ArgVal =~ m/^[-]?\d+$/ ) {
+			printf(STDERR "Sorry, for argument --%s=%s, %s must be numeric\n", $ArgName, $ArgName, $ArgVal);
+			exit 1;
+		}
+	}
+
+	$Params{$ArgName}->{value} = $ArgVal;
+	$Params{$ArgName}->{is_set} = 1;
+	return;
+}
+#----------------------------------------------------------------------------
+sub CheckArgs()
+{
+	foreach my $a ( keys(%Params) ) {
+		unless ( $Params{$a}->{is_set} ) { # For all arguments with no value set...
+			if ( $Params{$a}->{arg_mandatory} ) {
+				printf(STDERR "--%s is a mandatory argument\n", $a);
+				exit 1;
+			}
+			if ( $Params{$a}->{val_mandatory} ) {
+				if ( exists($Params{$a}->{val_default}) ) {
+					$Params{$a}->{value} = $Params{$a}->{val_default};
+					$Params{$a}->{is_set} = 1;
+				} else {
+					printf(
+					  STDERR "--%s requires an argument (no default available)\n",
+					  $a
+					);
+				}
+			}
+		}
+	}
+}
+#----------------------------------------------------------------------------

rpmbuild/SOURCES/dl-generic-0.1.0/configure

+#!/bin/sh
+# This is a generic replacement for GNU autoconf configure scripts.  Obviously you can use one