dist-readonly.sh 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. #! /bin/sh
  2. # Copyright (C) 2011-2017 Free Software Foundation, Inc.
  3. #
  4. # This program is free software; you can redistribute it and/or modify
  5. # it under the terms of the GNU General Public License as published by
  6. # the Free Software Foundation; either version 2, or (at your option)
  7. # any later version.
  8. #
  9. # This program is distributed in the hope that it will be useful,
  10. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. # GNU General Public License for more details.
  13. #
  14. # You should have received a copy of the GNU General Public License
  15. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  16. # Test that a readonly files are distributed as such, and not make
  17. # writable while being copied in the $(distdir).
  18. # This test expect the user to be unable to write on files lacking
  19. # write permissions -- so it won't work if the user is 'root'.
  20. required='non-root cc'
  21. . test-init.sh
  22. cat >> configure.ac << 'END'
  23. AC_PROG_CC
  24. AC_OUTPUT
  25. END
  26. cat > Makefile.am << 'END'
  27. bin_PROGRAMS = foo
  28. foo_SOURCES = foo.c
  29. EXTRA_DIST = bar.txt
  30. check-local: test
  31. .PHONY: test
  32. test:
  33. test -f $(srcdir)/foo.c && test ! -w $(srcdir)/foo.c
  34. if (echo x > $(srcdir)/foo.c); then exit 1; else :; fi
  35. grep 'main (void)' $(srcdir)/foo.c
  36. test -f $(srcdir)/bar.txt && test ! -w $(srcdir)/bar.txt
  37. if (echo x > $(srcdir)/bar.txt); then exit 1; else :; fi
  38. grep 'To be, or not to be' $(srcdir)/bar.txt
  39. END
  40. echo 'int main (void) { return 0; }' > foo.c
  41. echo To be, or not to be ... > bar.txt
  42. chmod a-w foo.c bar.txt
  43. $ACLOCAL
  44. $AUTOCONF
  45. $AUTOMAKE
  46. ./configure
  47. $MAKE distdir
  48. ls -l $distdir # For debugging.
  49. test -f foo.c && test ! -w foo.c || exit 1
  50. (echo x > foo.c) && exit 1
  51. test -f bar.txt && test ! -w bar.txt || exit 1
  52. (echo x > bar.txt) && exit 1
  53. $MAKE distcheck
  54. :