actions.py 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. #!/usr/bin/env python3
  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 inary.actionsapi import autotools
  7. from inary.actionsapi import inarytools
  8. from inary.actionsapi import shelltools
  9. from inary.actionsapi import kerneltools
  10. from inary.actionsapi import get
  11. import os
  12. WorkDir = "klibc-%s" % get.srcVERSION()
  13. NoStrip = "/"
  14. KDIR = kerneltools.getKernelVersion()
  15. klibcarch = "x86_64" if get.ARCH() == "x86_64" else "i386"
  16. docs = {"usr/klibc/arch/README.klibc.arch": "README.arch",
  17. "usr/dash/README.dash": "README.dash",
  18. "usr/dash/TOUR": "TOUR.dash",
  19. "usr/gzip/README": "README.gzip",
  20. "usr/gzip/COPYING": "COPYING.gzip",
  21. "usr/kinit/README": "README.kinit"}
  22. configh = """
  23. #ifndef _LINUX_CONFIG_H
  24. #define _LINUX_CONFIG_H
  25. #include <linux/autoconf.h>
  26. #endif
  27. """
  28. # shelltools.export("C_INCLUDE_PATH", "/usr/include")
  29. def fixperms(d):
  30. for root, dirs, files in os.walk(d):
  31. for name in dirs:
  32. shelltools.chmod(os.path.join(root, name), 0o755)
  33. for name in files:
  34. shelltools.chmod(os.path.join(root, name), 0o644)
  35. def setup():
  36. # we must include headers, but kernel headers chango too fast, maybe we should
  37. # go back to adding them as a patch
  38. # shelltools.sym("/lib/modules/%s/build" % KDIR, "linux")
  39. #~ shelltools.copytree("/lib/modules/%s/build" % KDIR, "linux")
  40. shelltools.makedirs("linux/include")
  41. shelltools.system("ln -s /usr/include/linux linux/include/")
  42. shelltools.system("ln -s /usr/include/asm linux/include/")
  43. shelltools.system("ln -s /usr/include/asm-generic linux/include/")
  44. # don't install kernel headers
  45. inarytools.dosed("scripts/Kbuild.install", ".*headers_install")
  46. # set the build directory
  47. #~ shelltools.echo("MCONFIG", "KRNLOBJ = /lib/modules/%s/build" % KDIR)
  48. #shelltools.sym("../linux-3.7","linux")
  49. # Workaround for prelink warnings
  50. shelltools.echo("70klibc", 'PRELINK_PATH_MASK="/usr/lib/klibc"')
  51. inarytools.dosed("Makefile", "/man", "/share/man")
  52. # shelltools.echo("linux/include/linux/config.h", configh)
  53. def build():
  54. shelltools.export("ARCH", "")
  55. autotools.make('EXTRA_KLIBCAFLAGS="-Wa,--noexecstack" \
  56. EXTRA_KLIBCLDFLAGS="-z,noexecstack" \
  57. HOSTCC="%s" CC="%s" \
  58. KLIBCARCH=%s \
  59. KLIBCASMARCH=x86 \
  60. libdir=/usr/lib \
  61. SHLIBDIR=/lib \
  62. mandir=/usr/share/man \
  63. INSTALLDIR=/usr/lib/klibc' % (get.CC(), get.CC(), klibcarch))
  64. def install():
  65. shelltools.export("ARCH", "")
  66. autotools.rawInstall('EXTRA_KLIBCAFLAGS="-Wa,--noexecstack" \
  67. EXTRA_KLIBCLDFLAGS="-z,noexecstack" \
  68. HOSTCC="%s" CC="%s" \
  69. KLIBCARCH=%s \
  70. KLIBCASMARCH=x86 \
  71. libdir=/usr/lib \
  72. SHLIBDIR=/lib \
  73. mandir=/usr/share/man \
  74. INSTALLROOT="%s" \
  75. INSTALLDIR=/usr/lib/klibc' % (get.CC(), get.CC(), klibcarch, get.installDIR()))
  76. asmSrcDir = "linux/arch/x86/include/asm"
  77. asmTargetDir = "/usr/lib/klibc/include/asm"
  78. # FIXME: we probably don't need old kernel workarounds anymore
  79. # just a workaround for installer bug with 2.6.24, will make it sane later
  80. #inarytools.remove(asmTargetDir)
  81. #inarytools.dosym("asm-x86", asmTargetDir)
  82. # yet another new kernel compatibility workaround for 2.6.28 and above
  83. #for f in shelltools.ls(asmSrcDir):
  84. # inarytools.insinto(asmTargetDir, "%s/%s" % (asmSrcDir, f))
  85. fixperms("%s/usr/lib/klibc/include" % get.installDIR())
  86. for f in ["gunzip", "zcat"]:
  87. inarytools.remove("/usr/lib/klibc/bin/%s" % f)
  88. inarytools.dosym("gzip", "/usr/lib/klibc/bin/%s" % f)
  89. inarytools.dodoc("README", "usr/klibc/LICENSE", "usr/klibc/CAVEATS")
  90. for f in docs:
  91. inarytools.newdoc(f, docs[f])
  92. inarytools.insinto("/usr/lib/klibc/include/linux", "linux/include/linux/*")
  93. inarytools.insinto("/usr/lib/klibc/include/asm", "linux/include/asm/*")
  94. inarytools.insinto("/usr/lib/klibc/include/asm-generic", "linux/include/asm-generic/*")