Skip to main content

Notice: This Wiki is now read only and edits are no longer possible. Please see: for the plan.

Jump to: navigation, search

CVS Source From Mapfile


For legal purposes, you want to scan your CVS sources, but you want to scan the sources for a given build, not a branch or HEAD. How do you ensure that the source you get from CVS matches what was used for a given build?


  • Download the mapfile for the build whose source you want to extract from CVS. For Modeling project builds, these can be found on the downloads page under Build Details. If you intend to scan multiple mapfiles, it's suggested you rename the file from directory.txt to something more meaningful like
  • Copy the contents of the script below into a file in the same directory where you downloaded the mapfile.
  • Set the script to executable, eg:
chmod +x
  • Run the script like this:
./ directory.txt
  - or - 

Note: the script below requires a linux system with cvs, grep, and gawk installed, or an equivalent cygwin install running on Windows. Linux is recommended over cygwin as long pathnames may be a problem on Windows.


# File:
# Author:, (renamed from to
# Version: Developer Edition 1.3
# Script takes a mapfiles as input and downloads via cvs the directory structure for a given
# build of eclipse. 
# Windows users require cygwin with grep, cvs, and gawk installed
# Usage:  ./
if [ -z "$1" ]; then
	echo Usage:
	echo "  ./ directory.txt"
	echo "    - or - "
	echo "  ./"
	echo For help type:  ./ -h
elif [ "$1" == "-h" ]; then
	echo The script takes a single mapfile as an argument
	echo and downloads the associated files from the cvs repository.
	echo If you are a Windows user, type $0 --help-windows for how to run.
	echo Usage:  ./
elif [ "$1" == "--help-windows" ]; then
	echo Windows users must download a program called Cygwin from 
	echo which will give you an emulated UNIX environment on the Windows platform.  The standard 
	echo install should be fine, but you must make sure that "install" is selected on the following 
	echo packages and if it is not, you must select "install" manually:
	echo "  base -> grep"
	echo "  Devel -> cvs"
	echo "  interpreters -> gawk"
	echo Usage: ./
elif [ ! -f "$1" ]; then
	echo Error: mapfile "$1" not found!
	echo Usage:  ./
	echo For help type:  ./ -h
	# Download the contents of the cvs repository into a dir where we've replaced ".map" and ".txt" with ".src" or if that failed, appended ".src" instead
	dirname=${1/\.map/\.src}; dirname=${dirname/\.txt/\.src}; if [[ $dirname = $1 ]]; then dirname=$dirname".src"; fi
	mkdir -p $dirname;
	grep ^[a-z] $1 > $dirname/$mapfile
	cd $dirname;
	gawk 'BEGIN {
	if (NF <  4) {
		split($1, version, "=");
		split(version[1], directory, "@");
		cvsdir=split($2, dirName, ":");
		printf("%s %s %s%s %s %s %s %s %s %s %s\n", "cvs", "-d", "", dirName[cvsdir], "-q", "export", "-r", version[2], "-d", directory[2], directory[2]) | "/bin/bash";
	else {
		split($1, version, "=");
		total=split($4, directory, "/");
		cvsdir=split($2, dirName, ":");
		printf("%s %s %s%s %s %s %s %s %s %s %s\n", "cvs", "-d", "", dirName[cvsdir], "-q", "export", "-r", version[2], "-d", directory[total], $4) | "/bin/bash";
	}' $mapfile
	rm $mapfile
	echo "Sources extracted to folder $dirname.";

Back to the top