[Piuparts-commits] rev 739 - piatti/home/piupartsm/bin

Holger Levsen holger at alioth.debian.org
Fri Nov 12 21:53:35 UTC 2010


Author: holger
Date: 2010-11-12 21:53:34 +0000 (Fri, 12 Nov 2010)
New Revision: 739

Modified:
   piatti/home/piupartsm/bin/archive_old_logs
Log:
fix script to really archive all old logs

Modified: piatti/home/piupartsm/bin/archive_old_logs
===================================================================
--- piatti/home/piupartsm/bin/archive_old_logs	2010-11-12 21:15:45 UTC (rev 738)
+++ piatti/home/piupartsm/bin/archive_old_logs	2010-11-12 21:53:34 UTC (rev 739)
@@ -1,6 +1,6 @@
 #!/bin/bash
 
-# Copyright 2009 Holger Levsen (holger at layer-acht.org)
+# Copyright 2009-2010 Holger Levsen (holger at layer-acht.org)
 # 
 # This program is free software; you can redistribute it and/or modify it
 # under the terms of the GNU General Public License as published by the
@@ -35,16 +35,16 @@
 for SECTION in $SECTIONS ; do 
 	mkdir -p $MASTER/$SECTION/archive
 	cd $MASTER/$SECTION
-	for DIR in fail pass bugged ; do
-		cd $DIR
-		LOGS=$( for i in `ls -1 | cut -d "_" -f1|sort -u `; do ls -rt1 ${i}_*|sed '$d' ; done ) 
-		if [ ! -z "$LOGS" ] ; then
-			mkdir -p $MASTER/$SECTION/archive/$DIR
-			for LOG in $LOGS ; do
-				mv $LOG $MASTER/$SECTION/archive/$DIR
+	mkdir -p archive/pass archive/bugged archive/fail
+	# loop through all packages logs 
+	for PACKAGE in $(find pass/ fail/ bugged/|cut -d "_" -f1|cut -d"/" -f2|sort -u|sed '1d') ; do 
+		# all logs except the last one (|sed '$d' deletes the last line)
+		OLDLOGS=$( ls -tr1 --color=none bugged/${PACKAGE}_* fail/${PACKAGE}_* pass/${PACKAGE}_* 2>/dev/null|sed '$d' )
+		if [ ! -z "$OLDLOGS" ] ; then
+			for LOG in $OLDLOGS ; do
+				echo mv $LOG archive/$(echo $LOG|cut -d"/" -f1)/
 			done
 		fi
-       		cd ..
 	done
 done
 




More information about the Piuparts-commits mailing list