Jump to: navigation, search

Difference between revisions of "CVS Source From Mapfile"

m
 
m (Script)
 
(4 intermediate revisions by one other user not shown)
Line 5: Line 5:
 
== Solution ==
 
== Solution ==
  
You use the script copied below to extract the source from CVS into a folder, then you can either zip those files and sent them where they need to go or scan them in place. Script requires a linux system with cvs, grep, and gawk installed, or an equivalent cygwin install running on Windows. Note that long pathnames may be a problem if run on Windows.
+
* Download the mapfile for the build whose source you want to extract from CVS. For Modeling project builds, these can be found on the [http://www.eclipse.org/modeling/emf/downloads/?project=emf 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 <code>emf-2.3.0M7.map</code>
 +
 
 +
* 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 getCVSBuildSource.sh
 +
 
 +
* Run the script like this:
 +
./getCVSBuildSource.sh directory.txt
 +
  - or -
 +
./getCVSBuildSource.sh emf-2.3.0M7.map
 +
 
 +
Note: the script below requires a linux system with <code>cvs</code>, <code>grep</code>, and <code>gawk</code> installed, or an equivalent [http://www.cygwin.com/setup.exe cygwin] install running on Windows. Linux is recommended over [http://www.cygwin.com/setup.exe cygwin] as long pathnames may be a problem on Windows.
  
 
== Script ==
 
== Script ==
  
<pre>
+
<source lang="bash">
 
#!/bin/bash
 
#!/bin/bash
 
#
 
#
Line 91: Line 103:
 
echo "Sources extracted to folder $dirname.";
 
echo "Sources extracted to folder $dirname.";
 
fi
 
fi
</pre>
+
</source>
 +
 
 +
[[Category:Modeling]] [[Category:Releng]]

Latest revision as of 15:53, 9 May 2009

Situation

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?

Solution

  • 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 emf-2.3.0M7.map
  • 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 getCVSBuildSource.sh
  • Run the script like this:
./getCVSBuildSource.sh directory.txt
  - or - 
./getCVSBuildSource.sh emf-2.3.0M7.map

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.

Script

#!/bin/bash
#
# File: getCVSBuildSource.sh
# Author: millertb@us.ibm.com, codeslave@ca.ibm.com (renamed from automation.sh to getCVSBuildSource.sh)
# 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:  ./getCVSBuildSource.sh mapfile.map
 
if [ -z "$1" ]; then
	echo Usage:
	echo "  ./getCVSBuildSource.sh directory.txt"
	echo "    - or - "
	echo "  ./getCVSBuildSource.sh mapfile.map"
	echo
	echo For help type:  ./getCVSBuildSource.sh -h
	echo
elif [ "$1" == "-h" ]; then
	echo The getCVSBuildSource.sh script takes a single mapfile as an argument
	echo and downloads the associated files from the eclipse.org cvs repository.
	echo If you are a Windows user, type $0 --help-windows for how to run.
	echo 
	echo Usage:  ./getCVSBuildSource.sh mapfile.map
	echo
elif [ "$1" == "--help-windows" ]; then
	echo Windows users must download a program called Cygwin from http://www.cygwin.com/setup.exe 
	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
	echo Usage: ./getCVSBuildSource.sh mapfile.map
	echo
elif [ ! -f "$1" ]; then
	echo Error: mapfile "$1" not found!
	echo 
	echo Usage:  ./getCVSBuildSource.sh mapfile.map
	echo
	echo For help type:  ./getCVSBuildSource.sh -h
	echo
else
	# 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
	mapfile=tempmapfile.map
 
	mkdir -p $dirname;
	grep ^[a-z] $1 > $dirname/$mapfile
	cd $dirname;
 
	gawk 'BEGIN {
		FS=","
	}
	{
	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", ":pserver:anonymous@dev.eclipse.org:", 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", ":pserver:anonymous@dev.eclipse.org:", dirName[cvsdir], "-q", "export", "-r", version[2], "-d", directory[total], $4) | "/bin/bash";
	}
 
 
	}' $mapfile
 
	rm $mapfile
 
	echo "Sources extracted to folder $dirname.";
fi