[Piuparts-commits] rev 104 - / trunk trunk/debian

Lars Wirzenius lars at alioth.debian.org
Mon Nov 5 21:27:23 UTC 2007


Author: lars
Date: 2007-11-05 21:27:23 +0000 (Mon, 05 Nov 2007)
New Revision: 104

Modified:
   /
   trunk/Makefile
   trunk/debian/changelog
   trunk/piuparts.py
Log:
Merged changes for defaults handling differences between Debian and Ubuntu.


Property changes on: 
___________________________________________________________________
Name: bzr:revision-info
   - timestamp: 2007-11-05 22:20:24.773999929 +0200
committer: Lars Wirzenius <liw at iki.fi>
properties: 
	branch-nick: piuparts.upstream

   + timestamp: 2007-11-05 23:26:53.927000046 +0200
committer: Lars Wirzenius <liw at iki.fi>
properties: 
	branch-nick: piuparts.upstream

Name: bzr:ancestry:v3-none
   - liw at iki.fi-20071105201927-x9hsrn0rzn1ojjwd

   + liw at iki.fi-20071105201927-x9hsrn0rzn1ojjwd
liw at iki.fi-20071105212614-utwqgghd1c996gg6

Name: bzr:revision-id:v3-none
   - 104 liw at iki.fi-20071105202024-ahct8ts13awaqfku

   + 104 liw at iki.fi-20071105202024-ahct8ts13awaqfku
105 liw at iki.fi-20071105212653-ttr3062izcfvnyj7


Modified: trunk/Makefile
===================================================================
--- trunk/Makefile	2007-11-05 20:24:53 UTC (rev 103)
+++ trunk/Makefile	2007-11-05 21:27:23 UTC (rev 104)
@@ -9,7 +9,9 @@
 etcdir = $(prefix)/etc
 version=${shell dpkg-parsechangelog | sed -n 's/^Version: *//p'}
 
+FLAVOR = debian
 
+
 # mirror = -m 'http://liw.iki.fi/debian main'
 ignore = -I fdmount -N
 
@@ -21,7 +23,8 @@
 install: all
 	install -d $(sbindir) 
 	echo $(version)
-	sed 's/__PIUPARTS_VERSION__/$(version)/g' piuparts.py > piuparts
+	sed -e 's/__PIUPARTS_VERSION__/$(version)/g' \
+	    -e 's/__DEBIAN_FLAVOR__/$(FLAVOR)/g' piuparts.py > piuparts
 	install piuparts $(sbindir)/piuparts
 
 	install -d $(man1dir) 

Modified: trunk/debian/changelog
===================================================================
--- trunk/debian/changelog	2007-11-05 20:24:53 UTC (rev 103)
+++ trunk/debian/changelog	2007-11-05 21:27:23 UTC (rev 104)
@@ -1,15 +1,20 @@
 piuparts (0.29) unreleased; urgency=low
 
   [ Ana Beatriz Guerrero Lopez ]
-  * Update uploaders, remove Amaya and Alastair. 
-  
+  * Update uploaders, remove Amaya and Alastair.
+
   [ Lars Wirzenius ]
   * piuparts.py: Call "apt-get update" before calling Chroot.minimize, so
     that we can find the debfoster package on Ubuntu.
   * debian/control: Fixed "Uploaders:" to have my preferred e-mail address
     (liw at iki.fi) instead of my Debian one.
+  * piuparts.py: Added -D option to set Debian flavor, plus two sets of
+    default settings depending on the flavor, one for Debian itself, and
+    another for Ubuntu. The settings choose default mirror and distribution
+    set (sid vs gutsy). This will allow an Ubuntu version of the package
+    to set defaults at package building time.
 
- -- Ana Beatriz Guerrero Lopez <ana at debian.org>  Thu, 18 Oct 2007 14:35:04 +0200
+ -- Lars Wirzenius <liw at iki.fi>  Mon, 05 Nov 2007 23:19:35 +0200
 
 piuparts (0.28) unstable; urgency=low
 

