From 24defe191da161b4e1353a4bb97ad0fc97eadb91 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Eray=20=C3=96zkural?= Date: Tue, 16 Aug 2005 09:00:00 +0000 Subject: [PATCH] * implement TODO in get_build_number that I wrote yesterday: search multiple old packages instead of one. * remove common * cosmetic changes --- pisi/build.py | 22 +++++++++++++--------- pisi/cli/commands.py | 7 +++---- pisi/cli/common.py | 38 -------------------------------------- tests/beta-upgrade.sh | 7 ++++--- 4 files changed, 20 insertions(+), 54 deletions(-) delete mode 100644 pisi/cli/common.py diff --git a/pisi/build.py b/pisi/build.py index 2773bf16..88c7f6d3 100644 --- a/pisi/build.py +++ b/pisi/build.py @@ -294,26 +294,30 @@ class PisiBuild: #NOTE: not functional yet.. old_package_fn = None # find previous build in config.options.output_dir - # FIXME: get the newest version, make this into another fxn + found = [] for root, dirs, files in os.walk(config.options.output_dir): - if old_package_fn: - break for fn in files: if fn.startswith(package_name + '-') and \ fn.endswith(const.package_prefix): old_package_fn = os.path.join(root, fn) ui.info('(found old version %s)' % old_package_fn) - break - if not old_package_fn: + old_pkg = Package(old_package_fn, 'r') + from os.path import join + old_pkg.read(join(config.tmp_dir(), 'oldpkg')) + old_build = old_pkg.metadata.package.build + found.append( (old_package_fn, old_build) ) + if not found: return 0 ui.warning('(no previous build found, setting build no to 0.)') else: - old_pkg = Package(old_package_fn, 'r') - from os.path import join - old_pkg.read(join(config.tmp_dir(), 'oldpkg')) + a = filter(lambda (x,y): y != None, found) + if a: + a.sort(lambda x,y : cmp(x[1],y[1])) + old_build = a[0][1] + else: + old_build = None # TODO: compare old files.xml with the new one.. changed = True - old_build = old_pkg.metadata.package.build if old_build is None: ui.warning('(old package lacks a build no, setting build no to 0.)') return 0 diff --git a/pisi/cli/commands.py b/pisi/cli/commands.py index 8d60d15b..5c36df35 100644 --- a/pisi/cli/commands.py +++ b/pisi/cli/commands.py @@ -15,7 +15,6 @@ from optparse import OptionParser import pisi from pisi.uri import URI -from pisi.cli.common import * def commands_string(): @@ -438,8 +437,8 @@ Usage: list-installed list = installdb.list_installed() list.sort() if self.options.install_info: - print 'Package Name |St| Version| Rel.| Build| Distro| Date' - print '=============================================================================' + print 'Package Name |St| Version| Rel.| Build| Distro| Date' + print '========================================================================' for pkg in list: package = pisi.packagedb.inst_packagedb.get_package(pkg) inst_info = installdb.get_info(pkg) @@ -447,7 +446,7 @@ Usage: list-installed print package print inst_info elif self.options.install_info: - print '%15s | %s ' % (package.name, inst_info.one_liner()) + print '%-15s | %s ' % (package.name, inst_info.one_liner()) else: print '%15s - %s ' % (package.name, package.summary) self.finalize() diff --git a/pisi/cli/common.py b/pisi/cli/common.py deleted file mode 100644 index dafc30c7..00000000 --- a/pisi/cli/common.py +++ /dev/null @@ -1,38 +0,0 @@ -# Copyright (C) 2005, TUBITAK/UEKAE -# -# This program 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 of the License, or (at your option) -# any later version. -# -# Please read the COPYING file. -# - -usage_text1 = """%prog [options] [arguments] - -where is one of: - -""" - -usage_text2 = """ -Use \"%prog help \" for help on a specific command. -""" - -def commonopts(parser): - p = parser - p.add_option("-D", "--destdir", action="store") - p.add_option("", "--yes-all", action="store_true", - default=False, help = "assume yes in all yes/no queries") - p.add_option("-u", "--username", action="store") - p.add_option("-p", "--password", action="store") - p.add_option("-P", action="store_true", dest="getpass", default=False, - help="Get password from the command line") - p.add_option("-v", "--verbose", action="store_true", - dest="verbose", default=False, - help="detailed output") - p.add_option("-d", "--debug", action="store_true", - default=True, help="show debugging information") - p.add_option("-n", "--dry-run", action="store_true", default=False, - help = "do not perform any action, just show what\ - would be done") - return p diff --git a/tests/beta-upgrade.sh b/tests/beta-upgrade.sh index d3b44b48..9f7b21bc 100755 --- a/tests/beta-upgrade.sh +++ b/tests/beta-upgrade.sh @@ -4,12 +4,12 @@ pwd PATH=$PATH:. set -x -e -pisi-cli build tests/zip/pspec.xml tests/unzip/pspec.xml +#pisi-cli --ignore-build-no build tests/zip/pspec.xml tests/unzip/pspec.xml pisi-cli --yes-all --ignore-comar install unzip-5.50-1.pisi zip-2.3-1.pisi mkdir -p myrepo cd myrepo -../pisi-cli build ../tests/zip2/pspec.xml ../tests/unzip2/pspec.xml +#../pisi-cli --ignore-build-no build ../tests/zip2/pspec.xml ../tests/unzip2/pspec.xml cd .. pisi-cli --absolute-uris index myrepo pisi-cli remove-repo repo1 @@ -17,5 +17,6 @@ pisi-cli add-repo repo1 pisi-index.xml pisi-cli list-repo pisi-cli update-repo repo1 pisi-cli list-available +pisi-cli --install-info list-installed pisi-cli --ignore-comar upgrade zip -pisi-cli list-installed +pisi-cli --install-info list-installed