changeset 244:2aa50412cca8

driver: skip building gpm-installed packages.
author janneke <janneke@gnu.org>
date Thu, 15 Dec 2005 13:58:36 +0100
parents b8f372c29c5c
children 55e12963bc63
files GNUmakefile cyg-apt.py.in driver.py specs/cpm.py
diffstat 4 files changed, 53 insertions(+), 23 deletions(-) [+]
line wrap: on
line diff
--- a/GNUmakefile	Thu Dec 15 09:47:21 2005 +0100
+++ b/GNUmakefile	Thu Dec 15 13:58:36 2005 +0100
@@ -61,3 +61,7 @@
 	rm -f ~/.cyg-apt .cyg-apt
 	./cyg-apt.py --root=target/i686-mingw32/system --mirror=file://uploads setup --ini=file://uploads/setup.ini
 	./cyg-apt.py list
+
+gpm-install: test-gub
+	./cyg-apt.py install $$(./cyg-apt.py available)
+	
\ No newline at end of file
--- a/cyg-apt.py.in	Thu Dec 15 09:47:21 2005 +0100
+++ b/cyg-apt.py.in	Thu Dec 15 13:58:36 2005 +0100
@@ -153,14 +153,16 @@
     -m,--mirror=URL        use mirror [%(mirror)s]
     -n,--netrel=DIR        set netrel dir [%(NETREL)s]
     -r,--root=DIR          set %(target)s root [%(ROOT)s]
