Index: /devel/lib/distro.pm
===================================================================
--- /devel/lib/distro.pm	(revision 2)
+++ /devel/lib/distro.pm	(revision 2)
@@ -0,0 +1,174 @@
+#!/bin/bash
+#
+# Create env depending on the distro on which we are
+#
+# $Id$
+#
+# Input parameters : $ddir (distro name) and $dver (distro version)
+# If they do not exist then deduce from current distro
+# Exports : $dfam (distro family) $suf (pkg suffix) $dtype (distro type) TOPBUILDDIR (dir to build packages) 
+
+#
+# Guess ddir and dver from the underlying distro
+#
+if [ _"$ddir" = _"" ]; then
+	if [ -e /etc/mandriva-release ]; then
+		export ddir="mandriva"
+		export dver=`awk '{print $4}' /etc/mandriva-release`
+	elif [ -e /etc/mandrake-release ]; then
+		export ddir="mandrake"
+		export dver=`awk '{print $3}' /etc/mandrake-release`
+	elif [ -e /etc/redhat-release ]; then
+		grep -q Enterprise /etc/redhat-release
+		if [ $? -eq 0 ]; then
+			export ddir="rhel"
+			export dver=`awk '{print $7}' /etc/redhat-release`
+		elif grep -q Fedora /etc/redhat-release ; then
+			export ddir="fedora"
+			grep -qi core /etc/redhat-release
+			if [ $? -eq 0 ]; then
+				export dver=`awk '{print $4}' /etc/redhat-release`
+			else
+				export dver=`awk '{print $3}' /etc/redhat-release`
+			fi
+		elif grep -q CentOS /etc/redhat-release ; then
+			export ddir="centos"
+			export dver=`awk '{print $3}' /etc/redhat-release | cut -d. -f1`
+		else
+			export ddir="redhat"
+			export dver=`awk '{print $5}' /etc/redhat-release`
+		fi
+	elif [ -e /etc/SuSE-release ]; then
+		grep -q Enterprise /etc/SuSE-release
+		if [ $? -eq 0 ]; then
+			export ddir="sles"
+			export dver=`head -1 /etc/SuSE-release | awk '{print $5}'`
+		elif grep -q openSUSE /etc/SuSE-release ; then
+			export ddir="suse"
+			export dver=`head -1 /etc/SuSE-release | awk '{print $2}'`
+		else
+			export ddir="suse"
+			export dver=`head -1 /etc/SuSE-release | awk '{print $3}'`
+		fi
+	elif [ -e /etc/slackware-version ]; then
+		export ddir="slackware"
+		export dver=`awk '{print $2}' /etc/slackware-version | cut -d. -f1-2`
+	elif [ -e /etc/gentoo-release ]; then
+		export ddir="gentoo"
+		export dver=`awk '{print $5}' /etc/gentoo-release | cut -d. -f1-2`
+	elif [ -e /etc/debian_version ]; then
+		export ddir="debian"
+		export dver=`cat /etc/debian_version`
+		# Debian assigns release names only once a release actually happens.
+		# Debian does not distinguish between testing and unstable because
+		# unstable today is what testing will be in about ten days time. So,
+		# in case we encounter "tesing/unstable", we assume unstable, i.e. sid.
+		# Note that for released versions, the numeric version will be contained
+		# in debian_version, e.g. on a sarge system, the value will be '3.1'.
+		if [ $dver = "testing/unstable" ]; then
+			export dver = "sid"
+		fi
+		if [ -e /etc/lsb-release ]; then
+			grep -qi ubuntu /etc/lsb-release
+			if  [ $? -eq 0 ]; then
+				export ddir="ubuntu"
+				export dver=`cat /etc/lsb-release | grep DISTRIB_RELEASE | cut -d= -f2`
+			fi
+		fi
+	elif [ -e /etc/motd ]; then
+		head -1 /etc/motd | grep -q FreeBSD
+		if [ $? -eq 0 ]; then
+			export ddir="freebsd"
+			export dver=`head -1 /etc/motd | awk '{print $2}' /etc/motd | cut -d- -f1`
+		else
+			export ddir="unknown"
+			export dver=""
+		fi
+	else
+		export ddir="unknown"
+		export dver=""
+	fi
+fi
+
+#
+# Generate all other parameters
+#
+if [ $ddir = "debian" -o $ddir = "ubuntu" ]; then
+	dfam="debian"
+	dtype="deb"
+	suf=".${ddir}${dver}"
+elif [ $ddir = "gentoo" ]; then
+	dfam="gentoo"
+	dtype="ebuild"
+	dver1=`echo ${dver} | sed "s/\.//"`
+	suf=".${ddir}${dver1}"
+elif [ $ddir = "slackware" ]; then
+	dfam="slackware"
+	dtype="tgz"
+	suf=".${dfam}${dver}"
+elif [ $ddir = "sles" -o $ddir = "suse" ]; then
+	dfam="suse"
+	dtype="rpm"
+	suf=".${ddir}${dver}"
+elif [ $ddir = "fedora" -o $ddir = "redhat" -o $ddir = "rhel" -o $ddir = "centos" ]; then
+	dfam="redhat"
+	dtype="rpm"
+	dver1=`echo ${dver} | sed "s/\.//"`
+	if [ $ddir = "fedora" ]; then
+		suf=".fc${dver1}"
+	elif [ $ddir = "centos" ]; then
+		dver1=`echo ${dver} | sed "s/\.[0-9]//"`
+		suf=".centos${dver1}"
+	elif [ $ddir = "redhat" ]; then
+		suf=".rh${dver1}"
+	else
+		suf=".rhel${dver1}"
+	fi
+elif [ $ddir = "mandrake" ]; then
+	dfam="mandriva"
+	dtype="rpm"
+	suf=".`echo $dver | sed 's/\.//'`mdk"
+elif [ $ddir = "mandriva" ]; then
+	dfam="mandriva"
+	dtype="rpm"
+	suf=".`echo $dver | sed 's/\.//'`mdv"
+elif [ $ddir = "freebsd" ]; then
+	dfam="freebsd"
+	dtype="port"
+	suf=".`echo $dver | sed 's/\.//'`fbsd"
+else
+	dfam="unknown"
+	dtype="unknown"
+	suf="unknown"
+fi
+
+export dfam
+export dtype
+export suf
+
+#
+# Additional exports and preparation for some distros
+#
+
+# Default
+export TOPBUILDDIR=${TOPDIR}/../build
+
+if [ _"$dtype" = _"rpm" ]; then
+	export TOPBUILDDIR=`rpmquery --eval '%{_topdir}' 2> /dev/null`
+	export ARCH=`rpm --showrc | egrep "^build arch" | awk '{print $4}'`
+	mkdir -p ${TOPBUILDDIR}/{RPMS,SRPMS,SPECS,SOURCES,BUILD}
+	if [ $? -ne 0 ]; then
+		echo "Please ensure that you can write into ${TOPBUILDDIR}"
+		echo "Solution: setup _topdir in your ~/.rpmmacros or"
+		echo "chown the ${TOPBUILDDIR} to your uid"
+		exit -1
+	fi
+elif [ _"$dtype" = _"deb" ]; then
+	mkdir -p ${TOPBUILDDIR}
+elif [ _"$dtype" = _"port" ]; then
+	mkdir -p ${TOPBUILDDIR}
+elif [ _"$dfam" = _"slackware" ]; then
+	mkdir -p ${TOPBUILDDIR}/install
+elif [ _"$dtype" = _"ebuild" ]; then
+	mkdir -p ${TOPBUILDDIR}/portage
+fi
Index: /devel/lib/toolhome.pm
===================================================================
--- /devel/lib/toolhome.pm	(revision 2)
+++ /devel/lib/toolhome.pm	(revision 2)
@@ -0,0 +1,27 @@
+#!/usr/bin/perl -w
+#
+# Module to compute TOOLHOME and put in the environment
+#
+# $Id$
+#
+require Exporter;
+@ISA = qw(Exporter);
+@EXPORT = qw(set_toolhome);
+
+use strict;
+use File::Basename;
+
+sub set_toolhome {
+
+my $tmp = dirname($PROGRAM_NAME);
+#print "$tmp\n";
+if ($tmp =~ /^\//) {
+        $ENV{'TOOLHOME'} = $tmp;
+        }
+else {
+        $ENV{'TOOLHOME'} = "$ENV{PWD}/$tmp";
+        }
+
+die "TOOLHOME doesn't exist" if (not (defined $ENV{'TOOLHOME'}));
+}
+1;
Index: /devel/lib/common.pm
===================================================================
--- /devel/lib/common.pm	(revision 2)
+++ /devel/lib/common.pm	(revision 2)
@@ -0,0 +1,40 @@
+#!/usr/bin/perl -w
+#
+# Creates common environment 
+#
+# $Id$
+#
+require Exporter;
+@ISA = qw(Exporter);
+@EXPORT = qw(set_env);
+
+use strict;
+use File::Basename;
+use ExtUtils::Command;
+use File::Temp qw /tempdir/;
+
+sub set_env {
+
+my $tmp = dirname($PROGRAM_NAME);
+#print "$tmp\n";
+if ($tmp =~ /^\//) {
+        $ENV{'TOOLHOME'} = $tmp;
+        }
+else {
+        $ENV{'TOOLHOME'} = "$ENV{PWD}/$tmp";
+        }
+
+die "TOOLHOME doesn't exist" if (not (defined $ENV{'TOOLHOME'}));
+
+# Adapt to your needs
+$ENV{'TOPDIR'}=$ENV{'TOOLHOME'}."/../delivery";
+mkpath $ENV{'TOPDIR'};
+
+if (undef $ENV{'TMPDIR'}) {
+	$ENV{'TMPDIR'}="/tmp";
+}
+$ENV{'PROJTMP'} = tempdir( "projbuild.XXXXXXXXXX", DIR => $ENV{'TMPDIR'}, CLEANUP => 1 );
+
+umask 0022
+}
+1;
Index: /devel/lib/proj.pm
===================================================================
--- /devel/lib/proj.pm	(revision 2)
+++ /devel/lib/proj.pm	(revision 2)
@@ -0,0 +1,16 @@
+#!/bin/bash
+#
+# Creates project environment
+#
+# $Id$
+#
+
+# If needed for CVS to login
+$ENV{'CVSVAR'}=":pserver:anonymous@linuxcoe.cvs.sourceforge.net:/cvsroot/linuxcoe"
+
+#
+my %defpkgdir = {
+	"linuxcoe-sd-base" => "SystemDesigner",
+	"linuxcoe-sd-rhel" => "SystemDesigner-RHEL",
+	"linuxcoe-sd-doc" => "docs",
+}
Index: /devel/lib/cms.pm
===================================================================
--- /devel/lib/cms.pm	(revision 2)
+++ /devel/lib/cms.pm	(revision 2)
@@ -0,0 +1,37 @@
+#!/usr/bin/perl -w
+#
+# Creates common environment for SVN/CVS repository
+#
+# $Id$
+#
+
+require Exporter;
+@ISA = qw(Exporter);
+@EXPORT = qw(get_toolhome);
+
+use strict;
+
+# Expects we are in the right directory to launch CMS commands
+
+my @args = ("svn", "info", "2>&1", "/dev/null");
+my $ret;
+system(@args) == 0 or die "system @args failed: $?";
+if ($? == -1) {
+	print "failed to execute: $!\n";
+} elsif ($? & 127) {
+	printf "child died with signal %d, %s coredump\n", ($? & 127),  ($? & 128) ? 'with' : 'without';
+} else {
+	$ret =  $? >> 8;
+	if ($ret == 0) {
+		$ENV{'REVISION'}=`(cd $TOOLHOME/.. ; svnversion .)`;
+		$ENV{'CMSLOG'}="svn log";
+		$ENV{'CMSEXP'}="svn export";
+	} else {
+		# By default if not SVN take CVS
+		$ENV{'REVISION'}=`(cd $TOOLHOME/.. ; cvs  rannotate  -f . 2>&1 | awk '{print $1}' | grep -E '^[0-9]' | cut -d. -f2 |sort -nu | tail -1)`;
+		$ENV{'CMSLOG'}="cvs log";
+		$ENV{'CMSEXP'}="cvs export"
+		$ENV{'CVSROOT'}=$ENV{'CVSVAR'};
+	}
+}
+1;
Index: /devel/bin/mknewshtml.pl
===================================================================
--- /devel/bin/mknewshtml.pl	(revision 2)
+++ /devel/bin/mknewshtml.pl	(revision 2)
@@ -0,0 +1,126 @@
+#!/usr/bin/perl -w
+#
+# Creates news html pages
+# 
+# $Id$
+#
+# Syntax : mknewshtml.pl dir
+#
+
+use strict;
+use Date::Manip;
+use File::Basename;
+use DBI;
+use English;
+
+
+# For date handling
+$ENV{LANG}="C";
+
+my $TOOLHOME;
+my $tmp = dirname($PROGRAM_NAME);
+if ($tmp =~ /^\//) {
+	$TOOLHOME = $tmp;
+	}
+else {
+	$TOOLHOME = "$ENV{PWD}/$tmp";
+	}
+
+my $lastnews="$ARGV[0]/latest-news.html";
+my $news="$ARGV[0]/news.shtml";
+my $db="$TOOLHOME/../website/announces3.sql";
+
+print "Using Database $db\n";
+
+my $dbh = DBI->connect("dbi:SQLite:dbname=$db","","") 
+			|| die "Unable to connect to $db";
+
+open(NEWS,"> $news") || die "Unable to open $news (write)";
+print NEWS << 'EOF';
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/x html1/DTD/xhtml1-strict.dtd">
+
+<html xmlns="http://www.w3.org/1999/xhtml" dir="ltr" xml:lang="en" lang="en">
+  <head>
+<!--#include virtual="/head.shtml" -->
+  </head>
+  <body>
+                  <!--#set var="curpage" value="news.shtml" -->
+<!--#include virtual="/top.shtml" -->
+
+                <h1>Mondo Rescue News</h1>
+  <div class="h2-1">
+    <h2>This year's News</h2>
+  </div>
+
+EOF
+
+my $today = &UnixDate("today","%Y-%m-%d");
+my $firstjan = &UnixDate("1st January","%Y-%m-%d");
+#print "today: $today - First: $firstjan\n";
+
+my $all = $dbh->selectall_arrayref("SELECT id,date,announce FROM announces ORDER BY date DESC");
+  foreach my $row (@$all) {
+    my ($id, $date, $announce) = @$row;
+    print NEWS "<p><B>$date</B> $announce\n" if ((Date_Cmp($date,$today) <= 0) && (Date_Cmp($firstjan,$date) <= 0));
+  }
+
+print NEWS << 'EOF';
+
+  <div class="h2-2">
+    <h2>Last year's News</h2>
+  </div>
+
+EOF
+
+my $oldfirst = &UnixDate(DateCalc("1st January","1 year ago"),"%Y-%m-%d");
+#print "oldfirst: $oldfirst - First: $firstjan\n";
+
+$all = $dbh->selectall_arrayref("SELECT id,date,announce FROM announces ORDER BY date DESC");
+  foreach my $row (@$all) {
+    my ($id, $date, $announce) = @$row;
+    print NEWS "<p><B>$date</B> $announce\n" if ((Date_Cmp($date,$firstjan) <= 0) && (Date_Cmp($oldfirst,$date) <= 0));
+  }
+
+
+print NEWS << 'EOF';
+
+  <div class="h2-3">
+    <h2>Older News</h2>
+  </div>
+
+EOF
+
+$all = $dbh->selectall_arrayref("SELECT id,date,announce FROM announces ORDER BY date DESC");
+  foreach my $row (@$all) {
+    my ($id, $date, $announce) = @$row;
+    print NEWS "<p><B>$date</B> $announce\n" if ((Date_Cmp($oldfirst,$date) >= 0));
+  }
+
+
+print NEWS << 'EOF';
+
+  <div class="h2-4">
+    <h2>Oldest News</h2>
+  </div>
+
+   <p>look at these pages for old News concerning the project</p>
+  <p><a href="gossip.html">Hugo's diary preserved (2001-2003)</a>
+  </p>
+
+<!--#include virtual="/bottom.shtml" -->
+  </body>
+</html>
+EOF
+
+close(NEWS);
+
+my $cpt = 4;
+open(NEWS,"> $lastnews") || die "Unable to open $lastnews (write)";
+$all = $dbh->selectall_arrayref("SELECT id,date,announce FROM announces ORDER BY date DESC");
+  foreach my $row (@$all) {
+    my ($id, $date, $announce) = @$row;
+    print NEWS "<p><B>$date</B> $announce\n" if ($cpt > 0);
+	$cpt--
+  }
+
+$dbh->disconnect;
Index: /devel/bin/mdv-changelog.pl
===================================================================
--- /devel/bin/mdv-changelog.pl	(revision 2)
+++ /devel/bin/mdv-changelog.pl	(revision 2)
@@ -0,0 +1,37 @@
+#!/usr/bin/perl -w
+#
+# Remove changelog from official mdv package and 
+# prepare the comment for the commit
+
+use strict;
+use File::Copy;
+
+open(FILE, $ARGV[0]) || die "Unable to open $ARGV[0]";
+open(OUT, "> $ENV{'PROJTMP'}/out.spec") || die "Unable to create $ENV{'MONDOTMP'}/out.spec";
+open(CMT, "> $ENV{'PROJTMP'}/cmt.spec") || die "Unable to create $ENV{'MONDOTMP'}/out.spec";
+while (<FILE>) {
+	if ($_ !~ /^\%changelog/) {
+		print OUT "$_";
+	} else {
+		# We found %changelog, that's the end for the spec
+		print OUT "$_";
+		close(OUT);
+		# Next line is the date + ver => unneeded
+		my $tmp = <FILE>;
+
+		# Get the first changelog set into the comment for SVN
+		while (<FILE>) {
+			if ($_ !~ /^[ 	]*$/) {
+				print CMT "$_";
+			} else {
+				# We found an empty line, that's the end for the cmt
+				close (CMT);
+				close (FILE);
+
+				move("$ENV{'PROJTMP'}/out.spec", $ARGV[0]);
+				exit(0);
+			}
+		}
+	}
+
+}
Index: /devel/bin/mkannounce.pl
===================================================================
--- /devel/bin/mkannounce.pl	(revision 2)
+++ /devel/bin/mkannounce.pl	(revision 2)
@@ -0,0 +1,53 @@
+#!/usr/bin/perl -w
+#
+# Creates announces for new mondorescue version/tag
+# 
+# $Id$
+#
+# Syntax : mkannounce announce-file
+#
+
+use strict;
+use Date::Manip;
+use File::Basename;
+use DBI;
+use English;
+
+
+# For date handling
+$ENV{LANG}="C";
+
+my $TOOLHOME;
+my $tmp = dirname($PROGRAM_NAME);
+print "$tmp\n";
+if ($tmp =~ /^\//) {
+	$TOOLHOME = $tmp;
+	}
+else {
+	$TOOLHOME = "$ENV{PWD}/$tmp";
+	}
+
+my $db="$TOOLHOME/../website/announces3.sql";
+
+my $dbh = DBI->connect("dbi:SQLite:dbname=$db","","",
+			{ RaiseError => 1, AutoCommit => 1 }) 
+			|| die "Unable to connect to $db";
+
+my $date = &UnixDate("today","%Y-%m-%d");
+
+# To read whole file
+local $/;
+open(ANNOUNCE,$ARGV[0]) || die "Unable to open $ARGV[0] (read)";
+my $announce = <ANNOUNCE>;
+#$announce =~ s/\"/\"\"/g;
+#$announce =~ s/!//g;
+close(ANNOUNCE);
+
+print "INSERT INTO announces VALUES (NULL, $date, $announce)\n";
+my $sth = $dbh->prepare(qq{INSERT INTO announces VALUES (NULL,?,?)}) 
+		|| die "Unable to insert into $db";
+$sth->execute($date, $announce);
+#$dbh->do(qq(INSERT INTO announces VALUES (NULL, '$date', '$announce'))) 
+#|| die "Unable to insert into $db";
+
+$dbh->disconnect;
Index: /devel/bin/mkchangelog.pl
===================================================================
--- /devel/bin/mkchangelog.pl	(revision 2)
+++ /devel/bin/mkchangelog.pl	(revision 2)
@@ -0,0 +1,140 @@
+#!/usr/bin/perl -w
+#
+# Creates changelog for packages from Changelog files in the apps
+#
+# $Id$
+#
+# Syntax : mkchangelog dtype package-name output-file
+#
+
+use strict;
+use Date::Manip;
+use File::Basename;
+use English;
+
+my $log = "";
+my $dtype = $ARGV[0];
+my $pkg = $ARGV[1];
+my $pkg2;
+my $outfile = $ARGV[2];
+my $chglog = "";
+my $ndate = "";
+my $n2date = "";
+my $tmp = "";
+my $ver = "";
+my $ver2 = "";
+my $date = "";
+my $tag = "";
+
+# For date handling
+$ENV{LANG}="C";
+
+die "Syntax : mkchangelog dtype package-name output-file" 
+	if ((not (defined $dtype)) || ($dtype eq "") || 
+		(not (defined $pkg)) || ($pkg eq "") || 
+		(not (defined $outfile)) || ($outfile eq ""));
+
+my $TOOLHOME;
+$tmp = dirname($PROGRAM_NAME);
+if ($tmp =~ /^\//) {
+	$TOOLHOME = $tmp;
+	}
+else {
+	$TOOLHOME = "$ENV{PWD}/$tmp";
+	}
+
+die "TOOLHOME doesn't exist" if (not (defined $TOOLHOME));
+
+if (-f "$TOOLHOME/../$pkg/ChangeLog") {
+	$chglog = "$TOOLHOME/../$pkg/ChangeLog";
+	}
+else {
+	$pkg2 = $pkg;
+	$pkg2 =~ s/-..*//;
+	if (-f "$TOOLHOME/../$pkg2/ChangeLog") {
+		$chglog = "$TOOLHOME/../$pkg2/ChangeLog";
+		}
+	else {
+		die "Unable to find a ChangeLog file for $pkg\n";
+	}
+}
+$tmp="$TOOLHOME/../$pkg/TAG";
+if (-f "$tmp") {
+	open(TAG,"$tmp") || die "Unable to open $tmp";
+	$tag = <TAG>;
+	chomp($tag);
+} else {
+	die "Unable to find a TAG file for $pkg\n";
+}
+#print "Using $chglog as input ChangeLog file for $pkg\n";
+
+open(INPUT,"$chglog") || die "Unable to open $chglog (read)";
+open(OUTPUT,"> $outfile") || die "Unable to open $outfile (write)";
+
+# Skip first 4 lines
+$tmp = <INPUT>;
+$tmp = <INPUT>;
+$tmp = <INPUT>;
+if ($dtype eq "announce") {
+	print OUTPUT $tmp;
+}
+$tmp = <INPUT>;
+if ($dtype eq "announce") {
+	print OUTPUT $tmp;
+}
+
+my $first=1;
+
+# Handle each block separated by newline
+while (<INPUT>) {
+	($ver, $date) = split(/ /);
+	$ver =~ s/^v//;
+	chomp($date);
+	$date =~ s/\(([0-9-]+)\)/$1/;
+	#print "**$date**\n";
+	$ndate = UnixDate($date,"%a", "%b", "%d", "%Y");
+	$n2date = &UnixDate($date,"%a, %d %b %Y %H:%M:%S %z");
+	#print "**$ndate**\n";
+	if (($dtype eq "rpm") || ($dtype eq "fc")) {
+		if ($ver !~ /-/) {
+			if ($first eq 1) {
+				$ver2 = "$ver-$tag"."$ENV{suf}";
+				$first=0;
+			} else {
+				$ver2 = "$ver-1"."$ENV{suf}";
+			}
+		} else {
+			$ver2 = "$ver"."$ENV{suf}";
+		}
+		print OUTPUT "* $ndate Bruno Cornec <bruno\@mondorescue.org> $ver2\n";
+		print OUTPUT "- Updated to $ver\n";
+		}
+	if ($dtype eq "deb") {
+		print OUTPUT "$pkg ($ver) unstable; urgency=low\n";
+		print OUTPUT "\n";
+		}
+
+	$tmp = <INPUT>;	
+	while ($tmp !~ /^$/) {
+		if ($dtype eq "deb") {
+			print OUTPUT "  * $tmp";
+		} elsif ($dtype eq "rpm") {
+			print OUTPUT "$tmp";
+		} else {
+			print OUTPUT "$tmp";
+		}
+		last if (eof(INPUT));
+		$tmp = <INPUT>;
+	}
+	print OUTPUT "\n";
+
+	if ($dtype eq "deb") {
+		print OUTPUT " -- Bruno Cornec <bruno\@mondorescue.org>  $n2date\n\n";
+		print OUTPUT "\n";
+		}
+
+	last if (eof(INPUT));
+	last if ($dtype eq "announce");
+}
+close(OUTPUT);
+close(INPUT);
Index: /devel/bin/ptest.pl
===================================================================
--- /devel/bin/ptest.pl	(revision 2)
+++ /devel/bin/ptest.pl	(revision 2)
@@ -0,0 +1,40 @@
+#!/usr/bin/perl -w
+
+use strict;
+use Data::Dumper;
+
+sub get_cmds {
+
+	my $dumb;
+	my $f;
+
+	open (FILE,"/bin/busybox --help 2>&1|") or die "Unable to call busybox";
+	undef $/;
+	($dumb,$f) = split /functions:/,<FILE>;
+	close(FILE);
+	$f =~ s/\s//g;
+return (split /,/,$f);
+}
+
+# Should probably be an absolute path
+my $basedir = "symlinks";
+my $tarfile = "$basedir.tgz";
+
+print "Making tarfile $tarfile ...\n";
+
+system ("rm -rf $basedir");
+unlink $tarfile;
+
+mkdir $basedir,0755;
+mkdir "$basedir/usr",0755;
+mkdir "$basedir/usr/bin",0755;
+
+chdir "$basedir/usr/bin";
+for my $l (get_cmds) {
+	symlink "../../bin/busybox",$l;
+}
+
+chdir "../..";
+system("tar cfz ../$tarfile .");
+print "Done.\n";
+
Index: /devel/bin/cms2build.pl
===================================================================
--- /devel/bin/cms2build.pl	(revision 2)
+++ /devel/bin/cms2build.pl	(revision 2)
@@ -0,0 +1,187 @@
+#!/usr/bin/perl -w
+#
+# Creates build environment and files for packages creation from CMS repository
+#
+# $Id$
+#
+
+use strict;
+use common.pm;
+use proj.pm;
+use cms.pm;
+
+set_env();
+
+VER=`cat ${TOOLHOME}/VERSION`
+TAG=`cat ${TOOLHOME}/TAG`
+DEST=${TOPDIR}/${VER}-$TAG
+TEST="false"
+OPT=""
+mkdir -p $DEST
+
+if [ "$1" = "--test" ]; then
+	TEST="true"
+	#OPT="-r BASE"
+	shift
+fi	
+
+if [ "$1" = "" ]; then
+	c="$DEFPKG[*]"
+else
+	if [ "$1" = "all" ]; then
+			c="$ALLPKG[*]"
+	else
+		c="$*"
+	fi
+fi
+
+# Make it safe for CMS commands
+cd ${TOOLHOME}/..
+
+for pkg in $c; do
+	p=$PKGDIR[
+	v=`cat ${TOOLHOME}/../$p/VERSION`
+	tag=`cat ${TOOLHOME}/../$p/TAG`
+	echo "Management of $p $v-$tag (rev $REVISION)"
+	dest="$DEST/$p-$v"
+	rm -fr $dest
+	$CMSEXP $OPT ${TOOLHOME}/../$p $dest
+	echo "$REVISION" > $dest/REVISION
+	echo "Generating SVN log file ..."
+	$SVNLOG $OPT -v ${TOOLHOME}/../$p > $dest/history.log
+
+	for d in `cat ${TOOLHOME}/DISTROS`; do
+		export ddir=`echo $d | cut -d_ -f1`
+		export dver=`echo $d | cut -d_ -f2`
+		echo "Generating build files for $ddir ($dver)"
+		. $TOOLHOME/distro-env
+
+		ddd=`LANG=C ; date '+%Y-%m-%d'`
+		cat > $PROJTMP/mondorescue.mc << EOF
+define(\`TTT', ${tag})dnl
+define(\`RRR', ${tag}${suf})dnl
+define(\`VVV', ${v})dnl
+define(\`DDD', ${ddd})dnl
+EOF
+
+		mkdir -p $dest/distributions/$ddir $dest/distributions/${ddir}-$dver
+		if [ "$dtype" = "rpm" ]; then
+			if [ -f $dest/distributions/$ddir/spec.m4 ]; then
+				inc=$dest/distributions/$ddir/spec.m4
+			elif [ -f $dest/distributions/$dfam/spec.m4 ]; then
+				inc=$dest/distributions/$dfam/spec.m4
+			else
+				echo "Unable to build the RPM specfile for this distro. Please report to authors"
+				exit -1
+			fi
+
+			if [ $ddir = "fedora" ]; then
+				$TOOLHOME/mkchangelog.pl fc $p $PROJTMP/$p-fc.spec
+				m4 $PROJTMP/mondorescue.mc $inc $dest/distributions/rpm/$p.spec $MONDOTMP/$p-fc.spec > $dest/distributions/${ddir}-$dver/$p-fc.spec
+			fi
+			$TOOLHOME/mkchangelog.pl $dtype $p $PROJTMP/$p.spec
+			if [ $? -ne 0 ]; then
+				echo "Unable to create changelog for ${ddir}-$dver/$p.spec"
+				exit -1
+			fi
+			m4 $PROJTMP/mondorescue.mc $inc $dest/distributions/rpm/$p.spec $MONDOTMP/$p.spec > $dest/distributions/${ddir}-$dver/$p.spec
+			if [ _"`/bin/arch`" = _"x86_64" ] && [ $ddir = "rhel" ]; then
+				# Bug on x86_64 on _sysconfdir on rhel4 at least
+				perl -pi -e 's~^export CONFDIR=.*~export CONFDIR=/etc~' $dest/distributions/${ddir}-$dver/$p.spec
+			fi
+
+			rm -f $PROJTMP/$p.spec
+		elif [ "$dtype" = "ebuild" ]; then
+			m4 $PROJTMP/mondorescue.mc $dest/distributions/$dfam/$p.ebuild > $dest/distributions/${ddir}-$dver/$p-$v.ebuild
+		elif [ "$dtype" = "tgz" ]; then
+			m4 $PROJTMP/mondorescue.mc $dest/distributions/$dfam/slack-desc > $dest/distributions/${ddir}-$dver/slack-desc
+		elif [ "$dtype" = "port" ]; then
+			m4 $PROJTMP/mondorescue.mc $dest/distributions/$dfam/Makefile > $dest/distributions/${ddir}-$dver/Makefile
+		elif [ "$dtype" = "deb" ]; then
+			if [ -f $dest/distributions/$ddir/rules ]; then
+				cp -a $dest/distributions/$ddir/* $dest/distributions/${ddir}-$dver
+				inc=$dest/distributions/$ddir/rules
+			elif [ -f $dest/distributions/$dfam/rules ]; then
+				cp -a $dest/distributions/$dfam/* $dest/distributions/${ddir}-$dver
+				inc=$dest/distributions/$dfam/rules
+			else
+				echo "Unable to build the .deb build files for this distro. Please report to authors"
+				exit -1
+			fi
+			m4 $PROJTMP/mondorescue.mc $inc > $dest/distributions/${ddir}-$dver/rules
+			$TOOLHOME/mkchangelog.pl $dtype $p $dest/distributions/${ddir}-$dver/changelog
+			if [ $? -ne 0 ]; then
+				echo "Unable to create changelog for ${ddir}-$dver/changelog"
+				exit -1
+			fi
+		else
+			echo "Unknown Build"
+		fi
+	done
+
+	# The rest is done there
+	cd $DEST
+	if [ _"`echo $p | grep mondo-doc`" != _"" ]; then
+		cd $dest
+		for f in mondorescue-howto.sgml *8; do
+			m4 $PROJTMP/mondorescue.mc $f > ${f}.new
+			mv ${f}.new $f
+		done
+		make -f Makefile.howto
+		if [ $? != 0 ]; then
+			exit -1
+		fi
+		make -f Makefile.man
+		if [ $? != 0 ]; then
+			exit -1
+		fi
+		cd ..
+	fi
+	if [ _"`echo $p | grep 'busybox'`" != _"" ]; then
+		cd $dest
+		mv Rules.mak Rules.mak.orig
+		cat Rules.mak.orig | sed "s/^EXTRAVERSION\([\t ]*\):=/EXTRAVERSION\1:=-$tag-r$REVISION/" > Rules.mak
+		cd ..
+	fi
+
+	if [ _"`echo $p | grep -vE 'kernel|busybox' | grep mindi`" != _"" ]; then
+		v1=`cat ${TOOLHOME}/../mondo-doc/VERSION`
+		if [ ! -d mondo-doc-$v1 ]; then
+			echo "mondo-doc should be created before $p"
+			exit -1
+		fi
+		(cd mondo-doc-$v1 ; make -f Makefile.man install-$p INSTALLDIR=../$p-$v)
+		rm -f $dest/rootfs/sbin/parted2fdisk-ia64 
+	fi
+	if [ "`echo $p | grep -v doc | grep  mondo`" != "" ]; then
+		v1=`cat ${TOOLHOME}/../mondo-doc/VERSION`
+		if [ ! -d mondo-doc-$v1 ]; then
+			echo "mondo-doc should be created before $p"
+			exit -1
+		fi
+		(cd mondo-doc-$v1 ; make -f Makefile.howto install INSTALLDIR=../$p-$v/docs/en ; make -f Makefile.man install-$p INSTALLDIR=../$p-$v/docs/man)
+		(cd $dest ; echo "Bootstraping mondo ... " ; ./bootstrap)
+	fi
+
+	# Finally creates the tar files
+	echo -n "Creating $p tar files (gzip... "
+	tar cfphz ${DEST}/$p-$v.tar.gz $p-$v
+	if [ $TEST = "false" ]; then
+		echo -n " bzip2..."
+		tar cfphj ${DEST}/$p-$v.tar.bz2 $p-$v
+	fi
+	echo " )"
+	if [ $TEST = "true" ]; then
+		echo "Use source under $DEST/$p-$v"
+	fi
+done
+
+rm -rf $PROJTMP
+
+echo "Version delivered :"
+echo "-------------------"
+echo "${VER}-$TAG"
+echo "-------------------"
+echo "${VER}-$TAG" > ${TOPDIR}/LAST
+exit 0
+) 2>&1 | tee /tmp/cms2build.log
Index: /devel/etc/VERSION
===================================================================
--- /devel/etc/VERSION	(revision 2)
+++ /devel/etc/VERSION	(revision 2)
@@ -0,0 +1,1 @@
+4.0
Index: /devel/etc/DISTROS
===================================================================
--- /devel/etc/DISTROS	(revision 2)
+++ /devel/etc/DISTROS	(revision 2)
@@ -0,0 +1,28 @@
+mandrake_10.1
+mandrake_10.2
+mandriva_2006.0
+mandriva_2007.0
+mandriva_2007.1
+redhat_7.3
+redhat_9
+fedora_4
+fedora_5
+fedora_6
+fedora_7
+rhel_2.1
+rhel_3
+rhel_4
+rhel_5
+suse_10.0
+suse_10.1
+suse_10.2
+sles_9
+sles_10
+debian_3.1
+debian_4.0
+ubuntu_6.06
+ubuntu_7.04
+gentoo_1.6
+slackware_10.2
+slackware_11.0
+freebsd_5.5
Index: /devel/etc/TAG
===================================================================
--- /devel/etc/TAG	(revision 2)
+++ /devel/etc/TAG	(revision 2)
@@ -0,0 +1,1 @@
+1
