changeset 11715:86bbba911de8 release-3-0-x

Allow installation of already extracted packages * * * * * *
author Thomas Weber <thomas.weber.mail@gmail.com>
date Mon, 24 Mar 2008 18:27:20 -0400
parents ed3315995d3c
children 017e13f0d056
files scripts/ChangeLog scripts/pkg/pkg.m
diffstat 2 files changed, 49 insertions(+), 36 deletions(-) [+]
line wrap: on
line diff
--- a/scripts/ChangeLog
+++ b/scripts/ChangeLog
@@ -1,3 +1,7 @@
+2008-03-24  Thomas Weber  <thomas.weber.mail@gmail.com>
+
+	* pkg/pkg.m: Allow installation of already extracted packages.
+
 2008-03-24  Michael Goffioul  <michael.goffioul@gmail.com>
 
 	* pkg/pkg.m (pkg:configure_make): Make it work with recent changes in
--- a/scripts/pkg/pkg.m
+++ b/scripts/pkg/pkg.m
@@ -599,45 +599,54 @@
 	if (length (dirlist) > 3)
 	  error ("bundles of packages are not allowed")
 	endif
+      endif
 
-	## the two first entries of dirlist are "." and ".."
-	for k = 3:length (dirlist)
-	  packdir = fullfile (tmpdir, dirlist{k});
-	  packdirs{end+1} = packdir;
-
-	  ## Make sure the package contains necessary files
-	  verify_directory (packdir);
+      ## The filename pointed to an uncompressed package to begin with
+      if (exist (tgz, "dir"))
+	dirlist = {".", "..", tgz};
+      endif
 
-	  ## Read the DESCRIPTION file
-	  filename = fullfile (packdir, "DESCRIPTION");
-	  desc = get_description (filename);
-
-	  ## Verify that package name corresponds with filename
-	  [dummy, nm] = fileparts (tgz); 
-	  if ((length (nm) >= length (desc.name))
-	      && ! strcmp (desc.name, nm(1:length(desc.name))))
-	    error ("package name '%s' doesn't correspond to its filename '%s'", 
-		   desc.name, nm);
+      if (exist (tgz, "file") || exist (tgz, "dir"))
+	## the two first entries of dirlist are "." and ".."
+	if (exist (tgz, "file"))
+	  packdir = fullfile (tmpdir, dirlist{3});
+	else
+	  packdir = fullfile (pwd(), dirlist{3});
+	endif
+	packdirs{end+1} = packdir;
+	
+	## Make sure the package contains necessary files
+	verify_directory (packdir);
+	
+	## Read the DESCRIPTION file
+	filename = fullfile (packdir, "DESCRIPTION");
+	desc = get_description (filename);
+	
+	## Verify that package name corresponds with filename
+	[dummy, nm] = fileparts (tgz); 
+	if ((length (nm) >= length (desc.name))
+	    && ! strcmp (desc.name, nm(1:length(desc.name))))
+	  error ("package name '%s' doesn't correspond to its filename '%s'", 
+		 desc.name, nm);
+	endif
+	
+	## Set default installation directory
+	desc.dir = fullfile (prefix, strcat (desc.name, "-", desc.version));
+	
+	## Set default architectire dependent installation directory
+	desc.archprefix = fullfile (archprefix, strcat (desc.name, "-",
+							desc.version));
+	
+	## Save desc
+	descriptions{end+1} = desc;
+	
+	## Are any of the new packages already installed?
+	## If so we'll remove the old version.
+	for j = 1:length (packages)
+	  if (strcmp (packages{j}.name, desc.name))
+	    packages_to_uninstall(end+1) = j;
 	  endif
-
-	  ## Set default installation directory
-	  desc.dir = fullfile (prefix, strcat (desc.name, "-", desc.version));
-
-	  ## Set default architectire dependent installation directory
-	  desc.archprefix = fullfile (archprefix, strcat (desc.name, "-",
-							  desc.version));
-
-	  ## Save desc
-	  descriptions{end+1} = desc;
-
-	  ## Are any of the new packages already installed?
-	  ## If so we'll remove the old version.
-	  for j = 1:length (packages)
-	    if (strcmp (packages{j}.name, desc.name))
-	      packages_to_uninstall(end+1) = j;
-	    endif
-	  endfor
-	endfor        
+	endfor
       endif
     endfor
   catch