+    -s,--name              print package name only
     -t,--dist=NAME         set dist name (curr, test, prev) [%(distname)s]
     -x,--no-deps           ignore dependencies
 ''' % d)
 			  
 (options, files) = getopt.getopt (sys.argv[1:],
-				  'c:dhi:m:r:t:x',
+				  'c:dhi:m:r:st:x',
 				  ('cache=', 'download', 'help', 'mirror=',
-				   'root=', 'ini=', 'dist=', 'no-deps'))
+				   'root=', 'ini=', 'dist=', 'name',
+				   'no-deps'))
 
 command = 'help'
 if len (files) > 0:
@@ -170,7 +172,7 @@
 if len (files) > 1:
 	packagename = files[1]
 
-
+name_p = 0
 nodeps_p = 0
 download_p = 0
 for i in options:
@@ -199,6 +201,8 @@
 		downloads = cache + '/' + urllib.quote (mirror, '').lower ()
 	elif o == '--dist' or o == '-t':
 		distname = a
+	elif o == '--name' or o == '-s':
+		name_p = 1
 	elif o == '--no-deps' or o == '-x':
 		nodeps_p = 1
 
@@ -406,7 +410,7 @@
 	'''installed packages'''
 	global packagename
 	for packagename in psort (cpm.installed ().keys ()):
-		ins = get_installed_version ()
+		ins = cpm.version (packagename)
 		new = 0
 		if dists[distname].has_key (packagename) \
 		   and dists[distname][packagename].has_key (INSTALL):
@@ -443,13 +447,6 @@
 		package['ver'] = split_ball (ball)[1]
 	return package['ver']
 	
-def get_installed_version ():
-	#FIXME: gub has no versions yet hack
-	try:
-		return split_ball (cpm.installed ()[packagename])[1]
-	except:
-		return ''
-
 def version ():
 	'''print installed version'''
 	global distname, packagename
@@ -458,7 +455,7 @@
 			distname = 'installed'
 			no_package ()
 			sys.exit (1)
-		print version_to_string (get_installed_version ())
+		print version_to_string (cpm.version (packagename))
 	else:
 		for packagename in psort (cpm.installed ().keys ()):
 			if not cpm.installed ().has_key (packagename):
@@ -466,14 +463,14 @@
 				no_package ()
 				sys.exit (1)
 			print '%-20s%-12s' % (packagename,
-					 version_to_string (get_installed_version ()))
+					 version_to_string (cpm.version (packagename)))
 	
 def get_new ():
 	global packagename
 	lst = []
 	for packagename in cpm.installed ().keys ():
 		new = get_version ()
-		ins = get_installed_version ()
+		ins = cpm.version (packagename)
 		if new > ins:
 			debug (" %s > %s" % (new, ins))
 			lst.append (packagename)
@@ -533,10 +530,17 @@
 	for packagename in psort (packages):
 		s = packagename
 		d = get_field ('sdesc') 
-		if d:
+		if d and not name_p:
 			s += ' - %s' % d[1:-1]
 		print s
 
+def available ():
+	'''print all installable package names'''
+	global name_p
+	name_p = 1
+	packagename = ''
+	search ()
+	
 def show ():
 	'''print information for package'''
 	s = packagename
@@ -556,7 +560,7 @@
 	if lst and packagename not in lst:
 		sys.stderr.write ('warning: missing packages: %s\n' % string.join (lst))
 	elif cpm.installed ().has_key (packagename):
-		ins = get_installed_version ()
+		ins = cpm.version (packagename)
 		new = get_version ()
 		if ins >= new:
 			sys.stderr.write ('%s is already the newest version\n' % packagename)
@@ -578,7 +582,7 @@
 			continue
 		sys.stderr.write ('removing %s %s\n' \
 				  % (packagename,
-				     version_to_string (get_installed_version ())))
+				     version_to_string (cpm.version (packagename))))
 		cpm.uninstall (packagename)
 	
 def install ():
@@ -602,7 +606,7 @@
 		if cpm.installed ().has_key (packagename):
 			sys.stderr.write ('preparing to replace %s %s\n' \
 					  % (packagename,
-					     version_to_string (get_installed_version ())))
+					     version_to_string (cpm.version (packagename))))
 			cpm.uninstall (packagename)
 		sys.stderr.write ('installing %s %s\n' \
 				  % (packagename,
--- a/driver.py	Thu Dec 15 09:47:21 2005 +0100
+++ b/driver.py	Thu Dec 15 13:58:36 2005 +0100
@@ -9,6 +9,7 @@
 
 sys.path.insert (0, 'specs/')
 
+import cpm
 import gub
 import framework
 
@@ -129,17 +130,30 @@
 
 
 def build_packages (settings, packages):
+	def skip (p):
+		# FIXME: next step might be to download/install using
+		# system_gpm unless --rebuild is set, or somesuch.
+		"""Return true if package P is installed by system_gpm.
+		"""
+		return p.system_gpm.is_installed (p.name()) \
+			   and p.system_gpm.version (p.name ()) \
+			   == cpm.string_to_version (p.ball_version)
+
 	if not settings.offline:
 		for i in packages:
-			i.download ()
+			# skip download for installed package
+			if not skip (i):
+				i.download ()
 
 	d = []
 	for i in packages:
-		if not i.__dict__.has_key ('depends'):
-			i.depends = d
-		process_package (i)
+		# skip stages for installed package
+		if not skip (i):
+			if not i.__dict__.has_key ('depends'):
+				i.depends = d
+			process_package (i)
 		d = [i.name ()]
-		
+
 ## FIXME: c/p from buildmac.py
 ##	gub.system ('cd %(root)s && strip bin/*' % locals ())
 ##	gub.system ('cd %(root)s && cp etc/pango/pango.modules etc/pango/pango.modules.in ' % locals ())
--- a/specs/cpm.py	Thu Dec 15 09:47:21 2005 +0100
+++ b/specs/cpm.py	Thu Dec 15 13:58:36 2005 +0100
@@ -145,6 +145,14 @@
 			self._load_installed ()
 		return self._installed
 
+	def is_installed (self, name):
+		return name in self._installed.keys ()
+
+	def version (self, name):
+		if name in self._installed.keys ():
+			return split_ball (self.installed ()[name])[1]
+		return 0, 0
+
 	def _install (self, name, ball, depends=[]):
 		root = self.root
 		z = self.compression