aboutsummaryrefslogtreecommitdiff
path: root/Tools
diff options
context:
space:
mode:
authorEdwin Groothuis <edwin@FreeBSD.org>2008-07-08 21:03:42 +0000
committerEdwin Groothuis <edwin@FreeBSD.org>2008-07-08 21:03:42 +0000
commit00809d33a05ba61f7332514df1b1b6eafd739e9e (patch)
treeb02466a358b47ba25ac4bc4bcc151242d204ce83 /Tools
parentd1fae5b1d52e3737534fe0fb56e2220102e5c829 (diff)
downloadports-00809d33a05ba61f7332514df1b1b6eafd739e9e.tar.gz
ports-00809d33a05ba61f7332514df1b1b6eafd739e9e.zip
Notes
Diffstat (limited to 'Tools')
-rw-r--r--Tools/scripts/modules/Makefile74
-rwxr-xr-xTools/scripts/modules/buildmodules.pl205
-rw-r--r--Tools/scripts/modules/modules.head60
-rwxr-xr-xTools/scripts/modules/update.sh22
4 files changed, 361 insertions, 0 deletions
diff --git a/Tools/scripts/modules/Makefile b/Tools/scripts/modules/Makefile
new file mode 100644
index 000000000000..a169ab6de436
--- /dev/null
+++ b/Tools/scripts/modules/Makefile
@@ -0,0 +1,74 @@
+#
+# $FreeBSD$
+#
+
+PORTSDIR= ../incoming-PRs/ports/
+INDEX= INDEX-6
+MODULES_HEAD= modules.head
+MODULES_SRC= src/CVSROOT/modules
+MODULES_PROJ= projects/CVSROOT/modules
+MODULES_DOC= doc/CVSROOT/modules
+MODULES_PORTS= ports/CVSROOT/modules
+CVSUSER= edwin
+
+NOW!= date "+%A %d %B %Y at %H:%M"
+
+all: modules
+
+commit: modules
+ cp modules ports/CVSROOT/
+ cd ports/CVSROOT; \
+ cvs commit -m "Ports modules update at ${NOW}" modules
+
+
+modules: ${MODULES_HEAD} modules.index
+ cat ${MODULES_HEAD} modules.index > modules
+
+modules.index: modules-ports modules-src modules-projects modules-doc
+ ./buildmodules.pl \
+ --portsdir=${PORTSDIR} \
+ --index=${INDEX} \
+ --outdir=modules.dir \
+ --outmod=modules.mod \
+ --header=${MODULES_HEAD} \
+ --modules-src=${MODULES_SRC} \
+ --modules-proj=${MODULES_PROJ} \
+ --modules-doc=${MODULES_DOC} \
+
+ (cat modules.dir; cat modules.mod) > modules.index
+
+modules-ports: ports
+ cd ports; \
+ cvs -d :ext:${CVSUSER}@pcvs.freebsd.org/home/pcvs co CVSROOT/modules; \
+ cd ..
+ cp ports/CVSROOT/modules modules-ports
+modules-doc: doc
+ cd doc; \
+ cvs -d :ext:${CVSUSER}@ncvs.freebsd.org/home/dcvs co CVSROOT/modules; \
+ cd ..
+ cp doc/CVSROOT/modules modules-doc
+modules-projects: projects
+ cd projects; \
+ cvs -d :ext:${CVSUSER}@ncvs.freebsd.org/home/projcvs co CVSROOT/modules; \
+ cd ..
+ cp projects/CVSROOT/modules modules-projects
+modules-src: src
+ cd src; \
+ cvs -d :ext:${CVSUSER}@ncvs.freebsd.org/home/ncvs co CVSROOT/modules; \
+ cd ..
+ cp src/CVSROOT/modules modules-src
+
+ports:
+ mkdir ports
+projects:
+ mkdir projects
+doc:
+ mkdir doc
+src:
+ mkdir src
+
+clean:
+ -rm modules.index
+ -rm modules modules.mod modules.dir
+ -rm modules-ports modules-src modules-doc modules-projects
+ -rm -rf src/CVSROOT ports/CVSROOT doc/CVSROOT projects/CVSROOT
diff --git a/Tools/scripts/modules/buildmodules.pl b/Tools/scripts/modules/buildmodules.pl
new file mode 100755
index 000000000000..66d990ab4974
--- /dev/null
+++ b/Tools/scripts/modules/buildmodules.pl
@@ -0,0 +1,205 @@
+#!/usr/bin/perl -w
+
+#
+# $FreeBSD$
+#
+
+#
+# This script is used to automatically generate the CVSROOT-ports/modules
+# file, based on the content of the ports INDEX file and the modules files
+# of the other CVSROOT-* directories.
+#
+# Created by Edwin Groothuis <edwin@FreeBSD.org>
+#
+# This script lives on hub in /home/gnats-aa and is called from a crontab
+# once per day.
+#
+
+use strict;
+use Data::Dumper;
+use Getopt::Long;
+
+my $portsdir = "";
+my $index = "";
+my $header = "";
+my $modules = "";
+my $modules_src = "";
+my $modules_doc = "";
+my $modules_proj = "";
+my $outdir = "modules.dir";
+my $outmod = "modules.out";
+GetOptions( "portsdir=s" => \$portsdir,
+ "index=s" => \$index,
+ "modules=s" => \$modules,
+ "modules-src=s" => \$modules_src,
+ "modules-doc=s" => \$modules_doc,
+ "modules-proj=s"=> \$modules_proj,
+ "header=s" => \$header,
+ "outdir=s" => \$outdir,
+ "outmod=s" => \$outmod
+);
+
+#
+# Get all directories in /usr/ports, and see if there is a PKGNAMEPREFIX to
+# be worried about
+#
+my %dirs = ();
+{
+ opendir(DH, $portsdir);
+ my @dirs = readdir(DH);
+ closedir(DH);
+ foreach my $dir (@dirs) {
+ next if (! -d "$portsdir/$dir");
+ next if ($dir =~ /^\./);
+ next if ($dir eq "distfiles");
+ next if ($dir eq "packages");
+
+ $dirs{$dir} = "";
+
+ next if (! -f "$portsdir/$dir/Makefile.inc");
+
+ my $prefix =
+ `make -C $portsdir/$dir -f Makefile.inc -V PKGNAMEPREFIX`;
+ chomp($prefix);
+ $dirs{$dir} = $prefix;
+ }
+}
+
+#
+# Write the modules.dir file in the following format: "ports_" + DIR
+#
+{
+ open(FOUT, ">$outdir");
+ print FOUT "\n#\n# Ports directories\n#\n";
+ printone("ports", "ports");
+ foreach my $d (sort(keys(%dirs))) {
+ my $d_ = $d;
+ $d_ =~ s/\-/_/g;
+ printone("ports_" . $d_, "ports/$d");
+ }
+ close(FOUT);
+}
+
+#
+# Import the modules file from CVSROOT-src and friends.
+#
+my %src_mods = ();
+{
+ my $line;
+
+ foreach my $mod (($modules_src, $modules_doc, $modules_proj)) {
+ my $foundMERGE = 0;
+ next if ($mod eq "");
+ open(FIN, $mod);
+ while (defined($line = <FIN>)) {
+ if ($line =~ /!!MERGE!!/) {
+ $foundMERGE = 1;
+ next;
+ }
+ next if (!$foundMERGE);
+ next if ($line =~ /^\#/);
+
+ my @a = split(" ", $line);
+ next if ($#a != 1);
+ $src_mods{$a[0]} = $a[1];
+ }
+ close(FIN);
+ }
+}
+
+#
+# Import the modules from modules.head
+#
+{
+ my $line;
+ open(FIN, $header);
+ while (defined($line = <FIN>)) {
+ next if ($line =~ /^\#/);
+
+ my @a = split(" ", $line);
+ next if ($#a <= 0);
+ $src_mods{$a[0]} = $a[1];
+ }
+ close(FIN);
+}
+
+#
+# Read the INDEX file and store it as a hash with the key modname
+# (PKGNAMEPREFIX + portname) in %mods.
+#
+# If a duplicate is found with CVSROOT-src/modules, rename the modname
+# to "ports_" + modname.
+#
+# If a duplicate modname is is found, copy the original to DIR + modname
+# and continue for these modnames (and any future ones) as DIR + modname.
+#
+my %mods = ();
+my %dupes = ();
+{
+ my $line;
+ open(FIN, "$portsdir/$index");
+ while (defined($line = <FIN>)) {
+ my @a = split(/\|/, $line);
+ @a = split(/\//, $a[1]);
+ my %names = ( lc($a[4]) => 1, $a[4] => 1 );
+ my $path = "$a[2]/$a[3]/$a[4]";
+ my $dir = $a[3];
+
+# next if ($a[4] ne "p5-Chemistry-Elements");
+
+ if (!defined $dirs{$dir}) {
+ print "Unknown dir: $dir\n";
+ exit(1);
+ }
+
+ foreach my $name (sort(keys(%names))) {
+ my $modname = $dirs{$dir} . $name;
+
+ $modname = "ports_" . $modname
+ if (defined($src_mods{$modname}));
+
+ if (defined $dupes{$modname}) {
+ $modname = $dir . "_" . $modname;
+ } else {
+ if (defined($mods{$modname})) {
+ $dupes{$name} = 1;
+
+ # save earlier one
+ my $dupemodname = $mods{$modname}{dir} .
+ "_" . $modname;
+ my $newmodname = $dir . "_" . $modname;
+ $mods{$dupemodname}{dir} =
+ $mods{$modname}{dir};
+ $mods{$dupemodname}{name} =
+ $mods{$modname}{dir} . "_" .
+ $mods{$modname}{name};
+ $mods{$dupemodname}{path} =
+ $mods{$modname}{path};
+ $mods{$modname}{ignore} = 1;
+
+ $modname = $dir . "_" . $modname;
+ }
+ }
+
+ $mods{$modname}{dir} = $dir;
+ $mods{$modname}{name} = $modname;
+ $mods{$modname}{path} = $path;
+ $mods{$modname}{ignore} = 0;
+ }
+ }
+ close(FIN);
+
+ open(FOUT, ">$outmod");
+ print FOUT "\n#\n# Ports modules\n#\n";
+ foreach my $mod (sort(keys(%mods))) {
+ next if ($mods{$mod}{ignore});
+ printone($mods{$mod}{name}, $mods{$mod}{path});
+ }
+ close(FOUT);
+}
+
+sub printone {
+ my $name = shift;
+ my $path = shift;
+ print FOUT "$name ", " " x (30 - length($name)), " $path\n";
+}
diff --git a/Tools/scripts/modules/modules.head b/Tools/scripts/modules/modules.head
new file mode 100644
index 000000000000..c791c98acab5
--- /dev/null
+++ b/Tools/scripts/modules/modules.head
@@ -0,0 +1,60 @@
+# The CVS Modules File
+#
+# $FreeBSD$
+#
+# Maintainer: Edwin Groothuis <edwin@FreeBSD.org>
+#
+# Note that this is an auto-generated file and that any changes will
+# be overwritten at the next update. Please contact the maintainer
+# if a change needs to be made.
+#
+# Three different line formats are valid:
+# key -a aliases...
+# key [options] directory
+# key [options] directory files...
+#
+# Where "options" are composed of:
+# -i prog Run "prog" on "cvs commit" from top-level of module.
+# -o prog Run "prog" on "cvs checkout" of module.
+# -e prog Run "prog" on "cvs export" of module.
+# -t prog Run "prog" on "cvs rtag" of module.
+# -u prog Run "prog" on "cvs update" of module.
+# -d dir Place module in directory "dir" instead of module name.
+# -l Top-level directory only -- do not recurse.
+#
+# NOTE: If you change any of the "Run" options above, you'll have to
+# release and re-checkout any working directories of these modules.
+#
+# And "directory" is a path to a directory relative to $CVSROOT.
+#
+# The "-a" option specifies an alias. An alias is interpreted as if
+# everything on the right of the "-a" had been typed on the command line.
+#
+# You can encode a module within a module by using the special '&'
+# character to interpose another module into the current module. This
+# can be useful for creating a module that consists of many directories
+# spread out over the entire source repository.
+#
+
+# Convenient aliases
+world -a .
+
+# CVSROOT support
+CVSROOT CVSROOT
+access CVSROOT access
+avail CVSROOT avail
+commit_prep CVSROOT commit_prep.pl
+commitcheck CVSROOT commitcheck
+commitinfo CVSROOT commitinfo
+cvs_acls CVSROOT cvs_acls.pl
+cvsedit CVSROOT cvsedit
+cvswrappers CVSROOT cvswrappers
+editinfo CVSROOT editinfo
+log_accum CVSROOT log_accum.pl
+loginfo CVSROOT loginfo
+modules CVSROOT modules
+rcsinfo CVSROOT rcsinfo
+rcstemplate CVSROOT rcstemplate
+taginfo CVSROOT taginfo
+
+# !!MERGE!!
diff --git a/Tools/scripts/modules/update.sh b/Tools/scripts/modules/update.sh
new file mode 100755
index 000000000000..4653941e5802
--- /dev/null
+++ b/Tools/scripts/modules/update.sh
@@ -0,0 +1,22 @@
+#!/bin/sh
+
+# $FreeBSD$
+
+cd /g/hubgnats/gnats-aa/modules
+
+make clean
+make
+
+pl=`wc -l modules-ports | awk '{ print $1 }'`
+ml=`wc -l modules | awk '{ print $1 }'`
+diff=`expr $pl - $ml`
+if [ $diff -lt 0 ]; then
+ diff=`expr 0 - $diff`
+fi
+echo Difference is $diff lines.
+if [ $diff -gt 50 ]; then
+ date | mail -s "DIFF > $diff" edwin@FreeBSD.org
+ exit
+fi
+
+make commit