]>
git.ipfire.org Git - pakfire.git/blob - python/pakfire/builder.py
2 ###############################################################################
4 # Pakfire - The IPFire package management system #
5 # Copyright (C) 2011 Pakfire development team #
7 # This program is free software: you can redistribute it and/or modify #
8 # it under the terms of the GNU General Public License as published by #
9 # the Free Software Foundation, either version 3 of the License, or #
10 # (at your option) any later version. #
12 # This program is distributed in the hope that it will be useful, #
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of #
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
15 # GNU General Public License for more details. #
17 # You should have received a copy of the GNU General Public License #
18 # along with this program. If not, see <http://www.gnu.org/licenses/>. #
20 ###############################################################################
37 import packages
.packager
43 log
= logging
.getLogger("pakfire")
45 from config
import ConfigBuilder
46 from system
import system
47 from constants
import *
49 from errors
import BuildError
, BuildRootLocked
, Error
52 BUILD_LOG_HEADER
= """
54 | _ \ __ _| | __/ _(_)_ __ ___ | |__ _ _(_) | __| | ___ _ __
55 | |_) / _` | |/ / |_| | '__/ _ \ | '_ \| | | | | |/ _` |/ _ \ '__|
56 | __/ (_| | <| _| | | | __/ | |_) | |_| | | | (_| | __/ |
57 |_| \__,_|_|\_\_| |_|_| \___| |_.__/ \__,_|_|_|\__,_|\___|_|
60 Host : %(hostname)s (%(host_arch)s)
65 class BuildEnviron(object):
66 # The version of the kernel this machine is running.
67 kernel_version
= os
.uname()[2]
69 def __init__(self
, filename
=None, distro_name
=None, config
=None, configs
=None, arch
=None,
70 build_id
=None, logfile
=None, builder_mode
="release", use_cache
=None, **pakfire_args
):
72 assert builder_mode
in ("development", "release",)
73 self
.mode
= builder_mode
75 # Disable the build repository in release mode.
76 if self
.mode
== "release":
77 if pakfire_args
.has_key("disable_repos") and pakfire_args
["disable_repos"]:
78 pakfire_args
["disable_repos"] += ["build",]
80 pakfire_args
["disable_repos"] = ["build",]
82 # Save the build id and generate one if no build id was provided.
84 build_id
= "%s" % uuid
.uuid4()
86 self
.build_id
= build_id
90 self
.log
= log
.getChild(self
.build_id
)
91 # Propage everything to the root logger that we will see something
93 self
.log
.propagate
= 1
94 self
.log
.setLevel(logging
.INFO
)
96 # Add the given logfile to the logger.
97 h
= logging
.FileHandler(logfile
)
98 self
.log
.addHandler(h
)
100 # Format the log output for the file.
101 f
= logger
.BuildFormatter()
104 # If no logile was given, we use the root logger.
105 self
.log
= logging
.getLogger("pakfire")
107 # Log information about pakfire and some more information, when we
108 # are running in release mode.
109 if self
.mode
== "release":
111 "host_arch" : system
.arch
,
112 "hostname" : system
.hostname
,
113 "time" : time
.strftime("%a, %d %b %Y %H:%M:%S +0000", time
.gmtime()),
114 "version" : "Pakfire %s" % PAKFIRE_VERSION
,
117 for line
in BUILD_LOG_HEADER
.splitlines():
118 self
.log
.info(line
% logdata
)
120 # Create pakfire instance.
121 if pakfire_args
.has_key("mode"):
122 del pakfire_args
["mode"]
125 config
= ConfigBuilder(files
=configs
)
128 if distro_name
is None:
129 distro_name
= config
.get("builder", "distro", None)
130 config
.load_distro_config(distro_name
)
132 if not config
.has_distro():
133 log
.error(_("You have not set the distribution for which you want to build."))
134 log
.error(_("Please do so in builder.conf or on the CLI."))
135 raise ConfigError
, _("Distribution configuration is missing.")
137 self
.pakfire
= base
.Pakfire(
144 self
.distro
= self
.pakfire
.distro
145 self
.path
= self
.pakfire
.path
147 # Check if this host can build the requested architecture.
148 if not system
.host_supports_arch(self
.arch
):
149 raise BuildError
, _("Cannot build for %s on this host.") % self
.arch
151 # Where do we put the result?
152 self
.resultdir
= os
.path
.join(self
.path
, "result")
154 # Check weather to use or not use the cache.
155 if use_cache
is None:
156 # If use_cache is None, the user did not provide anything and
158 if self
.mode
== "development":
163 self
.use_cache
= use_cache
166 # If we have a plain makefile, we first build a source package and go with that.
168 if filename
.endswith(".%s" % MAKEFILE_EXTENSION
):
169 pkg
= packages
.Makefile(self
.pakfire
, filename
)
170 filename
= pkg
.dist(os
.path
.join(self
.resultdir
, "src"))
172 assert os
.path
.exists(filename
), filename
174 # Open source package.
175 self
.pkg
= packages
.SourcePackage(self
.pakfire
, None, filename
)
176 assert self
.pkg
, filename
178 # Log the package information.
179 self
.log
.info(_("Package information:"))
180 for line
in self
.pkg
.dump(long=True).splitlines():
181 self
.log
.info(" %s" % line
)
184 # Path where we extract the package and put all the source files.
185 self
.build_dir
= os
.path
.join(self
.path
, "usr/src/packages", self
.pkg
.friendly_name
)
190 # XXX need to make this configureable
192 "enable_loop_devices" : True,
193 "enable_ccache" : True,
194 "enable_icecream" : False,
196 #self.settings.update(settings)
202 # Save the build time.
203 self
.build_time
= int(time
.time())
206 # Mount the directories.
212 # Setup domain name resolution in chroot.
215 # Extract all needed packages.
219 # Kill all still running processes.
220 util
.orphans_kill(self
.path
)
222 # Close pakfire instance.
225 # Umount the build environment.
234 Inherit architecture from distribution configuration.
236 return self
.distro
.arch
241 "build_date" : time
.strftime("%a, %d %b %Y %H:%M:%S +0000", time
.gmtime(self
.build_time
)),
242 "build_host" : socket
.gethostname(),
243 "build_id" : self
.build_id
,
244 "build_time" : self
.build_time
,
248 filename
= os
.path
.join(self
.path
, ".lock")
251 self
._lock
= open(filename
, "a+")
256 fcntl
.lockf(self
._lock
.fileno(), fcntl
.LOCK_EX | fcntl
.LOCK_NB
)
258 raise BuildRootLocked
, "Buildroot is locked"
267 def copyin(self
, file_out
, file_in
):
268 if file_in
.startswith("/"):
269 file_in
= file_in
[1:]
271 file_in
= self
.chrootPath(file_in
)
273 #if not os.path.exists(file_out):
276 dir_in
= os
.path
.dirname(file_in
)
277 if not os
.path
.exists(dir_in
):
280 self
.log
.debug("%s --> %s" % (file_out
, file_in
))
282 shutil
.copy2(file_out
, file_in
)
284 def copyout(self
, file_in
, file_out
):
285 if file_in
.startswith("/"):
286 file_in
= file_in
[1:]
288 file_in
= self
.chrootPath(file_in
)
290 #if not os.path.exists(file_in):
293 dir_out
= os
.path
.dirname(file_out
)
294 if not os
.path
.exists(dir_out
):
297 self
.log
.debug("%s --> %s" % (file_in
, file_out
))
299 shutil
.copy2(file_in
, file_out
)
301 def copy_result(self
, resultdir
):
302 # XXX should use find_result_packages
304 dir_in
= self
.chrootPath("result")
306 for dir, subdirs
, files
in os
.walk(dir_in
):
307 basename
= os
.path
.basename(dir)
308 dir = dir[len(self
.chrootPath()):]
310 file_in
= os
.path
.join(dir, file)
312 file_out
= os
.path
.join(
318 self
.copyout(file_in
, file_out
)
320 def find_result_packages(self
):
323 for dir, subdirs
, files
in os
.walk(self
.resultdir
):
325 if not file.endswith(".%s" % PACKAGE_EXTENSION
):
328 file = os
.path
.join(dir, file)
333 def extract(self
, requires
=None, build_deps
=True):
335 Gets a dependency set and extracts all packages
341 if self
.use_cache
and os
.path
.exists(self
.cache_file
):
342 # If we are told to use the cache, we just import the
346 # Add neccessary build dependencies.
347 requires
+= BUILD_PACKAGES
349 # If we have ccache enabled, we need to extract it
350 # to the build chroot.
351 if self
.settings
.get("enable_ccache"):
352 requires
.append("ccache")
354 # If we have icecream enabled, we need to extract it
355 # to the build chroot.
356 if self
.settings
.get("enable_icecream"):
357 requires
.append("icecream")
359 # Get build dependencies from source package.
361 for req
in self
.pkg
.requires
:
364 # Install all packages.
365 self
.log
.info(_("Install packages needed for build..."))
366 self
.install(requires
)
368 # Copy the makefile and load source tarballs.
370 self
.pkg
.extract(_("Extracting"), prefix
=self
.build_dir
)
372 def install(self
, requires
):
374 Install everything that is required in requires.
376 # If we got nothing to do, we quit immediately.
381 self
.pakfire
.install(requires
, interactive
=False,
382 allow_downgrade
=True, logger
=self
.log
)
384 # Catch dependency errors and log it.
385 except DependencyError
, e
:
388 def install_test(self
):
390 self
.pakfire
.localinstall(self
.find_result_packages(), yes
=True, allow_uninstall
=True, logger
=self
.log
)
392 # Dependency errors when trying to install the result packages are build errors.
393 except DependencyError
, e
:
396 def chrootPath(self
, *args
):
397 # Remove all leading slashes
400 if arg
.startswith("/"):
405 ret
= os
.path
.join(self
.path
, *args
)
406 ret
= ret
.replace("//", "/")
408 assert ret
.startswith(self
.path
)
412 def populate_dev(self
):
426 # If we need loop devices (which are optional) we create them here.
427 if self
.settings
["enable_loop_devices"]:
428 for i
in range(0, 7):
429 nodes
.append("/dev/loop%d" % i
)
432 # Stat the original node of the host system and copy it to
434 node_stat
= os
.stat(node
)
436 self
._create
_node
(node
, node_stat
.st_mode
, node_stat
.st_rdev
)
438 os
.symlink("/proc/self/fd/0", self
.chrootPath("dev", "stdin"))
439 os
.symlink("/proc/self/fd/1", self
.chrootPath("dev", "stdout"))
440 os
.symlink("/proc/self/fd/2", self
.chrootPath("dev", "stderr"))
441 os
.symlink("/proc/self/fd", self
.chrootPath("dev", "fd"))
445 Add DNS resolution facility to chroot environment by copying
446 /etc/resolv.conf and /etc/hosts.
448 for i
in ("/etc/resolv.conf", "/etc/hosts"):
451 def _create_node(self
, filename
, mode
, device
):
452 self
.log
.debug("Create node: %s (%s)" % (filename
, mode
))
454 filename
= self
.chrootPath(filename
)
456 # Create parent directory if it is missing.
457 dirname
= os
.path
.dirname(filename
)
458 if not os
.path
.exists(dirname
):
461 os
.mknod(filename
, mode
, device
)
464 self
.log
.debug("Destroying environment %s" % self
.path
)
466 if os
.path
.exists(self
.path
):
470 self
.log
.debug("Cleaning environemnt.")
472 # Remove the build directory and buildroot.
473 dirs
= (self
.build_dir
, self
.chrootPath("result"),)
476 if not os
.path
.exists(d
):
483 self
.log
.debug("Mounting environment")
484 for src
, dest
, fs
, options
in self
.mountpoints
:
485 mountpoint
= self
.chrootPath(dest
)
487 options
= "-o %s" % options
489 # Eventually create mountpoint directory
490 if not os
.path
.exists(mountpoint
):
491 os
.makedirs(mountpoint
)
493 cmd
= "mount -n -t %s %s %s %s" % \
494 (fs
, options
, src
, mountpoint
)
495 chroot
.do(cmd
, shell
=True)
497 def _umountall(self
):
498 self
.log
.debug("Umounting environment")
501 for src
, dest
, fs
, options
in reversed(self
.mountpoints
):
502 if not dest
in mountpoints
:
503 mountpoints
.append(dest
)
505 for dest
in mountpoints
:
506 mountpoint
= self
.chrootPath(dest
)
508 chroot
.do("umount -n %s" % mountpoint
, raiseExc
=0, shell
=True)
511 def mountpoints(self
):
514 # Make root as a tmpfs.
516 # ("pakfire_root", "/", "tmpfs", "defaults"),
520 # src, dest, fs, options
521 ("pakfire_proc", "/proc", "proc", "nosuid,noexec,nodev"),
522 ("/proc/sys", "/proc/sys", "bind", "bind"),
523 ("/proc/sys", "/proc/sys", "bind", "bind,ro,remount"),
524 ("/sys", "/sys", "bind", "bind"),
525 ("/sys", "/sys", "bind", "bind,ro,remount"),
526 ("pakfire_tmpfs", "/dev", "tmpfs", "mode=755,nosuid"),
527 ("/dev/pts", "/dev/pts", "bind", "bind"),
528 ("pakfire_tmpfs", "/run", "tmpfs", "mode=755,nosuid,nodev"),
531 # If selinux is enabled.
532 if os
.path
.exists("/sys/fs/selinux"):
534 ("/sys/fs/selinux", "/sys/fs/selinux", "bind", "bind"),
535 ("/sys/fs/selinux", "/sys/fs/selinux", "bind", "bind,ro,remount"),
538 # If ccache support is requested, we bind mount the cache.
539 if self
.settings
.get("enable_ccache"):
540 # Create ccache cache directory if it does not exist.
541 if not os
.path
.exists(CCACHE_CACHE_DIR
):
542 os
.makedirs(CCACHE_CACHE_DIR
)
545 (CCACHE_CACHE_DIR
, "/var/cache/ccache", "bind", "bind"),
553 # Add HOME manually, because it is occasionally not set
554 # and some builds get in trouble then.
556 "TERM" : os
.environ
.get("TERM", "dumb"),
560 "LANG" : os
.environ
.setdefault("LANG", "en_US.UTF-8"),
562 # Set the container that we can detect, if we are inside a
564 "container" : "pakfire-builder",
567 # Inherit environment from distro
568 env
.update(self
.pakfire
.distro
.environ
)
570 # Icecream environment settings
571 if self
.settings
.get("enable_icecream", False):
572 # Set the toolchain path
573 if self
.settings
.get("icecream_toolchain", None):
574 env
["ICECC_VERSION"] = self
.settings
.get("icecream_toolchain")
576 # Set preferred host if configured.
577 if self
.settings
.get("icecream_preferred_host", None):
578 env
["ICECC_PREFERRED_HOST"] = \
579 self
.settings
.get("icecream_preferred_host")
581 # Fake UTS_MACHINE, when we cannot use the personality syscall and
582 # if the host architecture is not equal to the target architecture.
583 if not self
.pakfire
.distro
.personality
and \
584 not system
.native_arch
== self
.pakfire
.distro
.arch
:
586 "LD_PRELOAD" : "/usr/lib/libpakfire_preload.so",
587 "UTS_MACHINE" : self
.pakfire
.distro
.arch
,
593 def installed_packages(self
):
595 Returns an iterator over all installed packages in this build environment.
597 # Get the repository of all installed packages.
598 repo
= self
.pakfire
.repos
.get_repo("@system")
600 # Return an iterator over the packages.
603 def write_config(self
):
604 # Cleanup everything in /etc/pakfire.
605 util
.rm(self
.chrootPath(CONFIG_DIR
))
607 for i
in (CONFIG_DIR
, CONFIG_REPOS_DIR
):
608 i
= self
.chrootPath(i
)
609 if not os
.path
.exists(i
):
612 # Write general.conf.
613 f
= open(self
.chrootPath(CONFIG_DIR
, "general.conf"), "w")
616 # Write builder.conf.
617 f
= open(self
.chrootPath(CONFIG_DIR
, "builder.conf"), "w")
618 f
.write(self
.distro
.get_config())
621 # Create pakfire configuration files.
622 for repo
in self
.pakfire
.repos
:
623 conf
= repo
.get_config()
628 filename
= self
.chrootPath(CONFIG_REPOS_DIR
, "%s.repo" % repo
.name
)
629 f
= open(filename
, "w")
630 f
.write("\n".join(conf
))
633 def do(self
, command
, shell
=True, personality
=None, logger
=None, *args
, **kwargs
):
636 # Environment variables
639 if kwargs
.has_key("env"):
640 env
.update(kwargs
.pop("env"))
642 self
.log
.debug("Environment:")
643 for k
, v
in sorted(env
.items()):
644 self
.log
.debug(" %s=%s" % (k
, v
))
646 # Update personality it none was set
648 personality
= self
.distro
.personality
650 # Make every shell to a login shell because we set a lot of
651 # environment things there.
653 command
= ["bash", "--login", "-c", command
]
655 if not kwargs
.has_key("chrootPath"):
656 kwargs
["chrootPath"] = self
.chrootPath()
660 personality
=personality
,
670 def build(self
, install_test
=True):
672 raise BuildError
, _("You cannot run a build when no package was given.")
674 # Search for the package file in build_dir and raise BuildError if it is not present.
675 pkgfile
= os
.path
.join(self
.build_dir
, "%s.%s" % (self
.pkg
.name
, MAKEFILE_EXTENSION
))
676 if not os
.path
.exists(pkgfile
):
677 raise BuildError
, _("Could not find makefile in build root: %s") % pkgfile
678 pkgfile
= "/%s" % os
.path
.relpath(pkgfile
, self
.chrootPath())
680 # Write pakfire configuration into the chroot.
683 # Create the build command, that is executed in the chroot.
685 "/usr/lib/pakfire/builder",
691 "--resultdir=/result",
695 self
.do(" ".join(build_command
), logger
=self
.log
)
698 self
.log
.error(_("Build failed."), exc_info
=True)
700 raise BuildError
, _("The build command failed. See logfile for details.")
702 # Perform install test.
706 def shell(self
, args
=[]):
707 if not util
.cli_is_interactive():
708 self
.log
.warning("Cannot run shell on non-interactive console.")
711 # Install all packages that are needed to run a shell.
712 self
.install(SHELL_PACKAGES
)
714 # XXX need to set CFLAGS here
715 command
= "/usr/sbin/chroot %s %s %s" % \
716 (self
.chrootPath(), SHELL_SCRIPT
, " ".join(args
))
718 # Add personality if we require one
719 if self
.pakfire
.distro
.personality
:
720 command
= "%s %s" % (self
.pakfire
.distro
.personality
, command
)
722 for key
, val
in self
.environ
.items():
723 command
= "%s=\"%s\" " % (key
, val
) + command
725 # Empty the environment
726 command
= "env -i - %s" % command
728 self
.log
.debug("Shell command: %s" % command
)
730 shell
= os
.system(command
)
731 return os
.WEXITSTATUS(shell
)
734 def cache_file(self
):
736 self
.pakfire
.distro
.sname
, # name of the distribution
737 self
.pakfire
.distro
.release
, # release version
738 self
.pakfire
.distro
.arch
, # architecture
741 return os
.path
.join(CACHE_ENVIRON_DIR
, "%s.cache" %"-".join(comps
))
743 def cache_export(self
, filename
):
744 # Sync all disk caches.
747 # A list to store all mountpoints, so we don't package them.
750 # A list containing all files we want to package.
753 # Walk through the whole tree and collect all files
754 # that are on the same disk (not crossing mountpoints).
755 log
.info(_("Creating filelist..."))
756 root
= self
.chrootPath()
757 for dir, subdirs
, files
in os
.walk(root
):
758 # Search for mountpoints and skip them.
759 if not dir == root
and os
.path
.ismount(dir):
760 mountpoints
.append(dir)
763 # Skip all directories under mountpoints.
764 if any([dir.startswith(m
) for m
in mountpoints
]):
767 # Add all other files.
770 file = os
.path
.join(dir, file)
771 filelist
.append(file)
773 # Create a nice progressbar.
774 p
= util
.make_progress(_("Compressing files..."), len(filelist
))
777 # Create tar file and add all files to it.
778 f
= packages
.file.InnerTarFile
.open(filename
, "w:gz")
779 for file in filelist
:
784 f
.add(file, os
.path
.relpath(file, root
), recursive
=False)
787 # Finish progressbar.
791 filesize
= os
.path
.getsize(filename
)
793 log
.info(_("Cache file was successfully created at %s.") % filename
)
794 log
.info(_(" Containing %(files)s files, it has a size of %(size)s.") % \
795 { "files" : len(filelist
), "size" : util
.format_size(filesize
), })
797 def cache_extract(self
):
798 root
= self
.chrootPath()
799 filename
= self
.cache_file
801 f
= packages
.file.InnerTarFile
.open(filename
, "r:gz")
802 members
= f
.getmembers()
804 # Make a nice progress bar as always.
805 p
= util
.make_progress(_("Extracting files..."), len(members
))
807 # Extract all files from the cache.
809 for member
in members
:
814 f
.extract(member
, path
=root
)
817 # Finish progressbar.
821 # Re-read local repository.
822 self
.pakfire
.repos
.local
.update(force
=True)
824 # Update all packages.
825 self
.log
.info(_("Updating packages from cache..."))
826 self
.pakfire
.update(interactive
=False, logger
=self
.log
,
827 allow_archchange
=True, allow_vendorchange
=True, allow_downgrade
=True)
830 class Builder(object):
831 def __init__(self
, pakfire
, filename
, resultdir
, **kwargs
):
832 self
.pakfire
= pakfire
834 self
.filename
= filename
836 self
.resultdir
= resultdir
839 self
.pkg
= packages
.Makefile(self
.pakfire
, self
.filename
)
847 Create a temporary file in the build environment.
849 file = "/tmp/pakfire_%s" % util
.random_string()
859 return self
.pkg
.buildroot
863 return self
.pakfire
.distro
869 # Get all definitions from the package.
870 environ
.update(self
.pkg
.exports
)
872 # Overwrite some definitions by default values.
873 environ
.update(self
._environ
)
877 def do(self
, command
, shell
=True, personality
=None, cwd
=None, *args
, **kwargs
):
878 # Environment variables
879 log
.debug("Environment:")
880 for k
, v
in sorted(self
.environ
.items()):
881 log
.debug(" %s=%s" % (k
, v
))
883 # Update personality it none was set
885 personality
= self
.distro
.personality
888 cwd
= "/%s" % LOCAL_TMP_PATH
890 # Make every shell to a login shell because we set a lot of
891 # environment things there.
893 command
= ["bash", "--login", "-c", command
]
897 personality
=personality
,
900 logger
=logging
.getLogger("pakfire"),
906 def create_icecream_toolchain(self
):
908 out
= self
.do("icecc --build-native 2>/dev/null", returnOutput
=True, cwd
="/tmp")
912 for line
in out
.splitlines():
913 m
= re
.match(r
"^creating ([a-z0-9]+\.tar\.gz)", line
)
915 self
._environ
["ICECC_VERSION"] = "/tmp/%s" % m
.group(1)
917 def create_buildscript(self
, stage
):
918 file = "/tmp/build_%s" % util
.random_string()
920 # Get buildscript from the package.
921 script
= self
.pkg
.get_buildscript(stage
)
923 # Write script to an empty file.
925 f
.write("#!/bin/sh\n\n")
928 f
.write("\n%s\n" % script
)
936 # Create buildroot and remove all content if it was existant.
937 util
.rm(self
.buildroot
)
938 os
.makedirs(self
.buildroot
)
940 # Build icecream toolchain if icecream is installed.
941 self
.create_icecream_toolchain()
943 for stage
in ("prepare", "build", "test", "install"):
944 self
.build_stage(stage
)
946 # Run post-build stuff.
947 self
.post_compress_man_pages()
948 self
.post_remove_static_libs()
949 self
.post_extract_debuginfo()
951 # Package the result.
952 # Make all these little package from the build environment.
953 log
.info(_("Creating packages:"))
955 for pkg
in reversed(self
.pkg
.packages
):
956 packager
= packages
.packager
.BinaryPackager(self
.pakfire
, pkg
,
957 self
, self
.buildroot
)
958 pkg
= packager
.run(self
.resultdir
)
962 for pkg
in sorted(pkgs
):
963 for line
in pkg
.dump(long=True).splitlines():
968 def build_stage(self
, stage
):
969 # Get the buildscript for this stage.
970 buildscript
= self
.create_buildscript(stage
)
972 # Execute the buildscript of this stage.
973 log
.info(_("Running stage %s:") % stage
)
976 self
.do(buildscript
, shell
=False)
979 # Remove the buildscript.
980 if os
.path
.exists(buildscript
):
981 os
.unlink(buildscript
)
983 def post_remove_static_libs(self
):
984 keep_libs
= self
.pkg
.lexer
.build
.get_var("keep_libraries")
985 keep_libs
= keep_libs
.split()
988 self
.do("%s/remove-static-libs %s %s" % \
989 (SCRIPT_DIR
, self
.buildroot
, " ".join(keep_libs
)))
991 log
.warning(_("Could not remove static libraries: %s") % e
)
993 def post_compress_man_pages(self
):
995 self
.do("%s/compress-man-pages %s" % (SCRIPT_DIR
, self
.buildroot
))
997 log
.warning(_("Compressing man pages did not complete successfully."))
999 def post_extract_debuginfo(self
):
1002 # Check if we need to run with strict build-id.
1003 strict_id
= self
.pkg
.lexer
.build
.get_var("debuginfo_strict_build_id", "true")
1004 if strict_id
in ("true", "yes", "1"):
1005 args
.append("--strict-build-id")
1007 args
.append("--buildroot=%s" % self
.pkg
.buildroot
)
1008 args
.append("--sourcedir=%s" % self
.pkg
.sourcedir
)
1010 # Get additional options to pass to script.
1011 options
= self
.pkg
.lexer
.build
.get_var("debuginfo_options", "")
1012 args
+= options
.split()
1015 self
.do("%s/extract-debuginfo %s %s" % (SCRIPT_DIR
, " ".join(args
), self
.pkg
.buildroot
))
1017 log
.error(_("Extracting debuginfo did not complete with success. Aborting build."))
1021 if os
.path
.exists(self
.buildroot
):
1022 util
.rm(self
.buildroot
)