actions.py 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  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 shelltools
  7. from inary.actionsapi import autotools
  8. from inary.actionsapi import inarytools
  9. from inary.actionsapi import get
  10. WorkDir = "%s-%s" % (get.srcNAME(), get.srcVERSION())
  11. WITHSSP = False
  12. XTRA_FIXCFLAGS = "" if WITHSSP else "-fno-stack-protector"
  13. CFLAGS = "%s %s %s" % (get.CFLAGS(),
  14. "-fomit-frame-pointer -fno-exceptions -fno-asynchronous-unwind-tables -Os -g3 -Werror-implicit-function-declaration -Wno-unused -Wno-switch",
  15. XTRA_FIXCFLAGS)
  16. MAKE_FLAGS = "CC=\"%s\" \
  17. CFLAGS=\"%s\" \
  18. PDIET=/usr/lib/dietlibc \
  19. STRIP=:" % (get.CC(), CFLAGS)
  20. MAKE_TEST_FLAGS = "CC=\"%s\" \
  21. CFLAGS=\"%s -fno-builtin\" \
  22. PDIET=/usr/lib/dietlibc \
  23. STRIP=:" % (get.CC(), CFLAGS)
  24. def setup():
  25. shelltools.cd(get.workDIR())
  26. for f, l in [("dietlibc-github-c3f1cf67fcc186bb859e64a085bf98aaa6182a82.patch", 1)]:
  27. shelltools.move(f, WorkDir)
  28. shelltools.cd(WorkDir)
  29. shelltools.system("patch --remove-empty-files --no-backup-if-mismatch -p%d -i %s" % (l, f))
  30. shelltools.cd("..")
  31. shelltools.cd(WorkDir)
  32. inarytools.dosed("Makefile", "^prefix\?=.*", "prefix=/usr/lib/dietlibc")
  33. inarytools.dosed("Makefile", "^(BINDIR=)[^\/]+(.*)", r"\1/usr\2")
  34. inarytools.dosed("Makefile", "^(MAN1DIR=)[^\/]+(.*)", r"\1/usr/share\2")
  35. inarytools.dosed("dietfeatures.h", "#define (WANT_LARGEFILE_BACKCOMPAT|WANT_VALGRIND_SUPPORT)", deleteLine=True)
  36. if not WITHSSP:
  37. inarytools.dosed("dietfeatures.h", "^(#define WANT_SSP)$", r"// \1")
  38. inarytools.dosed("dietfeatures.h", ".*(#define WANT_STACKGAP).*", r"\1")
  39. def build():
  40. autotools.make("%s all" % MAKE_FLAGS)
  41. # Build tests
  42. # autotools.make("%s -C test all DIET=\"%s/bin-*/diet\" -k" % (MAKE_TEST_FLAGS, get.curDIR()))
  43. # autotools.make("%s -C test/inet all DIET=\"%s/bin-*/diet\"" % (MAKE_TEST_FLAGS, get.curDIR()))
  44. #def check():
  45. # shelltools.cd("test")
  46. # shelltools.chmod("runtests-X.sh", 0755)
  47. # shelltools.system("ulimit -m $[ 128*1024 ] -v $[ 256*1024 ] -d $[ 128*1024 ] -s 512")
  48. # shelltools.system("./runtests-X.sh")
  49. def install():
  50. autotools.rawInstall("DESTDIR=%s" % get.installDIR())
  51. # Simple wrapper for gcc
  52. host_gcc = "/usr/bin/%s-dietlibc-gcc" % get.HOST()
  53. shelltools.echo("%s%s" % (get.installDIR(), host_gcc), """\
  54. #!/bin/bash
  55. exec /usr/bin/diet %s "$@"
  56. """ % get.CC())
  57. shelltools.chmod("%s%s" % (get.installDIR(), host_gcc), 0o755)
  58. inarytools.dosym(host_gcc, "/usr/bin/dietlibc-gcc")
  59. inarytools.dodoc("AUTHOR", "BUGS", "CAVEAT", "CHANGES", "FAQ", "README*", "THANKS", "TODO")