actions.py 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  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 shelltools
  7. from pisi.actionsapi import autotools
  8. from pisi.actionsapi import pisitools
  9. from pisi.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. ("dietlibc-0.33-biarch.patch", 0)]:
  28. shelltools.move(f, WorkDir)
  29. shelltools.cd(WorkDir)
  30. shelltools.system("patch --remove-empty-files --no-backup-if-mismatch -p%d -i %s" % (l, f))
  31. shelltools.cd("..")
  32. shelltools.cd(WorkDir)
  33. pisitools.dosed("Makefile", "^prefix\?=.*", "prefix=/usr/lib/dietlibc")
  34. pisitools.dosed("Makefile", "^(BINDIR=)[^\/]+(.*)", r"\1/usr\2")
  35. pisitools.dosed("Makefile", "^(MAN1DIR=)[^\/]+(.*)", r"\1/usr/share\2")
  36. pisitools.dosed("dietfeatures.h", "#define (WANT_LARGEFILE_BACKCOMPAT|WANT_VALGRIND_SUPPORT)", deleteLine=True)
  37. if not WITHSSP:
  38. pisitools.dosed("dietfeatures.h", "^(#define WANT_SSP)$", r"// \1")
  39. pisitools.dosed("dietfeatures.h", ".*(#define WANT_STACKGAP).*", r"\1")
  40. def build():
  41. autotools.make("%s all" % MAKE_FLAGS)
  42. # Build tests
  43. # autotools.make("%s -C test all DIET=\"%s/bin-*/diet\" -k" % (MAKE_TEST_FLAGS, get.curDIR()))
  44. # autotools.make("%s -C test/inet all DIET=\"%s/bin-*/diet\"" % (MAKE_TEST_FLAGS, get.curDIR()))
  45. #def check():
  46. # shelltools.cd("test")
  47. # shelltools.chmod("runtests-X.sh", 0755)
  48. # shelltools.system("ulimit -m $[ 128*1024 ] -v $[ 256*1024 ] -d $[ 128*1024 ] -s 512")
  49. # shelltools.system("./runtests-X.sh")
  50. def install():
  51. autotools.rawInstall("DESTDIR=%s" % get.installDIR())
  52. # Simple wrapper for gcc
  53. host_gcc = "/usr/bin/%s-dietlibc-gcc" % get.HOST()
  54. shelltools.echo("%s%s" % (get.installDIR(), host_gcc), """\
  55. #!/bin/bash
  56. exec /usr/bin/diet %s "$@"
  57. """ % get.CC())
  58. shelltools.chmod("%s%s" % (get.installDIR(), host_gcc), 0755)
  59. pisitools.dosym(host_gcc, "/usr/bin/dietlibc-gcc")
  60. pisitools.dodoc("AUTHOR", "BUGS", "CAVEAT", "CHANGES", "FAQ", "README*", "THANKS", "TODO")