Add an option to override version prefix (~ubuntu)

Bug #1702677 reported by Ondřej Surý
14
This bug affects 2 people
Affects Status Importance Assigned to Milestone
ubuntu-dev-tools (Ubuntu)
Confirmed
Undecided
Unassigned

Bug Description

Hi,

sometimes it is important to have a larger version number than in the target release, so an option to override (~ubuntu or ~debian) to something larger might be needed.

Here's the patch that adds an -p,--prefix option to backportpackage:
```
--- /usr/bin/backportpackage 2017-06-13 11:14:14.000000000 +0200
+++ /home/ondrej/bin/backportpackage 2017-07-06 14:13:37.022244568 +0200
@@ -83,6 +83,10 @@ def parse(args):
                       metavar='SUFFIX',
                       help='Suffix to append to version number '
                            '(default: ~ppa1 when uploading to a PPA)')
+ parser.add_option('-p', '--prefix',
+ metavar='PREFIX',
+ help='Prefix to prepend to version number '
+ '(default: ~<distribution> (debian or ubuntu)')
     parser.add_option('-b', '--build',
                       default=False,
                       action='store_true',
@@ -221,14 +225,16 @@ def find_package(mirror, workdir, packag
     return srcpkg

-def get_backport_version(version, suffix, upload, release):
+def get_backport_version(version, suffix, upload, release, prefix):
     distribution = codename_to_distribution(release)
     if not distribution:
         error('Unknown release codename %s' % release)
     series = Distribution(distribution.lower()).\
         getSeries(name_or_version=release)

- backport_version = version + ('~%s%s.1' % (distribution.lower(), series.version))
+ if prefix is None:
+ prefix = '~%s' % (distribution.lower())
+ backport_version = version + ('%s%s.1' % (prefix, series.version))
     if suffix is not None:
         backport_version += suffix
     elif upload and upload.startswith('ppa:'):
@@ -308,7 +314,7 @@ def orig_needed(upload, workdir, pkg):

 def do_backport(workdir, pkg, suffix, close, release, release_pocket, build,
- builder, update, upload, keyid, prompt):
+ builder, update, upload, keyid, prompt, prefix):
     dirname = '%s-%s' % (pkg.source, release)
     srcdir = os.path.join(workdir, dirname)

@@ -321,7 +327,7 @@ def do_backport(workdir, pkg, suffix, cl
     pkg.unpack(dirname)

     bp_version = get_backport_version(pkg.version.full_version, suffix,
- upload, release)
+ upload, release, prefix)
     old_version = get_old_version(pkg.source, release)
     bp_dist = get_backport_dist(release, release_pocket)

@@ -413,7 +419,8 @@ def main(args):
                         opts.update,
                         opts.upload,
                         opts.keyid,
- opts.prompt)
+ opts.prompt,
+ opts.prefix)
     except DownloadError as e:
         error(str(e))
     finally:
```

Tags: patch
tags: added: patch
Revision history for this message
Laurent Declercq (l-declercq) wrote :

We need that too ;)
That's really a valuable addition.

Revision history for this message
Launchpad Janitor (janitor) wrote :

Status changed to 'Confirmed' because the bug affects multiple users.

Changed in ubuntu-dev-tools (Ubuntu):
status: New → Confirmed
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.