Modified: trunk/piuparts.py
===================================================================
--- trunk/piuparts.py	2007-11-05 20:24:53 UTC (rev 103)
+++ trunk/piuparts.py	2007-11-05 21:27:23 UTC (rev 104)
@@ -31,6 +31,7 @@
 
 
 VERSION = "__PIUPARTS_VERSION__"
+FLAVOR = "__DEBIAN_FLAVOR__"
 
 
 import time
@@ -50,11 +51,69 @@
 import unittest
 
 
+class Defaults:
+
+    """Default settings which depend on flavor of Debian.
+    
+    Some settings, such as the default mirror and distribution, depend on
+    which flavor of Debian we run under: Debian itself, or a derived
+    distribution such as Ubuntu. This class abstracts away the defaults
+    so that the rest of the code can just refer to the values defined
+    herein.
+    
+    """
+
+    def get_mirror(self):
+        """Return default mirror."""
+    
+    def get_distribution(self):
+        """Return default distribution."""
+        
+
+class DebianDefaults(Defaults):
+
+    def get_mirror(self):
+        return [("http://ftp.debian.org/debian",
+                 ["main", "contrib", "non-free"])]
+
+    def get_distribution(self):
+        return ["sid"]
+
+
+class UbuntuDefaults(Defaults):
+
+    def get_mirror(self):
+        return [("http://archive.ubuntu.com/ubuntu",
+                 ["main", "universe", "restricted", "multiverse"])]
+
+    def get_distribution(self):
+        return ["gutsy"]
+
+
+class DefaultsFactory:
+
+    """Instantiate the right defaults class."""
+    
+    def guess_flavor(self):
+        return FLAVOR
+    
+    def new_defaults(self):
+        if not settings.defaults:
+            settings.defaults = self.guess_flavor()
+        if settings.defaults.lower() == "debian":
+            return DebianDefaults()
+        if settings.defaults.lower() == "ubuntu":
+            return UbuntuDefaults()
+        logging.error("Unknown set of defaults: %s" % settings.defaults)
+        panic()
+
+
 class Settings:
 
     """Global settings for this program."""
     
     def __init__(self):
+        self.defaults = None
         self.tmpdir = None
         self.scriptsdir = None
         self.keep_tmpdir = False
@@ -1212,6 +1271,10 @@
     parser = optparse.OptionParser(usage="%prog [options] package ...",
                                    version="piuparts %s" % VERSION)
     
+    parser.add_option("-D", "--defaults", action="store",
+                      help="Choose which set of defaults to use "
+                           "(debian/ubuntu).")
+    
     parser.add_option("-a", "--apt", action="store_true", default=False,
                       help="Command line arguments are package names " +
                            "to be installed via apt.")
@@ -1320,7 +1383,8 @@
                       help="No meaning anymore.")
     
     (opts, args) = parser.parse_args()
-    
+
+    settings.defaults = opts.defaults
     settings.args_are_package_files = not opts.apt
     settings.basetgz = opts.basetgz
     settings.debian_distros = opts.distribution
@@ -1366,14 +1430,15 @@
                           settings.scriptsdir)
             panic()
 
+    defaults = DefaultsFactory().new_defaults()
+    
     if not settings.debian_distros:
-        settings.debian_distros = ["sid"]
+        settings.debian_distros = defaults.get_distribution()
 
     if not settings.debian_mirrors:
         settings.debian_mirrors = find_default_debian_mirrors()
         if not settings.debian_mirrors:
-            settings.debian_mirrors = [("http://ftp.debian.org/",
-                                        ["main", "contrib", "non-free"])]
+            settings.debian_mirrors = defaults.get_mirror()
 
     if settings.keep_sources_list and \
        (not settings.basetgz or len(settings.debian_distros) > 1):




More information about the Piuparts-commits mailing list