1#!/usr/bin/env python
2# Copyright 2017 Google Inc.
3#
4# Licensed under the Apache License, Version 2.0 (the "License");
5# you may not use this file except in compliance with the License.
6# You may obtain a copy of the License at
7#
8#      http://www.apache.org/licenses/LICENSE-2.0
9#
10# Unless required by applicable law or agreed to in writing, software
11# distributed under the License is distributed on an "AS IS" BASIS,
12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13# See the License for the specific language governing permissions and
14# limitations under the License.
15#
16################################################################################
17
18from __future__ import print_function
19import glob
20import os
21import subprocess
22
23import package
24import wrapper_utils
25
26
27class Package(package.Package):
28  """systemd package."""
29
30  def __init__(self, apt_version):
31    super(Package, self).__init__('systemd', apt_version)
32
33  def PreBuild(self, source_directory, env, custom_bin_dir):
34    # Hide msan symbols from nm. the systemd build system uses this to find
35    # undefined symbols and errors out if it does.
36    nm_wrapper = (
37        '#!/bin/bash\n'
38        '/usr/bin/nm "$@" | grep -E -v "U (__msan|memset)"\n'
39        'exit ${PIPESTATUS[0]}\n')
40
41    wrapper_utils.InstallWrapper(custom_bin_dir, 'nm', nm_wrapper,
42                                 [wrapper_utils.DpkgHostArchitecture() + '-nm'])
43