]> git.ipfire.org Git - people/stevee/pakfire.git/commitdiff
Fix building of source packages.
authorMichael Tremer <michael.tremer@ipfire.org>
Sat, 8 Oct 2011 15:40:18 +0000 (17:40 +0200)
committerMichael Tremer <michael.tremer@ipfire.org>
Sat, 8 Oct 2011 16:27:57 +0000 (18:27 +0200)
macros/build.macro
macros/constants.macro
python/pakfire/builder.py
python/pakfire/packages/make.py

index 98e0976952d3cfb4abeb21686ae9e890cd424a30..74f8f04679369c67d9be6b9f36d64d44f57c3f74 100644 (file)
@@ -68,7 +68,7 @@ build
        make_install_targets = install
 
        def _prepare
-               [ -d "%{DIR_SRC}" ] && cd %{DIR_SRC}
+               mkdir -p %{DIR_SRC} && cd %{DIR_SRC}
 
                %{prepare}
        end
index 7fc9a37a94e94024f130dad8b03fc370047ccc0d..5a2d93d807071cc5d897b65fe2f4aab0b415125e 100644 (file)
@@ -1,6 +1,5 @@
 
 BUILDROOT   = %{DIR_TMP}/buildroot_%{name}-%{thisver}
-BASEDIR     = /build
 
 DIR_APP     = %{DIR_SRC}/%{thisapp}
 DIR_DL      = %{BASEDIR}/files
index ceb1b290d9e59a072dbfccdd1f3c06ccd7b2e8b1..4ee298b2e57ecae82684ba4b2e5fcd1031335d99 100644 (file)
@@ -117,15 +117,27 @@ class BuildEnviron(object):
                self.distro = self.pakfire.distro
                self.path = self.pakfire.path
 
+               # Open package.
+               if pkg.endswith(MAKEFILE_EXTENSION):
+                       self.pkg = packages.Makefile(self.pakfire, pkg)
+               elif pkg.endswith(PACKAGE_EXTENSION):
+                       self.pkg = packages.SourcePackage(self.pakfire, None, pkg)
+               assert self.pkg, pkg
+
                # Log the package information.
-               self.pkg = packages.Makefile(self.pakfire, pkg)
                self.log.info(_("Package information:"))
                for line in self.pkg.dump(long=True).splitlines():
                        self.log.info("  %s" % line)
                self.log.info("")
 
+               # Path where we extract the package and put all the source files.
+               self.build_dir = os.path.join(self.path, "usr/src", self.pkg.friendly_name)
+
                # Download all package files.
-               self.pkg.download()
+               # In case of a SourcePackage, we don't need to do that because
+               # it includes everyting we need.
+               if isinstance(self.pkg, packages.Makefile):
+                       self.pkg.download()
 
                # XXX need to make this configureable
                self.settings = {
@@ -284,8 +296,7 @@ class BuildEnviron(object):
                self.install(requires)
 
                # Copy the makefile and load source tarballs.
-               self.pkg.extract(_("Extracting"),
-                       prefix=os.path.join(self.path, "build"))
+               self.pkg.extract(_("Extracting"), prefix=self.build_dir)
 
        def install(self, requires):
                """
@@ -383,10 +394,9 @@ class BuildEnviron(object):
                logging.debug("Cleaning environemnt.")
 
                # Remove the build directory and buildroot.
-               dirs = ("build", "result")
+               dirs = (self.build_dir, self.chrootPath("result"),)
 
                for d in dirs:
-                       d = self.chrootPath(d)
                        if not os.path.exists(d):
                                continue
 
@@ -533,7 +543,12 @@ class BuildEnviron(object):
        def build(self, install_test=True):
                assert self.pkg
 
-               pkgfile = os.path.join("/build", os.path.basename(self.pkg.filename))
+               # Search for the package file in build_dir and raise BuildError if it is not present.
+               pkgfile = os.path.join(self.build_dir, "%s.%s" % (self.pkg.name, MAKEFILE_EXTENSION))
+               if not os.path.exists(pkgfile):
+                       raise BuildError, _("Could not find makefile in build root: %s") % pkgfile
+               pkgfile = os.path.relpath(pkgfile, self.chrootPath())
+
                resultdir = self.chrootPath("/result")
 
                # Create the build command, that is executed in the chroot.
index b23e82854cf91f3ea548033ed19486c3dc48fd1f..57a4eb59f5e17b4c7f38a3dcd637379071e39b83 100644 (file)
@@ -52,6 +52,7 @@ class MakefileBase(Package):
                # Update environment.
                environ = self.pakfire.environ
                environ.update({
+                       "BASEDIR"          : os.path.dirname(self.filename),
                        "PARALLELISMFLAGS" : "-j%s" % util.calc_parallelism(),
                })