finally:
# Remove the temporary copy of the repository we have created earlier.
repo.remove()
+ self.repos.rem_repo(repo)
def update(self, pkgs, check=False):
"""
return sorted(pkgs)
@staticmethod
- def build(pkg, resultdirs=None, shell=False, **kwargs):
+ def build(pkg, resultdirs=None, shell=False, install_test=True, **kwargs):
if not resultdirs:
resultdirs = []
try:
b.prepare()
b.extract()
- b.build()
- b.install_test()
+ b.build(install_test=install_test)
# Copy-out all resultfiles
for resultdir in resultdirs:
return ret
- def build(self):
+ def build(self, install_test=True):
assert self.pkg
- # Create icecream toolchain.
- self.create_icecream_toolchain()
-
- # Create the build script and build command.
- build_script = self.create_buildscript()
- build_cmd = "/bin/sh -e -x %s" % build_script
-
- try:
- self.do(build_cmd, logger=self.log)
-
- except Error:
- raise BuildError, "The build command failed."
-
- # XXX clean up that mess after this line
-
- # Create a temporary repository where we put in the just built packages.
- repo = repository.RepositoryDir(self.pakfire, "build-%s" % self.build_id,
- "", self.chrootPath("result"), type="binary")
- self.pakfire.repos.add_repo(repo)
-
- # Make all these little package from the build environment.
- for pkg in reversed(self.pkg.packages):
- packager = packages.packager.BinaryPackager(self.pakfire, pkg, self)
- packager.run([repo.path,])
- self.log.info("")
-
- # Update repository metadata.
- repo.update(force=True)
-
- self.log.info(_("Dumping created packages"))
-
- for line in repo.dump(long=True, filelist=True).splitlines():
- self.log.info(" %s" % line)
- self.log.info("")
-
- self.pakfire.repos.rem_repo(repo)
-
- return repo
-
- def build(self):
pkgfile = os.path.join("/build", os.path.basename(self.pkg.filename))
resultdir = self.chrootPath("/result")
# Create the build command, that is executed in the chroot.
build_command = ["pakfire-build2", "--offline", "build", pkgfile,
- "--nodeps",]
+ "--nodeps", "--resultdir=/result",]
try:
self.do(" ".join(build_command), logger=self.log)
except Error:
raise BuildError, _("The build command failed. See logfile for details.")
+ # Perform install test.
+ if install_test:
+ self.install_test()
+
# Copy the final packages and stuff.
# XXX TODO resultdir
logging.info(_("Creating packages:"))
for pkg in reversed(self.pkg.packages):
packager = packages.packager.BinaryPackager(self.pakfire, pkg, self.buildroot)
- packager.run([self.resultdir,])
+ packager.run(self.resultdir)
logging.info("")
def build_stage(self, stage):
# Execute the buildscript of this stage.
logging.info(_("Running stage %s:") % stage)
- self.do(buildscript, shell=False)
- # Remove the buildscript.
- if os.path.exists(buildscript):
- os.unlink(buildscript)
+ try:
+ self.do(buildscript, shell=False)
+
+ finally:
+ # Remove the buildscript.
+ if os.path.exists(buildscript):
+ os.unlink(buildscript)
def cleanup(self):
if os.path.exists(self.buildroot):
import pakfire.util as util
import pakfire.compress as compress
from pakfire.constants import *
+from pakfire.i18n import _
from base import Package
from lexer import FileLexer
self.addfile(tarinfo)
def extract(self, member, path=""):
+ target = os.path.join(path, member.name)
+
+ # Remove symlink targets, because tarfile cannot replace them.
+ if member.issym() and os.path.exists(target):
+ print "unlinking", target
+ os.unlink(target)
+
# Extract file the normal way...
- tarfile.TarFile.extract(self, member, path)
+ try:
+ tarfile.TarFile.extract(self, member, path)
+ except OSError, e:
+ logging.warning(_("Could not extract file: /%s - %s") \
+ % (member.name, e))
# ...and then apply the extended attributes.
if member.pax_headers:
- target = os.path.join(path, member.name)
-
for attr, val in member.pax_headers.items():
# Skip all attrs that are not supported (e.g. selinux).
if not attr in self.SUPPORTED_XATTRS:
# Recognize the type of the pattern. Patterns could be a glob
# pattern that is expanded here or just a directory which will
# be included recursively.
- if "*" in pattern or "?" in pattern:
- patterns += glob.glob(pattern)
+ if "*" in pattern or "?" in pattern or ("[" in pattern and "]" in pattern):
+ _patterns = glob.glob(pattern)
+ else:
+ _patterns = [pattern,]
+
+ for pattern in _patterns:
+ if not os.path.exists(pattern):
+ continue
- elif os.path.exists(pattern):
# Add directories recursively...
if os.path.isdir(pattern):
# Add directory itself.
def compress_datafile(self, datafile, algo="xz"):
pass
- def run(self, resultdirs=[]):
- assert resultdirs
-
+ def run(self, resultdir):
# Add all files to this package.
datafile = self.create_datafile()
tempfile = self.mktemp()
self.save(tempfile)
- for resultdir in resultdirs:
- # XXX sometimes, there has been a None in resultdirs
- if not resultdir:
- continue
+ # Add architecture information to path.
+ resultdir = "%s/%s" % (resultdir, self.pkg.arch)
- resultdir = "%s/%s" % (resultdir, self.pkg.arch)
-
- if not os.path.exists(resultdir):
- os.makedirs(resultdir)
-
- resultfile = os.path.join(resultdir, self.pkg.package_filename)
- logging.info("Saving package to %s" % resultfile)
- try:
- os.link(tempfile, resultfile)
- except OSError:
- shutil.copy2(tempfile, resultfile)
+ if not os.path.exists(resultdir):
+ os.makedirs(resultdir)
- ## Dump package information.
- #pkg = BinaryPackage(self.pakfire, self.pakfire.repos.dummy, tempfile)
- #for line in pkg.dump(long=True).splitlines():
- # logging.info(line)
- #logging.info("")
+ resultfile = os.path.join(resultdir, self.pkg.package_filename)
+ logging.info("Saving package to %s" % resultfile)
+ try:
+ os.link(tempfile, resultfile)
+ except OSError:
+ shutil.copy2(tempfile, resultfile)
class SourcePackager(Packager):
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2011-08-28 18:13+0200\n"
+"POT-Creation-Date: 2011-08-28 21:19+0200\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
msgstr ""
#: ../pakfire/base.py:199 ../pakfire/base.py:229 ../pakfire/base.py:275
-#: ../pakfire/base.py:315 ../pakfire/base.py:348
+#: ../pakfire/base.py:316 ../pakfire/base.py:349
msgid "Nothing to do"
msgstr ""
msgid "Extracting"
msgstr ""
-#: ../pakfire/builder.py:615
-msgid "Dumping created packages"
-msgstr ""
-
-#: ../pakfire/builder.py:637
+#: ../pakfire/builder.py:599
msgid "The build command failed. See logfile for details."
msgstr ""
#. Package the result.
#. Make all these little package from the build environment.
-#: ../pakfire/builder.py:779
+#: ../pakfire/builder.py:745
msgid "Creating packages:"
msgstr ""
#. Execute the buildscript of this stage.
-#: ../pakfire/builder.py:790
+#: ../pakfire/builder.py:756
#, python-format
msgid "Running stage %s:"
msgstr ""
msgid "Not set"
msgstr ""
-#: ../pakfire/packages/file.py:146
+#: ../pakfire/packages/file.py:106
+#, python-format
+msgid "Could not extract file: /%s - %s"
+msgstr ""
+
+#: ../pakfire/packages/file.py:156
#, python-format
msgid "Filename: %s"
msgstr ""
msgstr ""
#. Load progressbar.
-#: ../pakfire/packages/packager.py:306
+#: ../pakfire/packages/packager.py:309
msgid "Packaging"
msgstr ""
-#: ../pakfire/packages/packager.py:599
+#: ../pakfire/packages/packager.py:590
#, python-format
msgid "Building source package %s:"
msgstr ""