actions.py 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  1. #!/usr/bin/python
  2. # -*- coding: utf-8 -*-
  3. #
  4. # Licensed under the GNU General Public License, version 3.
  5. # See the file http://www.gnu.org/licenses/gpl.txt
  6. from pisi.actionsapi import autotools
  7. from pisi.actionsapi import pisitools
  8. from pisi.actionsapi import shelltools
  9. from pisi.actionsapi import get
  10. import os
  11. WorkDir = "glibc-%s" %get.srcVERSION()
  12. arch = "x86-64" if get.ARCH() == "x86_64" and not get.buildTYPE() == "emul32" else "i686"
  13. defaultflags = "-O3 -g -fasynchronous-unwind-tables -mtune=generic -march=%s" % arch
  14. if get.buildTYPE() == "emul32": defaultflags += " -m32"
  15. # this is getting ridiculous, also gdb3 breaks resulting binary
  16. #sysflags = "-mtune=generic -march=x86-64" if get.ARCH() == "x86_64" else "-mtune=generic -march=i686"
  17. ### helper functions ###
  18. def removePisiLinuxSection(_dir):
  19. for root, dirs, files in os.walk(_dir):
  20. for name in files:
  21. # FIXME: should we do this only on nonshared or all ?
  22. # if ("crt" in name and name.endswith(".o")) or name.endswith("nonshared.a"):
  23. if ("crt" in name and name.endswith(".o")) or name.endswith(".a"):
  24. i = os.path.join(root, name)
  25. shelltools.system('objcopy -R ".comment.PISILINUX.OPTs" -R ".note.gnu.build-id" %s' % i)
  26. ldconf32bit = """/lib32
  27. /usr/lib32
  28. """
  29. def setup():
  30. shelltools.export("LANGUAGE","C")
  31. shelltools.export("LANG","C")
  32. shelltools.export("LC_ALL","C")
  33. shelltools.export("CC", "gcc %s " % defaultflags)
  34. shelltools.export("CXX", "g++ %s " % defaultflags)
  35. shelltools.export("CFLAGS", defaultflags)
  36. shelltools.export("CXXFLAGS", defaultflags)
  37. shelltools.makedirs("build")
  38. shelltools.cd("build")
  39. options = "--prefix=/usr \
  40. --libdir=/usr/lib \
  41. --mandir=/usr/share/man \
  42. --infodir=/usr/share/info \
  43. --libexecdir=/usr/lib/misc \
  44. --with-bugurl=https://bugs.pisilinux.org \
  45. --enable-add-ons \
  46. --enable-kernel=3.2 \
  47. --enable-static-pie \
  48. --enable-bind-now --disable-profile \
  49. --enable-stackguard-randomization \
  50. --enable-lock-elision \
  51. --enable-multi-arch \
  52. --disable-werror"
  53. if get.buildTYPE() == "emul32":
  54. options += "\
  55. --libdir=/usr/lib32 \
  56. --enable-multi-arch i686-pc-linux-gnu \
  57. "
  58. shelltools.system("../configure %s" % options)
  59. def build():
  60. shelltools.cd("build")
  61. if get.buildTYPE() == "emul32":
  62. shelltools.echo("configparms","build-programs=no")
  63. shelltools.echo("configparms", "slibdir=/lib32")
  64. shelltools.echo("configparms", "rtlddir=/lib32")
  65. shelltools.echo("configparms", "bindir=/tmp32")
  66. shelltools.echo("configparms", "sbindir=/tmp32")
  67. shelltools.echo("configparms", "rootsbindir=/tmp32")
  68. shelltools.echo("configparms", "datarootdir=/tmp32/share")
  69. autotools.make()
  70. pisitools.dosed("configparms", "=no", "=yes")
  71. # shelltools.echo("configparms", "CC += -fstack-protector-strong -D_FORTIFY_SOURCE=2")
  72. # shelltools.echo("configparms", "CXX += -fstack-protector-strong -D_FORTIFY_SOURCE=2")
  73. else:
  74. shelltools.echo("configparms", "slibdir=/lib")
  75. shelltools.echo("configparms", "rtlddir=/lib")
  76. autotools.make()
  77. def check():
  78. shelltools.cd("build")
  79. if get.buildTYPE() != "emul32":
  80. autotools.make("check || true")
  81. else:
  82. pass
  83. def install():
  84. # maybe use system ldconfig executable?
  85. #pisitools.dosed("Makefile", "\$\(elf-objpfx\)ldconfig", "ldconfig")
  86. shelltools.cd("build")
  87. autotools.rawInstall("install_root=%s" % get.installDIR())
  88. pisitools.dodir("/etc/ld.so.conf.d")
  89. if get.buildTYPE() != "emul32":
  90. #Install locales once.
  91. autotools.rawInstall("install_root=%s localedata/install-locales" % get.installDIR())
  92. # Remove our options section from crt stuff
  93. #removePisiLinuxSection("%s/usr/lib/" % get.installDIR())
  94. if get.buildTYPE() == "emul32":
  95. pisitools.dosym("/lib32/ld-linux.so.2", "/lib/ld-linux.so.2")
  96. shelltools.echo("%s/etc/ld.so.conf.d/60-glibc-32bit.conf" % get.installDIR(), ldconf32bit)
  97. # Remove our options section from crt stuff
  98. #removePisiLinuxSection("%s/usr/lib32/" % get.installDIR())
  99. pisitools.removeDir("/tmp32")
  100. # We'll take care of the cache ourselves
  101. if shelltools.isFile("%s/etc/ld.so.cache" % get.installDIR()):
  102. pisitools.remove("/etc/ld.so.cache")
  103. # Prevent overwriting of the /etc/localtime symlink
  104. if shelltools.isFile("%s/etc/localtime" % get.installDIR()):
  105. pisitools.remove("/etc/localtime")
  106. # Nscd needs this to work
  107. pisitools.dodir("/var/run/nscd")
  108. pisitools.dodir("/var/db/nscd")
  109. # remove zoneinfo files since they are coming from timezone packages
  110. # we disable timezone build with a patch, keeping these lines for easier maintenance
  111. if shelltools.isDirectory("%s/usr/share/zoneinfo" % get.installDIR()):
  112. pisitools.removeDir("/usr/share/zoneinfo")
  113. #while bootstrapping whole system zic should not be removed. timezone package does not build without it. # 2013
  114. #for i in ["zdump","zic"]:
  115. #if shelltools.isFile("%s/usr/sbin/%s" % (get.installDIR(), i)):
  116. #pisitools.remove("/usr/sbin/%s" % i)
  117. shelltools.cd("..")
  118. pisitools.dodoc("NEWS", "README*", "LICENSES", "COPYING")