This is the mail archive of the ecos-patches@sources.redhat.com mailing list for the eCos project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

ecosadmin.tcl: delete empty directories after removal of package


This patch ensures that empty directories are deleted following the removal 
of an eCos package from the repository. I have also added a missing 
"hardware" attribute to the CYGPKG_DEVS_ETH_ARM_KS32C5000 record in 
ecos.db. Checked in.

John Dallaway
eCosCentric Limited
Index: ChangeLog
===================================================================
RCS file: /cvs/ecos/ecos/packages/ChangeLog,v
retrieving revision 1.132
diff -u -5 -r1.132 ChangeLog
--- ChangeLog	19 Jan 2004 14:35:01 -0000	1.132
+++ ChangeLog	30 Jan 2004 10:17:27 -0000
@@ -1,5 +1,13 @@
+2004-01-30  John Dallaway  <jld@ecoscentric.com>
+
+	* ecos.db: Add 'hardware' attribute to CYGPKG_DEVS_ETH_ARM_KS32C5000.
+
+	* ecosadmin.tcl: Delete empty directories in the repository following
+	eCos package removal. Read the hardware attribute from package records
+	in ecos.db.
+
 2004-01-19  Nick Garnett  <nickg@calivar.com>
 
 	* ecos.db: Added FAT12/16 filesystem packages.
 
 	* NEWS: Added line about FAT filesystem support.
Index: ecos.db
===================================================================
RCS file: /cvs/ecos/ecos/packages/ecos.db,v
retrieving revision 1.117
diff -u -5 -r1.117 ecos.db
--- ecos.db	19 Jan 2004 14:35:01 -0000	1.117
+++ ecos.db	30 Jan 2004 10:17:39 -0000
@@ -9,10 +9,11 @@
 #=============================================================================
 #####ECOSGPLCOPYRIGHTBEGIN####
 ## -------------------------------------------
 ## This file is part of eCos, the Embedded Configurable Operating System.
 ## Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.
+## Copyright (C) 2004 eCosCentric Limited
 ##
 ## eCos is free software; you can redistribute it and/or modify it under
 ## the terms of the GNU General Public License as published by the Free
 ## Software Foundation; either version 2 or (at your option) any later version.
 ##
@@ -1341,10 +1342,11 @@
                          development boards."
 }
 
 package CYGPKG_DEVS_ETH_ARM_KS32C5000 {
 	alias 		{ "Samsung KS32C5000 ethernet driver" eth_ks32c5000 }
+	hardware
 	directory	devs/eth/arm/ks32c5000
 	script		ks32c5000_eth.cdl
         description     "Ethernet driver for Samsung ks32c5000/S3c4510."
 }
 
Index: ecosadmin.tcl
===================================================================
RCS file: /cvs/ecos/ecos/packages/ecosadmin.tcl,v
retrieving revision 1.14
diff -u -5 -r1.14 ecosadmin.tcl
--- ecosadmin.tcl	12 Jun 2003 14:38:48 -0000	1.14
+++ ecosadmin.tcl	30 Jan 2004 10:17:42 -0000
@@ -17,10 +17,11 @@
 #####ECOSGPLCOPYRIGHTBEGIN####
 ## -------------------------------------------
 ## This file is part of eCos, the Embedded Configurable Operating System.
 ## Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.
 ## Copyright (C) 2003 John Dallaway
+## Copyright (C) 2004 eCosCentric Limited
 ##
 ## eCos is free software; you can redistribute it and/or modify it under
 ## the terms of the GNU General Public License as published by the Free
 ## Software Foundation; either version 2 or (at your option) any later version.
 ##
@@ -553,10 +554,11 @@
 	proc package { name body } {
 		add_known_package $name
 		set_package_data "$name,alias" ""
 		set_package_data "$name,versions" ""
 		set_package_data "$name,dir" ""
+		set_package_data "$name,hardware" 0
 		set ::current_package $name
 		eval $body
 		set ::current_package ""
 	}
 
@@ -597,14 +599,17 @@
 		if { $::current_package != "" } {
 			set_package_data "$::current_package,alias" $str
 		}
 	}
 
+	proc hardware { } {
+		set_package_data "$::current_package,hardware" 1
+	}
+
 	proc description { str } { }
 	proc disable { str } { }
 	proc enable { str } { }
-	proc hardware { } { }
 	proc script { str } { }
 	proc set_value { str1 str2 } { }
 	}
 
 	# The parser is ready to evaluate the script. To avoid having to give the
@@ -1034,11 +1039,20 @@
 				ecosadmin::report "removing package $name"
 			}
 			if { [ catch { file delete -force -- $package_dir } message ] != 0 } {
 				# issue a warning if package deletion failed - this is not fatal
 				ecosadmin::warning $message
-			}			
+			}
+			set dir [ file dirname $package_dir ]
+			while { [ llength [ glob -nocomplain -- [ file join $dir "*" ] ] ] == 0 } {
+				# the parent of the deleted directory is now empty so delete it
+				if { [ catch { file delete -- $dir } message ] != 0 } {
+					# issue a warning if empty directory deletion failed - this is not fatal
+					ecosadmin::warning $message
+				}
+				set dir [ file dirname $dir ]
+			}
 		}
 	}
 
 	# Create the parser, add the aliased commands, and then define
 	# the routines that do the real work.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]