From 4dde6f68f039a2c7922521cc0a437344c71abab8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Eray=20=C3=96zkural?= Date: Mon, 15 Aug 2005 13:14:12 +0000 Subject: [PATCH] * implement --ignore-build-no option in build * install remains * implement a warning function --- pisi.e3p | 14 +++++++++++++- pisi/build.py | 17 ++++++++++++++--- pisi/cli/commands.py | 21 +++++++++++++++++++++ pisi/metadata.py | 11 ++++++++--- pisi/ui.py | 6 +++++- tests/beta-light.sh | 2 +- 6 files changed, 62 insertions(+), 9 deletions(-) diff --git a/pisi.e3p b/pisi.e3p index f7daafb1..11e61a53 100644 --- a/pisi.e3p +++ b/pisi.e3p @@ -1,7 +1,7 @@ - + Python @@ -322,6 +322,18 @@ pisi-cli + + tests + beta-light.sh + + + tests + beta-upgrade.sh + + + tests + beta.sh + pisi-cli diff --git a/pisi/build.py b/pisi/build.py index 8b7b77e9..27214634 100644 --- a/pisi/build.py +++ b/pisi/build.py @@ -248,9 +248,6 @@ class PisiBuild: metadata = MetaData() metadata.from_spec(self.spec.source, package) - # FIXME: MEREEEEEN :) - metadata.package.build = 0 # BOGUS. WRONG. - metadata.package.distribution = config.values.general.distribution metadata.package.distributionRelease = config.values.general.distribution_release metadata.package.architecture = "Any" @@ -262,6 +259,20 @@ class PisiBuild: d = self.ctx.pkg_install_dir() size = util.dir_size(d) metadata.package.installedSize = str(size) + + # build no + # FIXME: @!#$%^*( MEREEEEEN :) + if config.options.ignore_build_no: + metadata.package.build = None # means, build no information n/a + ui.warning('Build number is not available.') + else: + found = False + # TODO: find previous build in config.options.output_dir + if not found: + metadata.package.build = None + # TODO: else: check if metadata has changed in any significant way + # TODO: see if any file has changed except metadata + metadata.write(os.path.join(self.ctx.pkg_dir(), const.metadata_xml)) def gen_files_xml(self, package): diff --git a/pisi/cli/commands.py b/pisi/cli/commands.py index f77864c3..1e904e5b 100644 --- a/pisi/cli/commands.py +++ b/pisi/cli/commands.py @@ -179,6 +179,13 @@ If run without parameters, it prints the general help.""" self.finalize() + +def buildno_opts(self): + self.parser.add_option("", "--ignore-build-no", action="store_true", + default=False, + help="Don't take build no into account.") + + class Build(Command): """Build a PISI package using a pspec.xml file @@ -193,6 +200,9 @@ fetch all necessary files and build the package for you. def name(self): return ("build", "bi") + def options(self): + buildno_opts(self) + def run(self): if not self.args: self.help() @@ -251,6 +261,10 @@ specified a package name, it should exist in a specified repository. def name(self): return ("install", "it") + def options(self): + super(Install, self).options() + buildno_opts(self) + def run(self): if not self.args: self.help() @@ -275,6 +289,9 @@ specified a package name, it should exist in a specified repository. def name(self): return ("upgrade", "up") + def options(self): + buildno_opts(self) + def run(self): if not self.args: self.help() @@ -391,6 +408,7 @@ source and binary packages. return self.finalize() + class ListInstalled(Command): """Print the list of all installed packages @@ -446,6 +464,7 @@ Synchronizes the PiSi databases with the current repository. pisi.toplevel.update_repo(repo) self.finalize() + class AddRepo(Command): """Add a repository @@ -584,6 +603,7 @@ class ListPending(Command): self.finalize() + class SearchAvailable(Command): """Search in available packages @@ -593,6 +613,7 @@ FIXME: this is bogus """ pass + # Partial build commands class BuildUntil(Command): diff --git a/pisi/metadata.py b/pisi/metadata.py index 6e8d0d90..b76a3d93 100644 --- a/pisi/metadata.py +++ b/pisi/metadata.py @@ -53,7 +53,11 @@ class PackageInfo(specfile.PackageInfo): specfile.PackageInfo.__init__(self, node) self.version = getNodeText(node, "Version") self.release = getNodeText(node, "Release") - self.build = int(getNodeText(node, "Build")) + build_ = getNodeText(node, "Build") + if build_: + self.build = int(build_) + else: + self.build = None self.distribution = getNodeText(node, "Distribution") self.distributionRelease = getNodeText(node, "DistributionRelease") self.architecture = getNodeText(node, "Architecture") @@ -64,7 +68,8 @@ class PackageInfo(specfile.PackageInfo): def elt(self, xml): node = specfile.PackageInfo.elt(self, xml) - xml.addTextNodeUnder(node, "Build", str(self.build)) + if self.build: + xml.addTextNodeUnder(node, "Build", str(self.build)) xml.addTextNodeUnder(node, "Distribution", self.distribution) xml.addTextNodeUnder(node, "DistributionRelease", self.distributionRelease) xml.addTextNodeUnder(node, "Architecture", self.architecture) @@ -76,7 +81,7 @@ class PackageInfo(specfile.PackageInfo): def has_errors(self): # FIXME: there should be real error msgs # and comment the logic here please, it isn't very clear -gurer - ret = (specfile.PackageInfo.has_errors(self) == None) and self.build!=None + ret = (specfile.PackageInfo.has_errors(self) == None) ret = ret and self.distribution!=None ret = ret and self.distributionRelease!=None ret = ret and self.architecture!=None and self.installedSize!=None diff --git a/pisi/ui.py b/pisi/ui.py index 6ffe1729..132fc917 100644 --- a/pisi/ui.py +++ b/pisi/ui.py @@ -46,8 +46,12 @@ class CLI: sys.stdout.write(msg) sys.stdout.flush() + def warning(self,msg): + sys.stdout.write(colorize('Warning:' + msg, 'purple')) + sys.stdout.flush() + def error(self,msg): - sys.stdout.write(colorize(msg, 'red')) + sys.stdout.write(colorize('Error:' + msg, 'red')) sys.stdout.flush() def action(self,msg): diff --git a/tests/beta-light.sh b/tests/beta-light.sh index 7caf8215..b0425519 100755 --- a/tests/beta-light.sh +++ b/tests/beta-light.sh @@ -4,7 +4,7 @@ pwd PATH=$PATH:. set -x -e pisi-cli --ignore-comar remove unzip -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 index . pisi-cli add-repo repo1 pisi-index.xml pisi-cli list-repo