admin: cvs/cvsconv.sh (NEW) - script to convert flat SPECS/SOURCES...

baggins baggins at pld-linux.org
Tue May 15 13:10:37 CEST 2007


Author: baggins                      Date: Tue May 15 11:10:37 2007 GMT
Module: admin                         Tag: HEAD
---- Log message:
- script to convert flat SPECS/SOURCES repo to packages/%{name} layout

---- Files affected:
admin/cvs:
   cvsconv.sh (NONE -> 1.1)  (NEW)

---- Diffs:

================================================================
Index: admin/cvs/cvsconv.sh
diff -u /dev/null admin/cvs/cvsconv.sh:1.1
--- /dev/null	Tue May 15 13:10:37 2007
+++ admin/cvs/cvsconv.sh	Tue May 15 13:10:32 2007
@@ -0,0 +1,104 @@
+#!/bin/ksh
+
+PATH="/bin:/usr/bin:/usr/sbin:/sbin:/usr/X11R6/bin"
+CVSROOT=/cvsroot
+TEMPFILE=$(mktemp /tmp/repoconv.XXXXXX)
+
+DEREF="-L"
+
+# we reset macros not to contain macros.build as all the %() macros are
+# executed here, while none of them are actually needed.
+# at the time of this writing macros.build + macros contained 70 "%(...)" macros.
+safe_macrofiles=$(rpm --showrc | awk -F: '/^macrofiles/ { gsub(/^macrofiles[ \t]+:/, "", $0); gsub(/:.*macros.build:/, ":", $0); print $0 } ')
+
+# TODO: move these to /usr/lib/rpm/macros
+cat > .builder-rpmmacros <<'EOF'
+%x8664 x86_64 amd64 ia32e
+%alt_kernel %{nil}
+%_alt_kernel %{nil}
+%requires_releq_kernel_up %{nil}
+%requires_releq_kernel_smp %{nil}
+%requires_releq_kernel %{nil}
+%requires_releq() %{nil}
+%pyrequires_eq() %{nil}
+%requires_eq() %{nil}
+%requires_eq_to() %{nil}
+%releq_kernel_up ERROR
+%releq_kernel_smp ERROR
+%releq_kernel ERROR
+%kgcc_PACKAGE ERROR
+%_fontsdir ERROR
+%ruby_version ERROR
+%ruby_ver_requires_eq() %{nil}
+%ruby_mod_ver_requires_eq() %{nil}
+%__php_api_requires() %{nil}
+%php_major_version ERROR
+%php_api_version ERROR
+%py_ver ERROR
+%perl_vendorarch ERROR
+%perl_vendorlib ERROR
+# damn. need it here! - copied from /usr/lib/rpm/macros.build
+%tmpdir		%(echo "${TMPDIR:-/tmp}")
+%patchset_source(f:b:) %(
+	base=%{-b*}%{!-b*:10000};
+	start=$(expr $base + %1);
+	end=$(expr $base + %{?2}%{!?2:%{1}});
+	# we need to call seq twice as it doesn't allow two formats
+	seq -f 'Patch%g:' $start $end > %{tmpdir}/__ps1;
+	seq -f '%{-f*}' %1 %{?2}%{!?2:%{1}} > %{tmpdir}/__ps2;
+	paste %{tmpdir}/__ps{1,2};
+	rm -f %{tmpdir}/__ps{1,2};
+) \
+%{nil}
+%_specdir ./
+%_sourcedir ./
+EOF
+
+for f in `find -name \*.spec,v -printf "%P\n"`; do
+	:>$TEMPFILE
+	SPECFILE=${f%%,v}
+	p=${SPECFILE%%.spec}
+	PACKAGE=${p##Attic/}
+	echo $PACKAGE
+	revs=`rlog $SPECFILE,v | awk '/^revision/ { print $2 }' | sort -u`
+	for rev in $revs; do
+		echo -ne "\033[1G${rev}"
+		co -r$rev $SPECFILE >/dev/null 2>&1 || continue
+		# icons are needed for successful spec parse
+		ICONS="`awk '/^Icon:/ {gsub(/.*\//,"", $2); print $2}' ${SPECFILE}`"
+		if [ -n "$ICONS" ]; then
+			for i in $ICONS ; do
+				j=${i##\%\{name\}}
+				if [ "$j" = "$i" ]; then
+					touch "$i"
+				else
+					touch "${PACKAGE}${j}"
+				fi
+			done
+		fi
+		# what we need from dump is NAME, VERSION, RELEASE and PATCHES/SOURCES.
+		rpmbuild --macros "$safe_macrofiles:.builder-rpmmacros" --nodigest --nosignature --nobuild --define "prep %dump" --nodeps $SPECFILE >>$TEMPFILE 2>&1
+	done
+	echo
+	sources="`awk '$2 ~ /^(SOURCE|PATCH)URL[0-9]+/ {gsub(/.*\//,"", $3); print $3}' $TEMPFILE | sort -u`"
+
+	mkdir -p $CVSROOT/packages/$PACKAGE/Attic
+	for s in $sources $ICONS; do
+		if [ -e "$CVSROOT/SOURCES/$s,v" ] ; then
+			cp -af $DEREF $CVSROOT/SOURCES/$s,v $CVSROOT/packages/$PACKAGE/
+			rm -f $CVSROOT/SOURCES/$s,v
+			ln -sf $CVSROOT/packages/$PACKAGE/$s,v $CVSROOT/SOURCES/$s,v
+		elif [ -e "$CVSROOT/SOURCES/Attic/$s,v" ] ; then
+			cp -af $DEREF $CVSROOT/SOURCES/Attic/$s,v $CVSROOT/packages/$PACKAGE/Attic/
+			rm -f $CVSROOT/SOURCES/Attic/$s,v
+			ln -sf $CVSROOT/packages/$PACKAGE/Attic/$s,v $CVSROOT/SOURCES/Attic/$s,v
+		fi
+	done
+
+	mv $CVSROOT/SPECS/$f $CVSROOT/packages/$PACKAGE/$f
+	ln -s $CVSROOT/packages/$PACKAGE/$f $CVSROOT/SPECS/$f
+	rm -f $SPECFILE
+done
+
+rm -f $TEMPFILE
+# vi:syntax=sh:noet
================================================================


More information about the pld-cvs-commit mailing list