From b5697ce98eea406dd765ef042143138616889ff9 Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Wed, 16 Nov 2011 14:30:39 +0000 Subject: [PATCH 001/482] Add .gitignore --- .gitignore | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..c8c85c9 --- /dev/null +++ b/.gitignore @@ -0,0 +1,6 @@ +stow +chkstow +Makefile +config.log +config.status +t/target/ From 9f8a6c2be3b89e694b8a615ff261c3253938c4f1 Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Thu, 24 Nov 2011 16:55:43 +0000 Subject: [PATCH 002/482] Remove auto-generated files from git. --- .gitignore | 5 + Makefile.in | 887 -------------- configure | 3297 -------------------------------------------------- stamp-vti | 4 - stow.info | 1335 -------------------- version.texi | 4 - 6 files changed, 5 insertions(+), 5527 deletions(-) delete mode 100644 Makefile.in delete mode 100755 configure delete mode 100644 stamp-vti delete mode 100644 stow.info delete mode 100644 version.texi diff --git a/.gitignore b/.gitignore index c8c85c9..cee7979 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,11 @@ stow chkstow Makefile +Makefile.in config.log config.status +configure +stamp-vti +stow.info t/target/ +version.texi diff --git a/Makefile.in b/Makefile.in deleted file mode 100644 index 36ccce6..0000000 --- a/Makefile.in +++ /dev/null @@ -1,887 +0,0 @@ -# Makefile.in generated by automake 1.10 from Makefile.am. -# @configure_input@ - -# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, -# 2003, 2004, 2005, 2006 Free Software Foundation, Inc. -# This Makefile.in is free software; the Free Software Foundation -# gives unlimited permission to copy and/or distribute it, -# with or without modifications, as long as this notice is preserved. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY, to the extent permitted by law; without -# even the implied warranty of MERCHANTABILITY or FITNESS FOR A -# PARTICULAR PURPOSE. - -@SET_MAKE@ - - -VPATH = @srcdir@ -pkgdatadir = $(datadir)/@PACKAGE@ -pkglibdir = $(libdir)/@PACKAGE@ -pkgincludedir = $(includedir)/@PACKAGE@ -am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd -install_sh_DATA = $(install_sh) -c -m 644 -install_sh_PROGRAM = $(install_sh) -c -install_sh_SCRIPT = $(install_sh) -c -INSTALL_HEADER = $(INSTALL_DATA) -transform = $(program_transform_name) -NORMAL_INSTALL = : -PRE_INSTALL = : -POST_INSTALL = : -NORMAL_UNINSTALL = : -PRE_UNINSTALL = : -POST_UNINSTALL = : -subdir = . -DIST_COMMON = README $(am__configure_deps) $(dist_doc_DATA) \ - $(dist_man_MANS) $(srcdir)/Makefile.am $(srcdir)/Makefile.in \ - $(srcdir)/stamp-vti $(srcdir)/version.texi \ - $(top_srcdir)/configure AUTHORS COPYING ChangeLog INSTALL NEWS \ - THANKS TODO install-sh mdate-sh missing texinfo.tex -ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 -am__aclocal_m4_deps = $(top_srcdir)/configure.ac -am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ - $(ACLOCAL_M4) -am__CONFIG_DISTCLEAN_FILES = config.status config.cache config.log \ - configure.lineno config.status.lineno -mkinstalldirs = $(install_sh) -d -CONFIG_CLEAN_FILES = -am__installdirs = "$(DESTDIR)$(bindir)" "$(DESTDIR)$(infodir)" \ - "$(DESTDIR)$(man8dir)" "$(DESTDIR)$(docdir)" -binSCRIPT_INSTALL = $(INSTALL_SCRIPT) -SCRIPTS = $(bin_SCRIPTS) -SOURCES = -DIST_SOURCES = -INFO_DEPS = $(srcdir)/stow.info -am__TEXINFO_TEX_DIR = $(srcdir) -DVIS = stow.dvi -PDFS = stow.pdf -PSS = stow.ps -HTMLS = stow.html -TEXINFOS = stow.texi -TEXI2DVI = texi2dvi -TEXI2PDF = $(TEXI2DVI) --pdf --batch -MAKEINFOHTML = $(MAKEINFO) --html -AM_MAKEINFOHTMLFLAGS = $(AM_MAKEINFOFLAGS) -DVIPS = dvips -am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; -am__vpath_adj = case $$p in \ - $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ - *) f=$$p;; \ - esac; -am__strip_dir = `echo $$p | sed -e 's|^.*/||'`; -man8dir = $(mandir)/man8 -NROFF = nroff -MANS = $(dist_man_MANS) $(man8_MANS) -dist_docDATA_INSTALL = $(INSTALL_DATA) -DATA = $(dist_doc_DATA) -DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) -distdir = $(PACKAGE)-$(VERSION) -top_distdir = $(distdir) -am__remove_distdir = \ - { test ! -d $(distdir) \ - || { find $(distdir) -type d ! -perm -200 -exec chmod u+w {} ';' \ - && rm -fr $(distdir); }; } -DIST_ARCHIVES = $(distdir).tar.gz $(distdir).shar.gz -GZIP_ENV = --best -distuninstallcheck_listfiles = find . -type f -print -distcleancheck_listfiles = find . -type f -print -ACLOCAL = @ACLOCAL@ -AMTAR = @AMTAR@ -AUTOCONF = @AUTOCONF@ -AUTOHEADER = @AUTOHEADER@ -AUTOMAKE = @AUTOMAKE@ -AWK = @AWK@ -CYGPATH_W = @CYGPATH_W@ -DEFS = @DEFS@ -ECHO_C = @ECHO_C@ -ECHO_N = @ECHO_N@ -ECHO_T = @ECHO_T@ -INSTALL = @INSTALL@ -INSTALL_DATA = @INSTALL_DATA@ -INSTALL_PROGRAM = @INSTALL_PROGRAM@ -INSTALL_SCRIPT = @INSTALL_SCRIPT@ -INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ -LIBOBJS = @LIBOBJS@ -LIBS = @LIBS@ -LTLIBOBJS = @LTLIBOBJS@ -MAKEINFO = @MAKEINFO@ -MKDIR_P = @MKDIR_P@ -PACKAGE = @PACKAGE@ -PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ -PACKAGE_NAME = @PACKAGE_NAME@ -PACKAGE_STRING = @PACKAGE_STRING@ -PACKAGE_TARNAME = @PACKAGE_TARNAME@ -PACKAGE_VERSION = @PACKAGE_VERSION@ -PATH_SEPARATOR = @PATH_SEPARATOR@ -PERL = @PERL@ -SET_MAKE = @SET_MAKE@ -SHELL = @SHELL@ -STRIP = @STRIP@ -VERSION = @VERSION@ -abs_builddir = @abs_builddir@ -abs_srcdir = @abs_srcdir@ -abs_top_builddir = @abs_top_builddir@ -abs_top_srcdir = @abs_top_srcdir@ -am__leading_dot = @am__leading_dot@ -am__tar = @am__tar@ -am__untar = @am__untar@ -bindir = @bindir@ -build_alias = @build_alias@ -builddir = @builddir@ -datadir = @datadir@ -datarootdir = @datarootdir@ -docdir = @docdir@ -dvidir = @dvidir@ -exec_prefix = @exec_prefix@ -host_alias = @host_alias@ -htmldir = @htmldir@ -includedir = @includedir@ -infodir = @infodir@ -install_sh = @install_sh@ -libdir = @libdir@ -libexecdir = @libexecdir@ -localedir = @localedir@ -localstatedir = @localstatedir@ -mandir = @mandir@ -mkdir_p = @mkdir_p@ -oldincludedir = @oldincludedir@ -pdfdir = @pdfdir@ -prefix = @prefix@ -program_transform_name = @program_transform_name@ -psdir = @psdir@ -sbindir = @sbindir@ -sharedstatedir = @sharedstatedir@ -srcdir = @srcdir@ -sysconfdir = @sysconfdir@ -target_alias = @target_alias@ -top_builddir = @top_builddir@ -top_srcdir = @top_srcdir@ -bin_SCRIPTS = stow chkstow -info_TEXINFOS = stow.texi -man8_MANS = stow.8 -dist_man_MANS = stow.8 -dist_doc_DATA = README -TESTS_ENVIRONMENT = $(PERL) -I $(top_srcdir) -TESTS = \ - t/cleanup_invalid_links.t \ - t/defer.t \ - t/examples.t \ - t/find_stowed_path.t \ - t/foldable.t \ - t/join_paths.t \ - t/parent.t \ - t/relative_path.t \ - t/stow_contents.t \ - t/stow.t \ - t/unstow_contents_orig.t \ - t/unstow_contents.t \ - t/chkstow.t - -AUTOMAKE_OPTIONS = dist-shar -EXTRA_DIST = $(TESTS) t/util.pm stow.in -CLEANFILES = $(bin_SCRIPTS) - -# this is more explicit and reliable than the config file trick -edit = sed -e 's|[@]PERL[@]|$(PERL)|g' \ - -e 's|[@]PACKAGE[@]|$(PACKAGE)|g' \ - -e 's|[@]VERSION[@]|$(VERSION)|g' - -all: all-am - -.SUFFIXES: -.SUFFIXES: .dvi .html .info .pdf .ps .texi -am--refresh: - @: -$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) - @for dep in $?; do \ - case '$(am__configure_deps)' in \ - *$$dep*) \ - echo ' cd $(srcdir) && $(AUTOMAKE) --gnu '; \ - cd $(srcdir) && $(AUTOMAKE) --gnu \ - && exit 0; \ - exit 1;; \ - esac; \ - done; \ - echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu Makefile'; \ - cd $(top_srcdir) && \ - $(AUTOMAKE) --gnu Makefile -.PRECIOUS: Makefile -Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status - @case '$?' in \ - *config.status*) \ - echo ' $(SHELL) ./config.status'; \ - $(SHELL) ./config.status;; \ - *) \ - echo ' cd $(top_builddir) && $(SHELL) ./config.status $@ $(am__depfiles_maybe)'; \ - cd $(top_builddir) && $(SHELL) ./config.status $@ $(am__depfiles_maybe);; \ - esac; - -$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) - $(SHELL) ./config.status --recheck - -$(top_srcdir)/configure: $(am__configure_deps) - cd $(srcdir) && $(AUTOCONF) -$(ACLOCAL_M4): $(am__aclocal_m4_deps) - cd $(srcdir) && $(ACLOCAL) $(ACLOCAL_AMFLAGS) -install-binSCRIPTS: $(bin_SCRIPTS) - @$(NORMAL_INSTALL) - test -z "$(bindir)" || $(MKDIR_P) "$(DESTDIR)$(bindir)" - @list='$(bin_SCRIPTS)'; for p in $$list; do \ - if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \ - if test -f $$d$$p; then \ - f=`echo "$$p" | sed 's|^.*/||;$(transform)'`; \ - echo " $(binSCRIPT_INSTALL) '$$d$$p' '$(DESTDIR)$(bindir)/$$f'"; \ - $(binSCRIPT_INSTALL) "$$d$$p" "$(DESTDIR)$(bindir)/$$f"; \ - else :; fi; \ - done - -uninstall-binSCRIPTS: - @$(NORMAL_UNINSTALL) - @list='$(bin_SCRIPTS)'; for p in $$list; do \ - f=`echo "$$p" | sed 's|^.*/||;$(transform)'`; \ - echo " rm -f '$(DESTDIR)$(bindir)/$$f'"; \ - rm -f "$(DESTDIR)$(bindir)/$$f"; \ - done - -.texi.info: - restore=: && backupdir="$(am__leading_dot)am$$$$" && \ - am__cwd=`pwd` && cd $(srcdir) && \ - rm -rf $$backupdir && mkdir $$backupdir && \ - if ($(MAKEINFO) --version) >/dev/null 2>&1; then \ - for f in $@ $@-[0-9] $@-[0-9][0-9] $(@:.info=).i[0-9] $(@:.info=).i[0-9][0-9]; do \ - if test -f $$f; then mv $$f $$backupdir; restore=mv; else :; fi; \ - done; \ - else :; fi && \ - cd "$$am__cwd"; \ - if $(MAKEINFO) $(AM_MAKEINFOFLAGS) $(MAKEINFOFLAGS) -I $(srcdir) \ - -o $@ $<; \ - then \ - rc=0; \ - cd $(srcdir); \ - else \ - rc=$$?; \ - cd $(srcdir) && \ - $$restore $$backupdir/* `echo "./$@" | sed 's|[^/]*$$||'`; \ - fi; \ - rm -rf $$backupdir; exit $$rc - -.texi.dvi: - TEXINPUTS="$(am__TEXINFO_TEX_DIR)$(PATH_SEPARATOR)$$TEXINPUTS" \ - MAKEINFO='$(MAKEINFO) $(AM_MAKEINFOFLAGS) $(MAKEINFOFLAGS) -I $(srcdir)' \ - $(TEXI2DVI) $< - -.texi.pdf: - TEXINPUTS="$(am__TEXINFO_TEX_DIR)$(PATH_SEPARATOR)$$TEXINPUTS" \ - MAKEINFO='$(MAKEINFO) $(AM_MAKEINFOFLAGS) $(MAKEINFOFLAGS) -I $(srcdir)' \ - $(TEXI2PDF) $< - -.texi.html: - rm -rf $(@:.html=.htp) - if $(MAKEINFOHTML) $(AM_MAKEINFOHTMLFLAGS) $(MAKEINFOFLAGS) -I $(srcdir) \ - -o $(@:.html=.htp) $<; \ - then \ - rm -rf $@; \ - if test ! -d $(@:.html=.htp) && test -d $(@:.html=); then \ - mv $(@:.html=) $@; else mv $(@:.html=.htp) $@; fi; \ - else \ - if test ! -d $(@:.html=.htp) && test -d $(@:.html=); then \ - rm -rf $(@:.html=); else rm -Rf $(@:.html=.htp) $@; fi; \ - exit 1; \ - fi -$(srcdir)/stow.info: stow.texi $(srcdir)/version.texi -stow.dvi: stow.texi $(srcdir)/version.texi -stow.pdf: stow.texi $(srcdir)/version.texi -stow.html: stow.texi $(srcdir)/version.texi -$(srcdir)/version.texi: $(srcdir)/stamp-vti -$(srcdir)/stamp-vti: stow.texi $(top_srcdir)/configure - @(dir=.; test -f ./stow.texi || dir=$(srcdir); \ - set `$(SHELL) $(srcdir)/mdate-sh $$dir/stow.texi`; \ - echo "@set UPDATED $$1 $$2 $$3"; \ - echo "@set UPDATED-MONTH $$2 $$3"; \ - echo "@set EDITION $(VERSION)"; \ - echo "@set VERSION $(VERSION)") > vti.tmp - @cmp -s vti.tmp $(srcdir)/version.texi \ - || (echo "Updating $(srcdir)/version.texi"; \ - cp vti.tmp $(srcdir)/version.texi) - -@rm -f vti.tmp - @cp $(srcdir)/version.texi $@ - -mostlyclean-vti: - -rm -f vti.tmp - -maintainer-clean-vti: - -rm -f $(srcdir)/stamp-vti $(srcdir)/version.texi -.dvi.ps: - TEXINPUTS="$(am__TEXINFO_TEX_DIR)$(PATH_SEPARATOR)$$TEXINPUTS" \ - $(DVIPS) -o $@ $< - -uninstall-dvi-am: - @$(NORMAL_UNINSTALL) - @list='$(DVIS)'; for p in $$list; do \ - f=$(am__strip_dir) \ - echo " rm -f '$(DESTDIR)$(dvidir)/$$f'"; \ - rm -f "$(DESTDIR)$(dvidir)/$$f"; \ - done - -uninstall-html-am: - @$(NORMAL_UNINSTALL) - @list='$(HTMLS)'; for p in $$list; do \ - f=$(am__strip_dir) \ - echo " rm -rf '$(DESTDIR)$(htmldir)/$$f'"; \ - rm -rf "$(DESTDIR)$(htmldir)/$$f"; \ - done - -uninstall-info-am: - @$(PRE_UNINSTALL) - @if test -d '$(DESTDIR)$(infodir)' && \ - (install-info --version && \ - install-info --version 2>&1 | sed 1q | grep -i -v debian) >/dev/null 2>&1; then \ - list='$(INFO_DEPS)'; \ - for file in $$list; do \ - relfile=`echo "$$file" | sed 's|^.*/||'`; \ - echo " install-info --info-dir='$(DESTDIR)$(infodir)' --remove '$(DESTDIR)$(infodir)/$$relfile'"; \ - install-info --info-dir="$(DESTDIR)$(infodir)" --remove "$(DESTDIR)$(infodir)/$$relfile"; \ - done; \ - else :; fi - @$(NORMAL_UNINSTALL) - @list='$(INFO_DEPS)'; \ - for file in $$list; do \ - relfile=`echo "$$file" | sed 's|^.*/||'`; \ - relfile_i=`echo "$$relfile" | sed 's|\.info$$||;s|$$|.i|'`; \ - (if test -d "$(DESTDIR)$(infodir)" && cd "$(DESTDIR)$(infodir)"; then \ - echo " cd '$(DESTDIR)$(infodir)' && rm -f $$relfile $$relfile-[0-9] $$relfile-[0-9][0-9] $$relfile_i[0-9] $$relfile_i[0-9][0-9]"; \ - rm -f $$relfile $$relfile-[0-9] $$relfile-[0-9][0-9] $$relfile_i[0-9] $$relfile_i[0-9][0-9]; \ - else :; fi); \ - done - -uninstall-pdf-am: - @$(NORMAL_UNINSTALL) - @list='$(PDFS)'; for p in $$list; do \ - f=$(am__strip_dir) \ - echo " rm -f '$(DESTDIR)$(pdfdir)/$$f'"; \ - rm -f "$(DESTDIR)$(pdfdir)/$$f"; \ - done - -uninstall-ps-am: - @$(NORMAL_UNINSTALL) - @list='$(PSS)'; for p in $$list; do \ - f=$(am__strip_dir) \ - echo " rm -f '$(DESTDIR)$(psdir)/$$f'"; \ - rm -f "$(DESTDIR)$(psdir)/$$f"; \ - done - -dist-info: $(INFO_DEPS) - @srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; \ - list='$(INFO_DEPS)'; \ - for base in $$list; do \ - case $$base in \ - $(srcdir)/*) base=`echo "$$base" | sed "s|^$$srcdirstrip/||"`;; \ - esac; \ - if test -f $$base; then d=.; else d=$(srcdir); fi; \ - base_i=`echo "$$base" | sed 's|\.info$$||;s|$$|.i|'`; \ - for file in $$d/$$base $$d/$$base-[0-9] $$d/$$base-[0-9][0-9] $$d/$$base_i[0-9] $$d/$$base_i[0-9][0-9]; do \ - if test -f $$file; then \ - relfile=`expr "$$file" : "$$d/\(.*\)"`; \ - test -f $(distdir)/$$relfile || \ - cp -p $$file $(distdir)/$$relfile; \ - else :; fi; \ - done; \ - done - -mostlyclean-aminfo: - -rm -rf stow.aux stow.cp stow.cps stow.fn stow.fns stow.ky stow.kys stow.log \ - stow.pg stow.pgs stow.tmp stow.toc stow.tp stow.tps stow.vr \ - stow.vrs stow.dvi stow.pdf stow.ps stow.html - -maintainer-clean-aminfo: - @list='$(INFO_DEPS)'; for i in $$list; do \ - i_i=`echo "$$i" | sed 's|\.info$$||;s|$$|.i|'`; \ - echo " rm -f $$i $$i-[0-9] $$i-[0-9][0-9] $$i_i[0-9] $$i_i[0-9][0-9]"; \ - rm -f $$i $$i-[0-9] $$i-[0-9][0-9] $$i_i[0-9] $$i_i[0-9][0-9]; \ - done -install-man8: $(man8_MANS) $(man_MANS) - @$(NORMAL_INSTALL) - test -z "$(man8dir)" || $(MKDIR_P) "$(DESTDIR)$(man8dir)" - @list='$(man8_MANS) $(dist_man8_MANS) $(nodist_man8_MANS)'; \ - l2='$(man_MANS) $(dist_man_MANS) $(nodist_man_MANS)'; \ - for i in $$l2; do \ - case "$$i" in \ - *.8*) list="$$list $$i" ;; \ - esac; \ - done; \ - for i in $$list; do \ - if test -f $(srcdir)/$$i; then file=$(srcdir)/$$i; \ - else file=$$i; fi; \ - ext=`echo $$i | sed -e 's/^.*\\.//'`; \ - case "$$ext" in \ - 8*) ;; \ - *) ext='8' ;; \ - esac; \ - inst=`echo $$i | sed -e 's/\\.[0-9a-z]*$$//'`; \ - inst=`echo $$inst | sed -e 's/^.*\///'`; \ - inst=`echo $$inst | sed '$(transform)'`.$$ext; \ - echo " $(INSTALL_DATA) '$$file' '$(DESTDIR)$(man8dir)/$$inst'"; \ - $(INSTALL_DATA) "$$file" "$(DESTDIR)$(man8dir)/$$inst"; \ - done -uninstall-man8: - @$(NORMAL_UNINSTALL) - @list='$(man8_MANS) $(dist_man8_MANS) $(nodist_man8_MANS)'; \ - l2='$(man_MANS) $(dist_man_MANS) $(nodist_man_MANS)'; \ - for i in $$l2; do \ - case "$$i" in \ - *.8*) list="$$list $$i" ;; \ - esac; \ - done; \ - for i in $$list; do \ - ext=`echo $$i | sed -e 's/^.*\\.//'`; \ - case "$$ext" in \ - 8*) ;; \ - *) ext='8' ;; \ - esac; \ - inst=`echo $$i | sed -e 's/\\.[0-9a-z]*$$//'`; \ - inst=`echo $$inst | sed -e 's/^.*\///'`; \ - inst=`echo $$inst | sed '$(transform)'`.$$ext; \ - echo " rm -f '$(DESTDIR)$(man8dir)/$$inst'"; \ - rm -f "$(DESTDIR)$(man8dir)/$$inst"; \ - done -install-dist_docDATA: $(dist_doc_DATA) - @$(NORMAL_INSTALL) - test -z "$(docdir)" || $(MKDIR_P) "$(DESTDIR)$(docdir)" - @list='$(dist_doc_DATA)'; for p in $$list; do \ - if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \ - f=$(am__strip_dir) \ - echo " $(dist_docDATA_INSTALL) '$$d$$p' '$(DESTDIR)$(docdir)/$$f'"; \ - $(dist_docDATA_INSTALL) "$$d$$p" "$(DESTDIR)$(docdir)/$$f"; \ - done - -uninstall-dist_docDATA: - @$(NORMAL_UNINSTALL) - @list='$(dist_doc_DATA)'; for p in $$list; do \ - f=$(am__strip_dir) \ - echo " rm -f '$(DESTDIR)$(docdir)/$$f'"; \ - rm -f "$(DESTDIR)$(docdir)/$$f"; \ - done -tags: TAGS -TAGS: - -ctags: CTAGS -CTAGS: - - -check-TESTS: $(TESTS) - @failed=0; all=0; xfail=0; xpass=0; skip=0; ws='[ ]'; \ - srcdir=$(srcdir); export srcdir; \ - list=' $(TESTS) '; \ - if test -n "$$list"; then \ - for tst in $$list; do \ - if test -f ./$$tst; then dir=./; \ - elif test -f $$tst; then dir=; \ - else dir="$(srcdir)/"; fi; \ - if $(TESTS_ENVIRONMENT) $${dir}$$tst; then \ - all=`expr $$all + 1`; \ - case " $(XFAIL_TESTS) " in \ - *$$ws$$tst$$ws*) \ - xpass=`expr $$xpass + 1`; \ - failed=`expr $$failed + 1`; \ - echo "XPASS: $$tst"; \ - ;; \ - *) \ - echo "PASS: $$tst"; \ - ;; \ - esac; \ - elif test $$? -ne 77; then \ - all=`expr $$all + 1`; \ - case " $(XFAIL_TESTS) " in \ - *$$ws$$tst$$ws*) \ - xfail=`expr $$xfail + 1`; \ - echo "XFAIL: $$tst"; \ - ;; \ - *) \ - failed=`expr $$failed + 1`; \ - echo "FAIL: $$tst"; \ - ;; \ - esac; \ - else \ - skip=`expr $$skip + 1`; \ - echo "SKIP: $$tst"; \ - fi; \ - done; \ - if test "$$failed" -eq 0; then \ - if test "$$xfail" -eq 0; then \ - banner="All $$all tests passed"; \ - else \ - banner="All $$all tests behaved as expected ($$xfail expected failures)"; \ - fi; \ - else \ - if test "$$xpass" -eq 0; then \ - banner="$$failed of $$all tests failed"; \ - else \ - banner="$$failed of $$all tests did not behave as expected ($$xpass unexpected passes)"; \ - fi; \ - fi; \ - dashes="$$banner"; \ - skipped=""; \ - if test "$$skip" -ne 0; then \ - skipped="($$skip tests were not run)"; \ - test `echo "$$skipped" | wc -c` -le `echo "$$banner" | wc -c` || \ - dashes="$$skipped"; \ - fi; \ - report=""; \ - if test "$$failed" -ne 0 && test -n "$(PACKAGE_BUGREPORT)"; then \ - report="Please report to $(PACKAGE_BUGREPORT)"; \ - test `echo "$$report" | wc -c` -le `echo "$$banner" | wc -c` || \ - dashes="$$report"; \ - fi; \ - dashes=`echo "$$dashes" | sed s/./=/g`; \ - echo "$$dashes"; \ - echo "$$banner"; \ - test -z "$$skipped" || echo "$$skipped"; \ - test -z "$$report" || echo "$$report"; \ - echo "$$dashes"; \ - test "$$failed" -eq 0; \ - else :; fi - -distdir: $(DISTFILES) - $(am__remove_distdir) - test -d $(distdir) || mkdir $(distdir) - @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ - topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ - list='$(DISTFILES)'; \ - dist_files=`for file in $$list; do echo $$file; done | \ - sed -e "s|^$$srcdirstrip/||;t" \ - -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ - case $$dist_files in \ - */*) $(MKDIR_P) `echo "$$dist_files" | \ - sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ - sort -u` ;; \ - esac; \ - for file in $$dist_files; do \ - if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ - if test -d $$d/$$file; then \ - dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ - if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ - cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \ - fi; \ - cp -pR $$d/$$file $(distdir)$$dir || exit 1; \ - else \ - test -f $(distdir)/$$file \ - || cp -p $$d/$$file $(distdir)/$$file \ - || exit 1; \ - fi; \ - done - $(MAKE) $(AM_MAKEFLAGS) \ - top_distdir="$(top_distdir)" distdir="$(distdir)" \ - dist-info - -find $(distdir) -type d ! -perm -777 -exec chmod a+rwx {} \; -o \ - ! -type d ! -perm -444 -links 1 -exec chmod a+r {} \; -o \ - ! -type d ! -perm -400 -exec chmod a+r {} \; -o \ - ! -type d ! -perm -444 -exec $(install_sh) -c -m a+r {} {} \; \ - || chmod -R a+r $(distdir) -dist-gzip: distdir - tardir=$(distdir) && $(am__tar) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).tar.gz - $(am__remove_distdir) - -dist-bzip2: distdir - tardir=$(distdir) && $(am__tar) | bzip2 -9 -c >$(distdir).tar.bz2 - $(am__remove_distdir) - -dist-tarZ: distdir - tardir=$(distdir) && $(am__tar) | compress -c >$(distdir).tar.Z - $(am__remove_distdir) -dist-shar: distdir - shar $(distdir) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).shar.gz - $(am__remove_distdir) - -dist-zip: distdir - -rm -f $(distdir).zip - zip -rq $(distdir).zip $(distdir) - $(am__remove_distdir) - -dist dist-all: distdir - tardir=$(distdir) && $(am__tar) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).tar.gz - shar $(distdir) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).shar.gz - $(am__remove_distdir) - -# This target untars the dist file and tries a VPATH configuration. Then -# it guarantees that the distribution is self-contained by making another -# tarfile. -distcheck: dist - case '$(DIST_ARCHIVES)' in \ - *.tar.gz*) \ - GZIP=$(GZIP_ENV) gunzip -c $(distdir).tar.gz | $(am__untar) ;;\ - *.tar.bz2*) \ - bunzip2 -c $(distdir).tar.bz2 | $(am__untar) ;;\ - *.tar.Z*) \ - uncompress -c $(distdir).tar.Z | $(am__untar) ;;\ - *.shar.gz*) \ - GZIP=$(GZIP_ENV) gunzip -c $(distdir).shar.gz | unshar ;;\ - *.zip*) \ - unzip $(distdir).zip ;;\ - esac - chmod -R a-w $(distdir); chmod a+w $(distdir) - mkdir $(distdir)/_build - mkdir $(distdir)/_inst - chmod a-w $(distdir) - dc_install_base=`$(am__cd) $(distdir)/_inst && pwd | sed -e 's,^[^:\\/]:[\\/],/,'` \ - && dc_destdir="$${TMPDIR-/tmp}/am-dc-$$$$/" \ - && cd $(distdir)/_build \ - && ../configure --srcdir=.. --prefix="$$dc_install_base" \ - $(DISTCHECK_CONFIGURE_FLAGS) \ - && $(MAKE) $(AM_MAKEFLAGS) \ - && $(MAKE) $(AM_MAKEFLAGS) dvi \ - && $(MAKE) $(AM_MAKEFLAGS) check \ - && $(MAKE) $(AM_MAKEFLAGS) install \ - && $(MAKE) $(AM_MAKEFLAGS) installcheck \ - && $(MAKE) $(AM_MAKEFLAGS) uninstall \ - && $(MAKE) $(AM_MAKEFLAGS) distuninstallcheck_dir="$$dc_install_base" \ - distuninstallcheck \ - && chmod -R a-w "$$dc_install_base" \ - && ({ \ - (cd ../.. && umask 077 && mkdir "$$dc_destdir") \ - && $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" install \ - && $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" uninstall \ - && $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" \ - distuninstallcheck_dir="$$dc_destdir" distuninstallcheck; \ - } || { rm -rf "$$dc_destdir"; exit 1; }) \ - && rm -rf "$$dc_destdir" \ - && $(MAKE) $(AM_MAKEFLAGS) dist \ - && rm -rf $(DIST_ARCHIVES) \ - && $(MAKE) $(AM_MAKEFLAGS) distcleancheck - $(am__remove_distdir) - @(echo "$(distdir) archives ready for distribution: "; \ - list='$(DIST_ARCHIVES)'; for i in $$list; do echo $$i; done) | \ - sed -e 1h -e 1s/./=/g -e 1p -e 1x -e '$$p' -e '$$x' -distuninstallcheck: - @cd $(distuninstallcheck_dir) \ - && test `$(distuninstallcheck_listfiles) | wc -l` -le 1 \ - || { echo "ERROR: files left after uninstall:" ; \ - if test -n "$(DESTDIR)"; then \ - echo " (check DESTDIR support)"; \ - fi ; \ - $(distuninstallcheck_listfiles) ; \ - exit 1; } >&2 -distcleancheck: distclean - @if test '$(srcdir)' = . ; then \ - echo "ERROR: distcleancheck can only run from a VPATH build" ; \ - exit 1 ; \ - fi - @test `$(distcleancheck_listfiles) | wc -l` -eq 0 \ - || { echo "ERROR: files left in build directory after distclean:" ; \ - $(distcleancheck_listfiles) ; \ - exit 1; } >&2 -check-am: all-am - $(MAKE) $(AM_MAKEFLAGS) check-TESTS -check: check-am -all-am: Makefile $(INFO_DEPS) $(SCRIPTS) $(MANS) $(DATA) -installdirs: - for dir in "$(DESTDIR)$(bindir)" "$(DESTDIR)$(infodir)" "$(DESTDIR)$(man8dir)" "$(DESTDIR)$(docdir)"; do \ - test -z "$$dir" || $(MKDIR_P) "$$dir"; \ - done -install: install-am -install-exec: install-exec-am -install-data: install-data-am -uninstall: uninstall-am - -install-am: all-am - @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am - -installcheck: installcheck-am -install-strip: - $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ - install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ - `test -z '$(STRIP)' || \ - echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install -mostlyclean-generic: - -clean-generic: - -test -z "$(CLEANFILES)" || rm -f $(CLEANFILES) - -distclean-generic: - -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) - -maintainer-clean-generic: - @echo "This command is intended for maintainers to use" - @echo "it deletes files that may require special tools to rebuild." -clean: clean-am - -clean-am: clean-generic clean-local mostlyclean-am - -distclean: distclean-am - -rm -f $(am__CONFIG_DISTCLEAN_FILES) - -rm -f Makefile -distclean-am: clean-am distclean-generic - -dvi: dvi-am - -dvi-am: $(DVIS) - -html: html-am - -html-am: $(HTMLS) - -info: info-am - -info-am: $(INFO_DEPS) - -install-data-am: install-dist_docDATA install-info-am install-man - -install-dvi: install-dvi-am - -install-dvi-am: $(DVIS) - @$(NORMAL_INSTALL) - test -z "$(dvidir)" || $(MKDIR_P) "$(DESTDIR)$(dvidir)" - @list='$(DVIS)'; for p in $$list; do \ - if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \ - f=$(am__strip_dir) \ - echo " $(INSTALL_DATA) '$$d$$p' '$(DESTDIR)$(dvidir)/$$f'"; \ - $(INSTALL_DATA) "$$d$$p" "$(DESTDIR)$(dvidir)/$$f"; \ - done -install-exec-am: install-binSCRIPTS - -install-html: install-html-am - -install-html-am: $(HTMLS) - @$(NORMAL_INSTALL) - test -z "$(htmldir)" || $(MKDIR_P) "$(DESTDIR)$(htmldir)" - @list='$(HTMLS)'; for p in $$list; do \ - if test -f "$$p" || test -d "$$p"; then d=; else d="$(srcdir)/"; fi; \ - f=$(am__strip_dir) \ - if test -d "$$d$$p"; then \ - echo " $(MKDIR_P) '$(DESTDIR)$(htmldir)/$$f'"; \ - $(MKDIR_P) "$(DESTDIR)$(htmldir)/$$f" || exit 1; \ - echo " $(INSTALL_DATA) '$$d$$p'/* '$(DESTDIR)$(htmldir)/$$f'"; \ - $(INSTALL_DATA) "$$d$$p"/* "$(DESTDIR)$(htmldir)/$$f"; \ - else \ - echo " $(INSTALL_DATA) '$$d$$p' '$(DESTDIR)$(htmldir)/$$f'"; \ - $(INSTALL_DATA) "$$d$$p" "$(DESTDIR)$(htmldir)/$$f"; \ - fi; \ - done -install-info: install-info-am - -install-info-am: $(INFO_DEPS) - @$(NORMAL_INSTALL) - test -z "$(infodir)" || $(MKDIR_P) "$(DESTDIR)$(infodir)" - @srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; \ - list='$(INFO_DEPS)'; \ - for file in $$list; do \ - case $$file in \ - $(srcdir)/*) file=`echo "$$file" | sed "s|^$$srcdirstrip/||"`;; \ - esac; \ - if test -f $$file; then d=.; else d=$(srcdir); fi; \ - file_i=`echo "$$file" | sed 's|\.info$$||;s|$$|.i|'`; \ - for ifile in $$d/$$file $$d/$$file-[0-9] $$d/$$file-[0-9][0-9] \ - $$d/$$file_i[0-9] $$d/$$file_i[0-9][0-9] ; do \ - if test -f $$ifile; then \ - relfile=`echo "$$ifile" | sed 's|^.*/||'`; \ - echo " $(INSTALL_DATA) '$$ifile' '$(DESTDIR)$(infodir)/$$relfile'"; \ - $(INSTALL_DATA) "$$ifile" "$(DESTDIR)$(infodir)/$$relfile"; \ - else : ; fi; \ - done; \ - done - @$(POST_INSTALL) - @if (install-info --version && \ - install-info --version 2>&1 | sed 1q | grep -i -v debian) >/dev/null 2>&1; then \ - list='$(INFO_DEPS)'; \ - for file in $$list; do \ - relfile=`echo "$$file" | sed 's|^.*/||'`; \ - echo " install-info --info-dir='$(DESTDIR)$(infodir)' '$(DESTDIR)$(infodir)/$$relfile'";\ - install-info --info-dir="$(DESTDIR)$(infodir)" "$(DESTDIR)$(infodir)/$$relfile" || :;\ - done; \ - else : ; fi -install-man: install-man8 - -install-pdf: install-pdf-am - -install-pdf-am: $(PDFS) - @$(NORMAL_INSTALL) - test -z "$(pdfdir)" || $(MKDIR_P) "$(DESTDIR)$(pdfdir)" - @list='$(PDFS)'; for p in $$list; do \ - if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \ - f=$(am__strip_dir) \ - echo " $(INSTALL_DATA) '$$d$$p' '$(DESTDIR)$(pdfdir)/$$f'"; \ - $(INSTALL_DATA) "$$d$$p" "$(DESTDIR)$(pdfdir)/$$f"; \ - done -install-ps: install-ps-am - -install-ps-am: $(PSS) - @$(NORMAL_INSTALL) - test -z "$(psdir)" || $(MKDIR_P) "$(DESTDIR)$(psdir)" - @list='$(PSS)'; for p in $$list; do \ - if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \ - f=$(am__strip_dir) \ - echo " $(INSTALL_DATA) '$$d$$p' '$(DESTDIR)$(psdir)/$$f'"; \ - $(INSTALL_DATA) "$$d$$p" "$(DESTDIR)$(psdir)/$$f"; \ - done -installcheck-am: - -maintainer-clean: maintainer-clean-am - -rm -f $(am__CONFIG_DISTCLEAN_FILES) - -rm -rf $(top_srcdir)/autom4te.cache - -rm -f Makefile -maintainer-clean-am: distclean-am maintainer-clean-aminfo \ - maintainer-clean-generic maintainer-clean-vti - -mostlyclean: mostlyclean-am - -mostlyclean-am: mostlyclean-aminfo mostlyclean-generic mostlyclean-vti - -pdf: pdf-am - -pdf-am: $(PDFS) - -ps: ps-am - -ps-am: $(PSS) - -uninstall-am: uninstall-binSCRIPTS uninstall-dist_docDATA \ - uninstall-dvi-am uninstall-html-am uninstall-info-am \ - uninstall-man uninstall-pdf-am uninstall-ps-am - -uninstall-man: uninstall-man8 - -.MAKE: install-am install-strip - -.PHONY: all all-am am--refresh check check-TESTS check-am clean \ - clean-generic clean-local dist dist-all dist-bzip2 dist-gzip \ - dist-info dist-shar dist-tarZ dist-zip distcheck distclean \ - distclean-generic distcleancheck distdir distuninstallcheck \ - dvi dvi-am html html-am info info-am install install-am \ - install-binSCRIPTS install-data install-data-am \ - install-dist_docDATA install-dvi install-dvi-am install-exec \ - install-exec-am install-html install-html-am install-info \ - install-info-am install-man install-man8 install-pdf \ - install-pdf-am install-ps install-ps-am install-strip \ - installcheck installcheck-am installdirs maintainer-clean \ - maintainer-clean-aminfo maintainer-clean-generic \ - maintainer-clean-vti mostlyclean mostlyclean-aminfo \ - mostlyclean-generic mostlyclean-vti pdf pdf-am ps ps-am \ - uninstall uninstall-am uninstall-binSCRIPTS \ - uninstall-dist_docDATA uninstall-dvi-am uninstall-html-am \ - uninstall-info-am uninstall-man uninstall-man8 \ - uninstall-pdf-am uninstall-ps-am - - -# clean up files left behind by test suite -clean-local: - -rm -rf t/target t/stow - -stow: stow.in Makefile - $(edit) < $< > $@ - chmod +x $@ - -chkstow: chkstow.in Makefile - $(edit) < $< > $@ - chmod +x $@ - -# The rules for manual.html and manual.texi are only used by -# the developer -manual.html: manual.texi - -rm -f $@ - texi2html -expandinfo -menu -monolithic -verbose $< - -manual.texi: stow.texi - -rm -f $@ - cp $< $@ -# Tell versions [3.59,3.63) of GNU make to not export all variables. -# Otherwise a system limit (for SysV at least) may be exceeded. -.NOEXPORT: diff --git a/configure b/configure deleted file mode 100755 index 8e79ed4..0000000 --- a/configure +++ /dev/null @@ -1,3297 +0,0 @@ -#! /bin/sh -# Guess values for system-dependent variables and create Makefiles. -# Generated by GNU Autoconf 2.61 for stow 2.0.2. -# -# Report bugs to . -# -# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001, -# 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc. -# This configure script is free software; the Free Software Foundation -# gives unlimited permission to copy, distribute and modify it. -## --------------------- ## -## M4sh Initialization. ## -## --------------------- ## - -# Be more Bourne compatible -DUALCASE=1; export DUALCASE # for MKS sh -if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then - emulate sh - NULLCMD=: - # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which - # is contrary to our usage. Disable this feature. - alias -g '${1+"$@"}'='"$@"' - setopt NO_GLOB_SUBST -else - case `(set -o) 2>/dev/null` in - *posix*) set -o posix ;; -esac - -fi - - - - -# PATH needs CR -# Avoid depending upon Character Ranges. -as_cr_letters='abcdefghijklmnopqrstuvwxyz' -as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ' -as_cr_Letters=$as_cr_letters$as_cr_LETTERS -as_cr_digits='0123456789' -as_cr_alnum=$as_cr_Letters$as_cr_digits - -# The user is always right. -if test "${PATH_SEPARATOR+set}" != set; then - echo "#! /bin/sh" >conf$$.sh - echo "exit 0" >>conf$$.sh - chmod +x conf$$.sh - if (PATH="/nonexistent;."; conf$$.sh) >/dev/null 2>&1; then - PATH_SEPARATOR=';' - else - PATH_SEPARATOR=: - fi - rm -f conf$$.sh -fi - -# Support unset when possible. -if ( (MAIL=60; unset MAIL) || exit) >/dev/null 2>&1; then - as_unset=unset -else - as_unset=false -fi - - -# IFS -# We need space, tab and new line, in precisely that order. Quoting is -# there to prevent editors from complaining about space-tab. -# (If _AS_PATH_WALK were called with IFS unset, it would disable word -# splitting by setting IFS to empty value.) -as_nl=' -' -IFS=" "" $as_nl" - -# Find who we are. Look in the path if we contain no directory separator. -case $0 in - *[\\/]* ) as_myself=$0 ;; - *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break -done -IFS=$as_save_IFS - - ;; -esac -# We did not find ourselves, most probably we were run as `sh COMMAND' -# in which case we are not to be found in the path. -if test "x$as_myself" = x; then - as_myself=$0 -fi -if test ! -f "$as_myself"; then - echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2 - { (exit 1); exit 1; } -fi - -# Work around bugs in pre-3.0 UWIN ksh. -for as_var in ENV MAIL MAILPATH -do ($as_unset $as_var) >/dev/null 2>&1 && $as_unset $as_var -done -PS1='$ ' -PS2='> ' -PS4='+ ' - -# NLS nuisances. -for as_var in \ - LANG LANGUAGE LC_ADDRESS LC_ALL LC_COLLATE LC_CTYPE LC_IDENTIFICATION \ - LC_MEASUREMENT LC_MESSAGES LC_MONETARY LC_NAME LC_NUMERIC LC_PAPER \ - LC_TELEPHONE LC_TIME -do - if (set +x; test -z "`(eval $as_var=C; export $as_var) 2>&1`"); then - eval $as_var=C; export $as_var - else - ($as_unset $as_var) >/dev/null 2>&1 && $as_unset $as_var - fi -done - -# Required to use basename. -if expr a : '\(a\)' >/dev/null 2>&1 && - test "X`expr 00001 : '.*\(...\)'`" = X001; then - as_expr=expr -else - as_expr=false -fi - -if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then - as_basename=basename -else - as_basename=false -fi - - -# Name of the executable. -as_me=`$as_basename -- "$0" || -$as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \ - X"$0" : 'X\(//\)$' \| \ - X"$0" : 'X\(/\)' \| . 2>/dev/null || -echo X/"$0" | - sed '/^.*\/\([^/][^/]*\)\/*$/{ - s//\1/ - q - } - /^X\/\(\/\/\)$/{ - s//\1/ - q - } - /^X\/\(\/\).*/{ - s//\1/ - q - } - s/.*/./; q'` - -# CDPATH. -$as_unset CDPATH - - -if test "x$CONFIG_SHELL" = x; then - if (eval ":") 2>/dev/null; then - as_have_required=yes -else - as_have_required=no -fi - - if test $as_have_required = yes && (eval ": -(as_func_return () { - (exit \$1) -} -as_func_success () { - as_func_return 0 -} -as_func_failure () { - as_func_return 1 -} -as_func_ret_success () { - return 0 -} -as_func_ret_failure () { - return 1 -} - -exitcode=0 -if as_func_success; then - : -else - exitcode=1 - echo as_func_success failed. -fi - -if as_func_failure; then - exitcode=1 - echo as_func_failure succeeded. -fi - -if as_func_ret_success; then - : -else - exitcode=1 - echo as_func_ret_success failed. -fi - -if as_func_ret_failure; then - exitcode=1 - echo as_func_ret_failure succeeded. -fi - -if ( set x; as_func_ret_success y && test x = \"\$1\" ); then - : -else - exitcode=1 - echo positional parameters were not saved. -fi - -test \$exitcode = 0) || { (exit 1); exit 1; } - -( - as_lineno_1=\$LINENO - as_lineno_2=\$LINENO - test \"x\$as_lineno_1\" != \"x\$as_lineno_2\" && - test \"x\`expr \$as_lineno_1 + 1\`\" = \"x\$as_lineno_2\") || { (exit 1); exit 1; } -") 2> /dev/null; then - : -else - as_candidate_shells= - as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in /bin$PATH_SEPARATOR/usr/bin$PATH_SEPARATOR$PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - case $as_dir in - /*) - for as_base in sh bash ksh sh5; do - as_candidate_shells="$as_candidate_shells $as_dir/$as_base" - done;; - esac -done -IFS=$as_save_IFS - - - for as_shell in $as_candidate_shells $SHELL; do - # Try only shells that exist, to save several forks. - if { test -f "$as_shell" || test -f "$as_shell.exe"; } && - { ("$as_shell") 2> /dev/null <<\_ASEOF -if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then - emulate sh - NULLCMD=: - # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which - # is contrary to our usage. Disable this feature. - alias -g '${1+"$@"}'='"$@"' - setopt NO_GLOB_SUBST -else - case `(set -o) 2>/dev/null` in - *posix*) set -o posix ;; -esac - -fi - - -: -_ASEOF -}; then - CONFIG_SHELL=$as_shell - as_have_required=yes - if { "$as_shell" 2> /dev/null <<\_ASEOF -if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then - emulate sh - NULLCMD=: - # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which - # is contrary to our usage. Disable this feature. - alias -g '${1+"$@"}'='"$@"' - setopt NO_GLOB_SUBST -else - case `(set -o) 2>/dev/null` in - *posix*) set -o posix ;; -esac - -fi - - -: -(as_func_return () { - (exit $1) -} -as_func_success () { - as_func_return 0 -} -as_func_failure () { - as_func_return 1 -} -as_func_ret_success () { - return 0 -} -as_func_ret_failure () { - return 1 -} - -exitcode=0 -if as_func_success; then - : -else - exitcode=1 - echo as_func_success failed. -fi - -if as_func_failure; then - exitcode=1 - echo as_func_failure succeeded. -fi - -if as_func_ret_success; then - : -else - exitcode=1 - echo as_func_ret_success failed. -fi - -if as_func_ret_failure; then - exitcode=1 - echo as_func_ret_failure succeeded. -fi - -if ( set x; as_func_ret_success y && test x = "$1" ); then - : -else - exitcode=1 - echo positional parameters were not saved. -fi - -test $exitcode = 0) || { (exit 1); exit 1; } - -( - as_lineno_1=$LINENO - as_lineno_2=$LINENO - test "x$as_lineno_1" != "x$as_lineno_2" && - test "x`expr $as_lineno_1 + 1`" = "x$as_lineno_2") || { (exit 1); exit 1; } - -_ASEOF -}; then - break -fi - -fi - - done - - if test "x$CONFIG_SHELL" != x; then - for as_var in BASH_ENV ENV - do ($as_unset $as_var) >/dev/null 2>&1 && $as_unset $as_var - done - export CONFIG_SHELL - exec "$CONFIG_SHELL" "$as_myself" ${1+"$@"} -fi - - - if test $as_have_required = no; then - echo This script requires a shell more modern than all the - echo shells that I found on your system. Please install a - echo modern shell, or manually run the script under such a - echo shell if you do have one. - { (exit 1); exit 1; } -fi - - -fi - -fi - - - -(eval "as_func_return () { - (exit \$1) -} -as_func_success () { - as_func_return 0 -} -as_func_failure () { - as_func_return 1 -} -as_func_ret_success () { - return 0 -} -as_func_ret_failure () { - return 1 -} - -exitcode=0 -if as_func_success; then - : -else - exitcode=1 - echo as_func_success failed. -fi - -if as_func_failure; then - exitcode=1 - echo as_func_failure succeeded. -fi - -if as_func_ret_success; then - : -else - exitcode=1 - echo as_func_ret_success failed. -fi - -if as_func_ret_failure; then - exitcode=1 - echo as_func_ret_failure succeeded. -fi - -if ( set x; as_func_ret_success y && test x = \"\$1\" ); then - : -else - exitcode=1 - echo positional parameters were not saved. -fi - -test \$exitcode = 0") || { - echo No shell found that supports shell functions. - echo Please tell autoconf@gnu.org about your system, - echo including any error possibly output before this - echo message -} - - - - as_lineno_1=$LINENO - as_lineno_2=$LINENO - test "x$as_lineno_1" != "x$as_lineno_2" && - test "x`expr $as_lineno_1 + 1`" = "x$as_lineno_2" || { - - # Create $as_me.lineno as a copy of $as_myself, but with $LINENO - # uniformly replaced by the line number. The first 'sed' inserts a - # line-number line after each line using $LINENO; the second 'sed' - # does the real work. The second script uses 'N' to pair each - # line-number line with the line containing $LINENO, and appends - # trailing '-' during substitution so that $LINENO is not a special - # case at line end. - # (Raja R Harinath suggested sed '=', and Paul Eggert wrote the - # scripts with optimization help from Paolo Bonzini. Blame Lee - # E. McMahon (1931-1989) for sed's syntax. :-) - sed -n ' - p - /[$]LINENO/= - ' <$as_myself | - sed ' - s/[$]LINENO.*/&-/ - t lineno - b - :lineno - N - :loop - s/[$]LINENO\([^'$as_cr_alnum'_].*\n\)\(.*\)/\2\1\2/ - t loop - s/-\n.*// - ' >$as_me.lineno && - chmod +x "$as_me.lineno" || - { echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2 - { (exit 1); exit 1; }; } - - # Don't try to exec as it changes $[0], causing all sort of problems - # (the dirname of $[0] is not the place where we might find the - # original and so on. Autoconf is especially sensitive to this). - . "./$as_me.lineno" - # Exit status is that of the last command. - exit -} - - -if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then - as_dirname=dirname -else - as_dirname=false -fi - -ECHO_C= ECHO_N= ECHO_T= -case `echo -n x` in --n*) - case `echo 'x\c'` in - *c*) ECHO_T=' ';; # ECHO_T is single tab character. - *) ECHO_C='\c';; - esac;; -*) - ECHO_N='-n';; -esac - -if expr a : '\(a\)' >/dev/null 2>&1 && - test "X`expr 00001 : '.*\(...\)'`" = X001; then - as_expr=expr -else - as_expr=false -fi - -rm -f conf$$ conf$$.exe conf$$.file -if test -d conf$$.dir; then - rm -f conf$$.dir/conf$$.file -else - rm -f conf$$.dir - mkdir conf$$.dir -fi -echo >conf$$.file -if ln -s conf$$.file conf$$ 2>/dev/null; then - as_ln_s='ln -s' - # ... but there are two gotchas: - # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail. - # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable. - # In both cases, we have to default to `cp -p'. - ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe || - as_ln_s='cp -p' -elif ln conf$$.file conf$$ 2>/dev/null; then - as_ln_s=ln -else - as_ln_s='cp -p' -fi -rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file -rmdir conf$$.dir 2>/dev/null - -if mkdir -p . 2>/dev/null; then - as_mkdir_p=: -else - test -d ./-p && rmdir ./-p - as_mkdir_p=false -fi - -if test -x / >/dev/null 2>&1; then - as_test_x='test -x' -else - if ls -dL / >/dev/null 2>&1; then - as_ls_L_option=L - else - as_ls_L_option= - fi - as_test_x=' - eval sh -c '\'' - if test -d "$1"; then - test -d "$1/."; - else - case $1 in - -*)set "./$1";; - esac; - case `ls -ld'$as_ls_L_option' "$1" 2>/dev/null` in - ???[sx]*):;;*)false;;esac;fi - '\'' sh - ' -fi -as_executable_p=$as_test_x - -# Sed expression to map a string onto a valid CPP name. -as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'" - -# Sed expression to map a string onto a valid variable name. -as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'" - - - -exec 7<&0 &1 - -# Name of the host. -# hostname on some systems (SVR3.2, Linux) returns a bogus exit status, -# so uname gets run too. -ac_hostname=`(hostname || uname -n) 2>/dev/null | sed 1q` - -# -# Initializations. -# -ac_default_prefix=/usr/local -ac_clean_files= -ac_config_libobj_dir=. -LIBOBJS= -cross_compiling=no -subdirs= -MFLAGS= -MAKEFLAGS= -SHELL=${CONFIG_SHELL-/bin/sh} - -# Identity of this package. -PACKAGE_NAME='stow' -PACKAGE_TARNAME='stow' -PACKAGE_VERSION='2.0.2' -PACKAGE_STRING='stow 2.0.2' -PACKAGE_BUGREPORT='bug-stow@gnu.org' - -ac_subst_vars='SHELL -PATH_SEPARATOR -PACKAGE_NAME -PACKAGE_TARNAME -PACKAGE_VERSION -PACKAGE_STRING -PACKAGE_BUGREPORT -exec_prefix -prefix -program_transform_name -bindir -sbindir -libexecdir -datarootdir -datadir -sysconfdir -sharedstatedir -localstatedir -includedir -oldincludedir -docdir -infodir -htmldir -dvidir -pdfdir -psdir -libdir -localedir -mandir -DEFS -ECHO_C -ECHO_N -ECHO_T -LIBS -build_alias -host_alias -target_alias -INSTALL_PROGRAM -INSTALL_SCRIPT -INSTALL_DATA -am__isrc -CYGPATH_W -PACKAGE -VERSION -ACLOCAL -AUTOCONF -AUTOMAKE -AUTOHEADER -MAKEINFO -install_sh -STRIP -INSTALL_STRIP_PROGRAM -mkdir_p -AWK -SET_MAKE -am__leading_dot -AMTAR -am__tar -am__untar -PERL -LIBOBJS -LTLIBOBJS' -ac_subst_files='' - ac_precious_vars='build_alias -host_alias -target_alias' - - -# Initialize some variables set by options. -ac_init_help= -ac_init_version=false -# The variables have the same names as the options, with -# dashes changed to underlines. -cache_file=/dev/null -exec_prefix=NONE -no_create= -no_recursion= -prefix=NONE -program_prefix=NONE -program_suffix=NONE -program_transform_name=s,x,x, -silent= -site= -srcdir= -verbose= -x_includes=NONE -x_libraries=NONE - -# Installation directory options. -# These are left unexpanded so users can "make install exec_prefix=/foo" -# and all the variables that are supposed to be based on exec_prefix -# by default will actually change. -# Use braces instead of parens because sh, perl, etc. also accept them. -# (The list follows the same order as the GNU Coding Standards.) -bindir='${exec_prefix}/bin' -sbindir='${exec_prefix}/sbin' -libexecdir='${exec_prefix}/libexec' -datarootdir='${prefix}/share' -datadir='${datarootdir}' -sysconfdir='${prefix}/etc' -sharedstatedir='${prefix}/com' -localstatedir='${prefix}/var' -includedir='${prefix}/include' -oldincludedir='/usr/include' -docdir='${datarootdir}/doc/${PACKAGE_TARNAME}' -infodir='${datarootdir}/info' -htmldir='${docdir}' -dvidir='${docdir}' -pdfdir='${docdir}' -psdir='${docdir}' -libdir='${exec_prefix}/lib' -localedir='${datarootdir}/locale' -mandir='${datarootdir}/man' - -ac_prev= -ac_dashdash= -for ac_option -do - # If the previous option needs an argument, assign it. - if test -n "$ac_prev"; then - eval $ac_prev=\$ac_option - ac_prev= - continue - fi - - case $ac_option in - *=*) ac_optarg=`expr "X$ac_option" : '[^=]*=\(.*\)'` ;; - *) ac_optarg=yes ;; - esac - - # Accept the important Cygnus configure options, so we can diagnose typos. - - case $ac_dashdash$ac_option in - --) - ac_dashdash=yes ;; - - -bindir | --bindir | --bindi | --bind | --bin | --bi) - ac_prev=bindir ;; - -bindir=* | --bindir=* | --bindi=* | --bind=* | --bin=* | --bi=*) - bindir=$ac_optarg ;; - - -build | --build | --buil | --bui | --bu) - ac_prev=build_alias ;; - -build=* | --build=* | --buil=* | --bui=* | --bu=*) - build_alias=$ac_optarg ;; - - -cache-file | --cache-file | --cache-fil | --cache-fi \ - | --cache-f | --cache- | --cache | --cach | --cac | --ca | --c) - ac_prev=cache_file ;; - -cache-file=* | --cache-file=* | --cache-fil=* | --cache-fi=* \ - | --cache-f=* | --cache-=* | --cache=* | --cach=* | --cac=* | --ca=* | --c=*) - cache_file=$ac_optarg ;; - - --config-cache | -C) - cache_file=config.cache ;; - - -datadir | --datadir | --datadi | --datad) - ac_prev=datadir ;; - -datadir=* | --datadir=* | --datadi=* | --datad=*) - datadir=$ac_optarg ;; - - -datarootdir | --datarootdir | --datarootdi | --datarootd | --dataroot \ - | --dataroo | --dataro | --datar) - ac_prev=datarootdir ;; - -datarootdir=* | --datarootdir=* | --datarootdi=* | --datarootd=* \ - | --dataroot=* | --dataroo=* | --dataro=* | --datar=*) - datarootdir=$ac_optarg ;; - - -disable-* | --disable-*) - ac_feature=`expr "x$ac_option" : 'x-*disable-\(.*\)'` - # Reject names that are not valid shell variable names. - expr "x$ac_feature" : ".*[^-._$as_cr_alnum]" >/dev/null && - { echo "$as_me: error: invalid feature name: $ac_feature" >&2 - { (exit 1); exit 1; }; } - ac_feature=`echo $ac_feature | sed 's/[-.]/_/g'` - eval enable_$ac_feature=no ;; - - -docdir | --docdir | --docdi | --doc | --do) - ac_prev=docdir ;; - -docdir=* | --docdir=* | --docdi=* | --doc=* | --do=*) - docdir=$ac_optarg ;; - - -dvidir | --dvidir | --dvidi | --dvid | --dvi | --dv) - ac_prev=dvidir ;; - -dvidir=* | --dvidir=* | --dvidi=* | --dvid=* | --dvi=* | --dv=*) - dvidir=$ac_optarg ;; - - -enable-* | --enable-*) - ac_feature=`expr "x$ac_option" : 'x-*enable-\([^=]*\)'` - # Reject names that are not valid shell variable names. - expr "x$ac_feature" : ".*[^-._$as_cr_alnum]" >/dev/null && - { echo "$as_me: error: invalid feature name: $ac_feature" >&2 - { (exit 1); exit 1; }; } - ac_feature=`echo $ac_feature | sed 's/[-.]/_/g'` - eval enable_$ac_feature=\$ac_optarg ;; - - -exec-prefix | --exec_prefix | --exec-prefix | --exec-prefi \ - | --exec-pref | --exec-pre | --exec-pr | --exec-p | --exec- \ - | --exec | --exe | --ex) - ac_prev=exec_prefix ;; - -exec-prefix=* | --exec_prefix=* | --exec-prefix=* | --exec-prefi=* \ - | --exec-pref=* | --exec-pre=* | --exec-pr=* | --exec-p=* | --exec-=* \ - | --exec=* | --exe=* | --ex=*) - exec_prefix=$ac_optarg ;; - - -gas | --gas | --ga | --g) - # Obsolete; use --with-gas. - with_gas=yes ;; - - -help | --help | --hel | --he | -h) - ac_init_help=long ;; - -help=r* | --help=r* | --hel=r* | --he=r* | -hr*) - ac_init_help=recursive ;; - -help=s* | --help=s* | --hel=s* | --he=s* | -hs*) - ac_init_help=short ;; - - -host | --host | --hos | --ho) - ac_prev=host_alias ;; - -host=* | --host=* | --hos=* | --ho=*) - host_alias=$ac_optarg ;; - - -htmldir | --htmldir | --htmldi | --htmld | --html | --htm | --ht) - ac_prev=htmldir ;; - -htmldir=* | --htmldir=* | --htmldi=* | --htmld=* | --html=* | --htm=* \ - | --ht=*) - htmldir=$ac_optarg ;; - - -includedir | --includedir | --includedi | --included | --include \ - | --includ | --inclu | --incl | --inc) - ac_prev=includedir ;; - -includedir=* | --includedir=* | --includedi=* | --included=* | --include=* \ - | --includ=* | --inclu=* | --incl=* | --inc=*) - includedir=$ac_optarg ;; - - -infodir | --infodir | --infodi | --infod | --info | --inf) - ac_prev=infodir ;; - -infodir=* | --infodir=* | --infodi=* | --infod=* | --info=* | --inf=*) - infodir=$ac_optarg ;; - - -libdir | --libdir | --libdi | --libd) - ac_prev=libdir ;; - -libdir=* | --libdir=* | --libdi=* | --libd=*) - libdir=$ac_optarg ;; - - -libexecdir | --libexecdir | --libexecdi | --libexecd | --libexec \ - | --libexe | --libex | --libe) - ac_prev=libexecdir ;; - -libexecdir=* | --libexecdir=* | --libexecdi=* | --libexecd=* | --libexec=* \ - | --libexe=* | --libex=* | --libe=*) - libexecdir=$ac_optarg ;; - - -localedir | --localedir | --localedi | --localed | --locale) - ac_prev=localedir ;; - -localedir=* | --localedir=* | --localedi=* | --localed=* | --locale=*) - localedir=$ac_optarg ;; - - -localstatedir | --localstatedir | --localstatedi | --localstated \ - | --localstate | --localstat | --localsta | --localst | --locals) - ac_prev=localstatedir ;; - -localstatedir=* | --localstatedir=* | --localstatedi=* | --localstated=* \ - | --localstate=* | --localstat=* | --localsta=* | --localst=* | --locals=*) - localstatedir=$ac_optarg ;; - - -mandir | --mandir | --mandi | --mand | --man | --ma | --m) - ac_prev=mandir ;; - -mandir=* | --mandir=* | --mandi=* | --mand=* | --man=* | --ma=* | --m=*) - mandir=$ac_optarg ;; - - -nfp | --nfp | --nf) - # Obsolete; use --without-fp. - with_fp=no ;; - - -no-create | --no-create | --no-creat | --no-crea | --no-cre \ - | --no-cr | --no-c | -n) - no_create=yes ;; - - -no-recursion | --no-recursion | --no-recursio | --no-recursi \ - | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r) - no_recursion=yes ;; - - -oldincludedir | --oldincludedir | --oldincludedi | --oldincluded \ - | --oldinclude | --oldinclud | --oldinclu | --oldincl | --oldinc \ - | --oldin | --oldi | --old | --ol | --o) - ac_prev=oldincludedir ;; - -oldincludedir=* | --oldincludedir=* | --oldincludedi=* | --oldincluded=* \ - | --oldinclude=* | --oldinclud=* | --oldinclu=* | --oldincl=* | --oldinc=* \ - | --oldin=* | --oldi=* | --old=* | --ol=* | --o=*) - oldincludedir=$ac_optarg ;; - - -prefix | --prefix | --prefi | --pref | --pre | --pr | --p) - ac_prev=prefix ;; - -prefix=* | --prefix=* | --prefi=* | --pref=* | --pre=* | --pr=* | --p=*) - prefix=$ac_optarg ;; - - -program-prefix | --program-prefix | --program-prefi | --program-pref \ - | --program-pre | --program-pr | --program-p) - ac_prev=program_prefix ;; - -program-prefix=* | --program-prefix=* | --program-prefi=* \ - | --program-pref=* | --program-pre=* | --program-pr=* | --program-p=*) - program_prefix=$ac_optarg ;; - - -program-suffix | --program-suffix | --program-suffi | --program-suff \ - | --program-suf | --program-su | --program-s) - ac_prev=program_suffix ;; - -program-suffix=* | --program-suffix=* | --program-suffi=* \ - | --program-suff=* | --program-suf=* | --program-su=* | --program-s=*) - program_suffix=$ac_optarg ;; - - -program-transform-name | --program-transform-name \ - | --program-transform-nam | --program-transform-na \ - | --program-transform-n | --program-transform- \ - | --program-transform | --program-transfor \ - | --program-transfo | --program-transf \ - | --program-trans | --program-tran \ - | --progr-tra | --program-tr | --program-t) - ac_prev=program_transform_name ;; - -program-transform-name=* | --program-transform-name=* \ - | --program-transform-nam=* | --program-transform-na=* \ - | --program-transform-n=* | --program-transform-=* \ - | --program-transform=* | --program-transfor=* \ - | --program-transfo=* | --program-transf=* \ - | --program-trans=* | --program-tran=* \ - | --progr-tra=* | --program-tr=* | --program-t=*) - program_transform_name=$ac_optarg ;; - - -pdfdir | --pdfdir | --pdfdi | --pdfd | --pdf | --pd) - ac_prev=pdfdir ;; - -pdfdir=* | --pdfdir=* | --pdfdi=* | --pdfd=* | --pdf=* | --pd=*) - pdfdir=$ac_optarg ;; - - -psdir | --psdir | --psdi | --psd | --ps) - ac_prev=psdir ;; - -psdir=* | --psdir=* | --psdi=* | --psd=* | --ps=*) - psdir=$ac_optarg ;; - - -q | -quiet | --quiet | --quie | --qui | --qu | --q \ - | -silent | --silent | --silen | --sile | --sil) - silent=yes ;; - - -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb) - ac_prev=sbindir ;; - -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \ - | --sbi=* | --sb=*) - sbindir=$ac_optarg ;; - - -sharedstatedir | --sharedstatedir | --sharedstatedi \ - | --sharedstated | --sharedstate | --sharedstat | --sharedsta \ - | --sharedst | --shareds | --shared | --share | --shar \ - | --sha | --sh) - ac_prev=sharedstatedir ;; - -sharedstatedir=* | --sharedstatedir=* | --sharedstatedi=* \ - | --sharedstated=* | --sharedstate=* | --sharedstat=* | --sharedsta=* \ - | --sharedst=* | --shareds=* | --shared=* | --share=* | --shar=* \ - | --sha=* | --sh=*) - sharedstatedir=$ac_optarg ;; - - -site | --site | --sit) - ac_prev=site ;; - -site=* | --site=* | --sit=*) - site=$ac_optarg ;; - - -srcdir | --srcdir | --srcdi | --srcd | --src | --sr) - ac_prev=srcdir ;; - -srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=*) - srcdir=$ac_optarg ;; - - -sysconfdir | --sysconfdir | --sysconfdi | --sysconfd | --sysconf \ - | --syscon | --sysco | --sysc | --sys | --sy) - ac_prev=sysconfdir ;; - -sysconfdir=* | --sysconfdir=* | --sysconfdi=* | --sysconfd=* | --sysconf=* \ - | --syscon=* | --sysco=* | --sysc=* | --sys=* | --sy=*) - sysconfdir=$ac_optarg ;; - - -target | --target | --targe | --targ | --tar | --ta | --t) - ac_prev=target_alias ;; - -target=* | --target=* | --targe=* | --targ=* | --tar=* | --ta=* | --t=*) - target_alias=$ac_optarg ;; - - -v | -verbose | --verbose | --verbos | --verbo | --verb) - verbose=yes ;; - - -version | --version | --versio | --versi | --vers | -V) - ac_init_version=: ;; - - -with-* | --with-*) - ac_package=`expr "x$ac_option" : 'x-*with-\([^=]*\)'` - # Reject names that are not valid shell variable names. - expr "x$ac_package" : ".*[^-._$as_cr_alnum]" >/dev/null && - { echo "$as_me: error: invalid package name: $ac_package" >&2 - { (exit 1); exit 1; }; } - ac_package=`echo $ac_package | sed 's/[-.]/_/g'` - eval with_$ac_package=\$ac_optarg ;; - - -without-* | --without-*) - ac_package=`expr "x$ac_option" : 'x-*without-\(.*\)'` - # Reject names that are not valid shell variable names. - expr "x$ac_package" : ".*[^-._$as_cr_alnum]" >/dev/null && - { echo "$as_me: error: invalid package name: $ac_package" >&2 - { (exit 1); exit 1; }; } - ac_package=`echo $ac_package | sed 's/[-.]/_/g'` - eval with_$ac_package=no ;; - - --x) - # Obsolete; use --with-x. - with_x=yes ;; - - -x-includes | --x-includes | --x-include | --x-includ | --x-inclu \ - | --x-incl | --x-inc | --x-in | --x-i) - ac_prev=x_includes ;; - -x-includes=* | --x-includes=* | --x-include=* | --x-includ=* | --x-inclu=* \ - | --x-incl=* | --x-inc=* | --x-in=* | --x-i=*) - x_includes=$ac_optarg ;; - - -x-libraries | --x-libraries | --x-librarie | --x-librari \ - | --x-librar | --x-libra | --x-libr | --x-lib | --x-li | --x-l) - ac_prev=x_libraries ;; - -x-libraries=* | --x-libraries=* | --x-librarie=* | --x-librari=* \ - | --x-librar=* | --x-libra=* | --x-libr=* | --x-lib=* | --x-li=* | --x-l=*) - x_libraries=$ac_optarg ;; - - -*) { echo "$as_me: error: unrecognized option: $ac_option -Try \`$0 --help' for more information." >&2 - { (exit 1); exit 1; }; } - ;; - - *=*) - ac_envvar=`expr "x$ac_option" : 'x\([^=]*\)='` - # Reject names that are not valid shell variable names. - expr "x$ac_envvar" : ".*[^_$as_cr_alnum]" >/dev/null && - { echo "$as_me: error: invalid variable name: $ac_envvar" >&2 - { (exit 1); exit 1; }; } - eval $ac_envvar=\$ac_optarg - export $ac_envvar ;; - - *) - # FIXME: should be removed in autoconf 3.0. - echo "$as_me: WARNING: you should use --build, --host, --target" >&2 - expr "x$ac_option" : ".*[^-._$as_cr_alnum]" >/dev/null && - echo "$as_me: WARNING: invalid host type: $ac_option" >&2 - : ${build_alias=$ac_option} ${host_alias=$ac_option} ${target_alias=$ac_option} - ;; - - esac -done - -if test -n "$ac_prev"; then - ac_option=--`echo $ac_prev | sed 's/_/-/g'` - { echo "$as_me: error: missing argument to $ac_option" >&2 - { (exit 1); exit 1; }; } -fi - -# Be sure to have absolute directory names. -for ac_var in exec_prefix prefix bindir sbindir libexecdir datarootdir \ - datadir sysconfdir sharedstatedir localstatedir includedir \ - oldincludedir docdir infodir htmldir dvidir pdfdir psdir \ - libdir localedir mandir -do - eval ac_val=\$$ac_var - case $ac_val in - [\\/$]* | ?:[\\/]* ) continue;; - NONE | '' ) case $ac_var in *prefix ) continue;; esac;; - esac - { echo "$as_me: error: expected an absolute directory name for --$ac_var: $ac_val" >&2 - { (exit 1); exit 1; }; } -done - -# There might be people who depend on the old broken behavior: `$host' -# used to hold the argument of --host etc. -# FIXME: To remove some day. -build=$build_alias -host=$host_alias -target=$target_alias - -# FIXME: To remove some day. -if test "x$host_alias" != x; then - if test "x$build_alias" = x; then - cross_compiling=maybe - echo "$as_me: WARNING: If you wanted to set the --build type, don't use --host. - If a cross compiler is detected then cross compile mode will be used." >&2 - elif test "x$build_alias" != "x$host_alias"; then - cross_compiling=yes - fi -fi - -ac_tool_prefix= -test -n "$host_alias" && ac_tool_prefix=$host_alias- - -test "$silent" = yes && exec 6>/dev/null - - -ac_pwd=`pwd` && test -n "$ac_pwd" && -ac_ls_di=`ls -di .` && -ac_pwd_ls_di=`cd "$ac_pwd" && ls -di .` || - { echo "$as_me: error: Working directory cannot be determined" >&2 - { (exit 1); exit 1; }; } -test "X$ac_ls_di" = "X$ac_pwd_ls_di" || - { echo "$as_me: error: pwd does not report name of working directory" >&2 - { (exit 1); exit 1; }; } - - -# Find the source files, if location was not specified. -if test -z "$srcdir"; then - ac_srcdir_defaulted=yes - # Try the directory containing this script, then the parent directory. - ac_confdir=`$as_dirname -- "$0" || -$as_expr X"$0" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ - X"$0" : 'X\(//\)[^/]' \| \ - X"$0" : 'X\(//\)$' \| \ - X"$0" : 'X\(/\)' \| . 2>/dev/null || -echo X"$0" | - sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ - s//\1/ - q - } - /^X\(\/\/\)[^/].*/{ - s//\1/ - q - } - /^X\(\/\/\)$/{ - s//\1/ - q - } - /^X\(\/\).*/{ - s//\1/ - q - } - s/.*/./; q'` - srcdir=$ac_confdir - if test ! -r "$srcdir/$ac_unique_file"; then - srcdir=.. - fi -else - ac_srcdir_defaulted=no -fi -if test ! -r "$srcdir/$ac_unique_file"; then - test "$ac_srcdir_defaulted" = yes && srcdir="$ac_confdir or .." - { echo "$as_me: error: cannot find sources ($ac_unique_file) in $srcdir" >&2 - { (exit 1); exit 1; }; } -fi -ac_msg="sources are in $srcdir, but \`cd $srcdir' does not work" -ac_abs_confdir=`( - cd "$srcdir" && test -r "./$ac_unique_file" || { echo "$as_me: error: $ac_msg" >&2 - { (exit 1); exit 1; }; } - pwd)` -# When building in place, set srcdir=. -if test "$ac_abs_confdir" = "$ac_pwd"; then - srcdir=. -fi -# Remove unnecessary trailing slashes from srcdir. -# Double slashes in file names in object file debugging info -# mess up M-x gdb in Emacs. -case $srcdir in -*/) srcdir=`expr "X$srcdir" : 'X\(.*[^/]\)' \| "X$srcdir" : 'X\(.*\)'`;; -esac -for ac_var in $ac_precious_vars; do - eval ac_env_${ac_var}_set=\${${ac_var}+set} - eval ac_env_${ac_var}_value=\$${ac_var} - eval ac_cv_env_${ac_var}_set=\${${ac_var}+set} - eval ac_cv_env_${ac_var}_value=\$${ac_var} -done - -# -# Report the --help message. -# -if test "$ac_init_help" = "long"; then - # Omit some internal or obsolete options to make the list less imposing. - # This message is too long to be a string in the A/UX 3.1 sh. - cat <<_ACEOF -\`configure' configures stow 2.0.2 to adapt to many kinds of systems. - -Usage: $0 [OPTION]... [VAR=VALUE]... - -To assign environment variables (e.g., CC, CFLAGS...), specify them as -VAR=VALUE. See below for descriptions of some of the useful variables. - -Defaults for the options are specified in brackets. - -Configuration: - -h, --help display this help and exit - --help=short display options specific to this package - --help=recursive display the short help of all the included packages - -V, --version display version information and exit - -q, --quiet, --silent do not print \`checking...' messages - --cache-file=FILE cache test results in FILE [disabled] - -C, --config-cache alias for \`--cache-file=config.cache' - -n, --no-create do not create output files - --srcdir=DIR find the sources in DIR [configure dir or \`..'] - -Installation directories: - --prefix=PREFIX install architecture-independent files in PREFIX - [$ac_default_prefix] - --exec-prefix=EPREFIX install architecture-dependent files in EPREFIX - [PREFIX] - -By default, \`make install' will install all the files in -\`$ac_default_prefix/bin', \`$ac_default_prefix/lib' etc. You can specify -an installation prefix other than \`$ac_default_prefix' using \`--prefix', -for instance \`--prefix=\$HOME'. - -For better control, use the options below. - -Fine tuning of the installation directories: - --bindir=DIR user executables [EPREFIX/bin] - --sbindir=DIR system admin executables [EPREFIX/sbin] - --libexecdir=DIR program executables [EPREFIX/libexec] - --sysconfdir=DIR read-only single-machine data [PREFIX/etc] - --sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com] - --localstatedir=DIR modifiable single-machine data [PREFIX/var] - --libdir=DIR object code libraries [EPREFIX/lib] - --includedir=DIR C header files [PREFIX/include] - --oldincludedir=DIR C header files for non-gcc [/usr/include] - --datarootdir=DIR read-only arch.-independent data root [PREFIX/share] - --datadir=DIR read-only architecture-independent data [DATAROOTDIR] - --infodir=DIR info documentation [DATAROOTDIR/info] - --localedir=DIR locale-dependent data [DATAROOTDIR/locale] - --mandir=DIR man documentation [DATAROOTDIR/man] - --docdir=DIR documentation root [DATAROOTDIR/doc/stow] - --htmldir=DIR html documentation [DOCDIR] - --dvidir=DIR dvi documentation [DOCDIR] - --pdfdir=DIR pdf documentation [DOCDIR] - --psdir=DIR ps documentation [DOCDIR] -_ACEOF - - cat <<\_ACEOF - -Program names: - --program-prefix=PREFIX prepend PREFIX to installed program names - --program-suffix=SUFFIX append SUFFIX to installed program names - --program-transform-name=PROGRAM run sed PROGRAM on installed program names -_ACEOF -fi - -if test -n "$ac_init_help"; then - case $ac_init_help in - short | recursive ) echo "Configuration of stow 2.0.2:";; - esac - cat <<\_ACEOF - -Report bugs to . -_ACEOF -ac_status=$? -fi - -if test "$ac_init_help" = "recursive"; then - # If there are subdirs, report their specific --help. - for ac_dir in : $ac_subdirs_all; do test "x$ac_dir" = x: && continue - test -d "$ac_dir" || continue - ac_builddir=. - -case "$ac_dir" in -.) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;; -*) - ac_dir_suffix=/`echo "$ac_dir" | sed 's,^\.[\\/],,'` - # A ".." for each directory in $ac_dir_suffix. - ac_top_builddir_sub=`echo "$ac_dir_suffix" | sed 's,/[^\\/]*,/..,g;s,/,,'` - case $ac_top_builddir_sub in - "") ac_top_builddir_sub=. ac_top_build_prefix= ;; - *) ac_top_build_prefix=$ac_top_builddir_sub/ ;; - esac ;; -esac -ac_abs_top_builddir=$ac_pwd -ac_abs_builddir=$ac_pwd$ac_dir_suffix -# for backward compatibility: -ac_top_builddir=$ac_top_build_prefix - -case $srcdir in - .) # We are building in place. - ac_srcdir=. - ac_top_srcdir=$ac_top_builddir_sub - ac_abs_top_srcdir=$ac_pwd ;; - [\\/]* | ?:[\\/]* ) # Absolute name. - ac_srcdir=$srcdir$ac_dir_suffix; - ac_top_srcdir=$srcdir - ac_abs_top_srcdir=$srcdir ;; - *) # Relative name. - ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix - ac_top_srcdir=$ac_top_build_prefix$srcdir - ac_abs_top_srcdir=$ac_pwd/$srcdir ;; -esac -ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix - - cd "$ac_dir" || { ac_status=$?; continue; } - # Check for guested configure. - if test -f "$ac_srcdir/configure.gnu"; then - echo && - $SHELL "$ac_srcdir/configure.gnu" --help=recursive - elif test -f "$ac_srcdir/configure"; then - echo && - $SHELL "$ac_srcdir/configure" --help=recursive - else - echo "$as_me: WARNING: no configuration information is in $ac_dir" >&2 - fi || ac_status=$? - cd "$ac_pwd" || { ac_status=$?; break; } - done -fi - -test -n "$ac_init_help" && exit $ac_status -if $ac_init_version; then - cat <<\_ACEOF -stow configure 2.0.2 -generated by GNU Autoconf 2.61 - -Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001, -2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc. -This configure script is free software; the Free Software Foundation -gives unlimited permission to copy, distribute and modify it. -_ACEOF - exit -fi -cat >config.log <<_ACEOF -This file contains any messages produced by compilers while -running configure, to aid debugging if configure makes a mistake. - -It was created by stow $as_me 2.0.2, which was -generated by GNU Autoconf 2.61. Invocation command line was - - $ $0 $@ - -_ACEOF -exec 5>>config.log -{ -cat <<_ASUNAME -## --------- ## -## Platform. ## -## --------- ## - -hostname = `(hostname || uname -n) 2>/dev/null | sed 1q` -uname -m = `(uname -m) 2>/dev/null || echo unknown` -uname -r = `(uname -r) 2>/dev/null || echo unknown` -uname -s = `(uname -s) 2>/dev/null || echo unknown` -uname -v = `(uname -v) 2>/dev/null || echo unknown` - -/usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null || echo unknown` -/bin/uname -X = `(/bin/uname -X) 2>/dev/null || echo unknown` - -/bin/arch = `(/bin/arch) 2>/dev/null || echo unknown` -/usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null || echo unknown` -/usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null || echo unknown` -/usr/bin/hostinfo = `(/usr/bin/hostinfo) 2>/dev/null || echo unknown` -/bin/machine = `(/bin/machine) 2>/dev/null || echo unknown` -/usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null || echo unknown` -/bin/universe = `(/bin/universe) 2>/dev/null || echo unknown` - -_ASUNAME - -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - echo "PATH: $as_dir" -done -IFS=$as_save_IFS - -} >&5 - -cat >&5 <<_ACEOF - - -## ----------- ## -## Core tests. ## -## ----------- ## - -_ACEOF - - -# Keep a trace of the command line. -# Strip out --no-create and --no-recursion so they do not pile up. -# Strip out --silent because we don't want to record it for future runs. -# Also quote any args containing shell meta-characters. -# Make two passes to allow for proper duplicate-argument suppression. -ac_configure_args= -ac_configure_args0= -ac_configure_args1= -ac_must_keep_next=false -for ac_pass in 1 2 -do - for ac_arg - do - case $ac_arg in - -no-create | --no-c* | -n | -no-recursion | --no-r*) continue ;; - -q | -quiet | --quiet | --quie | --qui | --qu | --q \ - | -silent | --silent | --silen | --sile | --sil) - continue ;; - *\'*) - ac_arg=`echo "$ac_arg" | sed "s/'/'\\\\\\\\''/g"` ;; - esac - case $ac_pass in - 1) ac_configure_args0="$ac_configure_args0 '$ac_arg'" ;; - 2) - ac_configure_args1="$ac_configure_args1 '$ac_arg'" - if test $ac_must_keep_next = true; then - ac_must_keep_next=false # Got value, back to normal. - else - case $ac_arg in - *=* | --config-cache | -C | -disable-* | --disable-* \ - | -enable-* | --enable-* | -gas | --g* | -nfp | --nf* \ - | -q | -quiet | --q* | -silent | --sil* | -v | -verb* \ - | -with-* | --with-* | -without-* | --without-* | --x) - case "$ac_configure_args0 " in - "$ac_configure_args1"*" '$ac_arg' "* ) continue ;; - esac - ;; - -* ) ac_must_keep_next=true ;; - esac - fi - ac_configure_args="$ac_configure_args '$ac_arg'" - ;; - esac - done -done -$as_unset ac_configure_args0 || test "${ac_configure_args0+set}" != set || { ac_configure_args0=; export ac_configure_args0; } -$as_unset ac_configure_args1 || test "${ac_configure_args1+set}" != set || { ac_configure_args1=; export ac_configure_args1; } - -# When interrupted or exit'd, cleanup temporary files, and complete -# config.log. We remove comments because anyway the quotes in there -# would cause problems or look ugly. -# WARNING: Use '\'' to represent an apostrophe within the trap. -# WARNING: Do not start the trap code with a newline, due to a FreeBSD 4.0 bug. -trap 'exit_status=$? - # Save into config.log some information that might help in debugging. - { - echo - - cat <<\_ASBOX -## ---------------- ## -## Cache variables. ## -## ---------------- ## -_ASBOX - echo - # The following way of writing the cache mishandles newlines in values, -( - for ac_var in `(set) 2>&1 | sed -n '\''s/^\([a-zA-Z_][a-zA-Z0-9_]*\)=.*/\1/p'\''`; do - eval ac_val=\$$ac_var - case $ac_val in #( - *${as_nl}*) - case $ac_var in #( - *_cv_*) { echo "$as_me:$LINENO: WARNING: Cache variable $ac_var contains a newline." >&5 -echo "$as_me: WARNING: Cache variable $ac_var contains a newline." >&2;} ;; - esac - case $ac_var in #( - _ | IFS | as_nl) ;; #( - *) $as_unset $ac_var ;; - esac ;; - esac - done - (set) 2>&1 | - case $as_nl`(ac_space='\'' '\''; set) 2>&1` in #( - *${as_nl}ac_space=\ *) - sed -n \ - "s/'\''/'\''\\\\'\'''\''/g; - s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\''\\2'\''/p" - ;; #( - *) - sed -n "/^[_$as_cr_alnum]*_cv_[_$as_cr_alnum]*=/p" - ;; - esac | - sort -) - echo - - cat <<\_ASBOX -## ----------------- ## -## Output variables. ## -## ----------------- ## -_ASBOX - echo - for ac_var in $ac_subst_vars - do - eval ac_val=\$$ac_var - case $ac_val in - *\'\''*) ac_val=`echo "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;; - esac - echo "$ac_var='\''$ac_val'\''" - done | sort - echo - - if test -n "$ac_subst_files"; then - cat <<\_ASBOX -## ------------------- ## -## File substitutions. ## -## ------------------- ## -_ASBOX - echo - for ac_var in $ac_subst_files - do - eval ac_val=\$$ac_var - case $ac_val in - *\'\''*) ac_val=`echo "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;; - esac - echo "$ac_var='\''$ac_val'\''" - done | sort - echo - fi - - if test -s confdefs.h; then - cat <<\_ASBOX -## ----------- ## -## confdefs.h. ## -## ----------- ## -_ASBOX - echo - cat confdefs.h - echo - fi - test "$ac_signal" != 0 && - echo "$as_me: caught signal $ac_signal" - echo "$as_me: exit $exit_status" - } >&5 - rm -f core *.core core.conftest.* && - rm -f -r conftest* confdefs* conf$$* $ac_clean_files && - exit $exit_status -' 0 -for ac_signal in 1 2 13 15; do - trap 'ac_signal='$ac_signal'; { (exit 1); exit 1; }' $ac_signal -done -ac_signal=0 - -# confdefs.h avoids OS command line length limits that DEFS can exceed. -rm -f -r conftest* confdefs.h - -# Predefined preprocessor variables. - -cat >>confdefs.h <<_ACEOF -#define PACKAGE_NAME "$PACKAGE_NAME" -_ACEOF - - -cat >>confdefs.h <<_ACEOF -#define PACKAGE_TARNAME "$PACKAGE_TARNAME" -_ACEOF - - -cat >>confdefs.h <<_ACEOF -#define PACKAGE_VERSION "$PACKAGE_VERSION" -_ACEOF - - -cat >>confdefs.h <<_ACEOF -#define PACKAGE_STRING "$PACKAGE_STRING" -_ACEOF - - -cat >>confdefs.h <<_ACEOF -#define PACKAGE_BUGREPORT "$PACKAGE_BUGREPORT" -_ACEOF - - -# Let the site file select an alternate cache file if it wants to. -# Prefer explicitly selected file to automatically selected ones. -if test -n "$CONFIG_SITE"; then - set x "$CONFIG_SITE" -elif test "x$prefix" != xNONE; then - set x "$prefix/share/config.site" "$prefix/etc/config.site" -else - set x "$ac_default_prefix/share/config.site" \ - "$ac_default_prefix/etc/config.site" -fi -shift -for ac_site_file -do - if test -r "$ac_site_file"; then - { echo "$as_me:$LINENO: loading site script $ac_site_file" >&5 -echo "$as_me: loading site script $ac_site_file" >&6;} - sed 's/^/| /' "$ac_site_file" >&5 - . "$ac_site_file" - fi -done - -if test -r "$cache_file"; then - # Some versions of bash will fail to source /dev/null (special - # files actually), so we avoid doing that. - if test -f "$cache_file"; then - { echo "$as_me:$LINENO: loading cache $cache_file" >&5 -echo "$as_me: loading cache $cache_file" >&6;} - case $cache_file in - [\\/]* | ?:[\\/]* ) . "$cache_file";; - *) . "./$cache_file";; - esac - fi -else - { echo "$as_me:$LINENO: creating cache $cache_file" >&5 -echo "$as_me: creating cache $cache_file" >&6;} - >$cache_file -fi - -# Check that the precious variables saved in the cache have kept the same -# value. -ac_cache_corrupted=false -for ac_var in $ac_precious_vars; do - eval ac_old_set=\$ac_cv_env_${ac_var}_set - eval ac_new_set=\$ac_env_${ac_var}_set - eval ac_old_val=\$ac_cv_env_${ac_var}_value - eval ac_new_val=\$ac_env_${ac_var}_value - case $ac_old_set,$ac_new_set in - set,) - { echo "$as_me:$LINENO: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&5 -echo "$as_me: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&2;} - ac_cache_corrupted=: ;; - ,set) - { echo "$as_me:$LINENO: error: \`$ac_var' was not set in the previous run" >&5 -echo "$as_me: error: \`$ac_var' was not set in the previous run" >&2;} - ac_cache_corrupted=: ;; - ,);; - *) - if test "x$ac_old_val" != "x$ac_new_val"; then - { echo "$as_me:$LINENO: error: \`$ac_var' has changed since the previous run:" >&5 -echo "$as_me: error: \`$ac_var' has changed since the previous run:" >&2;} - { echo "$as_me:$LINENO: former value: $ac_old_val" >&5 -echo "$as_me: former value: $ac_old_val" >&2;} - { echo "$as_me:$LINENO: current value: $ac_new_val" >&5 -echo "$as_me: current value: $ac_new_val" >&2;} - ac_cache_corrupted=: - fi;; - esac - # Pass precious variables to config.status. - if test "$ac_new_set" = set; then - case $ac_new_val in - *\'*) ac_arg=$ac_var=`echo "$ac_new_val" | sed "s/'/'\\\\\\\\''/g"` ;; - *) ac_arg=$ac_var=$ac_new_val ;; - esac - case " $ac_configure_args " in - *" '$ac_arg' "*) ;; # Avoid dups. Use of quotes ensures accuracy. - *) ac_configure_args="$ac_configure_args '$ac_arg'" ;; - esac - fi -done -if $ac_cache_corrupted; then - { echo "$as_me:$LINENO: error: changes in the environment can compromise the build" >&5 -echo "$as_me: error: changes in the environment can compromise the build" >&2;} - { { echo "$as_me:$LINENO: error: run \`make distclean' and/or \`rm $cache_file' and start over" >&5 -echo "$as_me: error: run \`make distclean' and/or \`rm $cache_file' and start over" >&2;} - { (exit 1); exit 1; }; } -fi - - - - - - - - - - - - - - - - - - - - - - - - - -ac_ext=c -ac_cpp='$CPP $CPPFLAGS' -ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' -ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' -ac_compiler_gnu=$ac_cv_c_compiler_gnu - - - -am__api_version='1.10' - -ac_aux_dir= -for ac_dir in "$srcdir" "$srcdir/.." "$srcdir/../.."; do - if test -f "$ac_dir/install-sh"; then - ac_aux_dir=$ac_dir - ac_install_sh="$ac_aux_dir/install-sh -c" - break - elif test -f "$ac_dir/install.sh"; then - ac_aux_dir=$ac_dir - ac_install_sh="$ac_aux_dir/install.sh -c" - break - elif test -f "$ac_dir/shtool"; then - ac_aux_dir=$ac_dir - ac_install_sh="$ac_aux_dir/shtool install -c" - break - fi -done -if test -z "$ac_aux_dir"; then - { { echo "$as_me:$LINENO: error: cannot find install-sh or install.sh in \"$srcdir\" \"$srcdir/..\" \"$srcdir/../..\"" >&5 -echo "$as_me: error: cannot find install-sh or install.sh in \"$srcdir\" \"$srcdir/..\" \"$srcdir/../..\"" >&2;} - { (exit 1); exit 1; }; } -fi - -# These three variables are undocumented and unsupported, -# and are intended to be withdrawn in a future Autoconf release. -# They can cause serious problems if a builder's source tree is in a directory -# whose full name contains unusual characters. -ac_config_guess="$SHELL $ac_aux_dir/config.guess" # Please don't use this var. -ac_config_sub="$SHELL $ac_aux_dir/config.sub" # Please don't use this var. -ac_configure="$SHELL $ac_aux_dir/configure" # Please don't use this var. - - -# Find a good install program. We prefer a C program (faster), -# so one script is as good as another. But avoid the broken or -# incompatible versions: -# SysV /etc/install, /usr/sbin/install -# SunOS /usr/etc/install -# IRIX /sbin/install -# AIX /bin/install -# AmigaOS /C/install, which installs bootblocks on floppy discs -# AIX 4 /usr/bin/installbsd, which doesn't work without a -g flag -# AFS /usr/afsws/bin/install, which mishandles nonexistent args -# SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff" -# OS/2's system install, which has a completely different semantic -# ./install, which can be erroneously created by make from ./install.sh. -{ echo "$as_me:$LINENO: checking for a BSD-compatible install" >&5 -echo $ECHO_N "checking for a BSD-compatible install... $ECHO_C" >&6; } -if test -z "$INSTALL"; then -if test "${ac_cv_path_install+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - # Account for people who put trailing slashes in PATH elements. -case $as_dir/ in - ./ | .// | /cC/* | \ - /etc/* | /usr/sbin/* | /usr/etc/* | /sbin/* | /usr/afsws/bin/* | \ - ?:\\/os2\\/install\\/* | ?:\\/OS2\\/INSTALL\\/* | \ - /usr/ucb/* ) ;; - *) - # OSF1 and SCO ODT 3.0 have their own names for install. - # Don't use installbsd from OSF since it installs stuff as root - # by default. - for ac_prog in ginstall scoinst install; do - for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_prog$ac_exec_ext" && $as_test_x "$as_dir/$ac_prog$ac_exec_ext"; }; then - if test $ac_prog = install && - grep dspmsg "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then - # AIX install. It has an incompatible calling convention. - : - elif test $ac_prog = install && - grep pwplus "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then - # program-specific install script used by HP pwplus--don't use. - : - else - ac_cv_path_install="$as_dir/$ac_prog$ac_exec_ext -c" - break 3 - fi - fi - done - done - ;; -esac -done -IFS=$as_save_IFS - - -fi - if test "${ac_cv_path_install+set}" = set; then - INSTALL=$ac_cv_path_install - else - # As a last resort, use the slow shell script. Don't cache a - # value for INSTALL within a source directory, because that will - # break other packages using the cache if that directory is - # removed, or if the value is a relative name. - INSTALL=$ac_install_sh - fi -fi -{ echo "$as_me:$LINENO: result: $INSTALL" >&5 -echo "${ECHO_T}$INSTALL" >&6; } - -# Use test -z because SunOS4 sh mishandles braces in ${var-val}. -# It thinks the first close brace ends the variable substitution. -test -z "$INSTALL_PROGRAM" && INSTALL_PROGRAM='${INSTALL}' - -test -z "$INSTALL_SCRIPT" && INSTALL_SCRIPT='${INSTALL}' - -test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644' - -{ echo "$as_me:$LINENO: checking whether build environment is sane" >&5 -echo $ECHO_N "checking whether build environment is sane... $ECHO_C" >&6; } -# Just in case -sleep 1 -echo timestamp > conftest.file -# Do `set' in a subshell so we don't clobber the current shell's -# arguments. Must try -L first in case configure is actually a -# symlink; some systems play weird games with the mod time of symlinks -# (eg FreeBSD returns the mod time of the symlink's containing -# directory). -if ( - set X `ls -Lt $srcdir/configure conftest.file 2> /dev/null` - if test "$*" = "X"; then - # -L didn't work. - set X `ls -t $srcdir/configure conftest.file` - fi - rm -f conftest.file - if test "$*" != "X $srcdir/configure conftest.file" \ - && test "$*" != "X conftest.file $srcdir/configure"; then - - # If neither matched, then we have a broken ls. This can happen - # if, for instance, CONFIG_SHELL is bash and it inherits a - # broken ls alias from the environment. This has actually - # happened. Such a system could not be considered "sane". - { { echo "$as_me:$LINENO: error: ls -t appears to fail. Make sure there is not a broken -alias in your environment" >&5 -echo "$as_me: error: ls -t appears to fail. Make sure there is not a broken -alias in your environment" >&2;} - { (exit 1); exit 1; }; } - fi - - test "$2" = conftest.file - ) -then - # Ok. - : -else - { { echo "$as_me:$LINENO: error: newly created file is older than distributed files! -Check your system clock" >&5 -echo "$as_me: error: newly created file is older than distributed files! -Check your system clock" >&2;} - { (exit 1); exit 1; }; } -fi -{ echo "$as_me:$LINENO: result: yes" >&5 -echo "${ECHO_T}yes" >&6; } -test "$program_prefix" != NONE && - program_transform_name="s&^&$program_prefix&;$program_transform_name" -# Use a double $ so make ignores it. -test "$program_suffix" != NONE && - program_transform_name="s&\$&$program_suffix&;$program_transform_name" -# Double any \ or $. echo might interpret backslashes. -# By default was `s,x,x', remove it if useless. -cat <<\_ACEOF >conftest.sed -s/[\\$]/&&/g;s/;s,x,x,$// -_ACEOF -program_transform_name=`echo $program_transform_name | sed -f conftest.sed` -rm -f conftest.sed - -# expand $ac_aux_dir to an absolute path -am_aux_dir=`cd $ac_aux_dir && pwd` - -test x"${MISSING+set}" = xset || MISSING="\${SHELL} $am_aux_dir/missing" -# Use eval to expand $SHELL -if eval "$MISSING --run true"; then - am_missing_run="$MISSING --run " -else - am_missing_run= - { echo "$as_me:$LINENO: WARNING: \`missing' script is too old or missing" >&5 -echo "$as_me: WARNING: \`missing' script is too old or missing" >&2;} -fi - -{ echo "$as_me:$LINENO: checking for a thread-safe mkdir -p" >&5 -echo $ECHO_N "checking for a thread-safe mkdir -p... $ECHO_C" >&6; } -if test -z "$MKDIR_P"; then - if test "${ac_cv_path_mkdir+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH$PATH_SEPARATOR/opt/sfw/bin -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_prog in mkdir gmkdir; do - for ac_exec_ext in '' $ac_executable_extensions; do - { test -f "$as_dir/$ac_prog$ac_exec_ext" && $as_test_x "$as_dir/$ac_prog$ac_exec_ext"; } || continue - case `"$as_dir/$ac_prog$ac_exec_ext" --version 2>&1` in #( - 'mkdir (GNU coreutils) '* | \ - 'mkdir (coreutils) '* | \ - 'mkdir (fileutils) '4.1*) - ac_cv_path_mkdir=$as_dir/$ac_prog$ac_exec_ext - break 3;; - esac - done - done -done -IFS=$as_save_IFS - -fi - - if test "${ac_cv_path_mkdir+set}" = set; then - MKDIR_P="$ac_cv_path_mkdir -p" - else - # As a last resort, use the slow shell script. Don't cache a - # value for MKDIR_P within a source directory, because that will - # break other packages using the cache if that directory is - # removed, or if the value is a relative name. - test -d ./--version && rmdir ./--version - MKDIR_P="$ac_install_sh -d" - fi -fi -{ echo "$as_me:$LINENO: result: $MKDIR_P" >&5 -echo "${ECHO_T}$MKDIR_P" >&6; } - -mkdir_p="$MKDIR_P" -case $mkdir_p in - [\\/$]* | ?:[\\/]*) ;; - */*) mkdir_p="\$(top_builddir)/$mkdir_p" ;; -esac - -for ac_prog in gawk mawk nawk awk -do - # Extract the first word of "$ac_prog", so it can be a program name with args. -set dummy $ac_prog; ac_word=$2 -{ echo "$as_me:$LINENO: checking for $ac_word" >&5 -echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; } -if test "${ac_cv_prog_AWK+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - if test -n "$AWK"; then - ac_cv_prog_AWK="$AWK" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then - ac_cv_prog_AWK="$ac_prog" - echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done -done -IFS=$as_save_IFS - -fi -fi -AWK=$ac_cv_prog_AWK -if test -n "$AWK"; then - { echo "$as_me:$LINENO: result: $AWK" >&5 -echo "${ECHO_T}$AWK" >&6; } -else - { echo "$as_me:$LINENO: result: no" >&5 -echo "${ECHO_T}no" >&6; } -fi - - - test -n "$AWK" && break -done - -{ echo "$as_me:$LINENO: checking whether ${MAKE-make} sets \$(MAKE)" >&5 -echo $ECHO_N "checking whether ${MAKE-make} sets \$(MAKE)... $ECHO_C" >&6; } -set x ${MAKE-make}; ac_make=`echo "$2" | sed 's/+/p/g; s/[^a-zA-Z0-9_]/_/g'` -if { as_var=ac_cv_prog_make_${ac_make}_set; eval "test \"\${$as_var+set}\" = set"; }; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - cat >conftest.make <<\_ACEOF -SHELL = /bin/sh -all: - @echo '@@@%%%=$(MAKE)=@@@%%%' -_ACEOF -# GNU make sometimes prints "make[1]: Entering...", which would confuse us. -case `${MAKE-make} -f conftest.make 2>/dev/null` in - *@@@%%%=?*=@@@%%%*) - eval ac_cv_prog_make_${ac_make}_set=yes;; - *) - eval ac_cv_prog_make_${ac_make}_set=no;; -esac -rm -f conftest.make -fi -if eval test \$ac_cv_prog_make_${ac_make}_set = yes; then - { echo "$as_me:$LINENO: result: yes" >&5 -echo "${ECHO_T}yes" >&6; } - SET_MAKE= -else - { echo "$as_me:$LINENO: result: no" >&5 -echo "${ECHO_T}no" >&6; } - SET_MAKE="MAKE=${MAKE-make}" -fi - -rm -rf .tst 2>/dev/null -mkdir .tst 2>/dev/null -if test -d .tst; then - am__leading_dot=. -else - am__leading_dot=_ -fi -rmdir .tst 2>/dev/null - -if test "`cd $srcdir && pwd`" != "`pwd`"; then - # Use -I$(srcdir) only when $(srcdir) != ., so that make's output - # is not polluted with repeated "-I." - am__isrc=' -I$(srcdir)' - # test to see if srcdir already configured - if test -f $srcdir/config.status; then - { { echo "$as_me:$LINENO: error: source directory already configured; run \"make distclean\" there first" >&5 -echo "$as_me: error: source directory already configured; run \"make distclean\" there first" >&2;} - { (exit 1); exit 1; }; } - fi -fi - -# test whether we have cygpath -if test -z "$CYGPATH_W"; then - if (cygpath --version) >/dev/null 2>/dev/null; then - CYGPATH_W='cygpath -w' - else - CYGPATH_W=echo - fi -fi - - -# Define the identity of the package. - PACKAGE='stow' - VERSION='2.0.2' - - -cat >>confdefs.h <<_ACEOF -#define PACKAGE "$PACKAGE" -_ACEOF - - -cat >>confdefs.h <<_ACEOF -#define VERSION "$VERSION" -_ACEOF - -# Some tools Automake needs. - -ACLOCAL=${ACLOCAL-"${am_missing_run}aclocal-${am__api_version}"} - - -AUTOCONF=${AUTOCONF-"${am_missing_run}autoconf"} - - -AUTOMAKE=${AUTOMAKE-"${am_missing_run}automake-${am__api_version}"} - - -AUTOHEADER=${AUTOHEADER-"${am_missing_run}autoheader"} - - -MAKEINFO=${MAKEINFO-"${am_missing_run}makeinfo"} - -install_sh=${install_sh-"\$(SHELL) $am_aux_dir/install-sh"} - -# Installed binaries are usually stripped using `strip' when the user -# run `make install-strip'. However `strip' might not be the right -# tool to use in cross-compilation environments, therefore Automake -# will honor the `STRIP' environment variable to overrule this program. -if test "$cross_compiling" != no; then - if test -n "$ac_tool_prefix"; then - # Extract the first word of "${ac_tool_prefix}strip", so it can be a program name with args. -set dummy ${ac_tool_prefix}strip; ac_word=$2 -{ echo "$as_me:$LINENO: checking for $ac_word" >&5 -echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; } -if test "${ac_cv_prog_STRIP+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - if test -n "$STRIP"; then - ac_cv_prog_STRIP="$STRIP" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then - ac_cv_prog_STRIP="${ac_tool_prefix}strip" - echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done -done -IFS=$as_save_IFS - -fi -fi -STRIP=$ac_cv_prog_STRIP -if test -n "$STRIP"; then - { echo "$as_me:$LINENO: result: $STRIP" >&5 -echo "${ECHO_T}$STRIP" >&6; } -else - { echo "$as_me:$LINENO: result: no" >&5 -echo "${ECHO_T}no" >&6; } -fi - - -fi -if test -z "$ac_cv_prog_STRIP"; then - ac_ct_STRIP=$STRIP - # Extract the first word of "strip", so it can be a program name with args. -set dummy strip; ac_word=$2 -{ echo "$as_me:$LINENO: checking for $ac_word" >&5 -echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; } -if test "${ac_cv_prog_ac_ct_STRIP+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - if test -n "$ac_ct_STRIP"; then - ac_cv_prog_ac_ct_STRIP="$ac_ct_STRIP" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then - ac_cv_prog_ac_ct_STRIP="strip" - echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done -done -IFS=$as_save_IFS - -fi -fi -ac_ct_STRIP=$ac_cv_prog_ac_ct_STRIP -if test -n "$ac_ct_STRIP"; then - { echo "$as_me:$LINENO: result: $ac_ct_STRIP" >&5 -echo "${ECHO_T}$ac_ct_STRIP" >&6; } -else - { echo "$as_me:$LINENO: result: no" >&5 -echo "${ECHO_T}no" >&6; } -fi - - if test "x$ac_ct_STRIP" = x; then - STRIP=":" - else - case $cross_compiling:$ac_tool_warned in -yes:) -{ echo "$as_me:$LINENO: WARNING: In the future, Autoconf will not detect cross-tools -whose name does not start with the host triplet. If you think this -configuration is useful to you, please write to autoconf@gnu.org." >&5 -echo "$as_me: WARNING: In the future, Autoconf will not detect cross-tools -whose name does not start with the host triplet. If you think this -configuration is useful to you, please write to autoconf@gnu.org." >&2;} -ac_tool_warned=yes ;; -esac - STRIP=$ac_ct_STRIP - fi -else - STRIP="$ac_cv_prog_STRIP" -fi - -fi -INSTALL_STRIP_PROGRAM="\$(install_sh) -c -s" - -# We need awk for the "check" target. The system "awk" is bad on -# some platforms. -# Always define AMTAR for backward compatibility. - -AMTAR=${AMTAR-"${am_missing_run}tar"} - -am__tar='${AMTAR} chof - "$$tardir"'; am__untar='${AMTAR} xf -' - - - - - -# Find a good install program. We prefer a C program (faster), -# so one script is as good as another. But avoid the broken or -# incompatible versions: -# SysV /etc/install, /usr/sbin/install -# SunOS /usr/etc/install -# IRIX /sbin/install -# AIX /bin/install -# AmigaOS /C/install, which installs bootblocks on floppy discs -# AIX 4 /usr/bin/installbsd, which doesn't work without a -g flag -# AFS /usr/afsws/bin/install, which mishandles nonexistent args -# SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff" -# OS/2's system install, which has a completely different semantic -# ./install, which can be erroneously created by make from ./install.sh. -{ echo "$as_me:$LINENO: checking for a BSD-compatible install" >&5 -echo $ECHO_N "checking for a BSD-compatible install... $ECHO_C" >&6; } -if test -z "$INSTALL"; then -if test "${ac_cv_path_install+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - # Account for people who put trailing slashes in PATH elements. -case $as_dir/ in - ./ | .// | /cC/* | \ - /etc/* | /usr/sbin/* | /usr/etc/* | /sbin/* | /usr/afsws/bin/* | \ - ?:\\/os2\\/install\\/* | ?:\\/OS2\\/INSTALL\\/* | \ - /usr/ucb/* ) ;; - *) - # OSF1 and SCO ODT 3.0 have their own names for install. - # Don't use installbsd from OSF since it installs stuff as root - # by default. - for ac_prog in ginstall scoinst install; do - for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_prog$ac_exec_ext" && $as_test_x "$as_dir/$ac_prog$ac_exec_ext"; }; then - if test $ac_prog = install && - grep dspmsg "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then - # AIX install. It has an incompatible calling convention. - : - elif test $ac_prog = install && - grep pwplus "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then - # program-specific install script used by HP pwplus--don't use. - : - else - ac_cv_path_install="$as_dir/$ac_prog$ac_exec_ext -c" - break 3 - fi - fi - done - done - ;; -esac -done -IFS=$as_save_IFS - - -fi - if test "${ac_cv_path_install+set}" = set; then - INSTALL=$ac_cv_path_install - else - # As a last resort, use the slow shell script. Don't cache a - # value for INSTALL within a source directory, because that will - # break other packages using the cache if that directory is - # removed, or if the value is a relative name. - INSTALL=$ac_install_sh - fi -fi -{ echo "$as_me:$LINENO: result: $INSTALL" >&5 -echo "${ECHO_T}$INSTALL" >&6; } - -# Use test -z because SunOS4 sh mishandles braces in ${var-val}. -# It thinks the first close brace ends the variable substitution. -test -z "$INSTALL_PROGRAM" && INSTALL_PROGRAM='${INSTALL}' - -test -z "$INSTALL_SCRIPT" && INSTALL_SCRIPT='${INSTALL}' - -test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644' - - -for ac_prog in perl perl5 -do - # Extract the first word of "$ac_prog", so it can be a program name with args. -set dummy $ac_prog; ac_word=$2 -{ echo "$as_me:$LINENO: checking for $ac_word" >&5 -echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; } -if test "${ac_cv_path_PERL+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - case $PERL in - [\\/]* | ?:[\\/]*) - ac_cv_path_PERL="$PERL" # Let the user override the test with a path. - ;; - *) - as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then - ac_cv_path_PERL="$as_dir/$ac_word$ac_exec_ext" - echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done -done -IFS=$as_save_IFS - - ;; -esac -fi -PERL=$ac_cv_path_PERL -if test -n "$PERL"; then - { echo "$as_me:$LINENO: result: $PERL" >&5 -echo "${ECHO_T}$PERL" >&6; } -else - { echo "$as_me:$LINENO: result: no" >&5 -echo "${ECHO_T}no" >&6; } -fi - - - test -n "$PERL" && break -done -test -n "$PERL" || PERL="false" - -if test "x$PERL" = xfalse -then - { echo "$as_me:$LINENO: WARNING: WARNING: Perl not found; you must edit line 1 of 'stow'" >&5 -echo "$as_me: WARNING: WARNING: Perl not found; you must edit line 1 of 'stow'" >&2;} -fi - -ac_config_files="$ac_config_files Makefile" - -cat >confcache <<\_ACEOF -# This file is a shell script that caches the results of configure -# tests run on this system so they can be shared between configure -# scripts and configure runs, see configure's option --config-cache. -# It is not useful on other systems. If it contains results you don't -# want to keep, you may remove or edit it. -# -# config.status only pays attention to the cache file if you give it -# the --recheck option to rerun configure. -# -# `ac_cv_env_foo' variables (set or unset) will be overridden when -# loading this file, other *unset* `ac_cv_foo' will be assigned the -# following values. - -_ACEOF - -# The following way of writing the cache mishandles newlines in values, -# but we know of no workaround that is simple, portable, and efficient. -# So, we kill variables containing newlines. -# Ultrix sh set writes to stderr and can't be redirected directly, -# and sets the high bit in the cache file unless we assign to the vars. -( - for ac_var in `(set) 2>&1 | sed -n 's/^\([a-zA-Z_][a-zA-Z0-9_]*\)=.*/\1/p'`; do - eval ac_val=\$$ac_var - case $ac_val in #( - *${as_nl}*) - case $ac_var in #( - *_cv_*) { echo "$as_me:$LINENO: WARNING: Cache variable $ac_var contains a newline." >&5 -echo "$as_me: WARNING: Cache variable $ac_var contains a newline." >&2;} ;; - esac - case $ac_var in #( - _ | IFS | as_nl) ;; #( - *) $as_unset $ac_var ;; - esac ;; - esac - done - - (set) 2>&1 | - case $as_nl`(ac_space=' '; set) 2>&1` in #( - *${as_nl}ac_space=\ *) - # `set' does not quote correctly, so add quotes (double-quote - # substitution turns \\\\ into \\, and sed turns \\ into \). - sed -n \ - "s/'/'\\\\''/g; - s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\\2'/p" - ;; #( - *) - # `set' quotes correctly as required by POSIX, so do not add quotes. - sed -n "/^[_$as_cr_alnum]*_cv_[_$as_cr_alnum]*=/p" - ;; - esac | - sort -) | - sed ' - /^ac_cv_env_/b end - t clear - :clear - s/^\([^=]*\)=\(.*[{}].*\)$/test "${\1+set}" = set || &/ - t end - s/^\([^=]*\)=\(.*\)$/\1=${\1=\2}/ - :end' >>confcache -if diff "$cache_file" confcache >/dev/null 2>&1; then :; else - if test -w "$cache_file"; then - test "x$cache_file" != "x/dev/null" && - { echo "$as_me:$LINENO: updating cache $cache_file" >&5 -echo "$as_me: updating cache $cache_file" >&6;} - cat confcache >$cache_file - else - { echo "$as_me:$LINENO: not updating unwritable cache $cache_file" >&5 -echo "$as_me: not updating unwritable cache $cache_file" >&6;} - fi -fi -rm -f confcache - -test "x$prefix" = xNONE && prefix=$ac_default_prefix -# Let make expand exec_prefix. -test "x$exec_prefix" = xNONE && exec_prefix='${prefix}' - -# Transform confdefs.h into DEFS. -# Protect against shell expansion while executing Makefile rules. -# Protect against Makefile macro expansion. -# -# If the first sed substitution is executed (which looks for macros that -# take arguments), then branch to the quote section. Otherwise, -# look for a macro that doesn't take arguments. -ac_script=' -t clear -:clear -s/^[ ]*#[ ]*define[ ][ ]*\([^ (][^ (]*([^)]*)\)[ ]*\(.*\)/-D\1=\2/g -t quote -s/^[ ]*#[ ]*define[ ][ ]*\([^ ][^ ]*\)[ ]*\(.*\)/-D\1=\2/g -t quote -b any -:quote -s/[ `~#$^&*(){}\\|;'\''"<>?]/\\&/g -s/\[/\\&/g -s/\]/\\&/g -s/\$/$$/g -H -:any -${ - g - s/^\n// - s/\n/ /g - p -} -' -DEFS=`sed -n "$ac_script" confdefs.h` - - -ac_libobjs= -ac_ltlibobjs= -for ac_i in : $LIBOBJS; do test "x$ac_i" = x: && continue - # 1. Remove the extension, and $U if already installed. - ac_script='s/\$U\././;s/\.o$//;s/\.obj$//' - ac_i=`echo "$ac_i" | sed "$ac_script"` - # 2. Prepend LIBOBJDIR. When used with automake>=1.10 LIBOBJDIR - # will be set to the directory where LIBOBJS objects are built. - ac_libobjs="$ac_libobjs \${LIBOBJDIR}$ac_i\$U.$ac_objext" - ac_ltlibobjs="$ac_ltlibobjs \${LIBOBJDIR}$ac_i"'$U.lo' -done -LIBOBJS=$ac_libobjs - -LTLIBOBJS=$ac_ltlibobjs - - - -: ${CONFIG_STATUS=./config.status} -ac_clean_files_save=$ac_clean_files -ac_clean_files="$ac_clean_files $CONFIG_STATUS" -{ echo "$as_me:$LINENO: creating $CONFIG_STATUS" >&5 -echo "$as_me: creating $CONFIG_STATUS" >&6;} -cat >$CONFIG_STATUS <<_ACEOF -#! $SHELL -# Generated by $as_me. -# Run this file to recreate the current configuration. -# Compiler output produced by configure, useful for debugging -# configure, is in config.log if it exists. - -debug=false -ac_cs_recheck=false -ac_cs_silent=false -SHELL=\${CONFIG_SHELL-$SHELL} -_ACEOF - -cat >>$CONFIG_STATUS <<\_ACEOF -## --------------------- ## -## M4sh Initialization. ## -## --------------------- ## - -# Be more Bourne compatible -DUALCASE=1; export DUALCASE # for MKS sh -if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then - emulate sh - NULLCMD=: - # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which - # is contrary to our usage. Disable this feature. - alias -g '${1+"$@"}'='"$@"' - setopt NO_GLOB_SUBST -else - case `(set -o) 2>/dev/null` in - *posix*) set -o posix ;; -esac - -fi - - - - -# PATH needs CR -# Avoid depending upon Character Ranges. -as_cr_letters='abcdefghijklmnopqrstuvwxyz' -as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ' -as_cr_Letters=$as_cr_letters$as_cr_LETTERS -as_cr_digits='0123456789' -as_cr_alnum=$as_cr_Letters$as_cr_digits - -# The user is always right. -if test "${PATH_SEPARATOR+set}" != set; then - echo "#! /bin/sh" >conf$$.sh - echo "exit 0" >>conf$$.sh - chmod +x conf$$.sh - if (PATH="/nonexistent;."; conf$$.sh) >/dev/null 2>&1; then - PATH_SEPARATOR=';' - else - PATH_SEPARATOR=: - fi - rm -f conf$$.sh -fi - -# Support unset when possible. -if ( (MAIL=60; unset MAIL) || exit) >/dev/null 2>&1; then - as_unset=unset -else - as_unset=false -fi - - -# IFS -# We need space, tab and new line, in precisely that order. Quoting is -# there to prevent editors from complaining about space-tab. -# (If _AS_PATH_WALK were called with IFS unset, it would disable word -# splitting by setting IFS to empty value.) -as_nl=' -' -IFS=" "" $as_nl" - -# Find who we are. Look in the path if we contain no directory separator. -case $0 in - *[\\/]* ) as_myself=$0 ;; - *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break -done -IFS=$as_save_IFS - - ;; -esac -# We did not find ourselves, most probably we were run as `sh COMMAND' -# in which case we are not to be found in the path. -if test "x$as_myself" = x; then - as_myself=$0 -fi -if test ! -f "$as_myself"; then - echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2 - { (exit 1); exit 1; } -fi - -# Work around bugs in pre-3.0 UWIN ksh. -for as_var in ENV MAIL MAILPATH -do ($as_unset $as_var) >/dev/null 2>&1 && $as_unset $as_var -done -PS1='$ ' -PS2='> ' -PS4='+ ' - -# NLS nuisances. -for as_var in \ - LANG LANGUAGE LC_ADDRESS LC_ALL LC_COLLATE LC_CTYPE LC_IDENTIFICATION \ - LC_MEASUREMENT LC_MESSAGES LC_MONETARY LC_NAME LC_NUMERIC LC_PAPER \ - LC_TELEPHONE LC_TIME -do - if (set +x; test -z "`(eval $as_var=C; export $as_var) 2>&1`"); then - eval $as_var=C; export $as_var - else - ($as_unset $as_var) >/dev/null 2>&1 && $as_unset $as_var - fi -done - -# Required to use basename. -if expr a : '\(a\)' >/dev/null 2>&1 && - test "X`expr 00001 : '.*\(...\)'`" = X001; then - as_expr=expr -else - as_expr=false -fi - -if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then - as_basename=basename -else - as_basename=false -fi - - -# Name of the executable. -as_me=`$as_basename -- "$0" || -$as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \ - X"$0" : 'X\(//\)$' \| \ - X"$0" : 'X\(/\)' \| . 2>/dev/null || -echo X/"$0" | - sed '/^.*\/\([^/][^/]*\)\/*$/{ - s//\1/ - q - } - /^X\/\(\/\/\)$/{ - s//\1/ - q - } - /^X\/\(\/\).*/{ - s//\1/ - q - } - s/.*/./; q'` - -# CDPATH. -$as_unset CDPATH - - - - as_lineno_1=$LINENO - as_lineno_2=$LINENO - test "x$as_lineno_1" != "x$as_lineno_2" && - test "x`expr $as_lineno_1 + 1`" = "x$as_lineno_2" || { - - # Create $as_me.lineno as a copy of $as_myself, but with $LINENO - # uniformly replaced by the line number. The first 'sed' inserts a - # line-number line after each line using $LINENO; the second 'sed' - # does the real work. The second script uses 'N' to pair each - # line-number line with the line containing $LINENO, and appends - # trailing '-' during substitution so that $LINENO is not a special - # case at line end. - # (Raja R Harinath suggested sed '=', and Paul Eggert wrote the - # scripts with optimization help from Paolo Bonzini. Blame Lee - # E. McMahon (1931-1989) for sed's syntax. :-) - sed -n ' - p - /[$]LINENO/= - ' <$as_myself | - sed ' - s/[$]LINENO.*/&-/ - t lineno - b - :lineno - N - :loop - s/[$]LINENO\([^'$as_cr_alnum'_].*\n\)\(.*\)/\2\1\2/ - t loop - s/-\n.*// - ' >$as_me.lineno && - chmod +x "$as_me.lineno" || - { echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2 - { (exit 1); exit 1; }; } - - # Don't try to exec as it changes $[0], causing all sort of problems - # (the dirname of $[0] is not the place where we might find the - # original and so on. Autoconf is especially sensitive to this). - . "./$as_me.lineno" - # Exit status is that of the last command. - exit -} - - -if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then - as_dirname=dirname -else - as_dirname=false -fi - -ECHO_C= ECHO_N= ECHO_T= -case `echo -n x` in --n*) - case `echo 'x\c'` in - *c*) ECHO_T=' ';; # ECHO_T is single tab character. - *) ECHO_C='\c';; - esac;; -*) - ECHO_N='-n';; -esac - -if expr a : '\(a\)' >/dev/null 2>&1 && - test "X`expr 00001 : '.*\(...\)'`" = X001; then - as_expr=expr -else - as_expr=false -fi - -rm -f conf$$ conf$$.exe conf$$.file -if test -d conf$$.dir; then - rm -f conf$$.dir/conf$$.file -else - rm -f conf$$.dir - mkdir conf$$.dir -fi -echo >conf$$.file -if ln -s conf$$.file conf$$ 2>/dev/null; then - as_ln_s='ln -s' - # ... but there are two gotchas: - # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail. - # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable. - # In both cases, we have to default to `cp -p'. - ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe || - as_ln_s='cp -p' -elif ln conf$$.file conf$$ 2>/dev/null; then - as_ln_s=ln -else - as_ln_s='cp -p' -fi -rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file -rmdir conf$$.dir 2>/dev/null - -if mkdir -p . 2>/dev/null; then - as_mkdir_p=: -else - test -d ./-p && rmdir ./-p - as_mkdir_p=false -fi - -if test -x / >/dev/null 2>&1; then - as_test_x='test -x' -else - if ls -dL / >/dev/null 2>&1; then - as_ls_L_option=L - else - as_ls_L_option= - fi - as_test_x=' - eval sh -c '\'' - if test -d "$1"; then - test -d "$1/."; - else - case $1 in - -*)set "./$1";; - esac; - case `ls -ld'$as_ls_L_option' "$1" 2>/dev/null` in - ???[sx]*):;;*)false;;esac;fi - '\'' sh - ' -fi -as_executable_p=$as_test_x - -# Sed expression to map a string onto a valid CPP name. -as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'" - -# Sed expression to map a string onto a valid variable name. -as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'" - - -exec 6>&1 - -# Save the log message, to keep $[0] and so on meaningful, and to -# report actual input values of CONFIG_FILES etc. instead of their -# values after options handling. -ac_log=" -This file was extended by stow $as_me 2.0.2, which was -generated by GNU Autoconf 2.61. Invocation command line was - - CONFIG_FILES = $CONFIG_FILES - CONFIG_HEADERS = $CONFIG_HEADERS - CONFIG_LINKS = $CONFIG_LINKS - CONFIG_COMMANDS = $CONFIG_COMMANDS - $ $0 $@ - -on `(hostname || uname -n) 2>/dev/null | sed 1q` -" - -_ACEOF - -cat >>$CONFIG_STATUS <<_ACEOF -# Files that config.status was made for. -config_files="$ac_config_files" - -_ACEOF - -cat >>$CONFIG_STATUS <<\_ACEOF -ac_cs_usage="\ -\`$as_me' instantiates files from templates according to the -current configuration. - -Usage: $0 [OPTIONS] [FILE]... - - -h, --help print this help, then exit - -V, --version print version number and configuration settings, then exit - -q, --quiet do not print progress messages - -d, --debug don't remove temporary files - --recheck update $as_me by reconfiguring in the same conditions - --file=FILE[:TEMPLATE] - instantiate the configuration file FILE - -Configuration files: -$config_files - -Report bugs to ." - -_ACEOF -cat >>$CONFIG_STATUS <<_ACEOF -ac_cs_version="\\ -stow config.status 2.0.2 -configured by $0, generated by GNU Autoconf 2.61, - with options \\"`echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`\\" - -Copyright (C) 2006 Free Software Foundation, Inc. -This config.status script is free software; the Free Software Foundation -gives unlimited permission to copy, distribute and modify it." - -ac_pwd='$ac_pwd' -srcdir='$srcdir' -INSTALL='$INSTALL' -MKDIR_P='$MKDIR_P' -_ACEOF - -cat >>$CONFIG_STATUS <<\_ACEOF -# If no file are specified by the user, then we need to provide default -# value. By we need to know if files were specified by the user. -ac_need_defaults=: -while test $# != 0 -do - case $1 in - --*=*) - ac_option=`expr "X$1" : 'X\([^=]*\)='` - ac_optarg=`expr "X$1" : 'X[^=]*=\(.*\)'` - ac_shift=: - ;; - *) - ac_option=$1 - ac_optarg=$2 - ac_shift=shift - ;; - esac - - case $ac_option in - # Handling of the options. - -recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r) - ac_cs_recheck=: ;; - --version | --versio | --versi | --vers | --ver | --ve | --v | -V ) - echo "$ac_cs_version"; exit ;; - --debug | --debu | --deb | --de | --d | -d ) - debug=: ;; - --file | --fil | --fi | --f ) - $ac_shift - CONFIG_FILES="$CONFIG_FILES $ac_optarg" - ac_need_defaults=false;; - --he | --h | --help | --hel | -h ) - echo "$ac_cs_usage"; exit ;; - -q | -quiet | --quiet | --quie | --qui | --qu | --q \ - | -silent | --silent | --silen | --sile | --sil | --si | --s) - ac_cs_silent=: ;; - - # This is an error. - -*) { echo "$as_me: error: unrecognized option: $1 -Try \`$0 --help' for more information." >&2 - { (exit 1); exit 1; }; } ;; - - *) ac_config_targets="$ac_config_targets $1" - ac_need_defaults=false ;; - - esac - shift -done - -ac_configure_extra_args= - -if $ac_cs_silent; then - exec 6>/dev/null - ac_configure_extra_args="$ac_configure_extra_args --silent" -fi - -_ACEOF -cat >>$CONFIG_STATUS <<_ACEOF -if \$ac_cs_recheck; then - echo "running CONFIG_SHELL=$SHELL $SHELL $0 "$ac_configure_args \$ac_configure_extra_args " --no-create --no-recursion" >&6 - CONFIG_SHELL=$SHELL - export CONFIG_SHELL - exec $SHELL "$0"$ac_configure_args \$ac_configure_extra_args --no-create --no-recursion -fi - -_ACEOF -cat >>$CONFIG_STATUS <<\_ACEOF -exec 5>>config.log -{ - echo - sed 'h;s/./-/g;s/^.../## /;s/...$/ ##/;p;x;p;x' <<_ASBOX -## Running $as_me. ## -_ASBOX - echo "$ac_log" -} >&5 - -_ACEOF -cat >>$CONFIG_STATUS <<_ACEOF -_ACEOF - -cat >>$CONFIG_STATUS <<\_ACEOF - -# Handling of arguments. -for ac_config_target in $ac_config_targets -do - case $ac_config_target in - "Makefile") CONFIG_FILES="$CONFIG_FILES Makefile" ;; - - *) { { echo "$as_me:$LINENO: error: invalid argument: $ac_config_target" >&5 -echo "$as_me: error: invalid argument: $ac_config_target" >&2;} - { (exit 1); exit 1; }; };; - esac -done - - -# If the user did not use the arguments to specify the items to instantiate, -# then the envvar interface is used. Set only those that are not. -# We use the long form for the default assignment because of an extremely -# bizarre bug on SunOS 4.1.3. -if $ac_need_defaults; then - test "${CONFIG_FILES+set}" = set || CONFIG_FILES=$config_files -fi - -# Have a temporary directory for convenience. Make it in the build tree -# simply because there is no reason against having it here, and in addition, -# creating and moving files from /tmp can sometimes cause problems. -# Hook for its removal unless debugging. -# Note that there is a small window in which the directory will not be cleaned: -# after its creation but before its name has been assigned to `$tmp'. -$debug || -{ - tmp= - trap 'exit_status=$? - { test -z "$tmp" || test ! -d "$tmp" || rm -fr "$tmp"; } && exit $exit_status -' 0 - trap '{ (exit 1); exit 1; }' 1 2 13 15 -} -# Create a (secure) tmp directory for tmp files. - -{ - tmp=`(umask 077 && mktemp -d "./confXXXXXX") 2>/dev/null` && - test -n "$tmp" && test -d "$tmp" -} || -{ - tmp=./conf$$-$RANDOM - (umask 077 && mkdir "$tmp") -} || -{ - echo "$me: cannot create a temporary directory in ." >&2 - { (exit 1); exit 1; } -} - -# -# Set up the sed scripts for CONFIG_FILES section. -# - -# No need to generate the scripts if there are no CONFIG_FILES. -# This happens for instance when ./config.status config.h -if test -n "$CONFIG_FILES"; then - -_ACEOF - - - -ac_delim='%!_!# ' -for ac_last_try in false false false false false :; do - cat >conf$$subs.sed <<_ACEOF -SHELL!$SHELL$ac_delim -PATH_SEPARATOR!$PATH_SEPARATOR$ac_delim -PACKAGE_NAME!$PACKAGE_NAME$ac_delim -PACKAGE_TARNAME!$PACKAGE_TARNAME$ac_delim -PACKAGE_VERSION!$PACKAGE_VERSION$ac_delim -PACKAGE_STRING!$PACKAGE_STRING$ac_delim -PACKAGE_BUGREPORT!$PACKAGE_BUGREPORT$ac_delim -exec_prefix!$exec_prefix$ac_delim -prefix!$prefix$ac_delim -program_transform_name!$program_transform_name$ac_delim -bindir!$bindir$ac_delim -sbindir!$sbindir$ac_delim -libexecdir!$libexecdir$ac_delim -datarootdir!$datarootdir$ac_delim -datadir!$datadir$ac_delim -sysconfdir!$sysconfdir$ac_delim -sharedstatedir!$sharedstatedir$ac_delim -localstatedir!$localstatedir$ac_delim -includedir!$includedir$ac_delim -oldincludedir!$oldincludedir$ac_delim -docdir!$docdir$ac_delim -infodir!$infodir$ac_delim -htmldir!$htmldir$ac_delim -dvidir!$dvidir$ac_delim -pdfdir!$pdfdir$ac_delim -psdir!$psdir$ac_delim -libdir!$libdir$ac_delim -localedir!$localedir$ac_delim -mandir!$mandir$ac_delim -DEFS!$DEFS$ac_delim -ECHO_C!$ECHO_C$ac_delim -ECHO_N!$ECHO_N$ac_delim -ECHO_T!$ECHO_T$ac_delim -LIBS!$LIBS$ac_delim -build_alias!$build_alias$ac_delim -host_alias!$host_alias$ac_delim -target_alias!$target_alias$ac_delim -INSTALL_PROGRAM!$INSTALL_PROGRAM$ac_delim -INSTALL_SCRIPT!$INSTALL_SCRIPT$ac_delim -INSTALL_DATA!$INSTALL_DATA$ac_delim -am__isrc!$am__isrc$ac_delim -CYGPATH_W!$CYGPATH_W$ac_delim -PACKAGE!$PACKAGE$ac_delim -VERSION!$VERSION$ac_delim -ACLOCAL!$ACLOCAL$ac_delim -AUTOCONF!$AUTOCONF$ac_delim -AUTOMAKE!$AUTOMAKE$ac_delim -AUTOHEADER!$AUTOHEADER$ac_delim -MAKEINFO!$MAKEINFO$ac_delim -install_sh!$install_sh$ac_delim -STRIP!$STRIP$ac_delim -INSTALL_STRIP_PROGRAM!$INSTALL_STRIP_PROGRAM$ac_delim -mkdir_p!$mkdir_p$ac_delim -AWK!$AWK$ac_delim -SET_MAKE!$SET_MAKE$ac_delim -am__leading_dot!$am__leading_dot$ac_delim -AMTAR!$AMTAR$ac_delim -am__tar!$am__tar$ac_delim -am__untar!$am__untar$ac_delim -PERL!$PERL$ac_delim -LIBOBJS!$LIBOBJS$ac_delim -LTLIBOBJS!$LTLIBOBJS$ac_delim -_ACEOF - - if test `sed -n "s/.*$ac_delim\$/X/p" conf$$subs.sed | grep -c X` = 62; then - break - elif $ac_last_try; then - { { echo "$as_me:$LINENO: error: could not make $CONFIG_STATUS" >&5 -echo "$as_me: error: could not make $CONFIG_STATUS" >&2;} - { (exit 1); exit 1; }; } - else - ac_delim="$ac_delim!$ac_delim _$ac_delim!! " - fi -done - -ac_eof=`sed -n '/^CEOF[0-9]*$/s/CEOF/0/p' conf$$subs.sed` -if test -n "$ac_eof"; then - ac_eof=`echo "$ac_eof" | sort -nru | sed 1q` - ac_eof=`expr $ac_eof + 1` -fi - -cat >>$CONFIG_STATUS <<_ACEOF -cat >"\$tmp/subs-1.sed" <<\CEOF$ac_eof -/@[a-zA-Z_][a-zA-Z_0-9]*@/!b end -_ACEOF -sed ' -s/[,\\&]/\\&/g; s/@/@|#_!!_#|/g -s/^/s,@/; s/!/@,|#_!!_#|/ -:n -t n -s/'"$ac_delim"'$/,g/; t -s/$/\\/; p -N; s/^.*\n//; s/[,\\&]/\\&/g; s/@/@|#_!!_#|/g; b n -' >>$CONFIG_STATUS >$CONFIG_STATUS <<_ACEOF -:end -s/|#_!!_#|//g -CEOF$ac_eof -_ACEOF - - -# VPATH may cause trouble with some makes, so we remove $(srcdir), -# ${srcdir} and @srcdir@ from VPATH if srcdir is ".", strip leading and -# trailing colons and then remove the whole line if VPATH becomes empty -# (actually we leave an empty line to preserve line numbers). -if test "x$srcdir" = x.; then - ac_vpsub='/^[ ]*VPATH[ ]*=/{ -s/:*\$(srcdir):*/:/ -s/:*\${srcdir}:*/:/ -s/:*@srcdir@:*/:/ -s/^\([^=]*=[ ]*\):*/\1/ -s/:*$// -s/^[^=]*=[ ]*$// -}' -fi - -cat >>$CONFIG_STATUS <<\_ACEOF -fi # test -n "$CONFIG_FILES" - - -for ac_tag in :F $CONFIG_FILES -do - case $ac_tag in - :[FHLC]) ac_mode=$ac_tag; continue;; - esac - case $ac_mode$ac_tag in - :[FHL]*:*);; - :L* | :C*:*) { { echo "$as_me:$LINENO: error: Invalid tag $ac_tag." >&5 -echo "$as_me: error: Invalid tag $ac_tag." >&2;} - { (exit 1); exit 1; }; };; - :[FH]-) ac_tag=-:-;; - :[FH]*) ac_tag=$ac_tag:$ac_tag.in;; - esac - ac_save_IFS=$IFS - IFS=: - set x $ac_tag - IFS=$ac_save_IFS - shift - ac_file=$1 - shift - - case $ac_mode in - :L) ac_source=$1;; - :[FH]) - ac_file_inputs= - for ac_f - do - case $ac_f in - -) ac_f="$tmp/stdin";; - *) # Look for the file first in the build tree, then in the source tree - # (if the path is not absolute). The absolute path cannot be DOS-style, - # because $ac_f cannot contain `:'. - test -f "$ac_f" || - case $ac_f in - [\\/$]*) false;; - *) test -f "$srcdir/$ac_f" && ac_f="$srcdir/$ac_f";; - esac || - { { echo "$as_me:$LINENO: error: cannot find input file: $ac_f" >&5 -echo "$as_me: error: cannot find input file: $ac_f" >&2;} - { (exit 1); exit 1; }; };; - esac - ac_file_inputs="$ac_file_inputs $ac_f" - done - - # Let's still pretend it is `configure' which instantiates (i.e., don't - # use $as_me), people would be surprised to read: - # /* config.h. Generated by config.status. */ - configure_input="Generated from "`IFS=: - echo $* | sed 's|^[^:]*/||;s|:[^:]*/|, |g'`" by configure." - if test x"$ac_file" != x-; then - configure_input="$ac_file. $configure_input" - { echo "$as_me:$LINENO: creating $ac_file" >&5 -echo "$as_me: creating $ac_file" >&6;} - fi - - case $ac_tag in - *:-:* | *:-) cat >"$tmp/stdin";; - esac - ;; - esac - - ac_dir=`$as_dirname -- "$ac_file" || -$as_expr X"$ac_file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ - X"$ac_file" : 'X\(//\)[^/]' \| \ - X"$ac_file" : 'X\(//\)$' \| \ - X"$ac_file" : 'X\(/\)' \| . 2>/dev/null || -echo X"$ac_file" | - sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ - s//\1/ - q - } - /^X\(\/\/\)[^/].*/{ - s//\1/ - q - } - /^X\(\/\/\)$/{ - s//\1/ - q - } - /^X\(\/\).*/{ - s//\1/ - q - } - s/.*/./; q'` - { as_dir="$ac_dir" - case $as_dir in #( - -*) as_dir=./$as_dir;; - esac - test -d "$as_dir" || { $as_mkdir_p && mkdir -p "$as_dir"; } || { - as_dirs= - while :; do - case $as_dir in #( - *\'*) as_qdir=`echo "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #( - *) as_qdir=$as_dir;; - esac - as_dirs="'$as_qdir' $as_dirs" - as_dir=`$as_dirname -- "$as_dir" || -$as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ - X"$as_dir" : 'X\(//\)[^/]' \| \ - X"$as_dir" : 'X\(//\)$' \| \ - X"$as_dir" : 'X\(/\)' \| . 2>/dev/null || -echo X"$as_dir" | - sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ - s//\1/ - q - } - /^X\(\/\/\)[^/].*/{ - s//\1/ - q - } - /^X\(\/\/\)$/{ - s//\1/ - q - } - /^X\(\/\).*/{ - s//\1/ - q - } - s/.*/./; q'` - test -d "$as_dir" && break - done - test -z "$as_dirs" || eval "mkdir $as_dirs" - } || test -d "$as_dir" || { { echo "$as_me:$LINENO: error: cannot create directory $as_dir" >&5 -echo "$as_me: error: cannot create directory $as_dir" >&2;} - { (exit 1); exit 1; }; }; } - ac_builddir=. - -case "$ac_dir" in -.) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;; -*) - ac_dir_suffix=/`echo "$ac_dir" | sed 's,^\.[\\/],,'` - # A ".." for each directory in $ac_dir_suffix. - ac_top_builddir_sub=`echo "$ac_dir_suffix" | sed 's,/[^\\/]*,/..,g;s,/,,'` - case $ac_top_builddir_sub in - "") ac_top_builddir_sub=. ac_top_build_prefix= ;; - *) ac_top_build_prefix=$ac_top_builddir_sub/ ;; - esac ;; -esac -ac_abs_top_builddir=$ac_pwd -ac_abs_builddir=$ac_pwd$ac_dir_suffix -# for backward compatibility: -ac_top_builddir=$ac_top_build_prefix - -case $srcdir in - .) # We are building in place. - ac_srcdir=. - ac_top_srcdir=$ac_top_builddir_sub - ac_abs_top_srcdir=$ac_pwd ;; - [\\/]* | ?:[\\/]* ) # Absolute name. - ac_srcdir=$srcdir$ac_dir_suffix; - ac_top_srcdir=$srcdir - ac_abs_top_srcdir=$srcdir ;; - *) # Relative name. - ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix - ac_top_srcdir=$ac_top_build_prefix$srcdir - ac_abs_top_srcdir=$ac_pwd/$srcdir ;; -esac -ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix - - - case $ac_mode in - :F) - # - # CONFIG_FILE - # - - case $INSTALL in - [\\/$]* | ?:[\\/]* ) ac_INSTALL=$INSTALL ;; - *) ac_INSTALL=$ac_top_build_prefix$INSTALL ;; - esac - ac_MKDIR_P=$MKDIR_P - case $MKDIR_P in - [\\/$]* | ?:[\\/]* ) ;; - */*) ac_MKDIR_P=$ac_top_build_prefix$MKDIR_P ;; - esac -_ACEOF - -cat >>$CONFIG_STATUS <<\_ACEOF -# If the template does not know about datarootdir, expand it. -# FIXME: This hack should be removed a few years after 2.60. -ac_datarootdir_hack=; ac_datarootdir_seen= - -case `sed -n '/datarootdir/ { - p - q -} -/@datadir@/p -/@docdir@/p -/@infodir@/p -/@localedir@/p -/@mandir@/p -' $ac_file_inputs` in -*datarootdir*) ac_datarootdir_seen=yes;; -*@datadir@*|*@docdir@*|*@infodir@*|*@localedir@*|*@mandir@*) - { echo "$as_me:$LINENO: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&5 -echo "$as_me: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&2;} -_ACEOF -cat >>$CONFIG_STATUS <<_ACEOF - ac_datarootdir_hack=' - s&@datadir@&$datadir&g - s&@docdir@&$docdir&g - s&@infodir@&$infodir&g - s&@localedir@&$localedir&g - s&@mandir@&$mandir&g - s&\\\${datarootdir}&$datarootdir&g' ;; -esac -_ACEOF - -# Neutralize VPATH when `$srcdir' = `.'. -# Shell code in configure.ac might set extrasub. -# FIXME: do we really want to maintain this feature? -cat >>$CONFIG_STATUS <<_ACEOF - sed "$ac_vpsub -$extrasub -_ACEOF -cat >>$CONFIG_STATUS <<\_ACEOF -:t -/@[a-zA-Z_][a-zA-Z_0-9]*@/!b -s&@configure_input@&$configure_input&;t t -s&@top_builddir@&$ac_top_builddir_sub&;t t -s&@srcdir@&$ac_srcdir&;t t -s&@abs_srcdir@&$ac_abs_srcdir&;t t -s&@top_srcdir@&$ac_top_srcdir&;t t -s&@abs_top_srcdir@&$ac_abs_top_srcdir&;t t -s&@builddir@&$ac_builddir&;t t -s&@abs_builddir@&$ac_abs_builddir&;t t -s&@abs_top_builddir@&$ac_abs_top_builddir&;t t -s&@INSTALL@&$ac_INSTALL&;t t -s&@MKDIR_P@&$ac_MKDIR_P&;t t -$ac_datarootdir_hack -" $ac_file_inputs | sed -f "$tmp/subs-1.sed" >$tmp/out - -test -z "$ac_datarootdir_hack$ac_datarootdir_seen" && - { ac_out=`sed -n '/\${datarootdir}/p' "$tmp/out"`; test -n "$ac_out"; } && - { ac_out=`sed -n '/^[ ]*datarootdir[ ]*:*=/p' "$tmp/out"`; test -z "$ac_out"; } && - { echo "$as_me:$LINENO: WARNING: $ac_file contains a reference to the variable \`datarootdir' -which seems to be undefined. Please make sure it is defined." >&5 -echo "$as_me: WARNING: $ac_file contains a reference to the variable \`datarootdir' -which seems to be undefined. Please make sure it is defined." >&2;} - - rm -f "$tmp/stdin" - case $ac_file in - -) cat "$tmp/out"; rm -f "$tmp/out";; - *) rm -f "$ac_file"; mv "$tmp/out" $ac_file;; - esac - ;; - - - - esac - -done # for ac_tag - - -{ (exit 0); exit 0; } -_ACEOF -chmod +x $CONFIG_STATUS -ac_clean_files=$ac_clean_files_save - - -# configure is writing to config.log, and then calls config.status. -# config.status does its own redirection, appending to config.log. -# Unfortunately, on DOS this fails, as config.log is still kept open -# by configure, so config.status won't be able to write to it; its -# output is simply discarded. So we exec the FD to /dev/null, -# effectively closing config.log, so it can be properly (re)opened and -# appended to by config.status. When coming back to configure, we -# need to make the FD available again. -if test "$no_create" != yes; then - ac_cs_success=: - ac_config_status_args= - test "$silent" = yes && - ac_config_status_args="$ac_config_status_args --quiet" - exec 5>/dev/null - $SHELL $CONFIG_STATUS $ac_config_status_args || ac_cs_success=false - exec 5>>config.log - # Use ||, not &&, to avoid exiting from the if with $? = 1, which - # would make configure fail if this is the last instruction. - $ac_cs_success || { (exit 1); exit 1; } -fi - diff --git a/stamp-vti b/stamp-vti deleted file mode 100644 index 3245b32..0000000 --- a/stamp-vti +++ /dev/null @@ -1,4 +0,0 @@ -@set UPDATED 20 February 2008 -@set UPDATED-MONTH February 2008 -@set EDITION 2.0.2 -@set VERSION 2.0.2 diff --git a/stow.info b/stow.info deleted file mode 100644 index 7b6b9de..0000000 --- a/stow.info +++ /dev/null @@ -1,1335 +0,0 @@ -This is stow.info, produced by makeinfo version 4.12 from stow.texi. - -INFO-DIR-SECTION Administration -START-INFO-DIR-ENTRY -* Stow: (stow). GNU Stow. -END-INFO-DIR-ENTRY - - This file describes GNU Stow version 2.0.2, a program for managing -the installation of software packages. - - Software and documentation Copyright (C) 1993, 1994, 1995, 1996 by -Bob Glickstein . Copyright (C) 2000, 2001 -Guillaume Morin . Copyright (C) 2007 Kahlil (Kal) -Hodgson . - - Permission is granted to make and distribute verbatim copies of this -manual provided the copyright notice and this permission notice are -preserved on all copies. - - Permission is granted to copy and distribute modified versions of -this manual under the conditions for verbatim copying, provided also -that the section entitled "GNU General Public License" is included with -the modified manual, and provided that the entire resulting derived -work is distributed under the terms of a permission notice identical to -this one. - - Permission is granted to copy and distribute translations of this -manual into another language, under the above conditions for modified -versions, except that this permission notice may be stated in a -translation approved by the Free Software Foundation. - - -File: stow.info, Node: Top, Next: Introduction, Prev: (dir), Up: (dir) - - This manual describes GNU Stow 2.0.2, a program for managing the -installation of software packages. - -* Menu: - -* Introduction:: Description of Stow. -* Terminology:: Terms used by this manual. -* Invoking Stow:: Option summary. -* Installing Packages:: Using Stow to install. -* Deleting Packages:: Using Stow to uninstall. -* Conflicts:: When Stow can't stow. -* Deferred Operation:: Using two passes to stow. -* Mixing Operations:: Multiple actions per invocation. -* Multiple Stow Directories:: Further segregating software. -* Target Maintenance:: Cleaning up mistakes. -* Resource Files:: Setting default command line options. -* Compile-time vs Install-time:: Faking out `make install'. -* Bootstrapping:: When stow and perl are not yet stowed. -* Reporting Bugs:: How, what, where, and when to report. -* Known Bugs:: Don't report any of these. -* GNU General Public License:: Copying terms. -* Index:: Index of concepts. - - --- The Detailed Node Listing --- - -Compile-time and install-time - -* GNU Emacs:: -* Other FSF Software:: -* Cygnus Software:: -* Perl and Perl 5 Modules:: - - -File: stow.info, Node: Introduction, Next: Terminology, Prev: Top, Up: Top - -1 Introduction -************** - -Stow is a tool for managing the installation of multiple software -packages in the same run-time directory tree. One historical difficulty -of this task has been the need to administer, upgrade, install, and -remove files in independent packages without confusing them with other -files sharing the same file system space. For instance, it is common to -install Perl and Emacs in `/usr/local'. When one does so, one winds up -with the following files(1) in `/usr/local/man/man1': - - a2p.1 - ctags.1 - emacs.1 - etags.1 - h2ph.1 - perl.1 - s2p.1 - -Now suppose it's time to uninstall Perl. Which man pages get removed? -Obviously `perl.1' is one of them, but it should not be the -administrator's responsibility to memorize the ownership of individual -files by separate packages. - - The approach used by Stow is to install each package into its own -tree, then use symbolic links to make it appear as though the files are -installed in the common tree. Administration can be performed in the -package's private tree in isolation from clutter from other packages. -Stow can then be used to update the symbolic links. The structure of -each private tree should reflect the desired structure in the common -tree; i.e. (in the typical case) there should be a `bin' directory -containing executables, a `man/man1' directory containing section 1 man -pages, and so on. - - Stow was inspired by Carnegie Mellon's Depot program, but is -substantially simpler and safer. Whereas Depot required database files -to keep things in sync, Stow stores no extra state between runs, so -there's no danger (as there was in Depot) of mangling directories when -file hierarchies don't match the database. Also unlike Depot, Stow will -never delete any files, directories, or links that appear in a Stow -directory (e.g., `/usr/local/stow/emacs'), so it's always possible to -rebuild the target tree (e.g., `/usr/local'). - - For information about the latest version of Stow, you can refer to -http://www.gnu.org/software/stow/. - - ---------- Footnotes ---------- - - (1) As of Perl 4.036 and Emacs 19.22. - - -File: stow.info, Node: Terminology, Next: Invoking Stow, Prev: Introduction, Up: Top - -2 Terminology -************* - - A "package" is a related collection of files and directories that -you wish to administer as a unit -- e.g., Perl or Emacs -- and that -needs to be installed in a particular directory structure -- e.g., with -`bin', `lib', and `man' subdirectories. - - A "target directory" is the root of a tree in which one or more -packages wish to _appear_ to be installed. A common, but by no means -the only such location is `/usr/local'. The examples in this manual -will use `/usr/local' as the target directory. - - A "stow directory" is the root of a tree containing separate -packages in private subtrees. When Stow runs, it uses the current -directory as the default stow directory. The examples in this manual -will use `/usr/local/stow' as the stow directory, so that individual -packages will be, for example, `/usr/local/stow/perl' and -`/usr/local/stow/emacs'. - - An "installation image" is the layout of files and directories -required by a package, relative to the target directory. Thus, the -installation image for Perl includes: a `bin' directory containing -`perl' and `a2p' (among others); an `info' directory containing Texinfo -documentation; a `lib/perl' directory containing Perl libraries; and a -`man/man1' directory containing man pages. - - A "package directory" is the root of a tree containing the -installation image for a particular package. Each package directory -must reside in a stow directory -- e.g., the package directory -`/usr/local/stow/perl' must reside in the stow directory -`/usr/local/stow'. The "name" of a package is the name of its -directory within the stow directory -- e.g., `perl'. - - Thus, the Perl executable might reside in -`/usr/local/stow/perl/bin/perl', where `/usr/local' is the target -directory, `/usr/local/stow' is the stow directory, -`/usr/local/stow/perl' is the package directory, and `bin/perl' within -is part of the installation image. - - A "symlink" is a symbolic link. A symlink can be "relative" or -"absolute". An absolute symlink names a full path; that is, one -starting from `/'. A relative symlink names a relative path; that is, -one not starting from `/'. The target of a relative symlink is -computed starting from the symlink's own directory. Stow only creates -relative symlinks. - - -File: stow.info, Node: Invoking Stow, Next: Installing Packages, Prev: Terminology, Up: Top - -3 Invoking Stow -*************** - -The syntax of the `stow' command is: - - stow [OPTIONS] [ACTION FLAG] PACKAGE ... - -Each PACKAGE is the name of a package (e.g., `perl') in the stow -directory that we wish to install into (or delete from) the target -directory. The default action is to install the given packages, -although alternate actions may be specified by preceding the package -name(s) with an ACTION FLAG. Unless otherwise specified, the stow -directory is assumed to be the current directory and the target -directory is assumed to be the parent of the current directory, so it -is typical to execute `stow' from the directory `/usr/local/stow'. - -The following options are supported: - -`-d DIR' -`--dir=DIR' - Set the stow directory to DIR instead of the current directory. - This also has the effect of making the default target directory be - the parent of DIR. - -`-t DIR' -`--target=DIR' - Set the target directory to DIR instead of the parent of the stow - directory. - -`--ignore=''' - This (repeatable) option lets you suppress acting on files that - match the given perl regular expression. For example, using the - options - - --ignore='~' --ignore='\.#.*' - - will cause stow to ignore emacs and CVS backup files. - - Note that the regular expression is anchored to the end of the - filename, because this is what you will want to do most of the - time. - -`--defer=''' - This (repeatable) option lets you defer stowing a file matching - the given regular expression, if that file is already stowed by - another package. For example, the following options - - --defer='man' --defer='info' - - will cause stow to skip over pre-existing man and info pages. - - Equivalently, you could use -defer='man|info' since the argument - is just a Perl regex. - - Note that the regular expression is anchored to the beginning of - the path relative to the target directory, because this is what - you will want to do most of the time. - -`--override=''' - This (repeatable) option forces any file matching the regular - expression to be stowed, even if the file is already stowed to - another package. For example, the following options - - --override='man' --override='info' - - will permit stow to overwrite links that point to pre-existing man - and info pages that are owned by stow and would otherwise cause a - conflict. - - The regular expression is anchored to the beginning of the path - relative to the target directory, because this is what you will - want to do most of the time. - -`-n' -`--no' -`--simulate' - Do not perform any operations that modify the file system; in - combination with `-v' can be used to merely show what would happen. - -`-v' -`--verbose[=N]' - Send verbose output to standard error describing what Stow is - doing. Verbosity levels are 0, 1, 2, and 3; 0 is the default. - Using `-v' or `--verbose' increases the verbosity by one; using - `--verbose=N' sets it to N. - -`-p' -`--compat' - Scan the whole target tree when unstowing. By default, only - directories specified in the "installation image" are scanned - during an unstow operation. Scanning the whole tree can be - prohibitive if your target tree is very large. This option - restores the legacy behaviour; however, the `--badlinks' option - may be a better way of ensuring that your installation does not - have any dangling symlinks. - -`-V' -`--version' - Show Stow version number, and exit. - -`-h' -`--help' - Show Stow command syntax, and exit. - - The following ACTION FLAGS are supported: - -`-D' -`--delete' - Delete (unstow) the package name(s) that follow this option from - the "target directory". This option may be repeated any number of - times. - -`-R' -`--restow' - Restow (first unstow, then stow again) the package names that - follow this option. This is useful for pruning obsolete symlinks - from the target tree after updating the software in a package. - This option may be repeated any number of times. - -`-S' - -`--stow' - explictly stow the package name(s) that follow this option. May - be omitted if you are not using the `-D' or `-R' options in the - same invocation. See *Note Mixing Operations::, for details of - when you might like to use this feature. This option may be - repeated any number of times. - - The following options are useful for cleaning up your target tree: - -`-b' -`--badlinks' - Checks target directory for bogus symbolic links. That is, links - that point to non-existent files. - -`-a' -`--aliens' - Checks for files in the target directory that are not symbolic - links. The target directory should be managed by stow alone, - except for directories that contain a `.stow' file. - -`-l' -`--list' - Will display the target package for every symbolic link in the - stow target directory. The following options are deprecated: - - The following options are deprecated as of Stow Version 2: -`-c' -`--conflicts' - Print any conflicts that are encountered. This option implies - `-n', and is used to search for all conflicts that might arise - from an actual Stow operation. - - This option is deprecated as conflicts are now printed by default - and no operations will be performed if any conflicts are detected. - - *note Resource Files:: for a way to set default values for any of -these options - - -File: stow.info, Node: Installing Packages, Next: Deleting Packages, Prev: Invoking Stow, Up: Top - -4 Installing Packages -********************* - -The default action of Stow is to install a package. This means creating -symlinks in the target tree that point into the package tree. Stow -attempts to do this with as few symlinks as possible; in other words, if -Stow can create a single symlink that points to an entire subtree within -the package tree, it will choose to do that rather than create a -directory in the target tree and populate it with symlinks. - - For example, suppose that no packages have yet been installed in -`/usr/local'; it's completely empty (except for the `stow' -subdirectory, of course). Now suppose the Perl package is installed. -Recall that it includes the following directories in its installation -image: `bin'; `info'; `lib/perl'; `man/man1'. Rather than creating -the directory `/usr/local/bin' and populating it with symlinks to -`../stow/perl/bin/perl' and `../stow/perl/bin/a2p' (and so on), Stow -will create a single symlink, `/usr/local/bin', which points to -`stow/perl/bin'. In this way, it still works to refer to -`/usr/local/bin/perl' and `/usr/local/bin/a2p', and fewer symlinks have -been created. This is called "tree folding", since an entire subtree -is "folded" into a single symlink. - - To complete this example, Stow will also create the symlink -`/usr/local/info' pointing to `stow/perl/info'; the symlink -`/usr/local/lib' pointing to `stow/perl/lib'; and the symlink -`/usr/local/man' pointing to `stow/perl/man'. - - Now suppose that instead of installing the Perl package into an empty -target tree, the target tree is not empty to begin with. Instead, it -contains several files and directories installed under a different -system-administration philosophy. In particular, `/usr/local/bin' -already exists and is a directory, as are `/usr/local/lib' and -`/usr/local/man/man1'. In this case, Stow will descend into -`/usr/local/bin' and create symlinks to `../stow/perl/bin/perl' and -`../stow/perl/bin/a2p' (etc.), and it will descend into -`/usr/local/lib' and create the tree-folding symlink `perl' pointing to -`../stow/perl/lib/perl', and so on. As a rule, Stow only descends as -far as necessary into the target tree when it can create a tree-folding -symlink. - - The time often comes when a tree-folding symlink has to be undone -because another package uses one or more of the folded subdirectories in -its installation image. This operation is called "splitting open" or -"unfolding" a folded tree. It involves removing the original symlink -from the target tree, creating a true directory in its place, and then -populating the new directory with symlinks to the newly-installed -package _and_ to the old package that used the old symlink. For -example, suppose that after installing Perl into an empty `/usr/local', -we wish to install Emacs. Emacs's installation image includes a `bin' -directory containing the `emacs' and `etags' executables, among others. -Stow must make these files appear to be installed in `/usr/local/bin', -but presently `/usr/local/bin' is a symlink to `stow/perl/bin'. Stow -therefore takes the following steps: the symlink `/usr/local/bin' is -deleted; the directory `/usr/local/bin' is created; links are made from -`/usr/local/bin' to `../stow/emacs/bin/emacs' and -`../stow/emacs/bin/etags'; and links are made from `/usr/local/bin' to -`../stow/perl/bin/perl' and `../stow/perl/bin/a2p'. - - When splitting open a folded tree, Stow makes sure that the symlink -it is about to remove points inside a valid package in the current stow -directory. _Stow will never delete anything that it doesn't own_. -Stow "owns" everything living in the target tree that points into a -package in the stow directory. Anything Stow owns, it can recompute if -lost: symlinks that point into a package in the stow directory, or -directories that only contain sysmlinks that stow "owns". Note that -by this definition, Stow doesn't "own" anything _in_ the stow directory -or in any of the packages. - - If Stow needs to create a directory or a symlink in the target tree -and it cannot because that name is already in use and is not owned by -Stow, then a "conflict" has arisen. *Note Conflicts::. - - -File: stow.info, Node: Deleting Packages, Next: Conflicts, Prev: Installing Packages, Up: Top - -5 Deleting Packages -******************* - -When the `-D' option is given, the action of Stow is to delete a -package from the target tree. Note that Stow will not delete anything -it doesn't "own". Deleting a package does _not_ mean removing it from -the stow directory or discarding the package tree. - - To delete a package, Stow recursively scans the target tree, -skipping over any directory that is not included in the installation -image.(1) For example, if the target directory is `/usr/local' and the -installation image for the package being deleted has only a `bin' -directory and a `man' directory at the top level, then we only scan -`/usr/local/bin' and `/usr/local/bin/man', and not `/usr/local/lib' or -`/usr/local/share', or for that matter `/usr/local/stow'. Any symlink -it finds that points into the package being deleted is removed. Any -directory that contained only symlinks to the package being deleted is -removed. Any directory that, after removing symlinks and empty -subdirectories, contains only symlinks to a single other package, is -considered to be a previously "folded" tree that was "split open." Stow -will re-fold the tree by removing the symlinks to the surviving package, -removing the directory, then linking the directory back to the surviving -package. - - ---------- Footnotes ---------- - - (1) This approach was introduced in version 2 of GNU Stow. -Previously, the whole target tree was scanned and stow directories were -explicitly omitted. This became problematic when dealing with very -large installations. The only situation where this is useful is if you -accidentally delete a directory in the package tree, leaving you with a -whole bunch of dangling links. Note that you can enable the old -approach with the `-p' option. Alternatively, you can use the -`--badlinks' option get stow to search for dangling links in your -target tree and remove the offenders manually. - - -File: stow.info, Node: Conflicts, Next: Deferred Operation, Prev: Deleting Packages, Up: Top - -5.1 Conflicts -============= - -If, during installation, a file or symlink exists in the target tree and -has the same name as something Stow needs to create, and if the -existing name is not a folded tree that can be split open, then a -"conflict" has arisen. A conflict also occurs if a directory exists -where Stow needs to place a symlink to a non-directory. On the other -hand, if the existing name is merely a symlink that already points -where Stow needs it to, then no conflict has occurred. (Thus it is -harmless to install a package that has already been installed.) - - A conflict causes Stow to exit immediately and print a warning -(unless `-c' is given), even if that means aborting an installation in -mid-package. - - When running Stow with the `-n' or `-c' options, no actual -filesystem-modifying operations take place. Thus if a folded tree would -have been split open, but instead was left in place because `-n' or -`-c' was used, then Stow will report a "false conflict", since the -directory that Stow was expecting to populate has remained an -un-populatable symlink. - - -File: stow.info, Node: Deferred Operation, Next: Mixing Operations, Prev: Conflicts, Up: Top - -6 Deferred Operation -******************** - -For complex packages, scanning the stow and target trees in tandem, and -deciding whether to make directories or links, split-open or fold -directories, can actually take a long time (a number of seconds). -Moreover, an accurate analysis of potential conflicts, requires us to -take in to account all of these operations. - - Accidentally stowing a package that will result in a conflict - - -File: stow.info, Node: Mixing Operations, Next: Multiple Stow Directories, Prev: Deferred Operation, Up: Top - -7 Mixing Operations -******************* - -Since Version 2.0, multiple distinct actions can be specified in a -single invocation of GNU Stow. For example, to update an installation -of Emacs from version 21.3 to 21.4a you can now do the following: - - stow -D emacs-21.3 -S emacs-21.4a - -which will replace emacs-21.3 with emacs-21.4a using a single -invocation. - - This is much faster and cleaner than performing two separate -invocations of stow, because redundant folding/unfolding operations can -be factored out. In addition, all the operations are calculated and -merged before being executed *note Deferred Operation::, so the amount -of of time in which GNU Emacs is unavailable is minimised. - - You can mix and match any number of actions, for example, - - stow -S pkg1 pkg2 -D pkg3 pkg4 -S pkg5 -R pkg6 - -will unstow pkg3, pkg4 and pkg6, then stow pkg1, pkg2, pkg5 and pkg6. - - -File: stow.info, Node: Multiple Stow Directories, Next: Target Maintenance, Prev: Mixing Operations, Up: Top - -8 Multiple Stow Directories -*************************** - -If there are two or more system administrators who wish to maintain -software separately, or if there is any other reason to want two or more -stow directories, it can be done by creating a file named `.stow' in -each stow directory. The presence of `/usr/local/foo/.stow' informs -Stow that, though `foo' is not the current stow directory, and though -it is a subdirectory of the target directory, nevertheless it is _a_ -stow directory and as such Stow doesn't "own" anything in it (*note -Installing Packages::). This will protect the contents of `foo' from a -`stow -D', for instance. - - XXX is this still true? XXX - - When multiple stow directories share a target tree, the effectiveness -of Stow is reduced. If a tree-folding symlink is encountered and needs -to be split open during an installation, but the symlink points into -the wrong stow directory, Stow will report a conflict rather than split -open the tree (because it doesn't consider itself to own the symlink, -and thus cannot remove it). - - -File: stow.info, Node: Target Maintenance, Next: Resource Files, Prev: Multiple Stow Directories, Up: Top - -9 Target Maintenance -******************** - -From time to time you will need to clean up your target tree. Stow -includes three operational modes that performs checks that would -generally be too expensive to performed during normal stow execution. - - I've added a -l option to chkstow which will give you a listing of -every package name that has already been stowed should be able to diff -this with your directory listing - - bash cd build/scripts diff <(../bin/chkstow -l) <(ls -1) - - -File: stow.info, Node: Resource Files, Next: Compile-time vs Install-time, Prev: Target Maintenance, Up: Top - -10 Resource Files -***************** - -Default command line options may be set in `.stowrc' (current -directory) or `~/.stowrc' (home directory). These are parsed in that -order, and effectively prepended to you command line. This feature can -be used for some interesting effects. - - For example, suppose your site uses more than one stow directory, -perhaps in order to share around responsibilities with a number of -systems administrators. One of the administrators might have the -following in there `~/.stowrc' file: - - --dir=/usr/local/stow2 - --target=/usr/local - --ignore='~' - --ignore='^CVS' - - so that the `stow' command will default to operating on the -`/usr/local/stow2' directory, with `/usr/local' as the target, and -ignoring vi backup files and CVS directories. - - If you had a stow directory `/usr/local/stow/perl-extras' that was -only used for Perl modules, then you might place the following in -`/usr/local/stow/perl-extras/.stowrc': - - --dir=/usr/local/stow/perl-extras - --target=/usr/local - --override=bin - --override=man - --ignore='perllocal\.pod' - --ignore='\.packlist' - --ignore='\.bs' - - so that the when your are in the `/usr/local/stow/perl-extras' -directory, `stow' will regard any subdirectories as stow packages, with -`/usr/local' as the target (rather than the immediate parent directoy -`/usr/local/stow'), overriding any pre-existing links to bin files or -man pages, and ignoring some cruft that gets installed by default. - - -File: stow.info, Node: Compile-time vs Install-time, Next: Bootstrapping, Prev: Resource Files, Up: Top - -11 Compile-time vs Install-time -******************************* - -Software whose installation is managed with Stow needs to be installed -in one place (the package directory, e.g. `/usr/local/stow/perl') but -needs to appear to run in another place (the target tree, e.g., -`/usr/local'). Why is this important? What's wrong with Perl, for -instance, looking for its files in `/usr/local/stow/perl' instead of in -`/usr/local'? - - The answer is that there may be another package, e.g., -`/usr/local/stow/perl-extras', stowed under `/usr/local'. If Perl is -configured to find its files in `/usr/local/stow/perl', it will never -find the extra files in the `perl-extras' package, even though they're -intended to be found by Perl. On the other hand, if Perl looks for its -files in `/usr/local', then it will find the intermingled Perl and -`perl-extras' files. - - This means that when you compile a package, you must tell it the -location of the run-time, or target tree; but when you install it, you -must place it in the stow tree. - - Some software packages allow you to specify, at compile-time, -separate locations for installation and for run-time. Perl is one such -package; *Note Perl and Perl 5 Modules::. Others allow you to compile -the package, then give a different destination in the `make install' -step without causing the binaries or other files to get rebuilt. Most -GNU software falls into this category; Emacs is a notable exception. -See *note GNU Emacs::, and *note Other FSF Software::. - - Still other software packages cannot abide the idea of separate -installation and run-time locations at all. If you try to `make -install prefix=/usr/local/stow/FOO', then first the whole package will -be recompiled to hardwire the `/usr/local/stow/FOO' path. With these -packages, it is best to compile normally, then run `make -n install', -which should report all the steps needed to install the just-built -software. Place this output into a file, edit the commands in the file -to remove recompilation steps and to reflect the Stow-based -installation location, and execute the edited file as a shell script in -place of `make install'. Be sure to execute the script using the same -shell that `make install' would have used. - - (If you use GNU Make and a shell [such as GNU bash] that understands -`pushd' and `popd', you can do the following: - - 1. Replace all lines matching `make[N]: Entering directory `DIR'' - with `pushd DIR'. - - 2. Replace all lines matching `make[N]: Leaving directory `DIR'' with - `popd'. - - 3. Delete all lines matching `make[N]: Nothing to be done for RULE'. - - Then find other lines in the output containing `cd' or `make' -commands and rewrite or delete them. In particular, you should be able -to delete sections of the script that resemble this: - - for i in DIR_1 DIR_2 ...; do \ - (cd $i; make ARGS ...) \ - done - -Note, that's "should be able to," not "can." Be sure to modulate these -guidelines with plenty of your own intelligence. - - The details of stowing some specific packages are described in the -following sections. - -* Menu: - -* GNU Emacs:: -* Other FSF Software:: -* Cygnus Software:: -* Perl and Perl 5 Modules:: - - -File: stow.info, Node: GNU Emacs, Next: Other FSF Software, Prev: Compile-time vs Install-time, Up: Compile-time vs Install-time - -11.1 GNU Emacs -============== - -Although the Free Software Foundation has many enlightened practices -regarding Makefiles and software installation (see *note Other FSF -Software::), Emacs, its flagship program, doesn't quite follow the -rules. In particular, most GNU software allows you to write: - - make - make install prefix=/usr/local/stow/PACKAGE - -If you try this with Emacs, then the new value for `prefix' in the -`make install' step will cause some files to get recompiled with the -new value of `prefix' wired into them. In Emacs 19.23 and later,(1) -the way to work around this problem is: - - make - make install-arch-dep install-arch-indep prefix=/usr/local/stow/emacs - - In 19.22 and some prior versions of Emacs, the workaround was: - - make - make do-install prefix=/usr/local/stow/emacs - - ---------- Footnotes ---------- - - (1) As I write this, the current version of Emacs is 19.31. - - -File: stow.info, Node: Other FSF Software, Next: Cygnus Software, Prev: GNU Emacs, Up: Compile-time vs Install-time - -11.2 Other FSF Software -======================= - -The Free Software Foundation, the organization behind the GNU project, -has been unifying the build procedure for its tools for some time. -Thanks to its tools `autoconf' and `automake', most packages now -respond well to these simple steps, with no other intervention -necessary: - - ./configure OPTIONS - make - make install prefix=/usr/local/stow/PACKAGE - - Hopefully, these tools can evolve to be aware of Stow-managed -packages, such that providing an option to `configure' can allow `make' -and `make install' steps to work correctly without needing to "fool" -the build process. - - -File: stow.info, Node: Cygnus Software, Next: Perl and Perl 5 Modules, Prev: Other FSF Software, Up: Compile-time vs Install-time - -11.3 Cygnus Software -==================== - -Cygnus is a commercial supplier and supporter of GNU software. It has -also written several of its own packages, released under the terms of -the GNU General Public License; and it has taken over the maintenance of -other packages. Among the packages released by Cygnus are `gdb', -`gnats', and `dejagnu'. - - Cygnus packages have the peculiarity that each one unpacks into a -directory tree with a generic top-level Makefile, which is set up to -compile _all_ of Cygnus' packages, any number of which may reside under -the top-level directory. In other words, even if you're only building -`gnats', the top-level Makefile will look for, and try to build, `gdb' -and `dejagnu' subdirectories, among many others. - - The result is that if you try `make -n install -prefix=/usr/local/stow/PACKAGE' at the top level of a Cygnus package, -you'll get a bewildering amount of output. It will then be very -difficult to visually scan the output to see whether the install will -proceed correctly. Unfortunately, it's not always clear how to invoke -an install from the subdirectory of interest. - - In cases like this, the best approach is to run your `make install -prefix=...', but be ready to interrupt it if you detect that it is -recompiling files. Usually it will work just fine; otherwise, install -manually. - - -File: stow.info, Node: Perl and Perl 5 Modules, Prev: Cygnus Software, Up: Compile-time vs Install-time - -11.4 Perl and Perl 5 Modules -============================ - -Perl 4.036 allows you to specify different locations for installation -and for run-time. It is the only widely-used package in this author's -experience that allows this, though hopefully more packages will adopt -this model. - - Unfortunately, the authors of Perl believed that only AFS sites need -this ability. The configuration instructions for Perl 4 misleadingly -state that some occult means are used under AFS to transport files from -their installation tree to their run-time tree. In fact, that confusion -arises from the fact that Depot, Stow's predecessor, originated at -Carnegie Mellon University, which was also the birthplace of AFS. CMU's -need to separate install-time and run-time trees stemmed from its use of -Depot, not from AFS. - - The result of this confusion is that Perl 5's configuration script -doesn't even offer the option of separating install-time and run-time -trees _unless_ you're running AFS. Fortunately, after you've entered -all the configuration settings, Perl's setup script gives you the -opportunity to edit those settings in a file called `config.sh'. When -prompted, you should edit this file and replace occurrences of - - inst.../usr/local... - -with - - inst.../usr/local/stow/perl... - -You can do this with the following Unix command: - - sed 's,^\(inst.*/usr/local\),\1/stow/perl,' config.sh > config.sh.new - mv config.sh.new config.sh - - Hopefully, the Perl authors will correct this deficiency in Perl 5's -configuration mechanism. - - Perl 5 modules--i.e., extensions to Perl 5--generally conform to a -set of standards for building and installing them. The standard says -that the package comes with a top-level `Makefile.PL', which is a Perl -script. When it runs, it generates a `Makefile'. - - If you followed the instructions above for editing `config.sh' when -Perl was built, then when you create a `Makefile' from a `Makefile.PL', -it will contain separate locations for run-time (`/usr/local') and -install-time (`/usr/local/stow/perl'). Thus you can do - - perl Makefile.PL - make - make install - -and the files will be installed into `/usr/local/stow/perl'. However, -you might prefer each Perl module to be stowed separately. In that -case, you must edit the resulting Makefile, replacing -`/usr/local/stow/perl' with `/usr/local/stow/MODULE'. The best way to -do this is: - - perl Makefile.PL - find . -name Makefile -print | \ - xargs perl -pi~ -e 's,^(INST.*/stow)/perl,$1/MODULE,;' - make - make install - -(The use of `find' and `xargs' ensures that all Makefiles in the -module's source tree, even those in subdirectories, get edited.) A -good convention to follow is to name the stow directory for a Perl -MODULE `cpan.MODULE', where `cpan' stands for Comprehensive Perl -Archive Network, a collection of FTP sites that is the source of most -Perl 5 extensions. This way, it's easy to tell at a glance which of -the subdirectories of `/usr/local/stow' are Perl 5 extensions. - - When you stow separate Perl 5 modules separately, you are likely to -encounter conflicts (*note Conflicts::) with files named `.exists' and -`perllocal.pod'. One way to work around this is to remove those files -before stowing the module. If you use the `cpan.MODULE' naming -convention, you can simply do this: - - cd /usr/local/stow - find cpan.* \( -name .exists -o -name perllocal.pod \) -print | \ - xargs rm - - -File: stow.info, Node: Bootstrapping, Next: Reporting Bugs, Prev: Compile-time vs Install-time, Up: Top - -12 Bootstrapping -**************** - -Suppose you have a stow directory all set up and ready to go: -`/usr/local/stow/perl' contains the Perl installation, -`/usr/local/stow/stow' contains Stow itself, and perhaps you have other -packages waiting to be stowed. You'd like to be able to do this: - - cd /usr/local/stow - stow -vv * - -but `stow' is not yet in your `PATH'. Nor can you do this: - - cd /usr/local/stow - stow/bin/stow -vv * - -because the `#!' line at the beginning of `stow' tries to locate Perl -(usually in `/usr/local/bin/perl'), and that won't be found. The -solution you must use is: - - cd /usr/local/stow - perl/bin/perl stow/bin/stow -vv * - - -File: stow.info, Node: Reporting Bugs, Next: Known Bugs, Prev: Bootstrapping, Up: Top - -13 Reporting Bugs -***************** - -Please send bug reports to the current maintaner, Kal Hodgson, by -electronic mail. The address to use is `'. Please -include: - - * the version number of Stow (`stow --version'); - - * the version number of Perl (`perl -v'); - - * the system information, which can often be obtained with `uname - -a'; - - * a description of the bug; - - * the precise command you gave; - - * the output from the command (preferably verbose output, obtained by - adding `--verbose=3' to the Stow command line). - - If you are really keen, consider developing a minimal test case and -creating a new test. See the `t/' for lots of examples. - - Before reporting a bug, please read the manual carefully, especially -*note Known Bugs::, to see whether you're encountering something that -doesn't need reporting. (*note Conflicts::). - - -File: stow.info, Node: Known Bugs, Next: GNU General Public License, Prev: Reporting Bugs, Up: Top - -14 Known Bugs -************* - - * When using multiple stow directories (*note Multiple Stow - Directories::), Stow fails to "split open" tree-folding symlinks - (*note Installing Packages::) that point into a stow directory - which is not the one in use by the current Stow command. Before - failing, it should search the target of the link to see whether - any element of the path contains a `.stow' file. If it finds one, - it can "learn" about the cooperating stow directory to - short-circuit the `.stow' search the next time it encounters a - tree-folding symlink. - - -File: stow.info, Node: GNU General Public License, Next: Index, Prev: Known Bugs, Up: Top - -GNU General Public License -************************** - - Version 2, June 1991 - - Copyright (C) 1989, 1991 Free Software Foundation, Inc. - 675 Mass Ave, Cambridge, MA 02139, USA - - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - -Preamble -======== - -The licenses for most software are designed to take away your freedom -to share and change it. By contrast, the GNU General Public License is -intended to guarantee your freedom to share and change free -software--to make sure the software is free for all its users. This -General Public License applies to most of the Free Software -Foundation's software and to any other program whose authors commit to -using it. (Some other Free Software Foundation software is covered by -the GNU Library General Public License instead.) You can apply it to -your programs, too. - - When we speak of free software, we are referring to freedom, not -price. Our General Public Licenses are designed to make sure that you -have the freedom to distribute copies of free software (and charge for -this service if you wish), that you receive source code or can get it -if you want it, that you can change the software or use pieces of it in -new free programs; and that you know you can do these things. - - To protect your rights, we need to make restrictions that forbid -anyone to deny you these rights or to ask you to surrender the rights. -These restrictions translate to certain responsibilities for you if you -distribute copies of the software, or if you modify it. - - For example, if you distribute copies of such a program, whether -gratis or for a fee, you must give the recipients all the rights that -you have. You must make sure that they, too, receive or can get the -source code. And you must show them these terms so they know their -rights. - - We protect your rights with two steps: (1) copyright the software, -and (2) offer you this license which gives you legal permission to copy, -distribute and/or modify the software. - - Also, for each author's protection and ours, we want to make certain -that everyone understands that there is no warranty for this free -software. If the software is modified by someone else and passed on, we -want its recipients to know that what they have is not the original, so -that any problems introduced by others will not reflect on the original -authors' reputations. - - Finally, any free program is threatened constantly by software -patents. We wish to avoid the danger that redistributors of a free -program will individually obtain patent licenses, in effect making the -program proprietary. To prevent this, we have made it clear that any -patent must be licensed for everyone's free use or not licensed at all. - - The precise terms and conditions for copying, distribution and -modification follow. - - TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION - 0. This License applies to any program or other work which contains a - notice placed by the copyright holder saying it may be distributed - under the terms of this General Public License. The "Program", - below, refers to any such program or work, and a "work based on - the Program" means either the Program or any derivative work under - copyright law: that is to say, a work containing the Program or a - portion of it, either verbatim or with modifications and/or - translated into another language. (Hereinafter, translation is - included without limitation in the term "modification".) Each - licensee is addressed as "you". - - Activities other than copying, distribution and modification are - not covered by this License; they are outside its scope. The act - of running the Program is not restricted, and the output from the - Program is covered only if its contents constitute a work based on - the Program (independent of having been made by running the - Program). Whether that is true depends on what the Program does. - - 1. You may copy and distribute verbatim copies of the Program's - source code as you receive it, in any medium, provided that you - conspicuously and appropriately publish on each copy an appropriate - copyright notice and disclaimer of warranty; keep intact all the - notices that refer to this License and to the absence of any - warranty; and give any other recipients of the Program a copy of - this License along with the Program. - - You may charge a fee for the physical act of transferring a copy, - and you may at your option offer warranty protection in exchange - for a fee. - - 2. You may modify your copy or copies of the Program or any portion - of it, thus forming a work based on the Program, and copy and - distribute such modifications or work under the terms of Section 1 - above, provided that you also meet all of these conditions: - - a. You must cause the modified files to carry prominent notices - stating that you changed the files and the date of any change. - - b. You must cause any work that you distribute or publish, that - in whole or in part contains or is derived from the Program - or any part thereof, to be licensed as a whole at no charge - to all third parties under the terms of this License. - - c. If the modified program normally reads commands interactively - when run, you must cause it, when started running for such - interactive use in the most ordinary way, to print or display - an announcement including an appropriate copyright notice and - a notice that there is no warranty (or else, saying that you - provide a warranty) and that users may redistribute the - program under these conditions, and telling the user how to - view a copy of this License. (Exception: if the Program - itself is interactive but does not normally print such an - announcement, your work based on the Program is not required - to print an announcement.) - - These requirements apply to the modified work as a whole. If - identifiable sections of that work are not derived from the - Program, and can be reasonably considered independent and separate - works in themselves, then this License, and its terms, do not - apply to those sections when you distribute them as separate - works. But when you distribute the same sections as part of a - whole which is a work based on the Program, the distribution of - the whole must be on the terms of this License, whose permissions - for other licensees extend to the entire whole, and thus to each - and every part regardless of who wrote it. - - Thus, it is not the intent of this section to claim rights or - contest your rights to work written entirely by you; rather, the - intent is to exercise the right to control the distribution of - derivative or collective works based on the Program. - - In addition, mere aggregation of another work not based on the - Program with the Program (or with a work based on the Program) on - a volume of a storage or distribution medium does not bring the - other work under the scope of this License. - - 3. You may copy and distribute the Program (or a work based on it, - under Section 2) in object code or executable form under the terms - of Sections 1 and 2 above provided that you also do one of the - following: - - a. Accompany it with the complete corresponding machine-readable - source code, which must be distributed under the terms of - Sections 1 and 2 above on a medium customarily used for - software interchange; or, - - b. Accompany it with a written offer, valid for at least three - years, to give any third party, for a charge no more than your - cost of physically performing source distribution, a complete - machine-readable copy of the corresponding source code, to be - distributed under the terms of Sections 1 and 2 above on a - medium customarily used for software interchange; or, - - c. Accompany it with the information you received as to the offer - to distribute corresponding source code. (This alternative is - allowed only for noncommercial distribution and only if you - received the program in object code or executable form with - such an offer, in accord with Subsection b above.) - - The source code for a work means the preferred form of the work for - making modifications to it. For an executable work, complete - source code means all the source code for all modules it contains, - plus any associated interface definition files, plus the scripts - used to control compilation and installation of the executable. - However, as a special exception, the source code distributed need - not include anything that is normally distributed (in either - source or binary form) with the major components (compiler, - kernel, and so on) of the operating system on which the executable - runs, unless that component itself accompanies the executable. - - If distribution of executable or object code is made by offering - access to copy from a designated place, then offering equivalent - access to copy the source code from the same place counts as - distribution of the source code, even though third parties are not - compelled to copy the source along with the object code. - - 4. You may not copy, modify, sublicense, or distribute the Program - except as expressly provided under this License. Any attempt - otherwise to copy, modify, sublicense or distribute the Program is - void, and will automatically terminate your rights under this - License. However, parties who have received copies, or rights, - from you under this License will not have their licenses - terminated so long as such parties remain in full compliance. - - 5. You are not required to accept this License, since you have not - signed it. However, nothing else grants you permission to modify - or distribute the Program or its derivative works. These actions - are prohibited by law if you do not accept this License. - Therefore, by modifying or distributing the Program (or any work - based on the Program), you indicate your acceptance of this - License to do so, and all its terms and conditions for copying, - distributing or modifying the Program or works based on it. - - 6. Each time you redistribute the Program (or any work based on the - Program), the recipient automatically receives a license from the - original licensor to copy, distribute or modify the Program - subject to these terms and conditions. You may not impose any - further restrictions on the recipients' exercise of the rights - granted herein. You are not responsible for enforcing compliance - by third parties to this License. - - 7. If, as a consequence of a court judgment or allegation of patent - infringement or for any other reason (not limited to patent - issues), conditions are imposed on you (whether by court order, - agreement or otherwise) that contradict the conditions of this - License, they do not excuse you from the conditions of this - License. If you cannot distribute so as to satisfy simultaneously - your obligations under this License and any other pertinent - obligations, then as a consequence you may not distribute the - Program at all. For example, if a patent license would not permit - royalty-free redistribution of the Program by all those who - receive copies directly or indirectly through you, then the only - way you could satisfy both it and this License would be to refrain - entirely from distribution of the Program. - - If any portion of this section is held invalid or unenforceable - under any particular circumstance, the balance of the section is - intended to apply and the section as a whole is intended to apply - in other circumstances. - - It is not the purpose of this section to induce you to infringe any - patents or other property right claims or to contest validity of - any such claims; this section has the sole purpose of protecting - the integrity of the free software distribution system, which is - implemented by public license practices. Many people have made - generous contributions to the wide range of software distributed - through that system in reliance on consistent application of that - system; it is up to the author/donor to decide if he or she is - willing to distribute software through any other system and a - licensee cannot impose that choice. - - This section is intended to make thoroughly clear what is believed - to be a consequence of the rest of this License. - - 8. If the distribution and/or use of the Program is restricted in - certain countries either by patents or by copyrighted interfaces, - the original copyright holder who places the Program under this - License may add an explicit geographical distribution limitation - excluding those countries, so that distribution is permitted only - in or among countries not thus excluded. In such case, this - License incorporates the limitation as if written in the body of - this License. - - 9. The Free Software Foundation may publish revised and/or new - versions of the General Public License from time to time. Such - new versions will be similar in spirit to the present version, but - may differ in detail to address new problems or concerns. - - Each version is given a distinguishing version number. If the - Program specifies a version number of this License which applies - to it and "any later version", you have the option of following - the terms and conditions either of that version or of any later - version published by the Free Software Foundation. If the Program - does not specify a version number of this License, you may choose - any version ever published by the Free Software Foundation. - - 10. If you wish to incorporate parts of the Program into other free - programs whose distribution conditions are different, write to the - author to ask for permission. For software which is copyrighted - by the Free Software Foundation, write to the Free Software - Foundation; we sometimes make exceptions for this. Our decision - will be guided by the two goals of preserving the free status of - all derivatives of our free software and of promoting the sharing - and reuse of software generally. - - NO WARRANTY - 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO - WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE - LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT - HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT - WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT - NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND - FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE - QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE - PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY - SERVICING, REPAIR OR CORRECTION. - - 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN - WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY - MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE - LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, - INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR - INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF - DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU - OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY - OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN - ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. - - END OF TERMS AND CONDITIONS -How to Apply These Terms to Your New Programs -============================================= - -If you develop a new program, and you want it to be of the greatest -possible use to the public, the best way to achieve this is to make it -free software which everyone can redistribute and change under these -terms. - - To do so, attach the following notices to the program. It is safest -to attach them to the start of each source file to most effectively -convey the exclusion of warranty; and each file should have at least -the "copyright" line and a pointer to where the full notice is found. - - ONE LINE TO GIVE THE PROGRAM'S NAME AND AN IDEA OF WHAT IT DOES. - Copyright (C) 19YY NAME OF AUTHOR - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License - as published by the Free Software Foundation; either version 2 - of the License, or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - - Also add information on how to contact you by electronic and paper -mail. - - If the program is interactive, make it output a short notice like -this when it starts in an interactive mode: - - Gnomovision version 69, Copyright (C) 19YY NAME OF AUTHOR - Gnomovision comes with ABSOLUTELY NO WARRANTY; for details - type `show w'. This is free software, and you are welcome - to redistribute it under certain conditions; type `show c' - for details. - - The hypothetical commands `show w' and `show c' should show the -appropriate parts of the General Public License. Of course, the -commands you use may be called something other than `show w' and `show -c'; they could even be mouse-clicks or menu items--whatever suits your -program. - - You should also get your employer (if you work as a programmer) or -your school, if any, to sign a "copyright disclaimer" for the program, -if necessary. Here is a sample; alter the names: - - Yoyodyne, Inc., hereby disclaims all copyright - interest in the program `Gnomovision' - (which makes passes at compilers) written - by James Hacker. - - SIGNATURE OF TY COON, 1 April 1989 - Ty Coon, President of Vice - - This General Public License does not permit incorporating your -program into proprietary programs. If your program is a subroutine -library, you may consider it more useful to permit linking proprietary -applications with the library. If this is what you want to do, use the -GNU Library General Public License instead of this License. - - -File: stow.info, Node: Index, Prev: GNU General Public License, Up: Top - -Index -***** - -[index] -* Menu: - -* absolute symlink: Terminology. (line 43) -* conflict: Installing Packages. (line 72) -* deletion: Deleting Packages. (line 6) -* directory folding: Installing Packages. (line 13) -* false conflict: Conflicts. (line 19) -* folding trees: Installing Packages. (line 13) -* installation: Installing Packages. (line 6) -* installation image: Terminology. (line 23) -* ownership: Installing Packages. (line 62) -* package: Terminology. (line 6) -* package directory: Terminology. (line 30) -* package name: Terminology. (line 30) -* relative symlink: Terminology. (line 43) -* splitting open folded trees: Installing Packages. (line 44) -* stow directory: Terminology. (line 16) -* symlink: Terminology. (line 43) -* target directory: Terminology. (line 11) -* tree folding: Installing Packages. (line 13) -* unfolding trees: Installing Packages. (line 44) - - - -Tag Table: -Node: Top1313 -Node: Introduction2684 -Ref: Introduction-Footnote-14845 -Node: Terminology4887 -Node: Invoking Stow7250 -Node: Installing Packages12809 -Node: Deleting Packages17066 -Ref: Deleting Packages-Footnote-118486 -Node: Conflicts19074 -Node: Deferred Operation20253 -Node: Mixing Operations20781 -Node: Multiple Stow Directories21780 -Node: Target Maintenance22954 -Node: Resource Files23550 -Node: Compile-time vs Install-time25160 -Node: GNU Emacs28447 -Ref: GNU Emacs-Footnote-129436 -Node: Other FSF Software29500 -Node: Cygnus Software30261 -Node: Perl and Perl 5 Modules31740 -Node: Bootstrapping35295 -Node: Reporting Bugs36076 -Node: Known Bugs37044 -Node: GNU General Public License37747 -Node: Index56887 - -End Tag Table diff --git a/version.texi b/version.texi deleted file mode 100644 index 3245b32..0000000 --- a/version.texi +++ /dev/null @@ -1,4 +0,0 @@ -@set UPDATED 20 February 2008 -@set UPDATED-MONTH February 2008 -@set EDITION 2.0.2 -@set VERSION 2.0.2 From f5e6bfddc2b95399d5552deaba6965a7013c89e4 Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Wed, 16 Nov 2011 14:30:55 +0000 Subject: [PATCH 003/482] Add test target to Makefile --- Makefile.am | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Makefile.am b/Makefile.am index 8b549ad..83bebcb 100644 --- a/Makefile.am +++ b/Makefile.am @@ -52,3 +52,6 @@ manual.html: manual.texi manual.texi: stow.texi -rm -f $@ cp $< $@ + +test: stow chkstow + perl -MTest::Harness -e 'runtests(@ARGV)' t/*.t From 5d7f967ebd05e64e4adc1e95b4a2c9bf811573a0 Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Wed, 16 Nov 2011 14:31:32 +0000 Subject: [PATCH 004/482] Run autoreconf with more recent GNU autotools. --- aclocal.m4 | 141 ++++++++++++++++++++++++++++++++++++----------------- 1 file changed, 97 insertions(+), 44 deletions(-) diff --git a/aclocal.m4 b/aclocal.m4 index 2981344..3052e91 100644 --- a/aclocal.m4 +++ b/aclocal.m4 @@ -1,7 +1,7 @@ -# generated automatically by aclocal 1.10 -*- Autoconf -*- +# generated automatically by aclocal 1.11.1 -*- Autoconf -*- # Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, -# 2005, 2006 Free Software Foundation, Inc. +# 2005, 2006, 2007, 2008, 2009 Free Software Foundation, Inc. # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. @@ -11,12 +11,15 @@ # even the implied warranty of MERCHANTABILITY or FITNESS FOR A # PARTICULAR PURPOSE. -m4_if(m4_PACKAGE_VERSION, [2.61],, -[m4_fatal([this file was generated for autoconf 2.61. -You have another version of autoconf. If you want to use that, -you should regenerate the build system entirely.], [63])]) +m4_ifndef([AC_AUTOCONF_VERSION], + [m4_copy([m4_PACKAGE_VERSION], [AC_AUTOCONF_VERSION])])dnl +m4_if(m4_defn([AC_AUTOCONF_VERSION]), [2.68],, +[m4_warning([this file was generated for autoconf 2.68. +You have another version of autoconf. It may work, but is not guaranteed to. +If you have problems, you may need to regenerate the build system entirely. +To do so, use the procedure documented by the package, typically `autoreconf'.])]) -# Copyright (C) 2002, 2003, 2005, 2006 Free Software Foundation, Inc. +# Copyright (C) 2002, 2003, 2005, 2006, 2007, 2008 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -28,10 +31,10 @@ you should regenerate the build system entirely.], [63])]) # generated from the m4 files accompanying Automake X.Y. # (This private macro should not be called outside this file.) AC_DEFUN([AM_AUTOMAKE_VERSION], -[am__api_version='1.10' +[am__api_version='1.11' dnl Some users find AM_AUTOMAKE_VERSION and mistake it for a way to dnl require some minimum version. Point them to the right macro. -m4_if([$1], [1.10], [], +m4_if([$1], [1.11.1], [], [AC_FATAL([Do not call $0, use AM_INIT_AUTOMAKE([$1]).])])dnl ]) @@ -45,10 +48,12 @@ m4_define([_AM_AUTOCONF_VERSION], []) # AM_SET_CURRENT_AUTOMAKE_VERSION # ------------------------------- # Call AM_AUTOMAKE_VERSION and AM_AUTOMAKE_VERSION so they can be traced. -# This function is AC_REQUIREd by AC_INIT_AUTOMAKE. +# This function is AC_REQUIREd by AM_INIT_AUTOMAKE. AC_DEFUN([AM_SET_CURRENT_AUTOMAKE_VERSION], -[AM_AUTOMAKE_VERSION([1.10])dnl -_AM_AUTOCONF_VERSION(m4_PACKAGE_VERSION)]) +[AM_AUTOMAKE_VERSION([1.11.1])dnl +m4_ifndef([AC_AUTOCONF_VERSION], + [m4_copy([m4_PACKAGE_VERSION], [AC_AUTOCONF_VERSION])])dnl +_AM_AUTOCONF_VERSION(m4_defn([AC_AUTOCONF_VERSION]))]) # AM_AUX_DIR_EXPAND -*- Autoconf -*- @@ -106,13 +111,13 @@ am_aux_dir=`cd $ac_aux_dir && pwd` # Do all the work for Automake. -*- Autoconf -*- # Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, -# 2005, 2006 Free Software Foundation, Inc. +# 2005, 2006, 2008, 2009 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. -# serial 12 +# serial 16 # This macro actually does too much. Some checks are only needed if # your package does certain things. But this isn't really a big deal. @@ -129,7 +134,7 @@ am_aux_dir=`cd $ac_aux_dir && pwd` # arguments mandatory, and then we can depend on a new Autoconf # release and drop the old call support. AC_DEFUN([AM_INIT_AUTOMAKE], -[AC_PREREQ([2.60])dnl +[AC_PREREQ([2.62])dnl dnl Autoconf wants to disallow AM_ names. We explicitly allow dnl the ones we care about. m4_pattern_allow([^AM_[A-Z]+FLAGS$])dnl @@ -180,8 +185,8 @@ AM_MISSING_PROG(AUTOCONF, autoconf) AM_MISSING_PROG(AUTOMAKE, automake-${am__api_version}) AM_MISSING_PROG(AUTOHEADER, autoheader) AM_MISSING_PROG(MAKEINFO, makeinfo) -AM_PROG_INSTALL_SH -AM_PROG_INSTALL_STRIP +AC_REQUIRE([AM_PROG_INSTALL_SH])dnl +AC_REQUIRE([AM_PROG_INSTALL_STRIP])dnl AC_REQUIRE([AM_PROG_MKDIR_P])dnl # We need awk for the "check" target. The system "awk" is bad on # some platforms. @@ -189,24 +194,37 @@ AC_REQUIRE([AC_PROG_AWK])dnl AC_REQUIRE([AC_PROG_MAKE_SET])dnl AC_REQUIRE([AM_SET_LEADING_DOT])dnl _AM_IF_OPTION([tar-ustar], [_AM_PROG_TAR([ustar])], - [_AM_IF_OPTION([tar-pax], [_AM_PROG_TAR([pax])], - [_AM_PROG_TAR([v7])])]) + [_AM_IF_OPTION([tar-pax], [_AM_PROG_TAR([pax])], + [_AM_PROG_TAR([v7])])]) _AM_IF_OPTION([no-dependencies],, [AC_PROVIDE_IFELSE([AC_PROG_CC], - [_AM_DEPENDENCIES(CC)], - [define([AC_PROG_CC], - defn([AC_PROG_CC])[_AM_DEPENDENCIES(CC)])])dnl + [_AM_DEPENDENCIES(CC)], + [define([AC_PROG_CC], + defn([AC_PROG_CC])[_AM_DEPENDENCIES(CC)])])dnl AC_PROVIDE_IFELSE([AC_PROG_CXX], - [_AM_DEPENDENCIES(CXX)], - [define([AC_PROG_CXX], - defn([AC_PROG_CXX])[_AM_DEPENDENCIES(CXX)])])dnl + [_AM_DEPENDENCIES(CXX)], + [define([AC_PROG_CXX], + defn([AC_PROG_CXX])[_AM_DEPENDENCIES(CXX)])])dnl AC_PROVIDE_IFELSE([AC_PROG_OBJC], - [_AM_DEPENDENCIES(OBJC)], - [define([AC_PROG_OBJC], - defn([AC_PROG_OBJC])[_AM_DEPENDENCIES(OBJC)])])dnl + [_AM_DEPENDENCIES(OBJC)], + [define([AC_PROG_OBJC], + defn([AC_PROG_OBJC])[_AM_DEPENDENCIES(OBJC)])])dnl ]) +_AM_IF_OPTION([silent-rules], [AC_REQUIRE([AM_SILENT_RULES])])dnl +dnl The `parallel-tests' driver may need to know about EXEEXT, so add the +dnl `am__EXEEXT' conditional if _AM_COMPILER_EXEEXT was seen. This macro +dnl is hooked onto _AC_COMPILER_EXEEXT early, see below. +AC_CONFIG_COMMANDS_PRE(dnl +[m4_provide_if([_AM_COMPILER_EXEEXT], + [AM_CONDITIONAL([am__EXEEXT], [test -n "$EXEEXT"])])])dnl ]) +dnl Hook into `_AC_COMPILER_EXEEXT' early to learn its expansion. Do not +dnl add the conditional right here, as _AC_COMPILER_EXEEXT may be further +dnl mangled by Autoconf and run in a shell conditional statement. +m4_define([_AC_COMPILER_EXEEXT], +m4_defn([_AC_COMPILER_EXEEXT])[m4_provide([_AM_COMPILER_EXEEXT])]) + # When config.status generates a header, we must update the stamp-h file. # This file resides in the same directory as the config header @@ -217,18 +235,19 @@ AC_PROVIDE_IFELSE([AC_PROG_OBJC], # our stamp files there. AC_DEFUN([_AC_AM_CONFIG_HEADER_HOOK], [# Compute $1's index in $config_headers. +_am_arg=$1 _am_stamp_count=1 for _am_header in $config_headers :; do case $_am_header in - $1 | $1:* ) + $_am_arg | $_am_arg:* ) break ;; * ) _am_stamp_count=`expr $_am_stamp_count + 1` ;; esac done -echo "timestamp for $1" >`AS_DIRNAME([$1])`/stamp-h[]$_am_stamp_count]) +echo "timestamp for $_am_arg" >`AS_DIRNAME(["$_am_arg"])`/stamp-h[]$_am_stamp_count]) -# Copyright (C) 2001, 2003, 2005 Free Software Foundation, Inc. +# Copyright (C) 2001, 2003, 2005, 2008 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -239,7 +258,14 @@ echo "timestamp for $1" >`AS_DIRNAME([$1])`/stamp-h[]$_am_stamp_count]) # Define $install_sh. AC_DEFUN([AM_PROG_INSTALL_SH], [AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl -install_sh=${install_sh-"\$(SHELL) $am_aux_dir/install-sh"} +if test x"${install_sh}" != xset; then + case $am_aux_dir in + *\ * | *\ *) + install_sh="\${SHELL} '$am_aux_dir/install-sh'" ;; + *) + install_sh="\${SHELL} $am_aux_dir/install-sh" + esac +fi AC_SUBST(install_sh)]) # Copyright (C) 2003, 2005 Free Software Foundation, Inc. @@ -265,14 +291,14 @@ AC_SUBST([am__leading_dot])]) # Fake the existence of programs that GNU maintainers use. -*- Autoconf -*- -# Copyright (C) 1997, 1999, 2000, 2001, 2003, 2004, 2005 +# Copyright (C) 1997, 1999, 2000, 2001, 2003, 2004, 2005, 2008 # Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. -# serial 5 +# serial 6 # AM_MISSING_PROG(NAME, PROGRAM) # ------------------------------ @@ -289,7 +315,14 @@ AC_SUBST($1)]) AC_DEFUN([AM_MISSING_HAS_RUN], [AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl AC_REQUIRE_AUX_FILE([missing])dnl -test x"${MISSING+set}" = xset || MISSING="\${SHELL} $am_aux_dir/missing" +if test x"${MISSING+set}" != xset; then + case $am_aux_dir in + *\ * | *\ *) + MISSING="\${SHELL} \"$am_aux_dir/missing\"" ;; + *) + MISSING="\${SHELL} $am_aux_dir/missing" ;; + esac +fi # Use eval to expand $SHELL if eval "$MISSING --run true"; then am_missing_run="$MISSING --run " @@ -327,13 +360,13 @@ esac # Helper functions for option handling. -*- Autoconf -*- -# Copyright (C) 2001, 2002, 2003, 2005 Free Software Foundation, Inc. +# Copyright (C) 2001, 2002, 2003, 2005, 2008 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. -# serial 3 +# serial 4 # _AM_MANGLE_OPTION(NAME) # ----------------------- @@ -350,7 +383,7 @@ AC_DEFUN([_AM_SET_OPTION], # ---------------------------------- # OPTIONS is a space-separated list of Automake options. AC_DEFUN([_AM_SET_OPTIONS], -[AC_FOREACH([_AM_Option], [$1], [_AM_SET_OPTION(_AM_Option)])]) +[m4_foreach_w([_AM_Option], [$1], [_AM_SET_OPTION(_AM_Option)])]) # _AM_IF_OPTION(OPTION, IF-SET, [IF-NOT-SET]) # ------------------------------------------- @@ -360,14 +393,14 @@ AC_DEFUN([_AM_IF_OPTION], # Check to make sure that the build environment is sane. -*- Autoconf -*- -# Copyright (C) 1996, 1997, 2000, 2001, 2003, 2005 +# Copyright (C) 1996, 1997, 2000, 2001, 2003, 2005, 2008 # Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. -# serial 4 +# serial 5 # AM_SANITY_CHECK # --------------- @@ -376,16 +409,29 @@ AC_DEFUN([AM_SANITY_CHECK], # Just in case sleep 1 echo timestamp > conftest.file +# Reject unsafe characters in $srcdir or the absolute working directory +# name. Accept space and tab only in the latter. +am_lf=' +' +case `pwd` in + *[[\\\"\#\$\&\'\`$am_lf]]*) + AC_MSG_ERROR([unsafe absolute working directory name]);; +esac +case $srcdir in + *[[\\\"\#\$\&\'\`$am_lf\ \ ]]*) + AC_MSG_ERROR([unsafe srcdir value: `$srcdir']);; +esac + # Do `set' in a subshell so we don't clobber the current shell's # arguments. Must try -L first in case configure is actually a # symlink; some systems play weird games with the mod time of symlinks # (eg FreeBSD returns the mod time of the symlink's containing # directory). if ( - set X `ls -Lt $srcdir/configure conftest.file 2> /dev/null` + set X `ls -Lt "$srcdir/configure" conftest.file 2> /dev/null` if test "$[*]" = "X"; then # -L didn't work. - set X `ls -t $srcdir/configure conftest.file` + set X `ls -t "$srcdir/configure" conftest.file` fi rm -f conftest.file if test "$[*]" != "X $srcdir/configure conftest.file" \ @@ -438,18 +484,25 @@ fi INSTALL_STRIP_PROGRAM="\$(install_sh) -c -s" AC_SUBST([INSTALL_STRIP_PROGRAM])]) -# Copyright (C) 2006 Free Software Foundation, Inc. +# Copyright (C) 2006, 2008 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. +# serial 2 + # _AM_SUBST_NOTMAKE(VARIABLE) # --------------------------- -# Prevent Automake from outputing VARIABLE = @VARIABLE@ in Makefile.in. +# Prevent Automake from outputting VARIABLE = @VARIABLE@ in Makefile.in. # This macro is traced by Automake. AC_DEFUN([_AM_SUBST_NOTMAKE]) +# AM_SUBST_NOTMAKE(VARIABLE) +# --------------------------- +# Public sister of _AM_SUBST_NOTMAKE. +AC_DEFUN([AM_SUBST_NOTMAKE], [_AM_SUBST_NOTMAKE($@)]) + # Check how to create a tarball. -*- Autoconf -*- # Copyright (C) 2004, 2005 Free Software Foundation, Inc. From 8e14cb641f047a696afbe2bbcc7505fd437e1c26 Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Wed, 16 Nov 2011 14:34:02 +0000 Subject: [PATCH 005/482] Support ./configure --disable-maintainer-mode to optionally avoid auto-reconfiguring on make. --- aclocal.m4 | 76 ++++++++++++++++++++++++++++++++++++++++++++++++++++ configure.ac | 2 ++ 2 files changed, 78 insertions(+) diff --git a/aclocal.m4 b/aclocal.m4 index 3052e91..fced0e9 100644 --- a/aclocal.m4 +++ b/aclocal.m4 @@ -108,6 +108,42 @@ AC_PREREQ([2.50])dnl am_aux_dir=`cd $ac_aux_dir && pwd` ]) +# AM_CONDITIONAL -*- Autoconf -*- + +# Copyright (C) 1997, 2000, 2001, 2003, 2004, 2005, 2006, 2008 +# Free Software Foundation, Inc. +# +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# serial 9 + +# AM_CONDITIONAL(NAME, SHELL-CONDITION) +# ------------------------------------- +# Define a conditional. +AC_DEFUN([AM_CONDITIONAL], +[AC_PREREQ(2.52)dnl + ifelse([$1], [TRUE], [AC_FATAL([$0: invalid condition: $1])], + [$1], [FALSE], [AC_FATAL([$0: invalid condition: $1])])dnl +AC_SUBST([$1_TRUE])dnl +AC_SUBST([$1_FALSE])dnl +_AM_SUBST_NOTMAKE([$1_TRUE])dnl +_AM_SUBST_NOTMAKE([$1_FALSE])dnl +m4_define([_AM_COND_VALUE_$1], [$2])dnl +if $2; then + $1_TRUE= + $1_FALSE='#' +else + $1_TRUE='#' + $1_FALSE= +fi +AC_CONFIG_COMMANDS_PRE( +[if test -z "${$1_TRUE}" && test -z "${$1_FALSE}"; then + AC_MSG_ERROR([[conditional "$1" was never defined. +Usually this means the macro was only invoked conditionally.]]) +fi])]) + # Do all the work for Automake. -*- Autoconf -*- # Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, @@ -289,6 +325,46 @@ fi rmdir .tst 2>/dev/null AC_SUBST([am__leading_dot])]) +# Add --enable-maintainer-mode option to configure. -*- Autoconf -*- +# From Jim Meyering + +# Copyright (C) 1996, 1998, 2000, 2001, 2002, 2003, 2004, 2005, 2008 +# Free Software Foundation, Inc. +# +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# serial 5 + +# AM_MAINTAINER_MODE([DEFAULT-MODE]) +# ---------------------------------- +# Control maintainer-specific portions of Makefiles. +# Default is to disable them, unless `enable' is passed literally. +# For symmetry, `disable' may be passed as well. Anyway, the user +# can override the default with the --enable/--disable switch. +AC_DEFUN([AM_MAINTAINER_MODE], +[m4_case(m4_default([$1], [disable]), + [enable], [m4_define([am_maintainer_other], [disable])], + [disable], [m4_define([am_maintainer_other], [enable])], + [m4_define([am_maintainer_other], [enable]) + m4_warn([syntax], [unexpected argument to AM@&t@_MAINTAINER_MODE: $1])]) +AC_MSG_CHECKING([whether to am_maintainer_other maintainer-specific portions of Makefiles]) + dnl maintainer-mode's default is 'disable' unless 'enable' is passed + AC_ARG_ENABLE([maintainer-mode], +[ --][am_maintainer_other][-maintainer-mode am_maintainer_other make rules and dependencies not useful + (and sometimes confusing) to the casual installer], + [USE_MAINTAINER_MODE=$enableval], + [USE_MAINTAINER_MODE=]m4_if(am_maintainer_other, [enable], [no], [yes])) + AC_MSG_RESULT([$USE_MAINTAINER_MODE]) + AM_CONDITIONAL([MAINTAINER_MODE], [test $USE_MAINTAINER_MODE = yes]) + MAINT=$MAINTAINER_MODE_TRUE + AC_SUBST([MAINT])dnl +] +) + +AU_DEFUN([jm_MAINTAINER_MODE], [AM_MAINTAINER_MODE]) + # Fake the existence of programs that GNU maintainers use. -*- Autoconf -*- # Copyright (C) 1997, 1999, 2000, 2001, 2003, 2004, 2005, 2008 diff --git a/configure.ac b/configure.ac index fe89853..09bac98 100644 --- a/configure.ac +++ b/configure.ac @@ -5,6 +5,8 @@ AC_PREREQ([2.61]) AM_INIT_AUTOMAKE([-Wall -Werror]) AC_PROG_INSTALL +AM_MAINTAINER_MODE([enable]) + dnl Check for perl on our system dnl call to AC_SUBST(PERL) is implicit AC_PATH_PROGS([PERL], [perl] [perl5], [false]) From d6dbb932acda5803c0c73370d63296c379aa5f56 Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Wed, 16 Nov 2011 14:45:56 +0000 Subject: [PATCH 006/482] Fix chkstow.in for emacs users --- chkstow.in | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) mode change 100644 => 100755 chkstow.in diff --git a/chkstow.in b/chkstow.in old mode 100644 new mode 100755 index 6e54b91..2219875 --- a/chkstow.in +++ b/chkstow.in @@ -101,4 +101,7 @@ sub list { 1; # Hey, it's a module! -# vim:ft=perl +# Local variables: +# mode: perl +# End: +# vim: ft=perl From 5fe30e9f1a9ae5bf1c9cf856d996c5e562ed4801 Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Wed, 16 Nov 2011 14:46:31 +0000 Subject: [PATCH 007/482] Add #! header to t/util.pm for benefit of editor mode selection --- t/util.pm | 2 ++ 1 file changed, 2 insertions(+) mode change 100644 => 100755 t/util.pm diff --git a/t/util.pm b/t/util.pm old mode 100644 new mode 100755 index abf670d..73e0f3a --- a/t/util.pm +++ b/t/util.pm @@ -1,3 +1,5 @@ +#!/usr/bin/perl + # # Utilities shared by test scripts # From 8da2a43eb1fa54b398e59870b8b214eea1983598 Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Wed, 16 Nov 2011 14:51:38 +0000 Subject: [PATCH 008/482] Fix chkstow.t --- chkstow.in | 3 +-- t/chkstow.t | 4 ++-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/chkstow.in b/chkstow.in index 2219875..f14ec25 100755 --- a/chkstow.in +++ b/chkstow.in @@ -60,8 +60,7 @@ sub check_stow { delete $Package{'..'}; if (keys %Package) { - local $,="\n"; - print sort(keys %Package), "\n"; + print map "$_\n", sort(keys %Package); } } return; diff --git a/t/chkstow.t b/t/chkstow.t index f75a88a..f38de57 100755 --- a/t/chkstow.t +++ b/t/chkstow.t @@ -79,7 +79,7 @@ $SIG{'__WARN__'} = sub { }; @ARGV = ('-t', '.', '-l',); stdout_like( \&run_chkstow, - qr{emacs$perl$stow}xms, + qr{emacs\nperl\nstow\n}xms, "List packages"); @ARGV = ('-t', '.', '-b',); @@ -111,5 +111,5 @@ stdout_like( @ARGV = ('-b',); process_options(); -ok($Target == q{/usr/local}, +ok($::Target == q{/usr/local}, "Default target is /usr/local/"); From 4296500c94159b40a1f844d29d26f187f0b06268 Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Wed, 16 Nov 2011 15:04:21 +0000 Subject: [PATCH 009/482] Fix t/stow.t --- t/stow.t | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) mode change 100644 => 100755 t/stow.t diff --git a/t/stow.t b/t/stow.t old mode 100644 new mode 100755 index 4281270..49d671a --- a/t/stow.t +++ b/t/stow.t @@ -88,7 +88,7 @@ is_deeply($Option{'override'}, [qr(\Aman), qr(\Ainfo)] => 'strip shell quoting') %Option=(); local @ARGV = ( '--ignore="~"', - '--ignore="\.#.*' + '--ignore="\.#.*"' ); process_options(); is_deeply($Option{'ignore'}, [ qr(~\z), qr(\.#.*\z) ] => 'ignore temp files'); From d74ae26f89f1a7b9ccd36e103b6d09b328f1ddf4 Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Wed, 16 Nov 2011 15:07:26 +0000 Subject: [PATCH 010/482] Fix %Options typo in several tests --- t/cleanup_invalid_links.t | 2 +- t/examples.t | 2 +- t/stow_contents.t | 2 +- t/unstow_contents.t | 2 +- t/unstow_contents_orig.t | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) mode change 100644 => 100755 t/cleanup_invalid_links.t mode change 100644 => 100755 t/examples.t mode change 100644 => 100755 t/stow_contents.t mode change 100644 => 100755 t/unstow_contents.t mode change 100644 => 100755 t/unstow_contents_orig.t diff --git a/t/cleanup_invalid_links.t b/t/cleanup_invalid_links.t old mode 100644 new mode 100755 index 8273926..92741cc --- a/t/cleanup_invalid_links.t +++ b/t/cleanup_invalid_links.t @@ -16,7 +16,7 @@ sub reset_state { @Conflicts = (); %Link_Task_For = (); %Dir_Task_For = (); - %Options = (); + %Option = (); return; } diff --git a/t/examples.t b/t/examples.t old mode 100644 new mode 100755 index 839f822..ec90cef --- a/t/examples.t +++ b/t/examples.t @@ -16,7 +16,7 @@ sub reset_state { @Conflicts = (); %Link_Task_For = (); %Dir_Task_For = (); - %Options = (); + %Option = (); return; } diff --git a/t/stow_contents.t b/t/stow_contents.t old mode 100644 new mode 100755 index 093a1df..bbfab62 --- a/t/stow_contents.t +++ b/t/stow_contents.t @@ -16,7 +16,7 @@ sub reset_state { @Conflicts = (); %Link_Task_For = (); %Dir_Task_For = (); - %Options = (); + %Option = (); return; } diff --git a/t/unstow_contents.t b/t/unstow_contents.t old mode 100644 new mode 100755 index 06880f3..e30fa2f --- a/t/unstow_contents.t +++ b/t/unstow_contents.t @@ -16,7 +16,7 @@ sub reset_state { @Conflicts = (); %Link_Task_For = (); %Dir_Task_For = (); - %Options = (); + %Option = (); return; } diff --git a/t/unstow_contents_orig.t b/t/unstow_contents_orig.t old mode 100644 new mode 100755 index ead3dc5..7b8c903 --- a/t/unstow_contents_orig.t +++ b/t/unstow_contents_orig.t @@ -16,7 +16,7 @@ sub reset_state { @Conflicts = (); %Link_Task_For = (); %Dir_Task_For = (); - %Options = (); + %Option = (); return; } From 8de15394bb08713e9cb87b933085a64274f1f0ca Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Wed, 16 Nov 2011 15:16:53 +0000 Subject: [PATCH 011/482] Catch warnings in tests when no outstanding operations to perform. Tests now all pass completely cleanly. --- t/stow_contents.t | 9 +++++++-- t/unstow_contents.t | 21 +++++++++++++++++---- t/unstow_contents_orig.t | 21 +++++++++++++++++---- 3 files changed, 41 insertions(+), 10 deletions(-) diff --git a/t/stow_contents.t b/t/stow_contents.t index bbfab62..e27d17b 100755 --- a/t/stow_contents.t +++ b/t/stow_contents.t @@ -7,7 +7,8 @@ # load as a library BEGIN { use lib qw(.); require "t/util.pm"; require "stow"; } -use Test::More tests => 13; +use Test::More tests => 14; +use Test::Output; use English qw(-no_match_vars); # local utility @@ -209,7 +210,11 @@ make_link('man10/man1/file10.1' => '../../../stow/pkg10a/man10/man1/file10.1'); make_dir('../stow/pkg10b/man10/man1'); make_file('../stow/pkg10b/man10/man1/file10.1'); stow_contents('../stow/pkg10b', './', '../stow/pkg10b'); -process_tasks(); +stderr_like( + sub { process_tasks(); }, + qr/There are no outstanding operations to perform/, + 'no tasks to process' +); ok( scalar(@Conflicts) == 0 && readlink('man10/man1/file10.1') eq '../../../stow/pkg10a/man10/man1/file10.1' diff --git a/t/unstow_contents.t b/t/unstow_contents.t index e30fa2f..83c5507 100755 --- a/t/unstow_contents.t +++ b/t/unstow_contents.t @@ -7,7 +7,8 @@ # load as a library BEGIN { use lib qw(.); require "t/util.pm"; require "stow"; } -use Test::More tests => 11; +use Test::More tests => 14; +use Test::Output; use English qw(-no_match_vars); # local utility @@ -162,7 +163,11 @@ make_file('stow/pkg7a/stow/pkg7b/file7b'); make_link('stow/pkg7b', '../stow/pkg7a/stow/pkg7b'); unstow_contents('stow/pkg7b', './'); -process_tasks(); +stderr_like( + sub { process_tasks(); }, + qr/There are no outstanding operations to perform/, + 'no tasks to process when unstowing pkg7b' +); ok( scalar(@Conflicts) == 0 && -l 'stow/pkg7b' && @@ -188,7 +193,11 @@ make_file('stow/pkg8a/stow2/pkg8b/file8b'); make_link('stow2/pkg8b', '../stow/pkg8a/stow2/pkg8b'); unstow_contents('stow/pkg8a', './'); -process_tasks(); +stderr_like( + sub { process_tasks(); }, + qr/There are no outstanding operations to perform/, + 'no tasks to process when unstowing pkg8a' +); ok( scalar(@Conflicts) == 0 && -l 'stow2/pkg8b' && @@ -240,7 +249,11 @@ make_link('man10/man1/file10b.1' => '../../../stow/pkg10b/man10/man1/file10b.1' make_dir('../stow/pkg10c/man10/man1'); make_file('../stow/pkg10c/man10/man1/file10a.1'); unstow_contents('../stow/pkg10c', './'); -process_tasks(); +stderr_like( + sub { process_tasks(); }, + qr/There are no outstanding operations to perform/, + 'no tasks to process when unstowing pkg10c' +); ok( scalar(@Conflicts) == 0 && readlink('man10/man1/file10a.1') eq '../../../stow/pkg10a/man10/man1/file10a.1' diff --git a/t/unstow_contents_orig.t b/t/unstow_contents_orig.t index 7b8c903..17fb6e1 100755 --- a/t/unstow_contents_orig.t +++ b/t/unstow_contents_orig.t @@ -7,7 +7,8 @@ # load as a library BEGIN { use lib qw(.); require "t/util.pm"; require "stow"; } -use Test::More tests => 11; +use Test::More tests => 14; +use Test::Output; use English qw(-no_match_vars); # local utility @@ -164,7 +165,11 @@ make_file('stow/pkg7a/stow/pkg7b/file7b'); make_link('stow/pkg7b', '../stow/pkg7a/stow/pkg7b'); unstow_contents_orig('stow/pkg7b', './'); -process_tasks(); +stderr_like( + sub { process_tasks(); }, + qr/There are no outstanding operations to perform/, + 'no tasks to process when unstowing pkg7b' +); ok( scalar(@Conflicts) == 0 && -l 'stow/pkg7b' && @@ -190,7 +195,11 @@ make_file('stow/pkg8a/stow2/pkg8b/file8b'); make_link('stow2/pkg8b', '../stow/pkg8a/stow2/pkg8b'); unstow_contents_orig('stow/pkg8a', './'); -process_tasks(); +stderr_like( + sub { process_tasks(); }, + qr/There are no outstanding operations to perform/, + 'no tasks to process when unstowing pkg8a' +); ok( scalar(@Conflicts) == 0 && -l 'stow2/pkg8b' && @@ -242,7 +251,11 @@ make_link('man10/man1/file10b.1' => '../../../stow/pkg10b/man10/man1/file10b.1' make_dir('../stow/pkg10c/man10/man1'); make_file('../stow/pkg10c/man10/man1/file10a.1'); unstow_contents_orig('../stow/pkg10c', './'); -process_tasks(); +stderr_like( + sub { process_tasks(); }, + qr/There are no outstanding operations to perform/, + 'no tasks to process when unstowing pkg8a' +); ok( scalar(@Conflicts) == 0 && readlink('man10/man1/file10a.1') eq '../../../stow/pkg10a/man10/man1/file10a.1' From d674d13a687ce5d9fedd06f5e4c455585d457994 Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Wed, 16 Nov 2011 14:59:58 +0000 Subject: [PATCH 012/482] Fix typos --- AUTHORS | 2 +- TODO | 6 +++--- stow.in | 26 +++++++++++++------------- stow.texi | 7 ++++--- t/relative_path.t | 2 +- t/unstow_contents.t | 4 ++-- t/unstow_contents_orig.t | 4 ++-- 7 files changed, 26 insertions(+), 25 deletions(-) mode change 100644 => 100755 t/relative_path.t diff --git a/AUTHORS b/AUTHORS index fbf4c2f..2fb9a6b 100644 --- a/AUTHORS +++ b/AUTHORS @@ -26,7 +26,7 @@ inorder to implement: 7. a test suite (and support code) to ensure that everything still works. As these changes required a dramatic reorganisation of the code, very little -was left untouched, and so stows major version was bumped up to version 2. +was left untouched, and so Stow's major version was bumped up to version 2. Austin Wood and Chris Hoobin helped clean up the documentation for diff --git a/TODO b/TODO index eaf9c82..e848da6 100644 --- a/TODO +++ b/TODO @@ -5,13 +5,13 @@ * Update stow.texi - The email address in 'Reporting Bugs' needs to be updated -* Figure out what needs the optin 'nostow' 'notstowed'. Can they be removed? +* Figure out what needs the option 'nostow' 'notstowed'. Can they be removed? * _texi2man_ needs author/copyright/license to be completed * Update http://directory.fsf.org/project/stow/ -* Update savanaugh CVS +* Update savannah CVS * Check that all email addresses are working: need an account on fenchpost for this bug-stow@gnu.org, help-stow@gnu.org @@ -45,5 +45,5 @@ From e-mail with meyering@na-net.ornl.gov: Does Version 2 fix this? (Kal) I think that because it never needs to create /usr/local/info, -it only needs to check th ownership of links that it _operatates_ on, +it only needs to check the ownership of links that it _operates_ on, not on all the elements of the path. diff --git a/stow.in b/stow.in index e6fd1cd..6d23f29 100755 --- a/stow.in +++ b/stow.in @@ -61,14 +61,14 @@ our $Stow_Path; # only use in main loop and find_stowed_path() # Store conflicts during pre-processing our @Conflicts = (); -# Store command line packges to stow (-S and -R) +# Store command line packages to stow (-S and -R) our @Pkgs_To_Stow = (); # Store command line packages to unstow (-D and -R) our @Pkgs_To_Delete = (); # The following structures are used by the abstractions that allow us to -# defer operating on the filesystem until after all potential conflcits have +# defer operating on the filesystem until after all potential conflicts have # been assessed. # our @Tasks: list of operations to be performed (in order) @@ -82,12 +82,12 @@ our @Pkgs_To_Delete = (); our @Tasks = (); # my %Dir_Task_For: map a path to the corresponding directory task reference -# This structurew allows us to quickly determine if a path has an existing +# This structure allows us to quickly determine if a path has an existing # directory task associated with it. our %Dir_Task_For = (); # my %Link_Task_For: map a path to the corresponding directory task reference -# This structurew allows us to quickly determine if a path has an existing +# This structure allows us to quickly determine if a path has an existing # directory task associated with it. our %Link_Task_For = (); @@ -269,7 +269,7 @@ sub process_options { # Returns : n/a # Throws : no exceptions # Comments : prepends the contents '~/.stowrc' and '.stowrc' to the command -# : line so they get parsed just like noremal arguments. (This was +# : line so they get parsed just like normal arguments. (This was # : hacked in so that Emil and I could set different preferences). #============================================================================= sub get_defaults { @@ -435,9 +435,9 @@ sub stow_contents { #===== SUBROUTINE =========================================================== # Name : stow_node() # Purpose : stow the given node -# Parameters: $path => realtive path to source node from the current directory -# : $target => realtive path to symlink target from the current directory -# : $source => realtive path to symlink source from the dir of target +# Parameters: $path => relative path to source node from the current directory +# : $target => relative path to symlink target from the current directory +# : $source => relative path to symlink source from the dir of target # Returns : n/a # Throws : fatal exception if a conflict arises # Comments : stow_node() and stow_contents() are mutually recursive @@ -455,7 +455,7 @@ sub stow_node { warn "--- $target => $source\n"; } - # don't try to stow absolute symlinks (they cant be unstowed) + # don't try to stow absolute symlinks (they can't be unstowed) if (-l $source) { my $second_source = read_a_link($source); if ($second_source =~ m{\A/} ) { @@ -640,9 +640,9 @@ sub unstow_node_orig { return; # XXX # } - # does the existing $target actually point to anything + # does the existing $target actually point to anything? if (-e $old_path) { - # does link points to the right place + # does link point to the right place? if ($old_path eq $path) { do_unlink($target); } @@ -1187,7 +1187,7 @@ sub process_tasks { # Returns : Boolean # Throws : none # Comments : returns false if an existing link is scheduled for removal -# : and true if a non-exsitent link is scheduled for creation +# : and true if a non-existent link is scheduled for creation #============================================================================ sub is_a_link { my ($path) = @_; @@ -1698,7 +1698,7 @@ sub relative_path { } #===== SUBROUTINE =========================================================== -# Name : join_path() +# Name : join_paths() # Purpose : concatenates given paths # Parameters: path1, path2, ... => paths # Returns : concatenation of given paths diff --git a/stow.texi b/stow.texi index 81630dc..f4c426c 100644 --- a/stow.texi +++ b/stow.texi @@ -388,7 +388,7 @@ directory. The following options are deprecated: @end table -The following options are deprecated as of Stow Version 2: +The following options are deprecated as of Stow version 2: @table @samp @item -c @itemx --conflicts @@ -400,7 +400,8 @@ This option is deprecated as conflicts are now printed by default and no operations will be performed if any conflicts are detected. @end table -@ref{Resource Files} for a way to set default values for any of these options +@ref{Resource Files} for a way to set default values for any of these +options. @c =========================================================================== @@ -480,7 +481,7 @@ current stow directory. @emph{Stow will never delete anything that it doesn't own}. Stow ``owns'' everything living in the target tree that points into a package in the stow directory. Anything Stow owns, it can recompute if lost: symlinks that point into a package in -the stow directory, or directories that only contain sysmlinks that stow +the stow directory, or directories that only contain symlinks that stow ``owns''. Note that by this definition, Stow doesn't ``own'' anything @emph{in} the stow directory or in any of the packages. diff --git a/t/relative_path.t b/t/relative_path.t old mode 100644 new mode 100755 index 7269b7d..7f60da2 --- a/t/relative_path.t +++ b/t/relative_path.t @@ -12,7 +12,7 @@ use Test::More tests => 5; is( relative_path('a/b/c', 'a/b/d'), '../d', - => 'diferent branches' + => 'different branches' ); is( diff --git a/t/unstow_contents.t b/t/unstow_contents.t index 83c5507..7dd3d6b 100755 --- a/t/unstow_contents.t +++ b/t/unstow_contents.t @@ -157,7 +157,7 @@ $Option{'verbose'} = 0; make_dir('stow'); # make out stow dir a subdir of target $Stow_Path = 'stow'; -# emulate stowing into ourself (bizzare corner case or accident) +# emulate stowing into ourself (bizarre corner case or accident) make_dir('stow/pkg7a/stow/pkg7b'); make_file('stow/pkg7a/stow/pkg7b/file7b'); make_link('stow/pkg7b', '../stow/pkg7a/stow/pkg7b'); @@ -187,7 +187,7 @@ $Stow_Path = 'stow'; make_dir('stow2'); # make our alternate stow dir a subdir of target make_file('stow2/.stow'); -# emulate stowing into ourself (bizzare corner case or accident) +# emulate stowing into ourself (bizarre corner case or accident) make_dir('stow/pkg8a/stow2/pkg8b'); make_file('stow/pkg8a/stow2/pkg8b/file8b'); make_link('stow2/pkg8b', '../stow/pkg8a/stow2/pkg8b'); diff --git a/t/unstow_contents_orig.t b/t/unstow_contents_orig.t index 17fb6e1..90575f6 100755 --- a/t/unstow_contents_orig.t +++ b/t/unstow_contents_orig.t @@ -159,7 +159,7 @@ $Option{'verbose'} = 0; make_dir('stow'); # make out stow dir a subdir of target $Stow_Path = 'stow'; -# emulate stowing into ourself (bizzare corner case or accident) +# emulate stowing into ourself (bizarre corner case or accident) make_dir('stow/pkg7a/stow/pkg7b'); make_file('stow/pkg7a/stow/pkg7b/file7b'); make_link('stow/pkg7b', '../stow/pkg7a/stow/pkg7b'); @@ -189,7 +189,7 @@ $Stow_Path = 'stow'; make_dir('stow2'); # make our alternate stow dir a subdir of target make_file('stow2/.stow'); -# emulate stowing into ourself (bizzare corner case or accident) +# emulate stowing into ourself (bizarre corner case or accident) make_dir('stow/pkg8a/stow2/pkg8b'); make_file('stow/pkg8a/stow2/pkg8b/file8b'); make_link('stow2/pkg8b', '../stow/pkg8a/stow2/pkg8b'); From 59b7835fd8044c3f2b801559f7d2696343688c85 Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Wed, 16 Nov 2011 15:20:21 +0000 Subject: [PATCH 013/482] Troy is the maintainer now. --- AUTHORS | 2 +- README | 4 ++-- TODO | 3 --- stow.texi | 2 +- 4 files changed, 4 insertions(+), 7 deletions(-) diff --git a/AUTHORS b/AUTHORS index 2fb9a6b..c2f7fd5 100644 --- a/AUTHORS +++ b/AUTHORS @@ -32,4 +32,4 @@ Austin Wood and Chris Hoobin helped clean up the documentation for version 2 and created the texi2man script. -Stow is currently maintained by Kahlil (Kal) Hodgson . +Stow is currently maintained by Troy Mill. diff --git a/README b/README index 913f245..58fa4f6 100644 --- a/README +++ b/README @@ -27,5 +27,5 @@ can be found in the file COPYING. See INSTALL for installation instructions. -Please mail comments, questions, and criticisms to the current maintainer, -Kahlil (Kal) Hodgson via help-stow@gnu.org or bug-stow@gnu.org. +Please mail comments, questions, and criticisms to the current maintainer +Troy Mill via help-stow@gnu.org or bug-stow@gnu.org. diff --git a/TODO b/TODO index e848da6..6a39dba 100644 --- a/TODO +++ b/TODO @@ -2,9 +2,6 @@ set up copyright papers? 'assign.future' and 'request-assign.future.manual' -* Update stow.texi - - The email address in 'Reporting Bugs' needs to be updated - * Figure out what needs the option 'nostow' 'notstowed'. Can they be removed? * _texi2man_ needs author/copyright/license to be completed diff --git a/stow.texi b/stow.texi index f4c426c..265ef0f 100644 --- a/stow.texi +++ b/stow.texi @@ -984,7 +984,7 @@ perl/bin/perl stow/bin/stow -vv * @node Reporting Bugs, Known Bugs, Bootstrapping, Top @chapter Reporting Bugs -Please send bug reports to the current maintaner, Kal Hodgson, by electronic +Please send bug reports to the current maintainer, Troy Will, by electronic mail. The address to use is @samp{}. Please include: From 8ce4d3be5262c44de6409b3ba2594f5f75b9897a Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Wed, 16 Nov 2011 15:22:12 +0000 Subject: [PATCH 014/482] Stow now requires Perl 5.6.1 or newer, due to use of 'our'. --- README | 6 +++--- chkstow.in | 2 ++ stow.in | 3 ++- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/README b/README index 58fa4f6..4801308 100644 --- a/README +++ b/README @@ -7,9 +7,9 @@ the database. Also, stow will never delete any files, directories, or links that appear in a stow directory, so it is always possible to rebuild the target tree. -Stow is a Perl script which should run correctly under Perl 4 and Perl 5. You -must install Perl before running Stow. For more information about Perl, see -http://www.perl.com/perl/. +Stow is a Perl script which should run correctly under Perl 5.6.1 or +newer. You must install Perl before running Stow. For more +information about Perl, see http://www.perl.com/perl/. You can get the latest information about Stow from http://www.gnu.org/software/stow/stow.html diff --git a/chkstow.in b/chkstow.in index f14ec25..3fe1741 100755 --- a/chkstow.in +++ b/chkstow.in @@ -3,6 +3,8 @@ use strict; use warnings; +require 5.6.1; + use File::Find; use Getopt::Long; diff --git a/stow.in b/stow.in index 6d23f29..5c6c6bc 100755 --- a/stow.in +++ b/stow.in @@ -22,7 +22,8 @@ use strict; use warnings; -require 5.005; +require 5.6.1; + use POSIX qw(getcwd); use Getopt::Long; From ad28894a85c6064f825c56b95c8b3756a03f6581 Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Wed, 16 Nov 2011 15:38:47 +0000 Subject: [PATCH 015/482] Switch NEWS and TODO to org-mode. org-mode has been included in emacs by default for a long time and is much more friendly than outline-mode. No impact to non-emacs users. --- NEWS | 6 ++++++ TODO | 5 +++++ 2 files changed, 11 insertions(+) diff --git a/NEWS b/NEWS index 1d663f8..c10e993 100644 --- a/NEWS +++ b/NEWS @@ -157,3 +157,9 @@ not exhaustive, but it should provide enough to check for regressions. ** `make clean' removes stow (which is generated from stow.in). * Initial public release (v1.0) of Stow. + + +* emacs local variables + Local Variables: + mode: org + End: diff --git a/TODO b/TODO index 6a39dba..132f689 100644 --- a/TODO +++ b/TODO @@ -44,3 +44,8 @@ Does Version 2 fix this? (Kal) I think that because it never needs to create /usr/local/info, it only needs to check the ownership of links that it _operates_ on, not on all the elements of the path. + +* emacs local variables + Local Variables: + mode: org + End: From 5a09c527b3a149d5d4fd8e6524ea4995e875b0cc Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Wed, 16 Nov 2011 15:40:46 +0000 Subject: [PATCH 016/482] Fix indentation issues in NEWS --- NEWS | 51 ++++++++++++++++++++++----------------------------- 1 file changed, 22 insertions(+), 29 deletions(-) diff --git a/NEWS b/NEWS index c10e993..c588a73 100644 --- a/NEWS +++ b/NEWS @@ -1,6 +1,6 @@ News file for Stow. -* Changes in version 2.0.1: +* Changes in version 2.0.1 ** Defer operations until all potential conflicts have been assessed. We do this by traversing the installation image(s) and recording the @@ -51,7 +51,7 @@ You can mix and match any number of actions, e.g., will unstow p3, p4 and p6, then stow p1, p2, p5 and p6. -* New (repeatable) command line arg: --ignore='' +** New (repeatable) command line arg: --ignore='' This suppresses operating on a file matching the regex (suffix), e.g., @@ -132,33 +132,26 @@ more easily check for equivalent functionality. The initial code base had to be refactored substantially to allow for testing. The test suite is not exhaustive, but it should provide enough to check for regressions. - -* Changes in version 1.3.3: -** Now requires Perl 5.005 or later -** Initially empty directories are not removed anymore -** Removed buggy fastcwd (we use POSIX::getcwd instead) -** Fixed bug when the common Parent of Target dir and Stow dir was "/" -** Fixed bug when handling directories named "0" -** Stow now only warns the user if a directory is unreadable during unstowing. - -* Changes in version 1.3: -** Added --restow option. -** Fixed handling of slashes in package names. -** Expanded configure-time search for Perl binary. - -* Changes in version 1.2: -** Dependency on `pwd' removed. -** Perl 4 compatibility fixes. -** Manual expanded even more. - -* Changes in version 1.1: -** Long and short options now accepted. -** Manual expanded. -** `make clean' removes stow (which is generated from stow.in). - -* Initial public release (v1.0) of Stow. - - +* Changes in version 1.3.3 +** Now requires Perl 5.005 or later +** Initially empty directories are not removed anymore +** Removed buggy fastcwd (we use POSIX::getcwd instead) +** Fixed bug when the common Parent of Target dir and Stow dir was "/" +** Fixed bug when handling directories named "0" +** Stow now only warns the user if a directory is unreadable during unstowing. +* Changes in version 1.3: +** Added --restow option. +** Fixed handling of slashes in package names. +** Expanded configure-time search for Perl binary. +* Changes in version 1.2: +** Dependency on `pwd' removed. +** Perl 4 compatibility fixes. +** Manual expanded even more. +* Changes in version 1.1: +** Long and short options now accepted. +** Manual expanded. +** `make clean' removes stow (which is generated from stow.in). +* Initial public release (v1.0) of Stow. * emacs local variables Local Variables: mode: org From 010877255aae1c0500186471d600f68d35e58d8d Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Wed, 16 Nov 2011 15:42:42 +0000 Subject: [PATCH 017/482] Add FIXME for Deferred Operation section in manual. --- TODO | 1 + stow.texi | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/TODO b/TODO index 132f689..eebb931 100644 --- a/TODO +++ b/TODO @@ -1,3 +1,4 @@ +* Finish 'Deferring' section of manual * get account on fencepost.gnu.org (email accounts@gnu.org) set up copyright papers? 'assign.future' and 'request-assign.future.manual' diff --git a/stow.texi b/stow.texi index 265ef0f..bd7ef5e 100644 --- a/stow.texi +++ b/stow.texi @@ -561,7 +561,8 @@ can actually take a long time (a number of seconds). Moreover, an accurate analysis of potential conflicts, requires us to take in to account all of these operations. -Accidentally stowing a package that will result in a conflict +Accidentally stowing a package that will result in a conflict ... +FIXME - doesn't look like this section was ever finished. @c =========================================================================== @node Mixing Operations, Multiple Stow Directories, Deferred Operation, Top From 8b5a0f5aa33122063d493bd764fd5b1697966223 Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Wed, 16 Nov 2011 15:51:54 +0000 Subject: [PATCH 018/482] Add a bunch of stuff to the TODO --- TODO | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/TODO b/TODO index eebb931..351eec9 100644 --- a/TODO +++ b/TODO @@ -1,3 +1,31 @@ +* Split core code into Stow.pm +* Add use strict / warnings to tests +* Honour .no-stow-folding and --no-folding +* Support ignore lists in files +*** Implement. +*** Add documentation about ignore lists. +***** Justification for having stow ignore lists independently of VCS ignore lists +******* If a file is in the VCS ignore list for its containing repo +********* generated during development + probably shouldn't be stowed +********* generated during compilation / install +*********** could be an intermediary file + again, probably shouldn't be stowed +*********** but most likely a file to install + e.g. compiled binary/library/docs - should be stowed +******* If a file is not in the VCS ignore list for its containing repo +********* it's probably tracked by the VCS - part of the repo +********* could intended for end use +*********** e.g. script/config file requiring no modifications, docs + should be stowed +********* or intended only to be used during compilation / build phase + shouldn't be stowed +*** (Eventually) rsync-like include/exclude lists instead of ignore lists +* Add semi-automatic conflict resolution +*** STOW_RESOLVE_CONFLICTS="non_stow_symlinks=t stow_symlinks=r" +*** Add documentation about conflict resolution +* Make CPAN-friendly via Module::Build +*** Include test-time dependencies on Test::More and Test::Output * Finish 'Deferring' section of manual * get account on fencepost.gnu.org (email accounts@gnu.org) set up copyright papers? From 801446a5ebf86ec5b61ec940a632b1d6c34b9182 Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Wed, 16 Nov 2011 15:57:17 +0000 Subject: [PATCH 019/482] Use File::Spec->abs2rel() instead of home-grown relative_path which actually gets some inputs wrong (e.g. "/" relative to "/") --- Makefile.am | 1 - stow.in | 36 ++---------------------------------- t/relative_path.t | 41 ----------------------------------------- 3 files changed, 2 insertions(+), 76 deletions(-) delete mode 100755 t/relative_path.t diff --git a/Makefile.am b/Makefile.am index 83bebcb..5d5217c 100644 --- a/Makefile.am +++ b/Makefile.am @@ -15,7 +15,6 @@ TESTS = \ t/foldable.t \ t/join_paths.t \ t/parent.t \ - t/relative_path.t \ t/stow_contents.t \ t/stow.t \ t/unstow_contents_orig.t \ diff --git a/stow.in b/stow.in index 5c6c6bc..5ddd4c1 100755 --- a/stow.in +++ b/stow.in @@ -24,6 +24,7 @@ use warnings; require 5.6.1; +use File::Spec; use POSIX qw(getcwd); use Getopt::Long; @@ -380,7 +381,7 @@ sub set_stow_path { } # set our one global - $Stow_Path = relative_path(getcwd(),$stow_dir); + $Stow_Path = File::Spec->abs2rel($stow_dir); if ($Option{'verbose'} > 1) { warn "current dir is ".getcwd()."\n"; @@ -1665,39 +1666,6 @@ sub strip_quotes { return $string; } -#===== SUBROUTINE =========================================================== -# Name : relative_path() -# Purpose : find the relative path between two given paths -# Parameters: path1 => a directory path -# : path2 => a directory path -# Returns : path2 relative to path1 -# Throws : n/a -# Comments : only used once by main interactive routine -# : factored out for testing -#============================================================================ -sub relative_path { - - my ($path1, $path2) = @_; - - my (@path1) = split m{/+}, $path1; - my (@path2) = split m{/+}, $path2; - - # drop common prefixes until we find a difference - PREFIX: - while ( @path1 && @path2 ) { - last PREFIX if $path1[0] ne $path2[0]; - shift @path1; - shift @path2; - } - - # prepend one '..' to $path2 for each component of $path1 - while ( shift @path1 ) { - unshift @path2, '..'; - } - - return join_paths(@path2); -} - #===== SUBROUTINE =========================================================== # Name : join_paths() # Purpose : concatenates given paths diff --git a/t/relative_path.t b/t/relative_path.t deleted file mode 100755 index 7f60da2..0000000 --- a/t/relative_path.t +++ /dev/null @@ -1,41 +0,0 @@ -#!/usr/local/bin/perl - -# -# Testing relative_path(); -# - -# load as a library -BEGIN { use lib qw(. ..); require "stow"; } - -use Test::More tests => 5; - -is( - relative_path('a/b/c', 'a/b/d'), - '../d', - => 'different branches' -); - -is( - relative_path('/a/b/c', '/a/b/c/d'), - 'd', - => 'lower same branch' -); - -is( - relative_path('a/b/c', 'a/b'), - '..', - => 'higher, same branch' -); - -is( - relative_path('/a/b/c', '/d/e/f'), - '../../../d/e/f', - => 'common parent is /' -); - -is( - relative_path('///a//b//c////', '/a////b/c/d////'), - 'd', - => 'extra /\'s ' -); - From 090519496cdb8967b3d2fb7dd0d528486bb7877e Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Wed, 16 Nov 2011 16:52:03 +0000 Subject: [PATCH 020/482] Stow directory now defaults to STOW_DIR environment variable if set. --- ChangeLog | 4 ++++ stow.8 | 3 ++- stow.in | 5 +++-- stow.texi | 16 ++++++---------- 4 files changed, 15 insertions(+), 13 deletions(-) diff --git a/ChangeLog b/ChangeLog index b513c25..636c7d4 100644 --- a/ChangeLog +++ b/ChangeLog @@ -49,6 +49,10 @@ Sun Nov 25 19:31:32 2007 Kahlil Hodgson * stow.8: update to reflect Version 2 changes. +Sat Jan 26 16:15:21 2002 Guillaume Morin + + * stow.in: if $ENV{'STOW_DIR'} is set, this becomes the default + Stow directory. Sun Jan 06 12:18:50 2002 Guillaume Morin diff --git a/stow.8 b/stow.8 index 339531f..38de9d6 100644 --- a/stow.8 +++ b/stow.8 @@ -146,7 +146,8 @@ The target of a relative symlink is computed starting from the symlink's own directory. Stow only creates relative symlinks. .SH OPTIONS -The stow directory is assumed to be the current directory, and the +The stow directory is assumed to be the value of the 'STOW_DIR' environment +variable or if unset the current directory, and the target directory is assumed to be the parent of the current directory (so it is typical to execute .I stow diff --git a/stow.in b/stow.in index 5ddd4c1..a127a8c 100755 --- a/stow.in +++ b/stow.in @@ -358,9 +358,10 @@ sub set_stow_path { my $current_dir = getcwd(); - # default stow dir is the current directory + # default stow dir is $STOW_DIR if set, otherwise the current + # directory if (not $Option{'dir'} ) { - $Option{'dir'} = getcwd(); + $Option{'dir'} = exists $ENV{STOW_DIR} ? $ENV{STOW_DIR} : getcwd(); } if (not chdir($Option{'dir'})) { error("Cannot chdir to target tree: '$Option{'dir'}'"); diff --git a/stow.texi b/stow.texi index bd7ef5e..0728f3a 100644 --- a/stow.texi +++ b/stow.texi @@ -239,14 +239,10 @@ stow [@var{options}] [@var{action flag}] @var{package @dots{}} @end example @noindent -Each @var{package} is the name of a package (e.g., @samp{perl}) in the stow +Each @var{package} is the name of a package (e.g., @samp{perl}) in the stow directory that we wish to install into (or delete from) the target directory. -The default action is to install the given packages, although alternate actions +The default action is to install the given packages, although alternate actions may be specified by preceding the package name(s) with an @var{action flag}. -Unless otherwise specified, the stow directory is assumed to be -the current directory and the target directory is assumed to be the parent of -the current directory, so it is typical to execute @code{stow} from the -directory @file{/usr/local/stow}. @noindent The following options are supported: @@ -255,14 +251,14 @@ The following options are supported: @item -d @var{dir} @itemx --dir=@var{dir} -Set the stow directory to @var{dir} instead of the current directory. -This also has the effect of making the default target directory be the -parent of @var{dir}. +Set the stow directory to @var{dir}. Defaults to the value of the environment +variable @code{STOW_DIR} if set, or the current directory otherwise. @item -t @var{dir} @itemx --target=@var{dir} Set the target directory to @var{dir} instead of the parent of the stow -directory. +directory. Defaults to the parent of the stow directory, so it is typical to +execute @code{stow} from the directory @file{/usr/local/stow}. @item --ignore='' This (repeatable) option lets you suppress acting on files that match the From 8da4e15fbfee1357357442f17b473061058feec3 Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Thu, 17 Nov 2011 12:45:36 +0000 Subject: [PATCH 021/482] Fix broken 'make install' due to man page being duplicated in install-man8 target --- Makefile.am | 1 - 1 file changed, 1 deletion(-) diff --git a/Makefile.am b/Makefile.am index 5d5217c..59051cc 100644 --- a/Makefile.am +++ b/Makefile.am @@ -2,7 +2,6 @@ bin_SCRIPTS = stow chkstow info_TEXINFOS = stow.texi -man8_MANS = stow.8 dist_man_MANS = stow.8 dist_doc_DATA = README From ca49579fa1869952adf2aee11418bf74e08f9192 Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Thu, 17 Nov 2011 13:26:04 +0000 Subject: [PATCH 022/482] Refactor verbosity-controlled output to STDERR into debug() subroutine. --- stow.in | 241 ++++++++++++++++++-------------------------------------- 1 file changed, 77 insertions(+), 164 deletions(-) diff --git a/stow.in b/stow.in index a127a8c..df66830 100755 --- a/stow.in +++ b/stow.in @@ -34,10 +34,11 @@ $ProgramName =~ s{.*/}{}; # Verbosity rules: # -# 0: errors only -# > 0: print operations: LINK/UNLINK/MKDIR/RMDIR -# > 1: print trace: stow/unstow package/contents/node -# > 2: print trace detail: "_this_ already points to _that_" +# 0: errors only +# >= 1: print operations: LINK/UNLINK/MKDIR/RMDIR +# >= 2: print trace: stow/unstow package/contents/node +# >= 3: print trace detail: "_this_ already points to _that_" +# >= 4: debug helper routines # # All output (except for version() and usage()) is to stderr to preserve # backward compatibility. @@ -108,9 +109,7 @@ if ( not caller() ) { if (not -d join_paths($Stow_Path,$package)) { error("The given package name ($package) is not in your stow path"); } - if ($Option{'verbose'} > 1) { - warn "Unstowing package $package...\n"; - } + debug(2, "Unstowing package $package..."); if ($Option{'compat'}) { unstow_contents_orig( join_paths($Stow_Path,$package), # path to package @@ -123,26 +122,20 @@ if ( not caller() ) { '', # target is current_dir ); } - if ($Option{'verbose'} > 1) { - warn "Unstowing package $package...done\n"; - } + debug(2, "Unstowing package $package...done"); } for my $package (@Pkgs_To_Stow) { if (not -d join_paths($Stow_Path,$package)) { error("The given package name ($package) is not in your stow path"); } - if ($Option{'verbose'} > 1) { - warn "Stowing package $package...\n"; - } + debug(2, "Stowing package $package..."); stow_contents( join_paths($Stow_Path,$package), # path package '', # target is current dir join_paths($Stow_Path,$package), # source from target ); - if ($Option{'verbose'} > 1) { - warn "Stowing package $package...done\n"; - } + debug(2, "Stowing package $package...done"); } # --verbose: tell me what you are planning to do @@ -264,6 +257,22 @@ sub process_options { return; } +#===== SUBROUTINE ============================================================ +# Name : debug() +# Purpose : log to STDERR based on verbosity setting +# Parameters: $level => minimum verbosity level required to output this message +# : $msg => the message +# Returns : n/a +# Throws : no exceptions +# Comments : none +#============================================================================= +sub debug { + my ($level, $msg) = @_; + if ($Option{'verbose'} >= $level) { + warn "$msg\n"; + } +} + #===== SUBROUTINE ============================================================ # Name : get_defaults() # Purpose : search for default settings in any .stow files @@ -384,10 +393,8 @@ sub set_stow_path { # set our one global $Stow_Path = File::Spec->abs2rel($stow_dir); - if ($Option{'verbose'} > 1) { - warn "current dir is ".getcwd()."\n"; - warn "stow dir path is $Stow_Path\n"; - } + debug(2, "current dir is " . getcwd()); + debug(2, "stow dir path is $Stow_Path"); } #===== SUBROUTINE =========================================================== @@ -406,12 +413,8 @@ sub stow_contents { my ($path, $target, $source) = @_; - if ($Option{'verbose'} > 1){ - warn "Stowing contents of $path\n"; - } - if ($Option{'verbose'} > 2){ - warn "--- $target => $source\n"; - } + debug(2, "Stowing contents of $path"); + debug(3, "--- $target => $source"); if (not -d $path) { error("stow_contents() called on a non-directory: $path"); @@ -451,21 +454,15 @@ sub stow_node { my ($path, $target, $source) = @_; - if ($Option{'verbose'} > 1) { - warn "Stowing $path\n"; - } - if ($Option{'verbose'} > 2) { - warn "--- $target => $source\n"; - } + debug(2, "Stowing $path"); + debug(3, "--- $target => $source"); # don't try to stow absolute symlinks (they can't be unstowed) if (-l $source) { my $second_source = read_a_link($source); if ($second_source =~ m{\A/} ) { conflict("source is an absolute symlink $source => $second_source"); - if ($Option{'verbose'} > 2) { - warn "absolute symlinks cannot be unstowed"; - } + debug(3, "absolute symlinks cannot be unstowed"); return; } } @@ -478,9 +475,7 @@ sub stow_node { if (not $old_source) { error("Could not read link: $target"); } - if ($Option{'verbose'} > 2) { - warn "--- Evaluate existing link: $target => $old_source\n"; - } + debug(3, "--- Evaluate existing link: $target => $old_source"); # does it point to a node under our stow directory? my $old_path = find_stowed_path($target, $old_source); @@ -492,19 +487,13 @@ sub stow_node { # does the existing $target actually point to anything? if (is_a_node($old_path)) { if ($old_source eq $source) { - if ($Option{'verbose'} > 2) { - warn "--- Skipping $target as it already points to $source\n"; - } + debug(3, "--- Skipping $target as it already points to $source"); } elsif (defer($target)) { - if ($Option{'verbose'} > 2) { - warn "--- deferring installation of: $target\n"; - } + debug(3, "--- deferring installation of: $target"); } elsif (override($target)) { - if ($Option{'verbose'} > 2) { - warn "--- overriding installation of: $target\n"; - } + debug(3, "--- overriding installation of: $target"); do_unlink($target); do_link($source,$target); } @@ -515,9 +504,7 @@ sub stow_node { # and the proposed new link points to a directory, # then we can unfold the tree at that point - if ($Option{'verbose'} > 2){ - warn "--- Unfolding $target\n"; - } + debug(3, "--- Unfolding $target"); do_unlink($target); do_mkdir($target); stow_contents($old_path, $target, join_paths('..',$old_source)); @@ -533,17 +520,13 @@ sub stow_node { } else { # the existing link is invalid, so replace it with a good link - if ($Option{'verbose'} > 2){ - warn "--- replacing invalid link: $path\n"; - } + debug(3, "--- replacing invalid link: $path"); do_unlink($target); do_link($source, $target); } } elsif (is_a_node($target)) { - if ($Option{'verbose'} > 2) { - warn("--- Evaluate existing node: $target\n"); - } + debug(3, "--- Evaluate existing node: $target"); if (is_a_dir($target)) { stow_contents($path, $target, join_paths('..',$source)); } @@ -577,12 +560,8 @@ sub unstow_contents_orig { if ($target eq $Stow_Path or -e "$target/.stow" or -e "$target/.nonstow") { return; } - if ($Option{'verbose'} > 1){ - warn "Unstowing in $target\n"; - } - if ($Option{'verbose'} > 2){ - warn "--- path is $path\n"; - } + debug(2, "Unstowing in $target"); + debug(3, "--- path is $path"); if (not -d $target) { error("unstow_contents() called on a non-directory: $target"); } @@ -617,18 +596,12 @@ sub unstow_node_orig { my ($path, $target) = @_; - if ($Option{'verbose'} > 1) { - warn "Unstowing $target\n"; - } - if ($Option{'verbose'} > 2) { - warn "--- path is $path\n"; - } + debug(2, "Unstowing $target"); + debug(3, "--- path is $path"); # does the target exist if (is_a_link($target)) { - if ($Option{'verbose'} > 2) { - warn("Evaluate existing link: $target\n"); - } + debug(3, "Evaluate existing link: $target"); # where is the link pointing? my $old_source = read_a_link($target); @@ -650,17 +623,13 @@ sub unstow_node_orig { do_unlink($target); } elsif (override($target)) { - if ($Option{'verbose'} > 2) { - warn("--- overriding installation of: $target\n"); - } + debug(3, "--- overriding installation of: $target"); do_unlink($target); } # else leave it alone } else { - if ($Option{'verbose'} > 2){ - warn "--- removing invalid link into a stow directory: $path\n"; - } + debug(3, "--- removing invalid link into a stow directory: $path"); do_unlink($target); } } @@ -693,12 +662,8 @@ sub unstow_contents { if ($target eq $Stow_Path or -e "$target/.stow") { return; } - if ($Option{'verbose'} > 1){ - warn "Unstowing in $target\n"; - } - if ($Option{'verbose'} > 2){ - warn "--- path is $path\n"; - } + debug(2, "Unstowing in $target"); + debug(3, "--- path is $path"); if (not -d $path) { error("unstow_contents() called on a non-directory: $path"); } @@ -736,18 +701,12 @@ sub unstow_node { my ($path, $target) = @_; - if ($Option{'verbose'} > 1) { - warn "Unstowing $path\n"; - } - if ($Option{'verbose'} > 2) { - warn "--- target is $target\n"; - } + debug(2, "Unstowing $path"); + debug(3, "--- target is $target"); # does the target exist if (is_a_link($target)) { - if ($Option{'verbose'} > 2) { - warn("Evaluate existing link: $target\n"); - } + debug(3, "Evaluate existing link: $target"); # where is the link pointing? my $old_source = read_a_link($target); @@ -780,14 +739,10 @@ sub unstow_node { # package. #elsif (defer($target)) { - # if ($Option{'verbose'} > 2) { - # warn("--- deferring to installation of: $target\n"); - # } + # debug(3, "--- deferring to installation of: $target"); #} #elsif (override($target)) { - # if ($Option{'verbose'} > 2) { - # warn("--- overriding installation of: $target\n"); - # } + # debug(3, "--- overriding installation of: $target"); # do_unlink($target); #} #else { @@ -799,16 +754,12 @@ sub unstow_node { #} } else { - if ($Option{'verbose'} > 2){ - warn "--- removing invalid link into a stow directory: $path\n"; - } + debug(3, "--- removing invalid link into a stow directory: $path"); do_unlink($target); } } elsif (-e $target) { - if ($Option{'verbose'} > 2) { - warn("Evaluate existing node: $target\n"); - } + debug(3, "Evaluate existing node: $target"); if (-d $target) { unstow_contents($path, $target); @@ -916,10 +867,8 @@ sub cleanup_invalid_links { not -e join_paths($dir,$source) and # bad link find_stowed_path($node_path,$source) # owned by stow ){ - if ($Option{'verbose'} > 2) { - warn "--- removing stale link: $node_path => ", - join_paths($dir,$source), "\n"; - } + debug(3, "--- removing stale link: $node_path => " . + join_paths($dir,$source)); do_unlink($node_path); } } @@ -941,9 +890,7 @@ sub foldable { my ($target) = @_; - if ($Option{'verbose'} > 2){ - warn "--- Is $target foldable?\n"; - } + debug(3, "--- Is $target foldable?"); opendir my $DIR, $target or error(qq{Cannot read directory "$target" ($!)\n}); @@ -988,9 +935,7 @@ sub foldable { # if the resulting path is owned by stow, we can fold it if (find_stowed_path($target,$parent)) { - if ($Option{'verbose'} > 2){ - warn "--- $target is foldable\n"; - } + debug(3, "--- $target is foldable"); return $parent; } else { @@ -1011,9 +956,7 @@ sub fold_tree { my ($target,$source) = @_; - if ($Option{'verbose'} > 2){ - warn "--- Folding tree: $target => $source\n"; - } + debug(3, "--- Folding tree: $target => $source"); opendir my $DIR, $target or error(qq{Cannot read directory "$target" ($!)\n}); @@ -1046,10 +989,8 @@ sub conflict { my $message = sprintf($format, @args); - if ($Option{'verbose'}) { - warn qq{CONFLICT: $message\n}; - } - push @Conflicts, qq{CONFLICT: $message\n}; + debug(1, "CONFLICT: $message"); + push @Conflicts, "CONFLICT: $message\n"; return; } @@ -1125,9 +1066,7 @@ sub override { #============================================================================ sub process_tasks { - if ($Option{'verbose'} > 1) { - warn "Processing tasks...\n" - } + debug(2, "Processing tasks..."); # strip out all tasks with a skip action @Tasks = grep { $_->{'action'} ne 'skip' } @Tasks; @@ -1177,9 +1116,7 @@ sub process_tasks { internal_error(qq(bad task action: $task->{'action'})); } } - if ($Option{'verbose'} > 1) { - warn "Processing tasks...done\n" - } + debug(2, "Processing tasks...done"); return; } @@ -1410,18 +1347,14 @@ sub do_link { ) } else { - if ($Option{'verbose'}) { - warn "LINK: $newfile => $oldfile (duplicates previous action)\n"; - } + debug(1, "LINK: $newfile => $oldfile (duplicates previous action)"); return; } } elsif ( $task_ref->{'action'} eq 'remove' ) { if ( $task_ref->{'source'} eq $oldfile ) { # no need to remove a link we are going to recreate - if ($Option{'verbose'}) { - warn "LINK: $newfile => $oldfile (reverts previous action)\n"; - } + debug(1, "LINK: $newfile => $oldfile (reverts previous action)"); $Link_Task_For{$newfile}->{'action'} = 'skip'; delete $Link_Task_For{$newfile}; return; @@ -1434,9 +1367,7 @@ sub do_link { } # creating a new link - if ($Option{'verbose'}) { - warn "LINK: $newfile => $oldfile\n"; - } + debug(1, "LINK: $newfile => $oldfile"); my $task = { action => 'create', type => 'link', @@ -1464,16 +1395,12 @@ sub do_unlink { if (exists $Link_Task_For{$file} ) { my $task_ref = $Link_Task_For{$file}; if ( $task_ref->{'action'} eq 'remove' ) { - if ($Option{'verbose'}) { - warn "UNLINK: $file (duplicates previous action)\n"; - } + debug(1, "UNLINK: $file (duplicates previous action)"); return; } elsif ( $task_ref->{'action'} eq 'create' ) { # do need to create a link then remove it - if ($Option{'verbose'}) { - warn "UNLINK: $file (reverts previous action)\n"; - } + debug(1, "UNLINK: $file (reverts previous action)"); $Link_Task_For{$file}->{'action'} = 'skip'; delete $Link_Task_For{$file}; return; @@ -1492,10 +1419,8 @@ sub do_unlink { } # remove the link - if ($Option{'verbose'}) { - #warn "UNLINK: $file (".(caller())[2].")\n"; - warn "UNLINK: $file\n"; - } + #debug(1, "UNLINK: $file (" . (caller())[2] . ")"); + debug(1, "UNLINK: $file"); my $source = readlink $file or error("could not readlink $file"); @@ -1548,15 +1473,11 @@ sub do_mkdir { my $task_ref = $Dir_Task_For{$dir}; if ($task_ref->{'action'} eq 'create') { - if ($Option{'verbose'}) { - warn "MKDIR: $dir (duplicates previous action)\n"; - } + debug(1, "MKDIR: $dir (duplicates previous action)"); return; } elsif ($task_ref->{'action'} eq 'remove') { - if ($Option{'verbose'}) { - warn "MKDIR: $dir (reverts previous action)\n"; - } + debug(1, "MKDIR: $dir (reverts previous action)"); $Dir_Task_For{$dir}->{'action'} = 'skip'; delete $Dir_Task_For{$dir}; return; @@ -1566,9 +1487,7 @@ sub do_mkdir { } } - if ($Option{'verbose'}) { - warn "MKDIR: $dir\n"; - } + debug(1, "MKDIR: $dir"); my $task = { action => 'create', type => 'dir', @@ -1607,15 +1526,11 @@ sub do_rmdir { my $task_ref = $Link_Task_For{$dir}; if ($task_ref->{'action'} eq 'remove' ) { - if ($Option{'verbose'}) { - warn "RMDIR $dir (duplicates previous action)\n"; - } + debug(1, "RMDIR $dir (duplicates previous action)"); return; } elsif ($task_ref->{'action'} eq 'create' ) { - if ($Option{'verbose'}) { - warn "MKDIR $dir (reverts previous action)\n"; - } + debug(1, "MKDIR $dir (reverts previous action)"); $Link_Task_For{$dir}->{'action'} = 'skip'; delete $Link_Task_For{$dir}; return; @@ -1625,9 +1540,7 @@ sub do_rmdir { } } - if ($Option{'verbose'}) { - warn "RMDIR $dir\n"; - } + debug(1, "RMDIR $dir"); my $task = { action => 'remove', type => 'dir', From ba3c052c1fc6f67d4ad7a9667bdb1ad5011af6ae Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Thu, 17 Nov 2011 14:12:12 +0000 Subject: [PATCH 023/482] Simplify GetOptions() code --- stow.in | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/stow.in b/stow.in index df66830..e9c25ec 100755 --- a/stow.in +++ b/stow.in @@ -170,15 +170,9 @@ sub process_options { Getopt::Long::config('no_ignore_case', 'bundling', 'permute'); GetOptions( - 'v' => sub { $Option{'verbose'}++ }, - 'verbose:i' => sub { $Option{'verbose'}+= $_[1] || 1 }, - 'h|help' => sub { $Option{'help'} = '1' }, - 'n|no|simulate' => sub { $Option{'simulate'} = '1' }, - 'c|conflicts' => sub { $Option{'conflicts'} = '1' }, - 'V|version' => sub { $Option{'version'} = '1' }, - 'p|compat' => sub { $Option{'compat'} = '1' }, - 'd|dir=s' => sub { $Option{'dir'} = $_[1] }, - 't|target=s' => sub { $Option{'target'} = $_[1] }, + \%Option, + 'verbose|v:+', 'help|h', 'simulate|n|no', 'conflicts|c', + 'version|V', 'compat|p', 'dir|d=s', 'target|t=s', # clean and pre-compile any regex's at parse time 'ignore=s' => From 6ee8747c9b99b8d96db4c353ebbc432eb21c4308 Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Thu, 17 Nov 2011 14:12:14 +0000 Subject: [PATCH 024/482] Set cperl-indent-level to 4 --- stow.in | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/stow.in b/stow.in index e9c25ec..8680578 100755 --- a/stow.in +++ b/stow.in @@ -1667,5 +1667,6 @@ sub version { # Local variables: # mode: perl -# End: +# cperl-indent-level: 4 +# end: # vim: ft=perl From 85f1f8619ca5e396d463e6a36d979bb61153afea Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Thu, 17 Nov 2011 14:17:24 +0000 Subject: [PATCH 025/482] Fix inconsistencies in coding style. --- stow.in | 198 +++++++++++++++++++++++------------------------------- t/util.pm | 2 +- 2 files changed, 85 insertions(+), 115 deletions(-) diff --git a/stow.in b/stow.in index 8680578..2168b78 100755 --- a/stow.in +++ b/stow.in @@ -98,7 +98,7 @@ our %Link_Task_For = (); # put the main loop in this block so we can load the # rest of the code as a module for testing -if ( not caller() ) { +if (not caller()) { process_options(); set_stow_path(); @@ -106,19 +106,19 @@ if ( not caller() ) { # current dir is now the target directory for my $package (@Pkgs_To_Delete) { - if (not -d join_paths($Stow_Path,$package)) { + if (not -d join_paths($Stow_Path, $package)) { error("The given package name ($package) is not in your stow path"); } debug(2, "Unstowing package $package..."); if ($Option{'compat'}) { unstow_contents_orig( - join_paths($Stow_Path,$package), # path to package + join_paths($Stow_Path, $package), # path to package '', # target is current_dir ); } else { unstow_contents( - join_paths($Stow_Path,$package), # path to package + join_paths($Stow_Path, $package), # path to package '', # target is current_dir ); } @@ -126,14 +126,14 @@ if ( not caller() ) { } for my $package (@Pkgs_To_Stow) { - if (not -d join_paths($Stow_Path,$package)) { + if (not -d join_paths($Stow_Path, $package)) { error("The given package name ($package) is not in your stow path"); } debug(2, "Stowing package $package..."); stow_contents( - join_paths($Stow_Path,$package), # path package + join_paths($Stow_Path, $package), # path package '', # target is current dir - join_paths($Stow_Path,$package), # source from target + join_paths($Stow_Path, $package), # source from target ); debug(2, "Stowing package $package...done"); } @@ -164,7 +164,6 @@ if ( not caller() ) { # Comments : checks @ARGV for valid package names #============================================================================ sub process_options { - get_defaults(); #$,="\n"; print @ARGV,"\n"; # for debugging rc file @@ -236,14 +235,14 @@ sub process_options { $Option{'simulate'} = 1; } - if (not scalar @Pkgs_To_Stow and not scalar @Pkgs_To_Delete ) { + if (not scalar @Pkgs_To_Stow and not scalar @Pkgs_To_Delete) { usage("No packages named"); } # check package arguments - for my $package ( (@Pkgs_To_Stow, @Pkgs_To_Delete) ) { + for my $package ((@Pkgs_To_Stow, @Pkgs_To_Delete)) { $package =~ s{/+$}{}; # delete trailing slashes - if ( $package =~ m{/} ) { + if ($package =~ m{/}) { error("Slashes are not permitted in package names"); } } @@ -278,14 +277,13 @@ sub debug { # : hacked in so that Emil and I could set different preferences). #============================================================================= sub get_defaults { - my @defaults = (); - for my $file ($ENV{'HOME'}.'/.stowrc','.stowrc') { - if (-r $file ) { + for my $file ($ENV{'HOME'}.'/.stowrc', '.stowrc') { + if (-r $file) { warn "Loading defaults from $file\n"; open my $FILE, '<', $file or die "Could not open $file for reading\n"; - while (my $line = <$FILE> ){ + while (my $line = <$FILE>){ chomp $line; push @defaults, split " ", $line; } @@ -341,7 +339,7 @@ OPTIONS: -V, --version Show stow version number -h, --help Show this help EOT - exit( $msg ? 1 : 0 ); + exit $msg ? 1 : 0; } #===== SUBROUTINE =========================================================== @@ -354,7 +352,6 @@ EOT # Comments : This sets the current working directory to $Option{target} #============================================================================ sub set_stow_path { - # Changing dirs helps a lot when soft links are used # Also prevents problems when 'stow_dir' or 'target' are # supplied as relative paths (FIXME: examples?) @@ -363,7 +360,7 @@ sub set_stow_path { # default stow dir is $STOW_DIR if set, otherwise the current # directory - if (not $Option{'dir'} ) { + if (not $Option{'dir'}) { $Option{'dir'} = exists $ENV{STOW_DIR} ? $ENV{STOW_DIR} : getcwd(); } if (not chdir($Option{'dir'})) { @@ -404,7 +401,6 @@ sub set_stow_path { # : $path is used for folding/unfolding trees as necessary #============================================================================ sub stow_contents { - my ($path, $target, $source) = @_; debug(2, "Stowing contents of $path"); @@ -425,9 +421,9 @@ sub stow_contents { next NODE if $node eq '..'; next NODE if ignore($node); stow_node( - join_paths($path, $node), # path - join_paths($target,$node), # target - join_paths($source,$node), # source + join_paths($path, $node), # path + join_paths($target, $node), # target + join_paths($source, $node), # source ); } } @@ -445,7 +441,6 @@ sub stow_contents { # : $path is used for folding/unfolding trees as necessary #============================================================================ sub stow_node { - my ($path, $target, $source) = @_; debug(2, "Stowing $path"); @@ -454,7 +449,7 @@ sub stow_node { # don't try to stow absolute symlinks (they can't be unstowed) if (-l $source) { my $second_source = read_a_link($source); - if ($second_source =~ m{\A/} ) { + if ($second_source =~ m{\A/}) { conflict("source is an absolute symlink $source => $second_source"); debug(3, "absolute symlinks cannot be unstowed"); return; @@ -489,10 +484,10 @@ sub stow_node { elsif (override($target)) { debug(3, "--- overriding installation of: $target"); do_unlink($target); - do_link($source,$target); + do_link($source, $target); } - elsif (is_a_dir(join_paths(parent($target),$old_source)) && - is_a_dir(join_paths(parent($target),$source)) ) { + elsif (is_a_dir(join_paths(parent($target), $old_source)) && + is_a_dir(join_paths(parent($target), $source)) ) { # if the existing link points to a directory, # and the proposed new link points to a directory, @@ -501,8 +496,8 @@ sub stow_node { debug(3, "--- Unfolding $target"); do_unlink($target); do_mkdir($target); - stow_contents($old_path, $target, join_paths('..',$old_source)); - stow_contents($path, $target, join_paths('..',$source)); + stow_contents($old_path, $target, join_paths('..', $old_source)); + stow_contents($path, $target, join_paths('..', $source)); } else { conflict( @@ -522,7 +517,7 @@ sub stow_node { elsif (is_a_node($target)) { debug(3, "--- Evaluate existing node: $target"); if (is_a_dir($target)) { - stow_contents($path, $target, join_paths('..',$source)); + stow_contents($path, $target, join_paths('..', $source)); } else { conflict( @@ -547,7 +542,6 @@ sub stow_node { # : Here we traverse the target tree, rather than the source tree. #============================================================================ sub unstow_contents_orig { - my ($path, $target) = @_; # don't try to remove anything under a stow directory @@ -587,7 +581,6 @@ sub unstow_contents_orig { # Comments : unstow_node() and unstow_contents() are mutually recursive #============================================================================ sub unstow_node_orig { - my ($path, $target) = @_; debug(2, "Unstowing $target"); @@ -632,7 +625,7 @@ sub unstow_node_orig { # this action may have made the parent directory foldable if (my $parent = foldable($target)) { - fold_tree($target,$parent); + fold_tree($target, $parent); } } return; @@ -649,7 +642,6 @@ sub unstow_node_orig { # : Here we traverse the target tree, rather than the source tree. #============================================================================ sub unstow_contents { - my ($path, $target) = @_; # don't try to remove anything under a stow directory @@ -692,7 +684,6 @@ sub unstow_contents { # Comments : unstow_node() and unstow_contents() are mutually recursive #============================================================================ sub unstow_node { - my ($path, $target) = @_; debug(2, "Unstowing $path"); @@ -723,7 +714,7 @@ sub unstow_node { } # does the existing $target actually point to anything - if (-e $old_path) { + if (-e $old_path) { # does link points to the right place if ($old_path eq $path) { do_unlink($target); @@ -759,7 +750,7 @@ sub unstow_node { # this action may have made the parent directory foldable if (my $parent = foldable($target)) { - fold_tree($target,$parent); + fold_tree($target, $parent); } } else { @@ -784,7 +775,6 @@ sub unstow_node { # : we could put more logic under here for multiple stow dirs #============================================================================ sub find_stowed_path { - my ($target, $source) = @_; # evaluate softlink relative to its target @@ -793,7 +783,7 @@ sub find_stowed_path { # search for .stow files my $dir = ''; for my $part (split m{/+}, $path) { - $dir = join_paths($dir,$part); + $dir = join_paths($dir, $part); if (-f "$dir/.stow") { return $path; } @@ -804,8 +794,8 @@ sub find_stowed_path { my @stow_path = split m{/+}, $Stow_Path; # strip off common prefixes - while ( @path && @stow_path ) { - if ( (shift @path) ne (shift @stow_path) ) { + while (@path && @stow_path) { + if ((shift @path) ne (shift @stow_path)) { return ''; } } @@ -829,7 +819,6 @@ sub find_stowed_path { # : it anyway #============================================================================= sub cleanup_invalid_links { - my ($dir) = @_; if (not -d $dir) { @@ -846,7 +835,7 @@ sub cleanup_invalid_links { next NODE if $node eq '.'; next NODE if $node eq '..'; - my $node_path = join_paths($dir,$node); + my $node_path = join_paths($dir, $node); if (-l $node_path and not exists $Link_Task_For{$node_path}) { @@ -858,11 +847,11 @@ sub cleanup_invalid_links { } if ( - not -e join_paths($dir,$source) and # bad link - find_stowed_path($node_path,$source) # owned by stow + not -e join_paths($dir, $source) and # bad link + find_stowed_path($node_path, $source) # owned by stow ){ debug(3, "--- removing stale link: $node_path => " . - join_paths($dir,$source)); + join_paths($dir, $source)); do_unlink($node_path); } } @@ -881,7 +870,6 @@ sub cleanup_invalid_links { # : that is, it can be used as the source for a replacement symlink #============================================================================ sub foldable { - my ($target) = @_; debug(3, "--- Is $target foldable?"); @@ -898,7 +886,7 @@ sub foldable { next NODE if $node eq '.'; next NODE if $node eq '..'; - my $path = join_paths($target,$node); + my $path = join_paths($target, $node); # skip nodes scheduled for removal next NODE if not is_a_node($path); @@ -928,7 +916,7 @@ sub foldable { $parent =~ s{\A\.\./}{}; # if the resulting path is owned by stow, we can fold it - if (find_stowed_path($target,$parent)) { + if (find_stowed_path($target, $parent)) { debug(3, "--- $target is foldable"); return $parent; } @@ -947,8 +935,7 @@ sub foldable { # Comments : only called iff foldable() is true so we can remove some checks #============================================================================ sub fold_tree { - - my ($target,$source) = @_; + my ($target, $source) = @_; debug(3, "--- Folding tree: $target => $source"); @@ -961,8 +948,8 @@ sub fold_tree { for my $node (@listing) { next NODE if $node eq '.'; next NODE if $node eq '..'; - next NODE if not is_a_node(join_paths($target,$node)); - do_unlink(join_paths($target,$node)); + next NODE if not is_a_node(join_paths($target, $node)); + do_unlink(join_paths($target, $node)); } do_rmdir($target); do_link($source, $target); @@ -979,7 +966,7 @@ sub fold_tree { # Comments : indicates what type of conflict it is #============================================================================ sub conflict { - my ( $format, @args ) = @_; + my ($format, @args) = @_; my $message = sprintf($format, @args); @@ -997,7 +984,6 @@ sub conflict { # Comments : none #============================================================================= sub ignore { - my ($path) = @_; for my $suffix (@{$Option{'ignore'}}) { @@ -1015,7 +1001,6 @@ sub ignore { # Comments : none #============================================================================= sub defer { - my ($path) = @_; for my $prefix (@{$Option{'defer'}}) { @@ -1033,7 +1018,6 @@ sub defer { # Comments : none #============================================================================= sub override { - my ($path) = @_; for my $regex (@{$Option{'override'}}) { @@ -1059,7 +1043,6 @@ sub override { # : an action is set to 'skip' if it is found to be redundant #============================================================================ sub process_tasks { - debug(2, "Processing tasks..."); # strip out all tasks with a skip action @@ -1076,14 +1059,14 @@ sub process_tasks { for my $task (@Tasks) { - if ( $task->{'action'} eq 'create' ) { - if ( $task->{'type'} eq 'dir' ) { + if ($task->{'action'} eq 'create') { + if ($task->{'type'} eq 'dir') { mkdir($task->{'path'}, 0777) or error(qq(Could not create directory: $task->{'path'})); } - elsif ( $task->{'type'} eq 'link' ) { + elsif ($task->{'type'} eq 'link') { symlink $task->{'source'}, $task->{'path'} - or error( + or error( q(Could not create symlink: %s => %s), $task->{'path'}, $task->{'source'} @@ -1093,12 +1076,12 @@ sub process_tasks { internal_error(qq(bad task type: $task->{'type'})); } } - elsif ( $task->{'action'} eq 'remove' ) { - if ( $task->{'type'} eq 'dir' ) { + elsif ($task->{'action'} eq 'remove') { + if ($task->{'type'} eq 'dir') { rmdir $task->{'path'} or error(qq(Could not remove directory: $task->{'path'})); } - elsif ( $task->{'type'} eq 'link' ) { + elsif ($task->{'type'} eq 'link') { unlink $task->{'path'} or error(qq(Could not remove link: $task->{'path'})); } @@ -1126,9 +1109,7 @@ sub process_tasks { sub is_a_link { my ($path) = @_; - - if ( exists $Link_Task_For{$path} ) { - + if (exists $Link_Task_For{$path}) { my $action = $Link_Task_For{$path}->{'action'}; if ($action eq 'remove') { @@ -1145,9 +1126,9 @@ sub is_a_link { # check if any of its parent are links scheduled for removal # (need this for edge case during unfolding) my $parent = ''; - for my $part (split m{/+}, $path ) { - $parent = join_paths($parent,$part); - if ( exists $Link_Task_For{$parent} ) { + for my $part (split m{/+}, $path) { + $parent = join_paths($parent, $part); + if (exists $Link_Task_For{$parent}) { if ($Link_Task_For{$parent}->{'action'} eq 'remove') { return 0; } @@ -1172,7 +1153,7 @@ sub is_a_link { sub is_a_dir { my ($path) = @_; - if ( exists $Dir_Task_For{$path} ) { + if (exists $Dir_Task_For{$path}) { my $action = $Dir_Task_For{$path}->{'action'}; if ($action eq 'remove') { return 0; @@ -1188,7 +1169,7 @@ sub is_a_dir { # are we really following a link that is scheduled for removal my $prefix = ''; for my $part (split m{/+}, $path) { - $prefix = join_paths($prefix,$part); + $prefix = join_paths($prefix, $part); if (exists $Link_Task_For{$prefix} and $Link_Task_For{$prefix}->{'action'} eq 'remove') { return 0; @@ -1214,8 +1195,7 @@ sub is_a_dir { sub is_a_node { my ($path) = @_; - if ( exists $Link_Task_For{$path} ) { - + if (exists $Link_Task_For{$path}) { my $action = $Link_Task_For{$path}->{'action'}; if ($action eq 'remove') { @@ -1229,8 +1209,7 @@ sub is_a_node { } } - if ( exists $Dir_Task_For{$path} ) { - + if (exists $Dir_Task_For{$path}) { my $action = $Dir_Task_For{$path}->{'action'}; if ($action eq 'remove') { @@ -1247,8 +1226,8 @@ sub is_a_node { # are we really following a link that is scheduled for removal my $prefix = ''; for my $part (split m{/+}, $path) { - $prefix = join_paths($prefix,$part); - if ( exists $Link_Task_For{$prefix} and + $prefix = join_paths($prefix, $part); + if (exists $Link_Task_For{$prefix} and $Link_Task_For{$prefix}->{'action'} eq 'remove') { return 0; } @@ -1270,10 +1249,9 @@ sub is_a_node { # Comments : none #============================================================================ sub read_a_link { - my ($path) = @_; - if ( exists $Link_Task_For{$path} ) { + if (exists $Link_Task_For{$path}) { my $action = $Link_Task_For{$path}->{'action'}; if ($action eq 'create') { @@ -1304,23 +1282,21 @@ sub read_a_link { # Comments : cleans up operations that undo previous operations #============================================================================ sub do_link { + my ($oldfile, $newfile) = @_; - my ( $oldfile, $newfile ) = @_; - - if ( exists $Dir_Task_For{$newfile} ) { - + if (exists $Dir_Task_For{$newfile}) { my $task_ref = $Dir_Task_For{$newfile}; - if ( $task_ref->{'action'} eq 'create' ) { + if ($task_ref->{'action'} eq 'create') { if ($task_ref->{'type'} eq 'dir') { internal_error( - "new link (%s => %s ) clashes with planned new directory", + "new link (%s => %s) clashes with planned new directory", $newfile, $oldfile, ); } } - elsif ( $task_ref->{'action'} eq 'remove' ) { + elsif ($task_ref->{'action'} eq 'remove') { # we may need to remove a directory before creating a link so continue; } else { @@ -1328,12 +1304,11 @@ sub do_link { } } - if ( exists $Link_Task_For{$newfile} ) { - + if (exists $Link_Task_For{$newfile}) { my $task_ref = $Link_Task_For{$newfile}; - if ( $task_ref->{'action'} eq 'create' ) { - if ( $task_ref->{'source'} ne $oldfile ) { + if ($task_ref->{'action'} eq 'create') { + if ($task_ref->{'source'} ne $oldfile) { internal_error( "new link clashes with planned new link: %s => %s", $task_ref->{'path'}, @@ -1345,8 +1320,8 @@ sub do_link { return; } } - elsif ( $task_ref->{'action'} eq 'remove' ) { - if ( $task_ref->{'source'} eq $oldfile ) { + elsif ($task_ref->{'action'} eq 'remove') { + if ($task_ref->{'source'} eq $oldfile) { # no need to remove a link we are going to recreate debug(1, "LINK: $newfile => $oldfile (reverts previous action)"); $Link_Task_For{$newfile}->{'action'} = 'skip'; @@ -1383,16 +1358,15 @@ sub do_link { # Comments : will remove an existing planned link #============================================================================ sub do_unlink { - my ($file) = @_; - if (exists $Link_Task_For{$file} ) { + if (exists $Link_Task_For{$file}) { my $task_ref = $Link_Task_For{$file}; - if ( $task_ref->{'action'} eq 'remove' ) { + if ($task_ref->{'action'} eq 'remove') { debug(1, "UNLINK: $file (duplicates previous action)"); return; } - elsif ( $task_ref->{'action'} eq 'create' ) { + elsif ($task_ref->{'action'} eq 'create') { # do need to create a link then remove it debug(1, "UNLINK: $file (reverts previous action)"); $Link_Task_For{$file}->{'action'} = 'skip'; @@ -1404,7 +1378,7 @@ sub do_unlink { } } - if ( exists $Dir_Task_For{$file} and $Dir_Task_For{$file} eq 'create' ) { + if (exists $Dir_Task_For{$file} and $Dir_Task_For{$file} eq 'create') { internal_error( "new unlink operation clashes with planned operation: %s dir %s", $Dir_Task_For{$file}->{'action'}, @@ -1443,8 +1417,7 @@ sub do_unlink { sub do_mkdir { my ($dir) = @_; - if ( exists $Link_Task_For{$dir} ) { - + if (exists $Link_Task_For{$dir}) { my $task_ref = $Link_Task_For{$dir}; if ($task_ref->{'action'} eq 'create') { @@ -1462,8 +1435,7 @@ sub do_mkdir { } } - if ( exists $Dir_Task_For{$dir} ) { - + if (exists $Dir_Task_For{$dir}) { my $task_ref = $Dir_Task_For{$dir}; if ($task_ref->{'action'} eq 'create') { @@ -1506,7 +1478,7 @@ sub do_mkdir { sub do_rmdir { my ($dir) = @_; - if (exists $Link_Task_For{$dir} ) { + if (exists $Link_Task_For{$dir}) { my $task_ref = $Link_Task_For{$dir}; internal_error( "rmdir clashes with planned operation: %s link %s => %s", @@ -1516,14 +1488,14 @@ sub do_rmdir { ); } - if (exists $Dir_Task_For{$dir} ) { + if (exists $Dir_Task_For{$dir}) { my $task_ref = $Link_Task_For{$dir}; - if ($task_ref->{'action'} eq 'remove' ) { + if ($task_ref->{'action'} eq 'remove') { debug(1, "RMDIR $dir (duplicates previous action)"); return; } - elsif ($task_ref->{'action'} eq 'create' ) { + elsif ($task_ref->{'action'} eq 'create') { debug(1, "MKDIR $dir (reverts previous action)"); $Link_Task_For{$dir}->{'action'} = 'skip'; delete $Link_Task_For{$dir}; @@ -1562,7 +1534,6 @@ sub do_rmdir { # Comments : none #============================================================================= sub strip_quotes { - my ($string) = @_; if ($string =~ m{\A\s*'(.*)'\s*\z}) { @@ -1584,7 +1555,6 @@ sub strip_quotes { # : '//' => '/' and 'a/b/../c' => 'a/c' #============================================================================ sub join_paths { - my @paths = @_; # weed out empty components and concatenate @@ -1593,7 +1563,7 @@ sub join_paths { # factor out back references and remove redundant /'s) my @result = (); PART: - for my $part ( split m{/+}, $result) { + for my $part (split m{/+}, $result) { next PART if $part eq '.'; if (@result && $part eq '..' && $result[-1] ne '..') { pop @result; @@ -1632,8 +1602,8 @@ sub parent { # Comments : none #============================================================================ sub internal_error { - my ($format,@args) = @_; - die "$ProgramName: INTERNAL ERROR: ".sprintf($format,@args)."\n", + my ($format, @args) = @_; + die "$ProgramName: INTERNAL ERROR: " . sprintf($format, @args) . "\n", "This _is_ a bug. Please submit a bug report so we can fix it:-)\n"; } @@ -1646,8 +1616,8 @@ sub internal_error { # Comments : none #============================================================================ sub error { - my ($format,@args) = @_; - die "$ProgramName: ERROR: ".sprintf($format,@args)." ($!)\n"; + my ($format, @args) = @_; + die "$ProgramName: ERROR: " . sprintf($format, @args) . " ($!)\n"; } #===== SUBROUTINE =========================================================== diff --git a/t/util.pm b/t/util.pm index 73e0f3a..ff74161 100755 --- a/t/util.pm +++ b/t/util.pm @@ -75,7 +75,7 @@ sub make_file { or die "could not create file: $path ($!)\n"; close $FILE; } - elsif ( not -f $path) { + elsif (not -f $path) { die "a non-file already exists at $path\n"; } return; From cb86578b879e81a31070dac61a5d3b64cb0f4fc9 Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Thu, 17 Nov 2011 15:22:58 +0000 Subject: [PATCH 026/482] Finish "Deferred Operation" section in manual. --- TODO | 1 - stow.texi | 19 ++++++++++++------- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/TODO b/TODO index 351eec9..0e2e614 100644 --- a/TODO +++ b/TODO @@ -26,7 +26,6 @@ *** Add documentation about conflict resolution * Make CPAN-friendly via Module::Build *** Include test-time dependencies on Test::More and Test::Output -* Finish 'Deferring' section of manual * get account on fencepost.gnu.org (email accounts@gnu.org) set up copyright papers? 'assign.future' and 'request-assign.future.manual' diff --git a/stow.texi b/stow.texi index 0728f3a..c30d61d 100644 --- a/stow.texi +++ b/stow.texi @@ -554,17 +554,21 @@ un-populatable symlink. For complex packages, scanning the stow and target trees in tandem, and deciding whether to make directories or links, split-open or fold directories, can actually take a long time (a number of seconds). Moreover, an accurate -analysis of potential conflicts, requires us to take in to account all of +analysis of potential conflicts requires us to take into account all of these operations. -Accidentally stowing a package that will result in a conflict ... -FIXME - doesn't look like this section was ever finished. +Since version 2.0, Stow now adopts a two-phase algorithm, first scanning +for any potential conflicts before any stowing or unstowing operations +are performed. This means that there is much less risk of a package +being partially stowed or unstowed due to conflicts. Prior to version +2.0, if a conflict was discovered, the stow or unstow operation could be +aborted mid-flow, leaving the target tree in an inconsistent state. @c =========================================================================== @node Mixing Operations, Multiple Stow Directories, Deferred Operation, Top @chapter Mixing Operations -Since Version 2.0, multiple distinct actions can be specified in a single +Since version 2.0, multiple distinct actions can be specified in a single invocation of GNU Stow. For example, to update an installation of Emacs from version 21.3 to 21.4a you can now do the following: @@ -576,9 +580,10 @@ stow -D emacs-21.3 -S emacs-21.4a which will replace emacs-21.3 with emacs-21.4a using a single invocation. This is much faster and cleaner than performing two separate invocations of -stow, because redundant folding/unfolding operations can be factored out. -In addition, all the operations are calculated and merged before being executed -@pxref{Deferred Operation}, so the amount of of time in which GNU Emacs is unavailable is minimised. +stow, because redundant folding/unfolding operations can be factored out. In +addition, all the operations are calculated and merged before being executed +@pxref{Deferred Operation}, so the amount of of time in which GNU Emacs is +unavailable is minimised. You can mix and match any number of actions, for example, From da7255528eac78799cd58665b73bf218d9d54bb9 Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Thu, 17 Nov 2011 15:32:51 +0000 Subject: [PATCH 027/482] Clarify meaning of `--defer' in the manual. --- stow.texi | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/stow.texi b/stow.texi index c30d61d..5286e13 100644 --- a/stow.texi +++ b/stow.texi @@ -275,9 +275,17 @@ Note that the regular expression is anchored to the end of the filename, because this is what you will want to do most of the time. @item --defer='' -This (repeatable) option lets you defer stowing a file matching the given -regular expression, if that file is already stowed by another package. For -example, the following options +This (repeatable) option avoids stowing a file matching the given +regular expression, if that file is already stowed by another package. +This is effectively the opposite of @code{--override}. + +(N.B. the name @code{--defer} was chosen in the sense that the package +currently being stowed is treated with lower precedence than any already +installed package, not in the sense that the operation is being +postponed to be run at a later point in time; do not confuse this +nomenclature with the wording used in @xref{Deferred Operation}.) + +For example, the following options @example --defer='man' --defer='info' From c23e31484845fa74c057332fa2ea8f11569fcdf3 Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Thu, 17 Nov 2011 19:47:20 +0000 Subject: [PATCH 028/482] Improve debug output --- stow.in | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/stow.in b/stow.in index 2168b78..7278ae8 100755 --- a/stow.in +++ b/stow.in @@ -122,7 +122,7 @@ if (not caller()) { '', # target is current_dir ); } - debug(2, "Unstowing package $package...done"); + debug(2, "Unstowing package $package... done"); } for my $package (@Pkgs_To_Stow) { @@ -135,7 +135,7 @@ if (not caller()) { '', # target is current dir join_paths($Stow_Path, $package), # source from target ); - debug(2, "Stowing package $package...done"); + debug(2, "Stowing package $package... done"); } # --verbose: tell me what you are planning to do @@ -385,7 +385,7 @@ sub set_stow_path { $Stow_Path = File::Spec->abs2rel($stow_dir); debug(2, "current dir is " . getcwd()); - debug(2, "stow dir path is $Stow_Path"); + debug(2, "stow dir path relative to cwd is $Stow_Path"); } #===== SUBROUTINE =========================================================== @@ -403,7 +403,8 @@ sub set_stow_path { sub stow_contents { my ($path, $target, $source) = @_; - debug(2, "Stowing contents of $path"); + my $cwd = getcwd(); + debug(2, "Stowing contents of $path (cwd is $cwd)"); debug(3, "--- $target => $source"); if (not -d $path) { @@ -443,7 +444,7 @@ sub stow_contents { sub stow_node { my ($path, $target, $source) = @_; - debug(2, "Stowing $path"); + debug(2, "Stowing from $path"); debug(3, "--- $target => $source"); # don't try to stow absolute symlinks (they can't be unstowed) @@ -548,8 +549,9 @@ sub unstow_contents_orig { if ($target eq $Stow_Path or -e "$target/.stow" or -e "$target/.nonstow") { return; } - debug(2, "Unstowing in $target"); - debug(3, "--- path is $path"); + my $cwd = getcwd(); + debug(2, "Unstowing from $target (compat mode, cwd is $cwd)"); + debug(3, "--- source path is $path"); if (not -d $target) { error("unstow_contents() called on a non-directory: $target"); } @@ -583,8 +585,8 @@ sub unstow_contents_orig { sub unstow_node_orig { my ($path, $target) = @_; - debug(2, "Unstowing $target"); - debug(3, "--- path is $path"); + debug(2, "Unstowing $target (compat mode)"); + debug(3, "--- source path is $path"); # does the target exist if (is_a_link($target)) { @@ -648,8 +650,9 @@ sub unstow_contents { if ($target eq $Stow_Path or -e "$target/.stow") { return; } - debug(2, "Unstowing in $target"); - debug(3, "--- path is $path"); + my $cwd = getcwd(); + debug(2, "Unstowing from $target (cwd is $cwd)"); + debug(3, "--- source path is $path"); if (not -d $path) { error("unstow_contents() called on a non-directory: $path"); } @@ -1093,7 +1096,7 @@ sub process_tasks { internal_error(qq(bad task action: $task->{'action'})); } } - debug(2, "Processing tasks...done"); + debug(2, "Processing tasks... done"); return; } From 422a7487247925a1acec3b877ad515df4f83f0f4 Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Thu, 17 Nov 2011 16:35:57 +0000 Subject: [PATCH 029/482] Fix Parameters comments. --- stow.in | 50 ++++++++++++++++++++++++++------------------------ 1 file changed, 26 insertions(+), 24 deletions(-) diff --git a/stow.in b/stow.in index 7278ae8..b1575b5 100755 --- a/stow.in +++ b/stow.in @@ -298,7 +298,7 @@ sub get_defaults { #===== SUBROUTINE =========================================================== # Name : usage() # Purpose : print program usage message and exit -# Parameters: msg => string to prepend to the usage message +# Parameters: $msg => string to prepend to the usage message # Returns : n/a # Throws : n/a # Comments : if 'msg' is given, then exit with non-zero status @@ -391,9 +391,9 @@ sub set_stow_path { #===== SUBROUTINE =========================================================== # Name : stow_contents() # Purpose : stow the contents of the given directory -# Parameters: $path => relative path to source dir from current directory -# : $source => relative path to symlink source from the dir of target -# : $target => relative path to symlink target from the current directory +# Parameters: $path => relative path to source dir from current directory +# : $target => relative path to symlink target from the current directory +# : $source => relative path to symlink source from the dir of target # Returns : n/a # Throws : a fatal error if directory cannot be read # Comments : stow_node() and stow_contents() are mutually recursive @@ -432,9 +432,9 @@ sub stow_contents { #===== SUBROUTINE =========================================================== # Name : stow_node() # Purpose : stow the given node -# Parameters: $path => relative path to source node from the current directory -# : $target => relative path to symlink target from the current directory -# : $source => relative path to symlink source from the dir of target +# Parameters: $path => relative path to source node from the current directory +# : $target => relative path to symlink target from the current directory +# : $source => relative path to symlink source from the dir of target # Returns : n/a # Throws : fatal exception if a conflict arises # Comments : stow_node() and stow_contents() are mutually recursive @@ -535,8 +535,8 @@ sub stow_node { #===== SUBROUTINE =========================================================== # Name : unstow_contents_orig() # Purpose : unstow the contents of the given directory -# Parameters: $path => relative path to source dir from current directory -# : $target => relative path to symlink target from the current directory +# Parameters: $path => relative path to source dir from current directory +# : $target => relative path to symlink target from the current directory # Returns : n/a # Throws : a fatal error if directory cannot be read # Comments : unstow_node() and unstow_contents() are mutually recursive @@ -576,8 +576,8 @@ sub unstow_contents_orig { #===== SUBROUTINE =========================================================== # Name : unstow_node_orig() # Purpose : unstow the given node -# Parameters: $path => relative path to source node from the current directory -# : $target => relative path to symlink target from the current directory +# Parameters: $path => relative path to source node from the current directory +# : $target => relative path to symlink target from the current directory # Returns : n/a # Throws : fatal error if a conflict arises # Comments : unstow_node() and unstow_contents() are mutually recursive @@ -636,8 +636,8 @@ sub unstow_node_orig { #===== SUBROUTINE =========================================================== # Name : unstow_contents() # Purpose : unstow the contents of the given directory -# Parameters: $path => relative path to source dir from current directory -# : $target => relative path to symlink target from the current directory +# Parameters: $path => relative path to source dir from current directory +# : $target => relative path to symlink target from the current directory # Returns : n/a # Throws : a fatal error if directory cannot be read # Comments : unstow_node() and unstow_contents() are mutually recursive @@ -680,8 +680,8 @@ sub unstow_contents { #===== SUBROUTINE =========================================================== # Name : unstow_node() # Purpose : unstow the given node -# Parameters: $path => relative path to source node from the current directory -# : $target => relative path to symlink target from the current directory +# Parameters: $path => relative path to source node from the current directory +# : $target => relative path to symlink target from the current directory # Returns : n/a # Throws : fatal error if a conflict arises # Comments : unstow_node() and unstow_contents() are mutually recursive @@ -866,7 +866,7 @@ sub cleanup_invalid_links { #===== SUBROUTINE =========================================================== # Name : foldable() # Purpose : determine if a tree can be folded -# Parameters: target => path to a directory +# Parameters: $target => path to a directory # Returns : path to the parent dir iff the tree can be safely folded # Throws : n/a # Comments : the path returned is relative to the parent of $target, @@ -963,7 +963,8 @@ sub fold_tree { #===== SUBROUTINE =========================================================== # Name : conflict() # Purpose : handle conflicts in stow operations -# Parameters: paths that conflict +# Parameters: $format => message printf format +# : @args => paths that conflict # Returns : n/a # Throws : fatal exception unless 'conflicts' option is set # Comments : indicates what type of conflict it is @@ -981,7 +982,7 @@ sub conflict { #===== SUBROUTINE ============================================================ # Name : ignore # Purpose : determine if the given path matches a regex in our ignore list -# Parameters: none +# Parameters: $path # Returns : Boolean # Throws : no exceptions # Comments : none @@ -998,7 +999,7 @@ sub ignore { #===== SUBROUTINE ============================================================ # Name : defer # Purpose : determine if the given path matches a regex in our defer list -# Parameters: none +# Parameters: $path # Returns : Boolean # Throws : no exceptions # Comments : none @@ -1015,7 +1016,7 @@ sub defer { #===== SUBROUTINE ============================================================ # Name : overide # Purpose : determine if the given path matches a regex in our override list -# Parameters: none +# Parameters: $path # Returns : Boolean # Throws : no exceptions # Comments : none @@ -1103,7 +1104,7 @@ sub process_tasks { #===== SUBROUTINE =========================================================== # Name : is_a_link() # Purpose : is the given path a current or planned link -# Parameters: none +# Parameters: $path # Returns : Boolean # Throws : none # Comments : returns false if an existing link is scheduled for removal @@ -1146,7 +1147,7 @@ sub is_a_link { #===== SUBROUTINE =========================================================== # Name : is_a_dir() # Purpose : is the given path a current or planned directory -# Parameters: none +# Parameters: $path # Returns : Boolean # Throws : none # Comments : returns false if an existing directory is scheduled for removal @@ -1188,7 +1189,7 @@ sub is_a_dir { #===== SUBROUTINE =========================================================== # Name : is_a_node() # Purpose : is the given path a current or planned node -# Parameters: none +# Parameters: $path # Returns : Boolean # Throws : none # Comments : returns false if an existing node is scheduled for removal @@ -1279,7 +1280,8 @@ sub read_a_link { #===== SUBROUTINE =========================================================== # Name : do_link() # Purpose : wrap 'link' operation for later processing -# Parameters: file => the file to link +# Parameters: $oldfile => the existing file to link to +# : $newfile => the file to link # Returns : n/a # Throws : error if this clashes with an existing planned operation # Comments : cleans up operations that undo previous operations From 063331c34daa7b3a6512b638e902daae4115ca23 Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Thu, 17 Nov 2011 16:37:37 +0000 Subject: [PATCH 030/482] Add debug tracing to helper routines --- stow.in | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/stow.in b/stow.in index b1575b5..837f2b5 100755 --- a/stow.in +++ b/stow.in @@ -1112,9 +1112,11 @@ sub process_tasks { #============================================================================ sub is_a_link { my ($path) = @_; + debug(4, " is_a_link($path)"); if (exists $Link_Task_For{$path}) { my $action = $Link_Task_For{$path}->{'action'}; + debug(4, "is_a_link($path): task exists with action $action"); if ($action eq 'remove') { return 0; @@ -1129,6 +1131,7 @@ sub is_a_link { elsif (-l $path) { # check if any of its parent are links scheduled for removal # (need this for edge case during unfolding) + debug(4, "is_a_link($path): is a real link"); my $parent = ''; for my $part (split m{/+}, $path) { $parent = join_paths($parent, $part); @@ -1140,6 +1143,7 @@ sub is_a_link { } return 1; } + debug(4, "is_a_link($path): returning false"); return 0; } @@ -1156,9 +1160,11 @@ sub is_a_link { #============================================================================ sub is_a_dir { my ($path) = @_; + debug(4, " is_a_dir($path)"); if (exists $Dir_Task_For{$path}) { my $action = $Dir_Task_For{$path}->{'action'}; + debug(4, "is_a_dir($path): task exists with action $action"); if ($action eq 'remove') { return 0; } @@ -1181,8 +1187,10 @@ sub is_a_dir { } if (-d $path) { + debug(4, "is_a_dir($path): real dir"); return 1; } + debug(4, "is_a_dir($path): returning false"); return 0; } @@ -1198,10 +1206,11 @@ sub is_a_dir { #============================================================================ sub is_a_node { my ($path) = @_; + debug(4, " is_a_node($path)"); if (exists $Link_Task_For{$path}) { my $action = $Link_Task_For{$path}->{'action'}; - + debug(4, "is_a_node($path): link task exists with action $action"); if ($action eq 'remove') { return 0; } @@ -1215,7 +1224,7 @@ sub is_a_node { if (exists $Dir_Task_For{$path}) { my $action = $Dir_Task_For{$path}->{'action'}; - + debug(4, "is_a_node($path): dir task exists with action $action"); if ($action eq 'remove') { return 0; } @@ -1230,16 +1239,20 @@ sub is_a_node { # are we really following a link that is scheduled for removal my $prefix = ''; for my $part (split m{/+}, $path) { - $prefix = join_paths($prefix, $part); + $prefix = join_paths($prefix, $part); + debug(4, "is_a_node($path): prefix $prefix"); if (exists $Link_Task_For{$prefix} and $Link_Task_For{$prefix}->{'action'} eq 'remove') { + debug(4, "is_a_node($path): link scheduled for removal"); return 0; } } if (-e $path) { + debug(4, "is_a_node($path): really exists"); return 1; } + debug(4, "is_a_node($path): returning false"); return 0; } @@ -1257,6 +1270,7 @@ sub read_a_link { if (exists $Link_Task_For{$path}) { my $action = $Link_Task_For{$path}->{'action'}; + debug(4, "read_a_link($path): task exists with action $action"); if ($action eq 'create') { return $Link_Task_For{$path}->{'source'}; @@ -1271,6 +1285,7 @@ sub read_a_link { } } elsif (-l $path) { + debug(4, "read_a_link($path): real link"); return readlink $path or error("Could not read link: $path"); } From 1d3f45580ba7f8b7f7cd35f304238dee94efa8b5 Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Thu, 17 Nov 2011 16:39:02 +0000 Subject: [PATCH 031/482] Don't tolerate '' as value for $target parameter to (un)stow_contents --- stow.in | 29 +++++++++++++++++------------ t/stow_contents.t | 2 +- t/unstow_contents.t | 22 +++++++++++----------- t/unstow_contents_orig.t | 22 +++++++++++----------- 4 files changed, 40 insertions(+), 35 deletions(-) diff --git a/stow.in b/stow.in index 837f2b5..dee5d8a 100755 --- a/stow.in +++ b/stow.in @@ -113,13 +113,13 @@ if (not caller()) { if ($Option{'compat'}) { unstow_contents_orig( join_paths($Stow_Path, $package), # path to package - '', # target is current_dir + '.', # target is current_dir ); } else { unstow_contents( join_paths($Stow_Path, $package), # path to package - '', # target is current_dir + '.', # target is current_dir ); } debug(2, "Unstowing package $package... done"); @@ -132,7 +132,7 @@ if (not caller()) { debug(2, "Stowing package $package..."); stow_contents( join_paths($Stow_Path, $package), # path package - '', # target is current dir + '.', # target is current dir join_paths($Stow_Path, $package), # source from target ); debug(2, "Stowing package $package... done"); @@ -407,9 +407,10 @@ sub stow_contents { debug(2, "Stowing contents of $path (cwd is $cwd)"); debug(3, "--- $target => $source"); - if (not -d $path) { - error("stow_contents() called on a non-directory: $path"); - } + error("stow_contents() called with non-directory path: $path") + unless -d $path; + error("stow_contents() called with non-directory target: $target") + unless is_a_node($target); opendir my $DIR, $path or error("cannot read directory: $path"); @@ -552,9 +553,11 @@ sub unstow_contents_orig { my $cwd = getcwd(); debug(2, "Unstowing from $target (compat mode, cwd is $cwd)"); debug(3, "--- source path is $path"); - if (not -d $target) { - error("unstow_contents() called on a non-directory: $target"); - } + # In compat mode we traverse the target tree not the source tree, + # so we're unstowing the contents of /target/foo, there's no + # guarantee that the corresponding /stow/mypkg/foo exists. + error("unstow_contents_orig() called with non-directory target: $target") + unless -d $target; opendir my $DIR, $target or error("cannot read directory: $target"); @@ -653,9 +656,11 @@ sub unstow_contents { my $cwd = getcwd(); debug(2, "Unstowing from $target (cwd is $cwd)"); debug(3, "--- source path is $path"); - if (not -d $path) { - error("unstow_contents() called on a non-directory: $path"); - } + # We traverse the source tree not the target tree, + error("unstow_contents() called with non-directory path: $path") + unless -d $path; + error("unstow_contents() called with non-directory target: $target") + unless is_a_node($target); opendir my $DIR, $path or error("cannot read directory: $path"); diff --git a/t/stow_contents.t b/t/stow_contents.t index e27d17b..97645c2 100755 --- a/t/stow_contents.t +++ b/t/stow_contents.t @@ -57,7 +57,7 @@ $Option{'verbose'} = 0; make_dir('../stow/pkg2/lib2'); make_file('../stow/pkg2/lib2/file2'); make_dir('lib2'); -stow_contents('../stow/pkg2', './', '../stow/pkg2'); +stow_contents('../stow/pkg2', '.', '../stow/pkg2'); process_tasks(); is( readlink('lib2/file2'), diff --git a/t/unstow_contents.t b/t/unstow_contents.t index 7dd3d6b..817f544 100755 --- a/t/unstow_contents.t +++ b/t/unstow_contents.t @@ -43,7 +43,7 @@ make_dir('../stow/pkg1/bin1'); make_file('../stow/pkg1/bin1/file1'); make_link('bin1','../stow/pkg1/bin1'); -unstow_contents('../stow/pkg1','./'); +unstow_contents('../stow/pkg1','.'); process_tasks(); ok( scalar(@Conflicts) == 0 && @@ -61,7 +61,7 @@ make_dir('lib2'); make_dir('../stow/pkg2/lib2'); make_file('../stow/pkg2/lib2/file2'); make_link('lib2/file2', '../../stow/pkg2/lib2/file2'); -unstow_contents('../stow/pkg2','./'); +unstow_contents('../stow/pkg2','.'); process_tasks(); ok( scalar(@Conflicts) == 0 && @@ -84,7 +84,7 @@ make_link('bin3/file3a' => '../../stow/pkg3a/bin3/file3a'); # emulate stow make_dir('../stow/pkg3b/bin3'); make_file('../stow/pkg3b/bin3/file3b'); make_link('bin3/file3b' => '../../stow/pkg3b/bin3/file3b'); # emulate stow -unstow_contents('../stow/pkg3b', './'); +unstow_contents('../stow/pkg3b', '.'); process_tasks(); ok( scalar(@Conflicts) == 0 && @@ -104,7 +104,7 @@ make_dir('../stow/pkg4/bin4'); make_file('../stow/pkg4/bin4/file4'); make_link('bin4/file4', '../../stow/pkg4/bin4/does-not-exist'); -unstow_contents('../stow/pkg4', './'); +unstow_contents('../stow/pkg4', '.'); process_tasks(); ok( scalar(@Conflicts) == 0 && @@ -121,7 +121,7 @@ $Option{'verbose'} = 0; make_dir('../stow/pkg5/bin5'); make_link('bin5', '../not-stow'); -unstow_contents('../stow/pkg5', './'); +unstow_contents('../stow/pkg5', '.'); like( $Conflicts[-1], qr(CONFLICT:.*existing target is not owned by stow) => q(existing link not owned by stow) @@ -140,7 +140,7 @@ make_link('bin6/file6', '../../stow/pkg6a/bin6/file6'); make_dir('../stow/pkg6b/bin6'); make_file('../stow/pkg6b/bin6/file6'); -unstow_contents('../stow/pkg6b', './'); +unstow_contents('../stow/pkg6b', '.'); ok( scalar(@Conflicts) == 0 && -l 'bin6/file6' && @@ -162,7 +162,7 @@ make_dir('stow/pkg7a/stow/pkg7b'); make_file('stow/pkg7a/stow/pkg7b/file7b'); make_link('stow/pkg7b', '../stow/pkg7a/stow/pkg7b'); -unstow_contents('stow/pkg7b', './'); +unstow_contents('stow/pkg7b', '.'); stderr_like( sub { process_tasks(); }, qr/There are no outstanding operations to perform/, @@ -192,7 +192,7 @@ make_dir('stow/pkg8a/stow2/pkg8b'); make_file('stow/pkg8a/stow2/pkg8b/file8b'); make_link('stow2/pkg8b', '../stow/pkg8a/stow2/pkg8b'); -unstow_contents('stow/pkg8a', './'); +unstow_contents('stow/pkg8a', '.'); stderr_like( sub { process_tasks(); }, qr/There are no outstanding operations to perform/, @@ -220,7 +220,7 @@ make_link('man9/man1/file9.1' => '../../../stow/pkg9a/man9/man1/file9.1'); # emu make_dir('../stow/pkg9b/man9/man1'); make_file('../stow/pkg9b/man9/man1/file9.1'); -unstow_contents('../stow/pkg9b', './'); +unstow_contents('../stow/pkg9b', '.'); process_tasks(); ok( scalar(@Conflicts) == 0 && @@ -248,7 +248,7 @@ make_link('man10/man1/file10b.1' => '../../../stow/pkg10b/man10/man1/file10b.1' make_dir('../stow/pkg10c/man10/man1'); make_file('../stow/pkg10c/man10/man1/file10a.1'); -unstow_contents('../stow/pkg10c', './'); +unstow_contents('../stow/pkg10c', '.'); stderr_like( sub { process_tasks(); }, qr/There are no outstanding operations to perform/, @@ -274,7 +274,7 @@ make_file('../stow/pkg12/man12/man1/.#file12.1'); make_dir('man12/man1'); make_link('man12/man1/file12.1' => '../../../stow/pkg12/man12/man1/file12.1'); -unstow_contents('../stow/pkg12', './'); +unstow_contents('../stow/pkg12', '.'); process_tasks(); ok( scalar(@Conflicts) == 0 && diff --git a/t/unstow_contents_orig.t b/t/unstow_contents_orig.t index 90575f6..ebed239 100755 --- a/t/unstow_contents_orig.t +++ b/t/unstow_contents_orig.t @@ -43,7 +43,7 @@ make_dir('../stow/pkg1/bin1'); make_file('../stow/pkg1/bin1/file1'); make_link('bin1','../stow/pkg1/bin1'); -unstow_contents_orig('../stow/pkg1','./'); +unstow_contents_orig('../stow/pkg1','.'); process_tasks(); ok( scalar(@Conflicts) == 0 && @@ -61,7 +61,7 @@ make_dir('lib2'); make_dir('../stow/pkg2/lib2'); make_file('../stow/pkg2/lib2/file2'); make_link('lib2/file2', '../../stow/pkg2/lib2/file2'); -unstow_contents_orig('../stow/pkg2','./'); +unstow_contents_orig('../stow/pkg2','.'); process_tasks(); ok( scalar(@Conflicts) == 0 && @@ -84,7 +84,7 @@ make_link('bin3/file3a' => '../../stow/pkg3a/bin3/file3a'); # emulate stow make_dir('../stow/pkg3b/bin3'); make_file('../stow/pkg3b/bin3/file3b'); make_link('bin3/file3b' => '../../stow/pkg3b/bin3/file3b'); # emulate stow -unstow_contents_orig('../stow/pkg3b', './'); +unstow_contents_orig('../stow/pkg3b', '.'); process_tasks(); ok( scalar(@Conflicts) == 0 && @@ -104,7 +104,7 @@ make_dir('../stow/pkg4/bin4'); make_file('../stow/pkg4/bin4/file4'); make_link('bin4/file4', '../../stow/pkg4/bin4/does-not-exist'); -unstow_contents_orig('../stow/pkg4', './'); +unstow_contents_orig('../stow/pkg4', '.'); process_tasks(); ok( scalar(@Conflicts) == 0 && @@ -121,7 +121,7 @@ $Option{'verbose'} = 0; make_dir('../stow/pkg5/bin5'); make_link('bin5', '../not-stow'); -unstow_contents_orig('../stow/pkg5', './'); +unstow_contents_orig('../stow/pkg5', '.'); #like( # $Conflicts[-1], qr(CONFLICT:.*can't unlink.*not owned by stow) # => q(existing link not owned by stow) @@ -144,7 +144,7 @@ make_link('bin6/file6', '../../stow/pkg6a/bin6/file6'); make_dir('../stow/pkg6b/bin6'); make_file('../stow/pkg6b/bin6/file6'); -unstow_contents_orig('../stow/pkg6b', './'); +unstow_contents_orig('../stow/pkg6b', '.'); ok( -l 'bin6/file6' && readlink('bin6/file6') eq '../../stow/pkg6a/bin6/file6' => q(existing link owned by stow but points to a different package) @@ -164,7 +164,7 @@ make_dir('stow/pkg7a/stow/pkg7b'); make_file('stow/pkg7a/stow/pkg7b/file7b'); make_link('stow/pkg7b', '../stow/pkg7a/stow/pkg7b'); -unstow_contents_orig('stow/pkg7b', './'); +unstow_contents_orig('stow/pkg7b', '.'); stderr_like( sub { process_tasks(); }, qr/There are no outstanding operations to perform/, @@ -194,7 +194,7 @@ make_dir('stow/pkg8a/stow2/pkg8b'); make_file('stow/pkg8a/stow2/pkg8b/file8b'); make_link('stow2/pkg8b', '../stow/pkg8a/stow2/pkg8b'); -unstow_contents_orig('stow/pkg8a', './'); +unstow_contents_orig('stow/pkg8a', '.'); stderr_like( sub { process_tasks(); }, qr/There are no outstanding operations to perform/, @@ -222,7 +222,7 @@ make_link('man9/man1/file9.1' => '../../../stow/pkg9a/man9/man1/file9.1'); # emu make_dir('../stow/pkg9b/man9/man1'); make_file('../stow/pkg9b/man9/man1/file9.1'); -unstow_contents_orig('../stow/pkg9b', './'); +unstow_contents_orig('../stow/pkg9b', '.'); process_tasks(); ok( scalar(@Conflicts) == 0 && @@ -250,7 +250,7 @@ make_link('man10/man1/file10b.1' => '../../../stow/pkg10b/man10/man1/file10b.1' make_dir('../stow/pkg10c/man10/man1'); make_file('../stow/pkg10c/man10/man1/file10a.1'); -unstow_contents_orig('../stow/pkg10c', './'); +unstow_contents_orig('../stow/pkg10c', '.'); stderr_like( sub { process_tasks(); }, qr/There are no outstanding operations to perform/, @@ -276,7 +276,7 @@ make_file('../stow/pkg12/man12/man1/.#file12.1'); make_dir('man12/man1'); make_link('man12/man1/file12.1' => '../../../stow/pkg12/man12/man1/file12.1'); -unstow_contents_orig('../stow/pkg12', './'); +unstow_contents_orig('../stow/pkg12', '.'); process_tasks(); ok( scalar(@Conflicts) == 0 && From 7167eeb903459c431e0a575dc24102269b9c3f96 Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Thu, 17 Nov 2011 17:23:04 +0000 Subject: [PATCH 032/482] Improve tree splitting comments. --- stow.in | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/stow.in b/stow.in index dee5d8a..7b516ab 100755 --- a/stow.in +++ b/stow.in @@ -94,7 +94,9 @@ our %Dir_Task_For = (); # directory task associated with it. our %Link_Task_For = (); -# NB: directory tasks and link tasks are NOT mutually exclusive +# N.B.: directory tasks and link tasks are NOT mutually exclusive due +# to tree splitting (which involves a remove link task followed by +# a create directory task). # put the main loop in this block so we can load the # rest of the code as a module for testing @@ -493,7 +495,7 @@ sub stow_node { # if the existing link points to a directory, # and the proposed new link points to a directory, - # then we can unfold the tree at that point + # then we can unfold (split open) the tree at that point debug(3, "--- Unfolding $target"); do_unlink($target); From aefaad37a40866eb6e5ea28c65574ef7f5e3d926 Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Thu, 17 Nov 2011 18:24:53 +0000 Subject: [PATCH 033/482] Refactored is_a_{link,dir,node}() code. --- stow.in | 212 +++++++++++++++++++++++++++++++++++--------------------- 1 file changed, 133 insertions(+), 79 deletions(-) diff --git a/stow.in b/stow.in index 7b516ab..4b68246 100755 --- a/stow.in +++ b/stow.in @@ -1108,6 +1108,81 @@ sub process_tasks { return; } +#===== SUBROUTINE =========================================================== +# Name : link_task_action() +# Purpose : finds the link task action for the given path, if there is one +# Parameters: $path +# Returns : 'remove', 'create', or '' if there is no action +# Throws : a fatal exception if an invalid action is found +# Comments : none +#============================================================================ +sub link_task_action { + my ($path) = @_; + + if (! exists $Link_Task_For{$path}) { + debug(4, " link_task_action($path): no task"); + return ''; + } + + my $action = $Link_Task_For{$path}->{'action'}; + internal_error("bad task action: $action") + unless $action eq 'remove' or $action eq 'create'; + + debug(4, " link_task_action($path): link task exists with action $action"); + return $action; +} + +#===== SUBROUTINE =========================================================== +# Name : dir_task_action() +# Purpose : finds the dir task action for the given path, if there is one +# Parameters: $path +# Returns : 'remove', 'create', or '' if there is no action +# Throws : a fatal exception if an invalid action is found +# Comments : none +#============================================================================ +sub dir_task_action { + my ($path) = @_; + + if (! exists $Dir_Task_For{$path}) { + debug(4, " dir_task_action($path): no task"); + return ''; + } + + my $action = $Dir_Task_For{$path}->{'action'}; + internal_error("bad task action: $action") + unless $action eq 'remove' or $action eq 'create'; + + debug(4, " dir_task_action($path): dir task exists with action $action"); + return $action; +} + +#===== SUBROUTINE =========================================================== +# Name : parent_link_scheduled_for_removal() +# Purpose : determines whether the given path or any parent thereof +# : is a link scheduled for removal +# Parameters: $path +# Returns : Boolean +# Throws : none +# Comments : none +#============================================================================ +sub parent_link_scheduled_for_removal { + my ($path) = @_; + + my $prefix = ''; + for my $part (split m{/+}, $path) { + $prefix = join_paths($prefix, $part); + debug(4, " parent_link_scheduled_for_removal($path): prefix $prefix"); + if (exists $Link_Task_For{$prefix} and + $Link_Task_For{$prefix}->{'action'} eq 'remove') { + debug(4, " parent_link_scheduled_for_removal($path): link scheduled for removal"); + return 1; + } + } + + debug(4, " parent_link_scheduled_for_removal($path): returning false"); + return 0; +} + #===== SUBROUTINE =========================================================== # Name : is_a_link() # Purpose : is the given path a current or planned link @@ -1121,40 +1196,26 @@ sub is_a_link { my ($path) = @_; debug(4, " is_a_link($path)"); - if (exists $Link_Task_For{$path}) { - my $action = $Link_Task_For{$path}->{'action'}; - debug(4, "is_a_link($path): task exists with action $action"); - + if (my $action = link_task_action($path)) { if ($action eq 'remove') { return 0; } elsif ($action eq 'create') { return 1; } - else { - internal_error("bad task action: $action"); - } } - elsif (-l $path) { + + if (-l $path) { # check if any of its parent are links scheduled for removal # (need this for edge case during unfolding) - debug(4, "is_a_link($path): is a real link"); - my $parent = ''; - for my $part (split m{/+}, $path) { - $parent = join_paths($parent, $part); - if (exists $Link_Task_For{$parent}) { - if ($Link_Task_For{$parent}->{'action'} eq 'remove') { - return 0; - } - } - } - return 1; + debug(4, " is_a_link($path): is a real link"); + return parent_link_scheduled_for_removal($path) ? 0 : 1; } - debug(4, "is_a_link($path): returning false"); + + debug(4, " is_a_link($path): returning false"); return 0; } - #===== SUBROUTINE =========================================================== # Name : is_a_dir() # Purpose : is the given path a current or planned directory @@ -1169,35 +1230,23 @@ sub is_a_dir { my ($path) = @_; debug(4, " is_a_dir($path)"); - if (exists $Dir_Task_For{$path}) { - my $action = $Dir_Task_For{$path}->{'action'}; - debug(4, "is_a_dir($path): task exists with action $action"); + if (my $action = dir_task_action($path)) { if ($action eq 'remove') { return 0; } elsif ($action eq 'create') { return 1; } - else { - internal_error("bad task action: $action"); - } } - # are we really following a link that is scheduled for removal - my $prefix = ''; - for my $part (split m{/+}, $path) { - $prefix = join_paths($prefix, $part); - if (exists $Link_Task_For{$prefix} and - $Link_Task_For{$prefix}->{'action'} eq 'remove') { - return 0; - } - } + return 0 if parent_link_scheduled_for_removal($path); if (-d $path) { - debug(4, "is_a_dir($path): real dir"); + debug(4, " is_a_dir($path): real dir"); return 1; } - debug(4, "is_a_dir($path): returning false"); + + debug(4, " is_a_dir($path): returning false"); return 0; } @@ -1215,51 +1264,60 @@ sub is_a_node { my ($path) = @_; debug(4, " is_a_node($path)"); - if (exists $Link_Task_For{$path}) { - my $action = $Link_Task_For{$path}->{'action'}; - debug(4, "is_a_node($path): link task exists with action $action"); - if ($action eq 'remove') { + my $laction = link_task_action($path); + my $daction = dir_task_action($path); + + if ($laction eq 'remove') { + if ($daction eq 'remove') { + internal_error("removing link and dir: $path"); return 0; } - elsif ($action eq 'create') { + elsif ($daction eq 'create') { + # Assume that we're unfolding $path, and that the link + # removal action is earlier than the dir creation action + # in the task queue. FIXME: is this a safe assumption? return 1; } - else { - internal_error("bad task action: $action"); + else { # no dir action + return 0; + } + } + elsif ($laction eq 'create') { + if ($daction eq 'remove') { + # Assume that we're folding $path, and that the dir + # removal action is earlier than the link creation action + # in the task queue. FIXME: is this a safe assumption? + return 1; + } + elsif ($daction eq 'create') { + internal_error("creating link and dir: $path"); + return 1; + } + else { # no dir action + return 1; + } + } + else { + # No link action + if ($daction eq 'remove') { + return 0; + } + elsif ($daction eq 'create') { + return 1; + } + else { # no dir action + # fall through to below } } - if (exists $Dir_Task_For{$path}) { - my $action = $Dir_Task_For{$path}->{'action'}; - debug(4, "is_a_node($path): dir task exists with action $action"); - if ($action eq 'remove') { - return 0; - } - elsif ($action eq 'create') { - return 1; - } - else { - internal_error("bad task action: $action"); - } - } - - # are we really following a link that is scheduled for removal - my $prefix = ''; - for my $part (split m{/+}, $path) { - $prefix = join_paths($prefix, $part); - debug(4, "is_a_node($path): prefix $prefix"); - if (exists $Link_Task_For{$prefix} and - $Link_Task_For{$prefix}->{'action'} eq 'remove') { - debug(4, "is_a_node($path): link scheduled for removal"); - return 0; - } - } + return 0 if parent_link_scheduled_for_removal($path); if (-e $path) { - debug(4, "is_a_node($path): really exists"); + debug(4, " is_a_node($path): really exists"); return 1; } - debug(4, "is_a_node($path): returning false"); + + debug(4, " is_a_node($path): returning false"); return 0; } @@ -1275,9 +1333,8 @@ sub is_a_node { sub read_a_link { my ($path) = @_; - if (exists $Link_Task_For{$path}) { - my $action = $Link_Task_For{$path}->{'action'}; - debug(4, "read_a_link($path): task exists with action $action"); + if (my $action = link_task_action($path)) { + debug(4, " read_a_link($path): task exists with action $action"); if ($action eq 'create') { return $Link_Task_For{$path}->{'source'}; @@ -1287,12 +1344,9 @@ sub read_a_link { "read_a_link() passed a path that is scheduled for removal: $path" ); } - else { - internal_error("bad task action: $action"); - } } elsif (-l $path) { - debug(4, "read_a_link($path): real link"); + debug(4, " read_a_link($path): real link"); return readlink $path or error("Could not read link: $path"); } From 497f272c125a5ad52600182336a02bb8704793d8 Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Thu, 17 Nov 2011 18:46:13 +0000 Subject: [PATCH 034/482] Refactored reset_state() into t/util.pm --- t/cleanup_invalid_links.t | 10 ---------- t/examples.t | 10 ---------- t/stow_contents.t | 10 ---------- t/unstow_contents.t | 10 ---------- t/unstow_contents_orig.t | 10 ---------- t/util.pm | 18 ++++++++++++++++++ 6 files changed, 18 insertions(+), 50 deletions(-) diff --git a/t/cleanup_invalid_links.t b/t/cleanup_invalid_links.t index 92741cc..d8fb839 100755 --- a/t/cleanup_invalid_links.t +++ b/t/cleanup_invalid_links.t @@ -10,16 +10,6 @@ BEGIN { use lib qw(.); require "t/util.pm"; require "stow"; } use Test::More tests => 3; use English qw(-no_match_vars); -# local utility -sub reset_state { - @Tasks = (); - @Conflicts = (); - %Link_Task_For = (); - %Dir_Task_For = (); - %Option = (); - return; -} - ### setup eval { remove_dir('t/target'); }; eval { remove_dir('t/stow'); }; diff --git a/t/examples.t b/t/examples.t index ec90cef..4a8b9ec 100755 --- a/t/examples.t +++ b/t/examples.t @@ -10,16 +10,6 @@ BEGIN { use lib qw(.); require "t/util.pm"; require "stow"; } use Test::More tests => 4; use English qw(-no_match_vars); -# local utility -sub reset_state { - @Tasks = (); - @Conflicts = (); - %Link_Task_For = (); - %Dir_Task_For = (); - %Option = (); - return; -} - ### setup eval { remove_dir('t/target'); }; make_dir('t/target/stow'); diff --git a/t/stow_contents.t b/t/stow_contents.t index 97645c2..d589844 100755 --- a/t/stow_contents.t +++ b/t/stow_contents.t @@ -11,16 +11,6 @@ use Test::More tests => 14; use Test::Output; use English qw(-no_match_vars); -# local utility -sub reset_state { - @Tasks = (); - @Conflicts = (); - %Link_Task_For = (); - %Dir_Task_For = (); - %Option = (); - return; -} - ### setup eval { remove_dir('t/target'); }; eval { remove_dir('t/stow'); }; diff --git a/t/unstow_contents.t b/t/unstow_contents.t index 817f544..f37d15e 100755 --- a/t/unstow_contents.t +++ b/t/unstow_contents.t @@ -11,16 +11,6 @@ use Test::More tests => 14; use Test::Output; use English qw(-no_match_vars); -# local utility -sub reset_state { - @Tasks = (); - @Conflicts = (); - %Link_Task_For = (); - %Dir_Task_For = (); - %Option = (); - return; -} - ### setup eval { remove_dir('t/target'); }; eval { remove_dir('t/stow'); }; diff --git a/t/unstow_contents_orig.t b/t/unstow_contents_orig.t index ebed239..612bcbf 100755 --- a/t/unstow_contents_orig.t +++ b/t/unstow_contents_orig.t @@ -11,16 +11,6 @@ use Test::More tests => 14; use Test::Output; use English qw(-no_match_vars); -# local utility -sub reset_state { - @Tasks = (); - @Conflicts = (); - %Link_Task_For = (); - %Dir_Task_For = (); - %Option = (); - return; -} - ### setup eval { remove_dir('t/target'); }; eval { remove_dir('t/stow'); }; diff --git a/t/util.pm b/t/util.pm index ff74161..0beade9 100755 --- a/t/util.pm +++ b/t/util.pm @@ -7,6 +7,24 @@ use strict; use warnings; + +#===== SUBROUTINE =========================================================== +# Name : reset_state() +# Purpose : reset internal state machine +# Parameters: none +# Returns : n/a +# Throws : n/a +# Comments : none +#============================================================================ +sub reset_state { + @::Tasks = (); + @::Conflicts = (); + %::Link_Task_For = (); + %::Dir_Task_For = (); + %::Option = (); + return; +} + #===== SUBROUTINE =========================================================== # Name : make_link() # Purpose : safely create a link From c26236d93c2109336646b727d4293ef30f7749ae Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Thu, 17 Nov 2011 18:46:32 +0000 Subject: [PATCH 035/482] Debug with maximum verbosity to STDOUT when running tests. --- stow.in | 5 ++++- t/util.pm | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/stow.in b/stow.in index 4b68246..704fe64 100755 --- a/stow.in +++ b/stow.in @@ -263,7 +263,10 @@ sub process_options { #============================================================================= sub debug { my ($level, $msg) = @_; - if ($Option{'verbose'} >= $level) { + if ($Option{'testmode'}) { + print "# $msg\n" if $ENV{TEST_VERBOSE}; + } + elsif ($Option{'verbose'} >= $level) { warn "$msg\n"; } } diff --git a/t/util.pm b/t/util.pm index 0beade9..7241cf6 100755 --- a/t/util.pm +++ b/t/util.pm @@ -21,7 +21,7 @@ sub reset_state { @::Conflicts = (); %::Link_Task_For = (); %::Dir_Task_For = (); - %::Option = (); + %::Option = ( testmode => 1 ); return; } From 28dbad2933ad060e1626298ab1fae16db116f92a Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Thu, 17 Nov 2011 19:04:10 +0000 Subject: [PATCH 036/482] Sync t/unstow_contents{,_orig}.t --- t/unstow_contents_orig.t | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/t/unstow_contents_orig.t b/t/unstow_contents_orig.t index 612bcbf..15e5915 100755 --- a/t/unstow_contents_orig.t +++ b/t/unstow_contents_orig.t @@ -136,8 +136,10 @@ make_file('../stow/pkg6b/bin6/file6'); unstow_contents_orig('../stow/pkg6b', '.'); ok( - -l 'bin6/file6' && readlink('bin6/file6') eq '../../stow/pkg6a/bin6/file6' - => q(existing link owned by stow but points to a different package) + scalar(@Conflicts) == 0 && + -l 'bin6/file6' && + readlink('bin6/file6') eq '../../stow/pkg6a/bin6/file6' + => q(ignore existing link that points to a different package) ); # @@ -244,7 +246,7 @@ unstow_contents_orig('../stow/pkg10c', '.'); stderr_like( sub { process_tasks(); }, qr/There are no outstanding operations to perform/, - 'no tasks to process when unstowing pkg8a' + 'no tasks to process when unstowing pkg10c' ); ok( scalar(@Conflicts) == 0 && @@ -274,6 +276,7 @@ ok( => 'ignore temp files' ); + # Todo # # Test cleaning up subdirs with --paranoid option From bcddf67d739ce9cb21377274abda6bbdcb4e16e5 Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Thu, 17 Nov 2011 19:10:02 +0000 Subject: [PATCH 037/482] Fix incorrect comments. --- stow.in | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/stow.in b/stow.in index 704fe64..d643787 100755 --- a/stow.in +++ b/stow.in @@ -545,7 +545,7 @@ sub stow_node { # : $target => relative path to symlink target from the current directory # Returns : n/a # Throws : a fatal error if directory cannot be read -# Comments : unstow_node() and unstow_contents() are mutually recursive +# Comments : unstow_node_orig() and unstow_contents_orig() are mutually recursive # : Here we traverse the target tree, rather than the source tree. #============================================================================ sub unstow_contents_orig { @@ -649,7 +649,7 @@ sub unstow_node_orig { # Returns : n/a # Throws : a fatal error if directory cannot be read # Comments : unstow_node() and unstow_contents() are mutually recursive -# : Here we traverse the target tree, rather than the source tree. +# : Here we traverse the source tree, rather than the target tree. #============================================================================ sub unstow_contents { my ($path, $target) = @_; From 9012dd8aa891594325f9d7f5a0001fd0c811bc44 Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Thu, 17 Nov 2011 19:33:09 +0000 Subject: [PATCH 038/482] Test unstowing an already unstowed package --- t/unstow_contents.t | 8 ++++++++ t/unstow_contents_orig.t | 8 ++++++++ 2 files changed, 16 insertions(+) diff --git a/t/unstow_contents.t b/t/unstow_contents.t index f37d15e..80ae7f4 100755 --- a/t/unstow_contents.t +++ b/t/unstow_contents.t @@ -272,6 +272,14 @@ ok( => 'ignore temp files' ); +# +# Unstow an already unstowed package +# + +unstow_contents('../stow/pkg12', '.'); +process_tasks(); +ok(scalar(@Conflicts) == 0); + # Todo # diff --git a/t/unstow_contents_orig.t b/t/unstow_contents_orig.t index 15e5915..52f6a46 100755 --- a/t/unstow_contents_orig.t +++ b/t/unstow_contents_orig.t @@ -276,6 +276,14 @@ ok( => 'ignore temp files' ); +# +# Unstow an already unstowed package +# + +unstow_contents('../stow/pkg12', '.'); +process_tasks(); +ok(scalar(@Conflicts) == 0); + # Todo # From 0592daf3efb2e6df897ade2b5e61390b2a37157a Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Thu, 17 Nov 2011 20:09:42 +0000 Subject: [PATCH 039/482] Add comments justifying is_a_node($target) check in unstow_contents(). --- stow.in | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/stow.in b/stow.in index d643787..a3a4956 100755 --- a/stow.in +++ b/stow.in @@ -661,10 +661,13 @@ sub unstow_contents { my $cwd = getcwd(); debug(2, "Unstowing from $target (cwd is $cwd)"); debug(3, "--- source path is $path"); - # We traverse the source tree not the target tree, + # We traverse the source tree not the target tree, so $path must exist. error("unstow_contents() called with non-directory path: $path") unless -d $path; - error("unstow_contents() called with non-directory target: $target") + # When called at the top level, $target should exist. And + # unstow_node() should only call this via mutual recursion if + # $target exists. + error("unstow_contents() called with invalid target: $target") unless is_a_node($target); opendir my $DIR, $path From b5c49db524703323494ab7e4821fa9d227cc01eb Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Thu, 17 Nov 2011 20:10:42 +0000 Subject: [PATCH 040/482] Add debug when target to be unstowed doesn't exist --- stow.in | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/stow.in b/stow.in index a3a4956..f1ebf88 100755 --- a/stow.in +++ b/stow.in @@ -638,6 +638,9 @@ sub unstow_node_orig { fold_tree($target, $parent); } } + else { + debug(3, "$target did not exist to be unstowed"); + } return; } @@ -775,6 +778,9 @@ sub unstow_node { ); } } + else { + debug(3, "$target did not exist to be unstowed"); + } return; } From fdca9bd57ac08e146560ff2b47a249002b7aa65c Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Thu, 17 Nov 2011 20:32:48 +0000 Subject: [PATCH 041/482] Debug when skipping over stow directories --- stow.in | 2 ++ 1 file changed, 2 insertions(+) diff --git a/stow.in b/stow.in index f1ebf88..2e3361b 100755 --- a/stow.in +++ b/stow.in @@ -553,6 +553,7 @@ sub unstow_contents_orig { # don't try to remove anything under a stow directory if ($target eq $Stow_Path or -e "$target/.stow" or -e "$target/.nonstow") { + debug(2, "Not unstowing from protected directory $target (compat mode)"); return; } my $cwd = getcwd(); @@ -659,6 +660,7 @@ sub unstow_contents { # don't try to remove anything under a stow directory if ($target eq $Stow_Path or -e "$target/.stow") { + debug(2, "Not unstowing from protected directory $target"); return; } my $cwd = getcwd(); From 5db0c0bbf7f8c61f6c08ed19524df1f62f2f3428 Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Fri, 18 Nov 2011 10:29:15 +0000 Subject: [PATCH 042/482] Allow TEST_VERBOSE to control level of verbosity. Defaults to 3. 'verbose' option now has precedence if set. --- stow.in | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/stow.in b/stow.in index 2e3361b..c9575fd 100755 --- a/stow.in +++ b/stow.in @@ -264,7 +264,12 @@ sub process_options { sub debug { my ($level, $msg) = @_; if ($Option{'testmode'}) { - print "# $msg\n" if $ENV{TEST_VERBOSE}; + $ENV{TEST_VERBOSE} = 3 + if $ENV{TEST_VERBOSE} && $ENV{TEST_VERBOSE} !~ /^\d+$/; + $Option{'verbose'} = $ENV{TEST_VERBOSE} + if $ENV{TEST_VERBOSE} && ! $Option{'verbose'}; + print "# $msg\n" + if $Option{'verbose'} >= $level; } elsif ($Option{'verbose'} >= $level) { warn "$msg\n"; From c26e62de439b9d9d5c64583d5edbd35e2b45c38c Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Fri, 18 Nov 2011 10:33:08 +0000 Subject: [PATCH 043/482] Trace individual cases separately when skipping stow dirs during unstow. --- stow.in | 41 +++++++++++++++++++++++++++++++---------- 1 file changed, 31 insertions(+), 10 deletions(-) diff --git a/stow.in b/stow.in index c9575fd..010e0ca 100755 --- a/stow.in +++ b/stow.in @@ -543,6 +543,33 @@ sub stow_node { return; } +#===== SUBROUTINE =========================================================== +# Name : should_skip_stow_dir_target() +# Purpose : determine whether target is a stow directory and should be skipped +# Parameters: $target => relative path to symlink target from the current directory +# Returns : true iff target is a stow directory +# Throws : n/a +# Comments : none +#============================================================================ +sub should_skip_stow_dir_target { + my ($target) = @_; + + # don't try to remove anything under a stow directory + if ($target eq $Stow_Path) { + debug(2, "Skipping target which was current stow directory $target"); + return 1; + } + for my $f (".stow", ".nonstow") { + if (-e join_paths($target, $f)) { + debug(2, "Skipping $target which contained $f"); + return 1; + } + } + + debug (4, "$target not protected"); + return 0; +} + #===== SUBROUTINE =========================================================== # Name : unstow_contents_orig() # Purpose : unstow the contents of the given directory @@ -556,11 +583,8 @@ sub stow_node { sub unstow_contents_orig { my ($path, $target) = @_; - # don't try to remove anything under a stow directory - if ($target eq $Stow_Path or -e "$target/.stow" or -e "$target/.nonstow") { - debug(2, "Not unstowing from protected directory $target (compat mode)"); - return; - } + return if should_skip_stow_dir_target($target); + my $cwd = getcwd(); debug(2, "Unstowing from $target (compat mode, cwd is $cwd)"); debug(3, "--- source path is $path"); @@ -663,11 +687,8 @@ sub unstow_node_orig { sub unstow_contents { my ($path, $target) = @_; - # don't try to remove anything under a stow directory - if ($target eq $Stow_Path or -e "$target/.stow") { - debug(2, "Not unstowing from protected directory $target"); - return; - } + return if should_skip_stow_dir_target($target); + my $cwd = getcwd(); debug(2, "Unstowing from $target (cwd is $cwd)"); debug(3, "--- source path is $path"); From 89b7de8c04d147a0185f9745993099eb852c0f13 Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Fri, 18 Nov 2011 10:34:23 +0000 Subject: [PATCH 044/482] Debug stow dir in stow/unstow contents routines --- stow.in | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/stow.in b/stow.in index 010e0ca..160e930 100755 --- a/stow.in +++ b/stow.in @@ -414,7 +414,9 @@ sub stow_contents { my ($path, $target, $source) = @_; my $cwd = getcwd(); - debug(2, "Stowing contents of $path (cwd is $cwd)"); + my $msg = "Stowing contents of $path (cwd=$cwd, stow dir=$Stow_Path)"; + $msg =~ s!$ENV{HOME}/!~/!g; + debug(2, $msg); debug(3, "--- $target => $source"); error("stow_contents() called with non-directory path: $path") @@ -586,7 +588,9 @@ sub unstow_contents_orig { return if should_skip_stow_dir_target($target); my $cwd = getcwd(); - debug(2, "Unstowing from $target (compat mode, cwd is $cwd)"); + my $msg = "Unstowing from $target (compat mode, cwd=$cwd, stow dir=$Stow_Path)"; + $msg =~ s!$ENV{HOME}/!~/!g; + debug(2, $msg); debug(3, "--- source path is $path"); # In compat mode we traverse the target tree not the source tree, # so we're unstowing the contents of /target/foo, there's no @@ -690,7 +694,9 @@ sub unstow_contents { return if should_skip_stow_dir_target($target); my $cwd = getcwd(); - debug(2, "Unstowing from $target (cwd is $cwd)"); + my $msg = "Unstowing from $target (cwd=$cwd, stow dir=$Stow_Path)"; + $msg =~ s!$ENV{HOME}/!~/!g; + debug(2, $msg); debug(3, "--- source path is $path"); # We traverse the source tree not the target tree, so $path must exist. error("unstow_contents() called with non-directory path: $path") From 80826b96e20777d855a771536da9cd82ec3e2286 Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Fri, 18 Nov 2011 10:48:48 +0000 Subject: [PATCH 045/482] Add protection against stowing into stow dirs --- stow.in | 2 ++ t/stow_contents.t | 23 ++++++++++++++++++++++- 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/stow.in b/stow.in index 160e930..685774c 100755 --- a/stow.in +++ b/stow.in @@ -413,6 +413,8 @@ sub set_stow_path { sub stow_contents { my ($path, $target, $source) = @_; + return if should_skip_stow_dir_target($target); + my $cwd = getcwd(); my $msg = "Stowing contents of $path (cwd=$cwd, stow dir=$Stow_Path)"; $msg =~ s!$ENV{HOME}/!~/!g; diff --git a/t/stow_contents.t b/t/stow_contents.t index d589844..da0e5eb 100755 --- a/t/stow_contents.t +++ b/t/stow_contents.t @@ -7,7 +7,7 @@ # load as a library BEGIN { use lib qw(.); require "t/util.pm"; require "stow"; } -use Test::More tests => 14; +use Test::More tests => 16; use Test::Output; use English qw(-no_match_vars); @@ -276,3 +276,24 @@ ok( readlink('lib13/libb.so.1') eq '../../stow/pkg13b/lib13/libb.so.1' => 'unfolding to stow links to libraries' ); + +# +# stowing to stow dir should fail +# +reset_state(); +$Stow_Path= 'stow'; + +make_dir('stow/pkg14/stow/pkg15'); +make_file('stow/pkg14/stow/pkg15/node15'); + +stow_contents('stow/pkg14', '.', 'stow/pkg14'); +stderr_like( + sub { process_tasks(); }, + qr/There are no outstanding operations to perform/, + 'no tasks to process' +); +ok( + scalar(@Conflicts) == 0 && + ! -l 'stow/pkg15' + => "stowing to stow dir should fail" +); From 3418cadb8e78a94ab9d2253980b8fe8ec62474f1 Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Fri, 18 Nov 2011 11:14:50 +0000 Subject: [PATCH 046/482] Make 'verbose' option default to 0 in testmode. --- stow.in | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/stow.in b/stow.in index 685774c..87da6fb 100755 --- a/stow.in +++ b/stow.in @@ -264,12 +264,13 @@ sub process_options { sub debug { my ($level, $msg) = @_; if ($Option{'testmode'}) { + # Convert TEST_VERBOSE=y into numeric value $ENV{TEST_VERBOSE} = 3 if $ENV{TEST_VERBOSE} && $ENV{TEST_VERBOSE} !~ /^\d+$/; - $Option{'verbose'} = $ENV{TEST_VERBOSE} - if $ENV{TEST_VERBOSE} && ! $Option{'verbose'}; - print "# $msg\n" - if $Option{'verbose'} >= $level; + + my $verbose = exists $Option{'verbose'} ? $Option{'verbose'} : + length $ENV{TEST_VERBOSE} ? $ENV{TEST_VERBOSE} : 0; + print "# $msg\n" if $verbose >= $level; } elsif ($Option{'verbose'} >= $level) { warn "$msg\n"; From a1246072dd894462c4537ae1d440851427fb5a1a Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Fri, 18 Nov 2011 12:00:05 +0000 Subject: [PATCH 047/482] Remove setting of verbosity from tests --- t/cleanup_invalid_links.t | 3 --- t/examples.t | 5 ----- t/foldable.t | 4 ---- t/stow_contents.t | 13 ------------- t/unstow_contents.t | 11 ----------- t/unstow_contents_orig.t | 11 ----------- 6 files changed, 47 deletions(-) mode change 100644 => 100755 t/foldable.t diff --git a/t/cleanup_invalid_links.t b/t/cleanup_invalid_links.t index d8fb839..69efbe8 100755 --- a/t/cleanup_invalid_links.t +++ b/t/cleanup_invalid_links.t @@ -25,7 +25,6 @@ $Stow_Path= '../stow'; # nothing to clean in a simple tree # reset_state(); -$Option{'verbose'} = 1; make_dir('../stow/pkg1/bin1'); make_file('../stow/pkg1/bin1/file1'); @@ -41,7 +40,6 @@ is( # cleanup a bad link in a simple tree # reset_state(); -$Option{'verbose'} = 0; make_dir('bin2'); make_dir('../stow/pkg2/bin2'); @@ -64,7 +62,6 @@ ok( # dont cleanup a bad link not owned by stow # reset_state(); -$Option{'verbose'} = 0; make_dir('bin3'); make_dir('../stow/pkg3/bin3'); diff --git a/t/examples.t b/t/examples.t index 4a8b9ec..adcaa97 100755 --- a/t/examples.t +++ b/t/examples.t @@ -43,7 +43,6 @@ make_file('stow/emacs/man/man1/emacs.1'); # stow perl into an empty target # reset_state(); -$Option{'verbose'} = 0; make_dir('stow/perl/bin'); make_file('stow/perl/bin/perl'); @@ -70,7 +69,6 @@ ok( # stow perl into a non-empty target # reset_state(); -$Option{'verbose'} = 0; # clean up previous stow remove_link('bin'); @@ -102,7 +100,6 @@ ok( # Install perl into an empty target and then install emacs # reset_state(); -$Option{'verbose'} = 0; # clean up previous stow remove_link('info'); @@ -155,7 +152,6 @@ ok( # behaviour is the same as if the empty directory had nothing to do with stow # reset_state(); -$Option{'verbose'} = 0; make_dir('stow/pkg1a/bin1'); make_dir('stow/pkg1b/bin1'); @@ -178,7 +174,6 @@ ok( # directories # reset_state(); -$Option{'verbose'} = 0; make_dir('stow2a/pkg2a/bin2'); make_file('stow2a/pkg2a/bin2/file2a'); diff --git a/t/foldable.t b/t/foldable.t old mode 100644 new mode 100755 index e4e4fec..171907c --- a/t/foldable.t +++ b/t/foldable.t @@ -25,7 +25,6 @@ $Stow_Path= '../stow'; # # can fold a simple tree # -$Option{'verbose'} = 0; make_dir('../stow/pkg1/bin1'); make_file('../stow/pkg1/bin1/file1'); @@ -37,7 +36,6 @@ is( foldable('bin1'), '../stow/pkg1/bin1' => q(can fold a simple tree) ); # # can't fold an empty directory # -$Option{'verbose'} = 0; make_dir('../stow/pkg2/bin2'); make_file('../stow/pkg2/bin2/file2'); @@ -48,7 +46,6 @@ is( foldable('bin2'), '' => q(can't fold an empty directory) ); # # can't fold if dir contains a non-link # -$Option{'verbose'} = 0; make_dir('../stow/pkg3/bin3'); make_file('../stow/pkg3/bin3/file3'); @@ -61,7 +58,6 @@ is( foldable('bin3'), '' => q(can't fold a dir containing non-links) ); # # can't fold if links point to different directories # -$Option{'verbose'} = 0; make_dir('bin4'); make_dir('../stow/pkg4a/bin4'); diff --git a/t/stow_contents.t b/t/stow_contents.t index da0e5eb..7cae0df 100755 --- a/t/stow_contents.t +++ b/t/stow_contents.t @@ -26,7 +26,6 @@ $Stow_Path= '../stow'; # stow a simple tree minimally # reset_state(); -$Option{'verbose'} = 0; make_dir('../stow/pkg1/bin1'); make_file('../stow/pkg1/bin1/file1'); @@ -42,7 +41,6 @@ is( # stow a simple tree into an existing directory # reset_state(); -$Option{'verbose'} = 0; make_dir('../stow/pkg2/lib2'); make_file('../stow/pkg2/lib2/file2'); @@ -59,7 +57,6 @@ is( # unfold existing tree # reset_state(); -$Option{'verbose'} = 0; make_dir('../stow/pkg3a/bin3'); make_file('../stow/pkg3a/bin3/file3a'); @@ -80,7 +77,6 @@ ok( # Link to a new dir conflicts with existing non-dir (can't unfold) # reset_state(); -$Option{'verbose'} = 0; make_file('bin4'); # this is a file but named like a directory make_dir('../stow/pkg4/bin4'); @@ -95,7 +91,6 @@ like( # Target already exists but is not owned by stow # reset_state(); -$Option{'verbose'} = 0; make_dir('bin5'); make_link('bin5/file5','../../empty'); @@ -110,7 +105,6 @@ like( # Replace existing but invalid target # reset_state(); -$Option{'verbose'} = 0; make_link('file6','../stow/path-does-not-exist'); make_dir('../stow/pkg6'); @@ -127,7 +121,6 @@ is( # (can't unfold) # reset_state(); -$Option{'verbose'} = 0; make_dir('bin7'); make_dir('../stow/pkg7a/bin7'); @@ -145,7 +138,6 @@ like( # stowing directories named 0 # reset_state(); -$Option{'verbose'} = 0; make_dir('../stow/pkg8a/0'); make_file('../stow/pkg8a/0/file8a'); @@ -167,7 +159,6 @@ ok( # overriding already stowed documentation # reset_state(); -$Option{'verbose'} = 0; $Option{'override'} = ['man9', 'info9']; make_dir('../stow/pkg9a/man9/man1'); @@ -189,7 +180,6 @@ ok( # deferring to already stowed documentation # reset_state(); -$Option{'verbose'} = 0; $Option{'defer'} = ['man10', 'info10']; make_dir('../stow/pkg10a/man10/man1'); @@ -215,7 +205,6 @@ ok( # Ignore temp files # reset_state(); -$Option{'verbose'} = 0; $Option{'ignore'} = ['~', '\.#.*']; make_dir('../stow/pkg11/man11/man1'); @@ -238,7 +227,6 @@ ok( # stowing links library files # reset_state(); -$Option{'verbose'} = 0; make_dir('../stow/pkg12/lib12/'); make_file('../stow/pkg12/lib12/lib.so'); @@ -257,7 +245,6 @@ ok( # unfolding to stow links to library files # reset_state(); -$Option{'verbose'} = 0; make_dir('../stow/pkg13a/lib13/'); make_file('../stow/pkg13a/lib13/liba.so'); diff --git a/t/unstow_contents.t b/t/unstow_contents.t index 80ae7f4..db4eabf 100755 --- a/t/unstow_contents.t +++ b/t/unstow_contents.t @@ -27,7 +27,6 @@ $Stow_Path= '../stow'; # reset_state(); -$Option{'verbose'} = 0; make_dir('../stow/pkg1/bin1'); make_file('../stow/pkg1/bin1/file1'); @@ -45,7 +44,6 @@ ok( # unstow a simple tree from an existing directory # reset_state(); -$Option{'verbose'} = 0; make_dir('lib2'); make_dir('../stow/pkg2/lib2'); @@ -63,7 +61,6 @@ ok( # fold tree after unstowing # reset_state(); -$Option{'verbose'} = 0; make_dir('bin3'); @@ -87,7 +84,6 @@ ok( # existing link is owned by stow but is invalid so it gets removed anyway # reset_state(); -$Option{'verbose'} = 0; make_dir('bin4'); make_dir('../stow/pkg4/bin4'); @@ -106,7 +102,6 @@ ok( # Existing link is not owned by stow # reset_state(); -$Option{'verbose'} = 0; make_dir('../stow/pkg5/bin5'); make_link('bin5', '../not-stow'); @@ -120,7 +115,6 @@ like( # Target already exists, is owned by stow, but points to a different package # reset_state(); -$Option{'verbose'} = 0; make_dir('bin6'); make_dir('../stow/pkg6a/bin6'); @@ -142,7 +136,6 @@ ok( # Don't unlink anything under the stow directory # reset_state(); -$Option{'verbose'} = 0; make_dir('stow'); # make out stow dir a subdir of target $Stow_Path = 'stow'; @@ -169,7 +162,6 @@ ok( # Don't unlink any nodes under another stow directory # reset_state(); -$Option{'verbose'} = 0; make_dir('stow'); # make out stow dir a subdir of target $Stow_Path = 'stow'; @@ -200,7 +192,6 @@ ok( # reset_state(); $Stow_Path = '../stow'; -$Option{'verbose'} = 0; $Option{'override'} = ['man9', 'info9']; make_dir('../stow/pkg9a/man9/man1'); @@ -222,7 +213,6 @@ ok( # deferring to already stowed documentation # reset_state(); -$Option{'verbose'} = 0; $Option{'defer'} = ['man10', 'info10']; make_dir('../stow/pkg10a/man10/man1'); @@ -254,7 +244,6 @@ ok( # Ignore temp files # reset_state(); -$Option{'verbose'} = 0; $Option{'ignore'} = ['~', '\.#.*']; make_dir('../stow/pkg12/man12/man1'); diff --git a/t/unstow_contents_orig.t b/t/unstow_contents_orig.t index 52f6a46..a705bc8 100755 --- a/t/unstow_contents_orig.t +++ b/t/unstow_contents_orig.t @@ -27,7 +27,6 @@ $Stow_Path= '../stow'; # reset_state(); -$Option{'verbose'} = 0; make_dir('../stow/pkg1/bin1'); make_file('../stow/pkg1/bin1/file1'); @@ -45,7 +44,6 @@ ok( # unstow a simple tree from an existing directory # reset_state(); -$Option{'verbose'} = 0; make_dir('lib2'); make_dir('../stow/pkg2/lib2'); @@ -63,7 +61,6 @@ ok( # fold tree after unstowing # reset_state(); -$Option{'verbose'} = 0; make_dir('bin3'); @@ -87,7 +84,6 @@ ok( # existing link is owned by stow but is invalid so it gets removed anyway # reset_state(); -$Option{'verbose'} = 0; make_dir('bin4'); make_dir('../stow/pkg4/bin4'); @@ -106,7 +102,6 @@ ok( # Existing link is not owned by stow # reset_state(); -$Option{'verbose'} = 0; make_dir('../stow/pkg5/bin5'); make_link('bin5', '../not-stow'); @@ -124,7 +119,6 @@ ok( # Target already exists, is owned by stow, but points to a different package # reset_state(); -$Option{'verbose'} = 0; make_dir('bin6'); make_dir('../stow/pkg6a/bin6'); @@ -146,7 +140,6 @@ ok( # Don't unlink anything under the stow directory # reset_state(); -$Option{'verbose'} = 0; make_dir('stow'); # make out stow dir a subdir of target $Stow_Path = 'stow'; @@ -173,7 +166,6 @@ ok( # Don't unlink any nodes under another stow directory # reset_state(); -$Option{'verbose'} = 0; make_dir('stow'); # make out stow dir a subdir of target $Stow_Path = 'stow'; @@ -204,7 +196,6 @@ ok( # reset_state(); $Stow_Path = '../stow'; -$Option{'verbose'} = 0; $Option{'override'} = ['man9', 'info9']; make_dir('../stow/pkg9a/man9/man1'); @@ -226,7 +217,6 @@ ok( # deferring to already stowed documentation # reset_state(); -$Option{'verbose'} = 0; $Option{'defer'} = ['man10', 'info10']; make_dir('../stow/pkg10a/man10/man1'); @@ -258,7 +248,6 @@ ok( # Ignore temp files # reset_state(); -$Option{'verbose'} = 0; $Option{'ignore'} = ['~', '\.#.*']; make_dir('../stow/pkg12/man12/man1'); From eda2b8335549cc97878c12973552346df5f2af52 Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Thu, 17 Nov 2011 20:11:32 +0000 Subject: [PATCH 048/482] Add a missing conflict if we tried to unstow a file in compat mode. --- stow.in | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/stow.in b/stow.in index 87da6fb..df58cc8 100755 --- a/stow.in +++ b/stow.in @@ -675,6 +675,11 @@ sub unstow_node_orig { fold_tree($target, $parent); } } + elsif (-e $target) { + conflict( + qq{existing target is neither a link nor a directory: $target}, + ); + } else { debug(3, "$target did not exist to be unstowed"); } From 6e7ed071c1b4a5c5a0d8f25aa77fc8ffd890f10b Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Thu, 17 Nov 2011 20:11:06 +0000 Subject: [PATCH 049/482] Test unstowing stuff which doesn't exist in the target tree. --- t/unstow_contents.t | 35 +++++++++++++++++++++++++++++++---- t/unstow_contents_orig.t | 35 +++++++++++++++++++++++++++++++---- 2 files changed, 62 insertions(+), 8 deletions(-) diff --git a/t/unstow_contents.t b/t/unstow_contents.t index db4eabf..f07d37b 100755 --- a/t/unstow_contents.t +++ b/t/unstow_contents.t @@ -7,7 +7,7 @@ # load as a library BEGIN { use lib qw(.); require "t/util.pm"; require "stow"; } -use Test::More tests => 14; +use Test::More tests => 18; use Test::Output; use English qw(-no_match_vars); @@ -191,6 +191,7 @@ ok( # overriding already stowed documentation # reset_state(); +make_file('stow/.stow'); $Stow_Path = '../stow'; $Option{'override'} = ['man9', 'info9']; @@ -264,10 +265,36 @@ ok( # # Unstow an already unstowed package # - +reset_state(); unstow_contents('../stow/pkg12', '.'); -process_tasks(); -ok(scalar(@Conflicts) == 0); +stderr_like( + sub { process_tasks(); }, + qr/There are no outstanding operations to perform/, + 'no tasks to process when unstowing pkg12' +); +ok( + scalar(@Conflicts) == 0 + => 'unstow already unstowed package pkg12' +); + +# +# Unstow a never stowed package +# + +eval { remove_dir('t/target'); }; +mkdir('t/target'); + +reset_state(); +unstow_contents('../stow/pkg12', '.'); +stderr_like( + sub { process_tasks(); }, + qr/There are no outstanding operations to perform/, + 'no tasks to process when unstowing pkg12 which was never stowed' +); +ok( + scalar(@Conflicts) == 0 + => 'unstow never stowed package pkg12' +); # Todo diff --git a/t/unstow_contents_orig.t b/t/unstow_contents_orig.t index a705bc8..a6179ea 100755 --- a/t/unstow_contents_orig.t +++ b/t/unstow_contents_orig.t @@ -7,7 +7,7 @@ # load as a library BEGIN { use lib qw(.); require "t/util.pm"; require "stow"; } -use Test::More tests => 14; +use Test::More tests => 18; use Test::Output; use English qw(-no_match_vars); @@ -195,6 +195,7 @@ ok( # overriding already stowed documentation # reset_state(); +make_file('stow/.stow'); $Stow_Path = '../stow'; $Option{'override'} = ['man9', 'info9']; @@ -268,10 +269,36 @@ ok( # # Unstow an already unstowed package # +reset_state(); +unstow_contents_orig('../stow/pkg12', '.'); +stderr_like( + sub { process_tasks(); }, + qr/There are no outstanding operations to perform/, + 'no tasks to process when unstowing pkg12' +); +ok( + scalar(@Conflicts) == 0 + => 'unstow already unstowed package pkg12' +); -unstow_contents('../stow/pkg12', '.'); -process_tasks(); -ok(scalar(@Conflicts) == 0); +# +# Unstow a never stowed package +# + +eval { remove_dir('t/target'); }; +mkdir('t/target'); + +reset_state(); +unstow_contents_orig('../stow/pkg12', '.'); +stderr_like( + sub { process_tasks(); }, + qr/There are no outstanding operations to perform/, + 'no tasks to process when unstowing pkg12 which was never stowed' +); +ok( + scalar(@Conflicts) == 0 + => 'unstow never stowed package pkg12' +); # Todo From fbe547c1326082f528d94a4048faa3e860f9e4e8 Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Fri, 18 Nov 2011 11:24:36 +0000 Subject: [PATCH 050/482] Test unstowing when target contains a real file generates a conflict. --- t/unstow_contents.t | 20 +++++++++++++++++++- t/unstow_contents_orig.t | 20 +++++++++++++++++++- 2 files changed, 38 insertions(+), 2 deletions(-) diff --git a/t/unstow_contents.t b/t/unstow_contents.t index f07d37b..80fccc5 100755 --- a/t/unstow_contents.t +++ b/t/unstow_contents.t @@ -7,7 +7,7 @@ # load as a library BEGIN { use lib qw(.); require "t/util.pm"; require "stow"; } -use Test::More tests => 18; +use Test::More tests => 20; use Test::Output; use English qw(-no_match_vars); @@ -296,6 +296,24 @@ ok( => 'unstow never stowed package pkg12' ); +# +# Unstowing when target contains a real file shouldn't be an issue. +# +make_file('man12/man1/file12.1'); + +reset_state(); +unstow_contents('../stow/pkg12', '.'); +stderr_like( + sub { process_tasks(); }, + qr/There are no outstanding operations to perform/, + 'no tasks to process when unstowing pkg12 for third time' +); +ok( + scalar(@Conflicts) == 1 && + $Conflicts[0] =~ m!existing target is neither a link nor a directory: man12/man1/file12\.1! + => 'unstow pkg12 for third time' +); + # Todo # diff --git a/t/unstow_contents_orig.t b/t/unstow_contents_orig.t index a6179ea..d41d9c1 100755 --- a/t/unstow_contents_orig.t +++ b/t/unstow_contents_orig.t @@ -7,7 +7,7 @@ # load as a library BEGIN { use lib qw(.); require "t/util.pm"; require "stow"; } -use Test::More tests => 18; +use Test::More tests => 20; use Test::Output; use English qw(-no_match_vars); @@ -300,6 +300,24 @@ ok( => 'unstow never stowed package pkg12' ); +# +# Unstowing when target contains a real file shouldn't be an issue. +# +make_file('man12/man1/file12.1'); + +reset_state(); +unstow_contents('../stow/pkg12', '.'); +stderr_like( + sub { process_tasks(); }, + qr/There are no outstanding operations to perform/, + 'no tasks to process when unstowing pkg12 for third time' +); +ok( + scalar(@Conflicts) == 1 && + $Conflicts[0] =~ m!existing target is neither a link nor a directory: man12/man1/file12\.1! + => 'unstow pkg12 for third time' +); + # Todo # From 1365c4c4f110b732bcc924a3d59d62b3fe054b9a Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Fri, 18 Nov 2011 15:09:39 +0000 Subject: [PATCH 051/482] Fix indentation in Makefile.am --- Makefile.am | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Makefile.am b/Makefile.am index 59051cc..61afb72 100644 --- a/Makefile.am +++ b/Makefile.am @@ -30,8 +30,8 @@ clean-local: # this is more explicit and reliable than the config file trick edit = sed -e 's|[@]PERL[@]|$(PERL)|g' \ - -e 's|[@]PACKAGE[@]|$(PACKAGE)|g' \ - -e 's|[@]VERSION[@]|$(VERSION)|g' + -e 's|[@]PACKAGE[@]|$(PACKAGE)|g' \ + -e 's|[@]VERSION[@]|$(VERSION)|g' stow: stow.in Makefile $(edit) < $< > $@ From dc61da22d4fc0ee5f6f0b6a550c8d162e7f1e3bb Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Thu, 24 Nov 2011 16:28:09 +0000 Subject: [PATCH 052/482] Major refactoring of code into separate Stow and Stow::Util Perl modules --- .gitignore | 1 + Makefile.am | 14 +- TODO | 2 - configure.ac | 6 + lib/Stow.pm.in | 1675 ++++++++++++++++++++++++++++++++++++ lib/Stow/Util.pm | 202 +++++ stow.in | 1657 ++--------------------------------- t/chkstow.t | 21 +- t/cleanup_invalid_links.t | 55 +- t/defer.t | 24 +- t/examples.t | 76 +- t/find_stowed_path.t | 40 +- t/foldable.t | 25 +- t/join_paths.t | 6 +- t/parent.t | 6 +- t/stow.t | 66 +- t/stow_contents.t | 153 ++-- t/{util.pm => testutil.pm} | 64 +- t/unstow_contents.t | 166 ++-- t/unstow_contents_orig.t | 160 ++-- 20 files changed, 2439 insertions(+), 1980 deletions(-) create mode 100755 lib/Stow.pm.in create mode 100644 lib/Stow/Util.pm mode change 100644 => 100755 t/defer.t mode change 100644 => 100755 t/find_stowed_path.t mode change 100644 => 100755 t/join_paths.t mode change 100644 => 100755 t/parent.t rename t/{util.pm => testutil.pm} (83%) diff --git a/.gitignore b/.gitignore index cee7979..fffadc6 100644 --- a/.gitignore +++ b/.gitignore @@ -9,3 +9,4 @@ stamp-vti stow.info t/target/ version.texi +lib/Stow.pm diff --git a/Makefile.am b/Makefile.am index 61afb72..e72767e 100644 --- a/Makefile.am +++ b/Makefile.am @@ -4,6 +4,8 @@ bin_SCRIPTS = stow chkstow info_TEXINFOS = stow.texi dist_man_MANS = stow.8 dist_doc_DATA = README +pmdir = $(libdir)/perl5 +pm_DATA = lib/Stow.pm lib/Stow/Util.pm TESTS_ENVIRONMENT=$(PERL) -I $(top_srcdir) TESTS = \ @@ -21,7 +23,7 @@ TESTS = \ t/chkstow.t AUTOMAKE_OPTIONS = dist-shar -EXTRA_DIST = $(TESTS) t/util.pm stow.in +EXTRA_DIST = $(TESTS) t/testutil.pm CLEANFILES = $(bin_SCRIPTS) # clean up files left behind by test suite @@ -30,7 +32,6 @@ clean-local: # this is more explicit and reliable than the config file trick edit = sed -e 's|[@]PERL[@]|$(PERL)|g' \ - -e 's|[@]PACKAGE[@]|$(PACKAGE)|g' \ -e 's|[@]VERSION[@]|$(VERSION)|g' stow: stow.in Makefile @@ -41,6 +42,9 @@ chkstow: chkstow.in Makefile $(edit) < $< > $@ chmod +x $@ +lib/Stow.pm: lib/Stow.pm.in + $(edit) < $< > $@ + # The rules for manual.html and manual.texi are only used by # the developer manual.html: manual.texi @@ -51,5 +55,7 @@ manual.texi: stow.texi -rm -f $@ cp $< $@ -test: stow chkstow - perl -MTest::Harness -e 'runtests(@ARGV)' t/*.t +MODULES = lib/Stow.pm lib/Stow/Util.pm + +test: stow chkstow $(MODULES) + perl -MTest::Harness -Ilib -It -Ibin -e 'runtests(@ARGV)' t/*.t diff --git a/TODO b/TODO index 0e2e614..b873238 100644 --- a/TODO +++ b/TODO @@ -1,5 +1,3 @@ -* Split core code into Stow.pm -* Add use strict / warnings to tests * Honour .no-stow-folding and --no-folding * Support ignore lists in files *** Implement. diff --git a/configure.ac b/configure.ac index 09bac98..063733e 100644 --- a/configure.ac +++ b/configure.ac @@ -15,5 +15,11 @@ then AC_MSG_WARN([WARNING: Perl not found; you must edit line 1 of 'stow']) fi +AC_ARG_WITH( + pmdir, + [ --with-pmdir=DIR perl modules are in DIR [[LIBDIR/perl5]]], + [PMDIR=${withval}], [PMDIR=${libdir}/perl5] +) + AC_CONFIG_FILES([Makefile]) AC_OUTPUT diff --git a/lib/Stow.pm.in b/lib/Stow.pm.in new file mode 100755 index 0000000..ecc4087 --- /dev/null +++ b/lib/Stow.pm.in @@ -0,0 +1,1675 @@ +#!/usr/bin/perl + +package Stow; + +=head1 NAME + +Stow - manage the installation of multiple software packages + +=head1 SYNOPSIS + + my $stow = new Stow(%$options); + + $stow->plan_unstow(@pkgs_to_unstow); + $stow->plan_stow (@pkgs_to_stow); + + my @conflicts = $stow->get_conflicts; + $stow->process_tasks() unless @conflicts; + +=head1 DESCRIPTION + +This is the backend Perl module for GNU Stow, a program for managing +the installation of software packages, keeping them separate +(C vs. C, for example) +while making them appear to be installed in the same place +(C). + +Stow doesn't store an extra state between runs, so there's no danger +of mangling directories when file hierarchies don't match the +database. Also, stow will never delete any files, directories, or +links that appear in a stow directory, so it is always possible to +rebuild the target tree. + +=cut + +use strict; +use warnings; + +use Carp qw(carp cluck croak confess); +use File::Spec; +use POSIX qw(getcwd); + +use Stow::Util qw(set_debug_level debug error set_test_mode + join_paths restore_cwd canon_path parent); + +our $ProgramName = 'stow'; +our $VERSION = '@VERSION@'; + +# These are the default options for each Stow instance. +our %DEFAULT_OPTIONS = ( + conflicts => 0, + simulate => 0, + verbose => 0, + paranoid => 0, + compat => 0, + test_mode => 0, + ignore => [], + override => [], + defer => [], +); + +=head1 CONSTRUCTORS + +=head2 new(%options) + +=head3 Required options + +=over 4 + +=item * dir - the stow directory + +=item * target - the target directory + +=back + +=head3 Non-mandatory options + +=over 4 + +=item * conflicts + +=item * simulate + +=item * verbose + +=item * paranoid + +=item * ignore + +=item * override + +=item * defer + +=back + +N.B. This sets the current working directory to the target directory. + +=cut + +sub new { + my $self = shift; + my $class = ref($self) || $self; + my %opts = @_; + + my $new = bless { }, $class; + + for my $required_arg (qw(dir target)) { + croak "$class->new() called without '$required_arg' parameter\n" + unless exists $opts{$required_arg}; + $new->{$required_arg} = delete $opts{$required_arg}; + } + + for my $opt (keys %DEFAULT_OPTIONS) { + $new->{$opt} = exists $opts{$opt} ? delete $opts{$opt} + : $DEFAULT_OPTIONS{$opt}; + } + + if (%opts) { + croak "$class->new() called with unrecognised parameter(s): ", + join(", ", keys %opts), "\n"; + } + + $opts{'simulate'} = 1 if $opts{'conflicts'}; + + set_debug_level($new->get_verbosity()); + set_test_mode($new->{test_mode}); + $new->set_stow_dir(); + $new->init_state(); + + return $new; +} + +sub get_verbosity { + my $self = shift; + + return $self->{verbose} unless $self->{test_mode}; + + return 0 unless length $ENV{TEST_VERBOSE}; + + # Convert TEST_VERBOSE=y into numeric value + $ENV{TEST_VERBOSE} = 3 if $ENV{TEST_VERBOSE} !~ /^\d+$/; + + return $ENV{TEST_VERBOSE}; +} + +=head2 set_stow_dir([$dir]) + +Sets a new stow directory. This allows the use of multiple stow +directories within one Stow instance, e.g. + + $stow->plan_stow('foo'); + $stow->set_stow_dir('/different/stow/dir'); + $stow->plan_stow('bar'); + $stow->process_tasks; + +If C<$dir> is omitted, uses the value of the C parameter passed +to the L constructor. + +=cut + +sub set_stow_dir { + my $self = shift; + my ($dir) = @_; + if (defined $dir) { + $self->{dir} = $dir; + } + + my $stow_dir = canon_path($self->{dir}); + + $self->{stow_path} = File::Spec->abs2rel($stow_dir, $self->{target}); + + debug(2, "stow dir is $stow_dir"); + debug(2, "stow dir path relative to target $self->{target} is $self->{stow_path}"); +} + +sub init_state { + my $self = shift; + + # Store conflicts during pre-processing + $self->{conflicts} = []; + + # Store command line packages to stow (-S and -R) + $self->{pkgs_to_stow} = []; + + # Store command line packages to unstow (-D and -R) + $self->{pkgs_to_delete} = []; + + # The following structures are used by the abstractions that allow us to + # defer operating on the filesystem until after all potential conflicts have + # been assessed. + + # $self->{tasks}: list of operations to be performed (in order) + # each element is a hash ref of the form + # { + # action => ... + # type => ... + # path => ... (unique) + # source => ... (only for links) + # } + $self->{tasks} = []; + + # $self->{dir_task_for}: map a path to the corresponding directory task reference + # This structure allows us to quickly determine if a path has an existing + # directory task associated with it. + $self->{dir_task_for} = {}; + + # $self->{link_task_for}: map a path to the corresponding directory task reference + # This structure allows us to quickly determine if a path has an existing + # directory task associated with it. + $self->{link_task_for} = {}; + + # N.B.: directory tasks and link tasks are NOT mutually exclusive due + # to tree splitting (which involves a remove link task followed by + # a create directory task). +} + +=head1 METHODS + +=head2 plan_unstow(@packages) + +Plan which symlink/directory creation/removal tasks need to be executed +in order to unstow the given packages. Any potential conflicts are then +accessible via L. + +=cut + +sub plan_unstow { + my $self = shift; + my @packages = @_; + + $self->within_target_do(sub { + for my $package (@packages) { + if (not -d join_paths($self->{stow_path}, $package)) { + error("The given package name ($package) is not in your stow path $self->{stow_path}"); + } + debug(2, "Unstowing package $package..."); + if ($self->{'compat'}) { + $self->unstow_contents_orig( + join_paths($self->{stow_path}, $package), # path to package + '.', # target is current_dir + ); + } + else { + $self->unstow_contents( + join_paths($self->{stow_path}, $package), # path to package + '.', # target is current_dir + ); + } + debug(2, "Unstowing package $package... done"); + } + }); +} + +=head2 plan_stow(@packages) + +Plan which symlink/directory creation/removal tasks need to be executed +in order to stow the given packages. Any potential conflicts are then +accessible via L. + +=cut + +sub plan_stow { + my $self = shift; + my @packages = @_; + + $self->within_target_do(sub { + for my $package (@packages) { + if (not -d join_paths($self->{stow_path}, $package)) { + error("The given package name ($package) is not in your stow path $self->{stow_path}"); + } + debug(2, "Stowing package $package..."); + $self->stow_contents( + join_paths($self->{stow_path}, $package), # path package + '.', # target is current dir + join_paths($self->{stow_path}, $package), # source from target + ); + debug(2, "Stowing package $package... done"); + } + }); +} + +#===== METHOD =============================================================== +# Name : within_target_do() +# Purpose : execute code within target directory, preserving cwd +# Parameters: $code => anonymous subroutine to execute within target dir +# Returns : n/a +# Throws : n/a +# Comments : This is done to ensure that the consumer of the Stow interface +# : doesn't have to worry about (a) what their cwd is, and +# : (b) that their cwd might change. +#============================================================================ +sub within_target_do { + my $self = shift; + my ($code) = @_; + + my $cwd = getcwd(); + chdir($self->{'target'}) + or error("Cannot chdir to target tree: $self->{'target'}"); + debug(3, "cwd now $self->{target}"); + + $self->$code(); + + restore_cwd($cwd); + debug(3, "cwd restored to $cwd"); +} + +#===== METHOD =============================================================== +# Name : stow_contents() +# Purpose : stow the contents of the given directory +# Parameters: $path => relative path to source dir from current directory +# : $target => relative path to symlink target from the current directory +# : $source => relative path to symlink source from the dir of target +# Returns : n/a +# Throws : a fatal error if directory cannot be read +# Comments : stow_node() and stow_contents() are mutually recursive +# : $source and $target are used for creating the symlink +# : $path is used for folding/unfolding trees as necessary +#============================================================================ +sub stow_contents { + my $self = shift; + my ($path, $target, $source) = @_; + + return if $self->should_skip_stow_dir_target($target); + + my $cwd = getcwd(); + my $msg = "Stowing contents of $path (cwd=$cwd, stow dir=$self->{stow_path})"; + $msg =~ s!$ENV{HOME}/!~/!g; + debug(2, $msg); + debug(3, "--- $target => $source"); + + error("stow_contents() called with non-directory path: $path") + unless -d $path; + error("stow_contents() called with non-directory target: $target") + unless $self->is_a_node($target); + + opendir my $DIR, $path + or error("cannot read directory: $path"); + my @listing = readdir $DIR; + closedir $DIR; + + NODE: + for my $node (@listing) { + next NODE if $node eq '.'; + next NODE if $node eq '..'; + next NODE if $self->ignore($node); + $self->stow_node( + join_paths($path, $node), # path + join_paths($target, $node), # target + join_paths($source, $node), # source + ); + } +} + +#===== METHOD =============================================================== +# Name : stow_node() +# Purpose : stow the given node +# Parameters: $path => relative path to source node from the current directory +# : $target => relative path to symlink target from the current directory +# : $source => relative path to symlink source from the dir of target +# Returns : n/a +# Throws : fatal exception if a conflict arises +# Comments : stow_node() and stow_contents() are mutually recursive +# : $source and $target are used for creating the symlink +# : $path is used for folding/unfolding trees as necessary +#============================================================================ +sub stow_node { + my $self = shift; + my ($path, $target, $source) = @_; + + debug(2, "Stowing from $path"); + debug(3, "--- $target => $source"); + + # don't try to stow absolute symlinks (they can't be unstowed) + if (-l $source) { + my $second_source = $self->read_a_link($source); + if ($second_source =~ m{\A/}) { + $self->conflict("source is an absolute symlink $source => $second_source"); + debug(3, "absolute symlinks cannot be unstowed"); + return; + } + } + + # does the target already exist? + if ($self->is_a_link($target)) { + + # where is the link pointing? + my $old_source = $self->read_a_link($target); + if (not $old_source) { + error("Could not read link: $target"); + } + debug(3, "--- Evaluate existing link: $target => $old_source"); + + # does it point to a node under our stow directory? + my $old_path = $self->find_stowed_path($target, $old_source); + if (not $old_path) { + $self->conflict("existing target is not owned by stow: $target"); + return; # XXX # + } + + # does the existing $target actually point to anything? + if ($self->is_a_node($old_path)) { + if ($old_source eq $source) { + debug(3, "--- Skipping $target as it already points to $source"); + } + elsif ($self->defer($target)) { + debug(3, "--- deferring installation of: $target"); + } + elsif ($self->override($target)) { + debug(3, "--- overriding installation of: $target"); + $self->do_unlink($target); + $self->do_link($source, $target); + } + elsif ($self->is_a_dir(join_paths(parent($target), $old_source)) && + $self->is_a_dir(join_paths(parent($target), $source)) ) { + + # if the existing link points to a directory, + # and the proposed new link points to a directory, + # then we can unfold (split open) the tree at that point + + debug(3, "--- Unfolding $target"); + $self->do_unlink($target); + $self->do_mkdir($target); + $self->stow_contents($old_path, $target, join_paths('..', $old_source)); + $self->stow_contents($path, $target, join_paths('..', $source)); + } + else { + $self->conflict( + q{existing target is stowed to a different package: %s => %s}, + $target, + $old_source, + ); + } + } + else { + # the existing link is invalid, so replace it with a good link + debug(3, "--- replacing invalid link: $path"); + $self->do_unlink($target); + $self->do_link($source, $target); + } + } + elsif ($self->is_a_node($target)) { + debug(3, "--- Evaluate existing node: $target"); + if ($self->is_a_dir($target)) { + $self->stow_contents($path, $target, join_paths('..', $source)); + } + else { + $self->conflict( + qq{existing target is neither a link nor a directory: $target} + ); + } + } + else { + $self->do_link($source, $target); + } + return; +} + +#===== METHOD =============================================================== +# Name : should_skip_stow_dir_target() +# Purpose : determine whether target is a stow directory and should be skipped +# Parameters: $target => relative path to symlink target from the current directory +# Returns : true iff target is a stow directory +# Throws : n/a +# Comments : none +#============================================================================ +sub should_skip_stow_dir_target { + my $self = shift; + my ($target) = @_; + + # don't try to remove anything under a stow directory + if ($target eq $self->{stow_path}) { + debug(2, "Skipping target which was current stow directory $target"); + return 1; + } + + if ($self->protected_dir($target)) { + debug(2, "Skipping protected directory $target"); + return 1; + } + + debug (4, "$target not protected"); + return 0; +} + +sub protected_dir { + my $self = shift; + my ($target) = @_; + for my $f (".stow", ".nonstow") { + if (-e join_paths($target, $f)) { + debug(4, "$target contained $f"); + return 1; + } + } + return 0; +} + +#===== METHOD =============================================================== +# Name : unstow_contents_orig() +# Purpose : unstow the contents of the given directory +# Parameters: $path => relative path to source dir from current directory +# : $target => relative path to symlink target from the current directory +# Returns : n/a +# Throws : a fatal error if directory cannot be read +# Comments : unstow_node_orig() and unstow_contents_orig() are mutually recursive +# : Here we traverse the target tree, rather than the source tree. +#============================================================================ +sub unstow_contents_orig { + my $self = shift; + my ($path, $target) = @_; + + return if $self->should_skip_stow_dir_target($target); + + my $cwd = getcwd(); + my $msg = "Unstowing from $target (compat mode, cwd=$cwd, stow dir=$self->{stow_path})"; + $msg =~ s!$ENV{HOME}/!~/!g; + debug(2, $msg); + debug(3, "--- source path is $path"); + # In compat mode we traverse the target tree not the source tree, + # so we're unstowing the contents of /target/foo, there's no + # guarantee that the corresponding /stow/mypkg/foo exists. + error("unstow_contents_orig() called with non-directory target: $target") + unless -d $target; + + opendir my $DIR, $target + or error("cannot read directory: $target"); + my @listing = readdir $DIR; + closedir $DIR; + + NODE: + for my $node (@listing) { + next NODE if $node eq '.'; + next NODE if $node eq '..'; + next NODE if $self->ignore($node); + $self->unstow_node_orig( + join_paths($path, $node), # path + join_paths($target, $node), # target + ); + } +} + +#===== METHOD =============================================================== +# Name : unstow_node_orig() +# Purpose : unstow the given node +# Parameters: $path => relative path to source node from the current directory +# : $target => relative path to symlink target from the current directory +# Returns : n/a +# Throws : fatal error if a conflict arises +# Comments : unstow_node() and unstow_contents() are mutually recursive +#============================================================================ +sub unstow_node_orig { + my $self = shift; + my ($path, $target) = @_; + + debug(2, "Unstowing $target (compat mode)"); + debug(3, "--- source path is $path"); + + # does the target exist + if ($self->is_a_link($target)) { + debug(3, "Evaluate existing link: $target"); + + # where is the link pointing? + my $old_source = $self->read_a_link($target); + if (not $old_source) { + error("Could not read link: $target"); + } + + # does it point to a node under our stow directory? + my $old_path = $self->find_stowed_path($target, $old_source); + if (not $old_path) { + # skip links not owned by stow + return; # XXX # + } + + # does the existing $target actually point to anything? + if (-e $old_path) { + # does link point to the right place? + if ($old_path eq $path) { + $self->do_unlink($target); + } + elsif ($self->override($target)) { + debug(3, "--- overriding installation of: $target"); + $self->do_unlink($target); + } + # else leave it alone + } + else { + debug(3, "--- removing invalid link into a stow directory: $path"); + $self->do_unlink($target); + } + } + elsif (-d $target) { + $self->unstow_contents_orig($path, $target); + + # this action may have made the parent directory foldable + if (my $parent = $self->foldable($target)) { + $self->fold_tree($target, $parent); + } + } + elsif (-e $target) { + $self->conflict( + qq{existing target is neither a link nor a directory: $target}, + ); + } + else { + debug(3, "$target did not exist to be unstowed"); + } + return; +} + +#===== METHOD =============================================================== +# Name : unstow_contents() +# Purpose : unstow the contents of the given directory +# Parameters: $path => relative path to source dir from current directory +# : $target => relative path to symlink target from the current directory +# Returns : n/a +# Throws : a fatal error if directory cannot be read +# Comments : unstow_node() and unstow_contents() are mutually recursive +# : Here we traverse the source tree, rather than the target tree. +#============================================================================ +sub unstow_contents { + my $self = shift; + my ($path, $target) = @_; + + return if $self->should_skip_stow_dir_target($target); + + my $cwd = getcwd(); + my $msg = "Unstowing from $target (cwd=$cwd, stow dir=$self->{stow_path})"; + $msg =~ s!$ENV{HOME}/!~/!g; + debug(2, $msg); + debug(3, "--- source path is $path"); + # We traverse the source tree not the target tree, so $path must exist. + error("unstow_contents() called with non-directory path: $path") + unless -d $path; + # When called at the top level, $target should exist. And + # unstow_node() should only call this via mutual recursion if + # $target exists. + error("unstow_contents() called with invalid target: $target") + unless $self->is_a_node($target); + + opendir my $DIR, $path + or error("cannot read directory: $path"); + my @listing = readdir $DIR; + closedir $DIR; + + NODE: + for my $node (@listing) { + next NODE if $node eq '.'; + next NODE if $node eq '..'; + next NODE if $self->ignore($node); + $self->unstow_node( + join_paths($path, $node), # path + join_paths($target, $node), # target + ); + } + if (-d $target) { + $self->cleanup_invalid_links($target); + } +} + +#===== METHOD =============================================================== +# Name : unstow_node() +# Purpose : unstow the given node +# Parameters: $path => relative path to source node from the current directory +# : $target => relative path to symlink target from the current directory +# Returns : n/a +# Throws : fatal error if a conflict arises +# Comments : unstow_node() and unstow_contents() are mutually recursive +#============================================================================ +sub unstow_node { + my $self = shift; + my ($path, $target) = @_; + + debug(2, "Unstowing $path"); + debug(3, "--- target is $target"); + + # does the target exist + if ($self->is_a_link($target)) { + debug(3, "Evaluate existing link: $target"); + + # where is the link pointing? + my $old_source = $self->read_a_link($target); + if (not $old_source) { + error("Could not read link: $target"); + } + + if ($old_source =~ m{\A/}) { + warn "ignoring a absolute symlink: $target => $old_source\n"; + return; # XXX # + } + + # does it point to a node under our stow directory? + my $old_path = $self->find_stowed_path($target, $old_source); + if (not $old_path) { + $self->conflict( + qq{existing target is not owned by stow: $target => $old_source} + ); + return; # XXX # + } + + # does the existing $target actually point to anything + if (-e $old_path) { + # does link points to the right place + if ($old_path eq $path) { + $self->do_unlink($target); + } + + # XXX we quietly ignore links that are stowed to a different + # package. + + #elsif (defer($target)) { + # debug(3, "--- deferring to installation of: $target"); + #} + #elsif ($self->override($target)) { + # debug(3, "--- overriding installation of: $target"); + # $self->do_unlink($target); + #} + #else { + # $self->conflict( + # q{existing target is stowed to a different package: %s => %s}, + # $target, + # $old_source + # ); + #} + } + else { + debug(3, "--- removing invalid link into a stow directory: $path"); + $self->do_unlink($target); + } + } + elsif (-e $target) { + debug(3, "Evaluate existing node: $target"); + if (-d $target) { + $self->unstow_contents($path, $target); + + # this action may have made the parent directory foldable + if (my $parent = $self->foldable($target)) { + $self->fold_tree($target, $parent); + } + } + else { + $self->conflict( + qq{existing target is neither a link nor a directory: $target}, + ); + } + } + else { + debug(3, "$target did not exist to be unstowed"); + } + return; +} + +#===== METHOD =============================================================== +# Name : find_stowed_path() +# Purpose : determine if the given link points to a member of a +# : stowed package +# Parameters: $target => path to a symbolic link under current directory +# : $source => where that link points to +# Returns : relative path to stowed node (from the current directory) +# : or '' if link is not owned by stow +# Throws : fatal exception if link is unreadable +# Comments : allow for stow dir not being under target dir +# : we could put more logic under here for multiple stow dirs +#============================================================================ +sub find_stowed_path { + my $self = shift; + my ($target, $source) = @_; + + # evaluate softlink relative to its target + my $path = join_paths(parent($target), $source); + debug(4, " is path $path under $self->{stow_path} ?"); + + # search for .stow files + my $dir = ''; + for my $part (split m{/+}, $path) { + $dir = join_paths($dir, $part); + return $path if $self->protected_dir($dir); + } + + # compare with $self->{stow_path} + my @path = split m{/+}, $path; + my @stow_path = split m{/+}, $self->{stow_path}; + + # strip off common prefixes until one is empty + while (@path && @stow_path) { + if ((shift @path) ne (shift @stow_path)) { + debug(4, " no - either $path not under $self->{stow_path} or vice-versa"); + return ''; + } + } + + if (@stow_path) { # @path must be empty + debug(4, " no - $path is not under $self->{stow_path}"); + return ''; + } + + debug(4, " yes - in " . join_paths(@path)); + return $path; +} + +#===== METHOD ================================================================ +# Name : cleanup_invalid_links() +# Purpose : clean up invalid links that may block folding +# Parameters: $dir => path to directory to check +# Returns : n/a +# Throws : no exceptions +# Comments : removing files from a stowed package is probably a bad practice +# : so this kind of clean up is not _really_ stow's responsibility; +# : however, failing to clean up can block tree folding, so we'll do +# : it anyway +#============================================================================= +sub cleanup_invalid_links { + my $self = shift; + my ($dir) = @_; + + if (not -d $dir) { + error("cleanup_invalid_links() called with a non-directory: $dir"); + } + + opendir my $DIR, $dir + or error("cannot read directory: $dir"); + my @listing = readdir $DIR; + closedir $DIR; + + NODE: + for my $node (@listing) { + next NODE if $node eq '.'; + next NODE if $node eq '..'; + + my $node_path = join_paths($dir, $node); + + if (-l $node_path and not exists $self->{link_task_for}{$node_path}) { + + # where is the link pointing? + # (dont use read_a_link here) + my $source = readlink($node_path); + if (not $source) { + error("Could not read link $node_path"); + } + + if ( + not -e join_paths($dir, $source) and # bad link + $self->find_stowed_path($node_path, $source) # owned by stow + ){ + debug(3, "--- removing stale link: $node_path => " . + join_paths($dir, $source)); + $self->do_unlink($node_path); + } + } + } + return; +} + + +#===== METHOD =============================================================== +# Name : foldable() +# Purpose : determine if a tree can be folded +# Parameters: $target => path to a directory +# Returns : path to the parent dir iff the tree can be safely folded +# Throws : n/a +# Comments : the path returned is relative to the parent of $target, +# : that is, it can be used as the source for a replacement symlink +#============================================================================ +sub foldable { + my $self = shift; + my ($target) = @_; + + debug(3, "--- Is $target foldable?"); + + opendir my $DIR, $target + or error(qq{Cannot read directory "$target" ($!)\n}); + my @listing = readdir $DIR; + closedir $DIR; + + my $parent = ''; + NODE: + for my $node (@listing) { + + next NODE if $node eq '.'; + next NODE if $node eq '..'; + + my $path = join_paths($target, $node); + + # skip nodes scheduled for removal + next NODE if not $self->is_a_node($path); + + # if its not a link then we can't fold its parent + return '' if not $self->is_a_link($path); + + # where is the link pointing? + my $source = $self->read_a_link($path); + if (not $source) { + error("Could not read link $path"); + } + if ($parent eq '') { + $parent = parent($source) + } + elsif ($parent ne parent($source)) { + return ''; + } + } + return '' if not $parent; + + # if we get here then all nodes inside $target are links, and those links + # point to nodes inside the same directory. + + # chop of leading '..' to get the path to the common parent directory + # relative to the parent of our $target + $parent =~ s{\A\.\./}{}; + + # if the resulting path is owned by stow, we can fold it + if ($self->find_stowed_path($target, $parent)) { + debug(3, "--- $target is foldable"); + return $parent; + } + else { + return ''; + } +} + +#===== METHOD =============================================================== +# Name : fold_tree() +# Purpose : fold the given tree +# Parameters: $source => link to the folded tree source +# : $target => directory that we will replace with a link to $source +# Returns : n/a +# Throws : none +# Comments : only called iff foldable() is true so we can remove some checks +#============================================================================ +sub fold_tree { + my $self = shift; + my ($target, $source) = @_; + + debug(3, "--- Folding tree: $target => $source"); + + opendir my $DIR, $target + or error(qq{Cannot read directory "$target" ($!)\n}); + my @listing = readdir $DIR; + closedir $DIR; + + NODE: + for my $node (@listing) { + next NODE if $node eq '.'; + next NODE if $node eq '..'; + next NODE if not $self->is_a_node(join_paths($target, $node)); + $self->do_unlink(join_paths($target, $node)); + } + $self->do_rmdir($target); + $self->do_link($source, $target); + return; +} + + +#===== METHOD =============================================================== +# Name : conflict() +# Purpose : handle conflicts in stow operations +# Parameters: $format => message printf format +# : @args => paths that conflict +# Returns : n/a +# Throws : fatal exception unless 'conflicts' option is set +# Comments : indicates what type of conflict it is +#============================================================================ +sub conflict { + my $self = shift; + my ($format, @args) = @_; + + my $message = sprintf($format, @args); + + debug(1, "CONFLICT: $message"); + push @{ $self->{conflicts} }, "CONFLICT: $message\n"; + return; +} + +=head2 get_conflicts() + +Returns a list of all potential conflicts discovered. + +=cut + +sub get_conflicts { + my $self = shift; + return @{ $self->{conflicts} }; +} + +=head2 get_tasks() + +Returns a list of all symlink/directory creation/removal tasks. + +=cut + +sub get_tasks { + my $self = shift; + return @{ $self->{tasks} }; +} + +#===== METHOD ================================================================ +# Name : ignore +# Purpose : determine if the given path matches a regex in our ignore list +# Parameters: $path +# Returns : Boolean +# Throws : no exceptions +# Comments : none +#============================================================================= +sub ignore { + my $self = shift; + my ($path) = @_; + + for my $suffix (@{$self->{'ignore'}}) { + return 1 if $path =~ m/$suffix/; + } + return 0; +} + +#===== METHOD ================================================================ +# Name : defer +# Purpose : determine if the given path matches a regex in our defer list +# Parameters: $path +# Returns : Boolean +# Throws : no exceptions +# Comments : none +#============================================================================= +sub defer { + my $self = shift; + my ($path) = @_; + + for my $prefix (@{$self->{'defer'}}) { + return 1 if $path =~ m/$prefix/; + } + return 0; +} + +#===== METHOD ================================================================ +# Name : overide +# Purpose : determine if the given path matches a regex in our override list +# Parameters: $path +# Returns : Boolean +# Throws : no exceptions +# Comments : none +#============================================================================= +sub override { + my $self = shift; + my ($path) = @_; + + for my $regex (@{$self->{'override'}}) { + return 1 if $path =~ m/$regex/; + } + return 0; +} + +############################################################################## +# +# The following code provides the abstractions that allow us to defer operating +# on the filesystem until after all potential conflcits have been assessed. +# +############################################################################## + +#===== METHOD =============================================================== +# Name : process_tasks() +# Purpose : process each task in the tasks list +# Parameters: none +# Returns : n/a +# Throws : fatal error if tasks list is corrupted or a task fails +# Comments : none +#============================================================================ +sub process_tasks { + my $self = shift; + + debug(2, "Processing tasks..."); + + if ($self->{'simulate'}) { + warn "WARNING: simulating so all operations are deferred.\n"; + return; + } + + # strip out all tasks with a skip action + $self->{tasks} = [ grep { $_->{'action'} ne 'skip' } @{ $self->{tasks} } ]; + + if (not @{ $self->{tasks} }) { + warn "There are no outstanding operations to perform.\n"; + return; + } + + $self->within_target_do(sub { + for my $task (@{ $self->{tasks} }) { + $self->process_task($task); + } + }); + + debug(2, "Processing tasks... done"); +} + +#===== METHOD =============================================================== +# Name : process_task() +# Purpose : process a single task +# Parameters: $task => the task to process +# Returns : n/a +# Throws : fatal error if task fails +# Comments : Must run from within target directory. +# : Task involve either creating or deleting dirs and symlinks +# : an action is set to 'skip' if it is found to be redundant +#============================================================================ +sub process_task { + my $self = shift; + my ($task) = @_; + + if ($task->{'action'} eq 'create') { + if ($task->{'type'} eq 'dir') { + mkdir($task->{'path'}, 0777) + or error(qq(Could not create directory: $task->{'path'})); + } + elsif ($task->{'type'} eq 'link') { + symlink $task->{'source'}, $task->{'path'} + or error( + q(Could not create symlink: %s => %s), + $task->{'path'}, + $task->{'source'} + ); + } + else { + internal_error(qq(bad task type: $task->{'type'})); + } + } + elsif ($task->{'action'} eq 'remove') { + if ($task->{'type'} eq 'dir') { + rmdir $task->{'path'} + or error(qq(Could not remove directory: $task->{'path'})); + } + elsif ($task->{'type'} eq 'link') { + unlink $task->{'path'} + or error(qq(Could not remove link: $task->{'path'})); + } + else { + internal_error(qq(bad task type: $task->{'type'})); + } + } + else { + internal_error(qq(bad task action: $task->{'action'})); + } +} + +#===== METHOD =============================================================== +# Name : link_task_action() +# Purpose : finds the link task action for the given path, if there is one +# Parameters: $path +# Returns : 'remove', 'create', or '' if there is no action +# Throws : a fatal exception if an invalid action is found +# Comments : none +#============================================================================ +sub link_task_action { + my $self = shift; + my ($path) = @_; + + if (! exists $self->{link_task_for}{$path}) { + debug(4, " link_task_action($path): no task"); + return ''; + } + + my $action = $self->{link_task_for}{$path}->{'action'}; + internal_error("bad task action: $action") + unless $action eq 'remove' or $action eq 'create'; + + debug(4, " link_task_action($path): link task exists with action $action"); + return $action; +} + +#===== METHOD =============================================================== +# Name : dir_task_action() +# Purpose : finds the dir task action for the given path, if there is one +# Parameters: $path +# Returns : 'remove', 'create', or '' if there is no action +# Throws : a fatal exception if an invalid action is found +# Comments : none +#============================================================================ +sub dir_task_action { + my $self = shift; + my ($path) = @_; + + if (! exists $self->{dir_task_for}{$path}) { + debug(4, " dir_task_action($path): no task"); + return ''; + } + + my $action = $self->{dir_task_for}{$path}->{'action'}; + internal_error("bad task action: $action") + unless $action eq 'remove' or $action eq 'create'; + + debug(4, " dir_task_action($path): dir task exists with action $action"); + return $action; +} + +#===== METHOD =============================================================== +# Name : parent_link_scheduled_for_removal() +# Purpose : determines whether the given path or any parent thereof +# : is a link scheduled for removal +# Parameters: $path +# Returns : Boolean +# Throws : none +# Comments : none +#============================================================================ +sub parent_link_scheduled_for_removal { + my $self = shift; + my ($path) = @_; + + my $prefix = ''; + for my $part (split m{/+}, $path) { + $prefix = join_paths($prefix, $part); + debug(4, " parent_link_scheduled_for_removal($path): prefix $prefix"); + if (exists $self->{link_task_for}{$prefix} and + $self->{link_task_for}{$prefix}->{'action'} eq 'remove') { + debug(4, " parent_link_scheduled_for_removal($path): link scheduled for removal"); + return 1; + } + } + + debug(4, " parent_link_scheduled_for_removal($path): returning false"); + return 0; +} + +#===== METHOD =============================================================== +# Name : is_a_link() +# Purpose : is the given path a current or planned link +# Parameters: $path +# Returns : Boolean +# Throws : none +# Comments : returns false if an existing link is scheduled for removal +# : and true if a non-existent link is scheduled for creation +#============================================================================ +sub is_a_link { + my $self = shift; + my ($path) = @_; + debug(4, " is_a_link($path)"); + + if (my $action = $self->link_task_action($path)) { + if ($action eq 'remove') { + return 0; + } + elsif ($action eq 'create') { + return 1; + } + } + + if (-l $path) { + # check if any of its parent are links scheduled for removal + # (need this for edge case during unfolding) + debug(4, " is_a_link($path): is a real link"); + return $self->parent_link_scheduled_for_removal($path) ? 0 : 1; + } + + debug(4, " is_a_link($path): returning false"); + return 0; +} + +#===== METHOD =============================================================== +# Name : is_a_dir() +# Purpose : is the given path a current or planned directory +# Parameters: $path +# Returns : Boolean +# Throws : none +# Comments : returns false if an existing directory is scheduled for removal +# : and true if a non-existent directory is scheduled for creation +# : we also need to be sure we are not just following a link +#============================================================================ +sub is_a_dir { + my $self = shift; + my ($path) = @_; + debug(4, " is_a_dir($path)"); + + if (my $action = $self->dir_task_action($path)) { + if ($action eq 'remove') { + return 0; + } + elsif ($action eq 'create') { + return 1; + } + } + + return 0 if $self->parent_link_scheduled_for_removal($path); + + if (-d $path) { + debug(4, " is_a_dir($path): real dir"); + return 1; + } + + debug(4, " is_a_dir($path): returning false"); + return 0; +} + +#===== METHOD =============================================================== +# Name : is_a_node() +# Purpose : is the given path a current or planned node +# Parameters: $path +# Returns : Boolean +# Throws : none +# Comments : returns false if an existing node is scheduled for removal +# : true if a non-existent node is scheduled for creation +# : we also need to be sure we are not just following a link +#============================================================================ +sub is_a_node { + my $self = shift; + my ($path) = @_; + debug(4, " is_a_node($path)"); + + my $laction = $self->link_task_action($path); + my $daction = $self->dir_task_action($path); + + if ($laction eq 'remove') { + if ($daction eq 'remove') { + internal_error("removing link and dir: $path"); + return 0; + } + elsif ($daction eq 'create') { + # Assume that we're unfolding $path, and that the link + # removal action is earlier than the dir creation action + # in the task queue. FIXME: is this a safe assumption? + return 1; + } + else { # no dir action + return 0; + } + } + elsif ($laction eq 'create') { + if ($daction eq 'remove') { + # Assume that we're folding $path, and that the dir + # removal action is earlier than the link creation action + # in the task queue. FIXME: is this a safe assumption? + return 1; + } + elsif ($daction eq 'create') { + internal_error("creating link and dir: $path"); + return 1; + } + else { # no dir action + return 1; + } + } + else { + # No link action + if ($daction eq 'remove') { + return 0; + } + elsif ($daction eq 'create') { + return 1; + } + else { # no dir action + # fall through to below + } + } + + return 0 if $self->parent_link_scheduled_for_removal($path); + + if (-e $path) { + debug(4, " is_a_node($path): really exists"); + return 1; + } + + debug(4, " is_a_node($path): returning false"); + return 0; +} + +#===== METHOD =============================================================== +# Name : read_a_link() +# Purpose : return the source of a current or planned link +# Parameters: $path => path to the link target +# Returns : a string +# Throws : fatal exception if the given path is not a current or planned +# : link +# Comments : none +#============================================================================ +sub read_a_link { + my $self = shift; + my ($path) = @_; + + if (my $action = $self->link_task_action($path)) { + debug(4, " read_a_link($path): task exists with action $action"); + + if ($action eq 'create') { + return $self->{link_task_for}{$path}->{'source'}; + } + elsif ($action eq 'remove') { + internal_error( + "read_a_link() passed a path that is scheduled for removal: $path" + ); + } + } + elsif (-l $path) { + debug(4, " read_a_link($path): real link"); + return readlink $path + or error("Could not read link: $path"); + } + internal_error("read_a_link() passed a non link path: $path\n"); +} + +#===== METHOD =============================================================== +# Name : do_link() +# Purpose : wrap 'link' operation for later processing +# Parameters: $oldfile => the existing file to link to +# : $newfile => the file to link +# Returns : n/a +# Throws : error if this clashes with an existing planned operation +# Comments : cleans up operations that undo previous operations +#============================================================================ +sub do_link { + my $self = shift; + my ($oldfile, $newfile) = @_; + + if (exists $self->{dir_task_for}{$newfile}) { + my $task_ref = $self->{dir_task_for}{$newfile}; + + if ($task_ref->{'action'} eq 'create') { + if ($task_ref->{'type'} eq 'dir') { + internal_error( + "new link (%s => %s) clashes with planned new directory", + $newfile, + $oldfile, + ); + } + } + elsif ($task_ref->{'action'} eq 'remove') { + # we may need to remove a directory before creating a link so continue; + } + else { + internal_error("bad task action: $task_ref->{'action'}"); + } + } + + if (exists $self->{link_task_for}{$newfile}) { + my $task_ref = $self->{link_task_for}{$newfile}; + + if ($task_ref->{'action'} eq 'create') { + if ($task_ref->{'source'} ne $oldfile) { + internal_error( + "new link clashes with planned new link: %s => %s", + $task_ref->{'path'}, + $task_ref->{'source'}, + ) + } + else { + debug(1, "LINK: $newfile => $oldfile (duplicates previous action)"); + return; + } + } + elsif ($task_ref->{'action'} eq 'remove') { + if ($task_ref->{'source'} eq $oldfile) { + # no need to remove a link we are going to recreate + debug(1, "LINK: $newfile => $oldfile (reverts previous action)"); + $self->{link_task_for}{$newfile}->{'action'} = 'skip'; + delete $self->{link_task_for}{$newfile}; + return; + } + # we may need to remove a link to replace it so continue + } + else { + internal_error("bad task action: $task_ref->{'action'}"); + } + } + + # creating a new link + debug(1, "LINK: $newfile => $oldfile"); + my $task = { + action => 'create', + type => 'link', + path => $newfile, + source => $oldfile, + }; + push @{ $self->{tasks} }, $task; + $self->{link_task_for}{$newfile} = $task; + + return; +} + +#===== METHOD =============================================================== +# Name : do_unlink() +# Purpose : wrap 'unlink' operation for later processing +# Parameters: $file => the file to unlink +# Returns : n/a +# Throws : error if this clashes with an existing planned operation +# Comments : will remove an existing planned link +#============================================================================ +sub do_unlink { + my $self = shift; + my ($file) = @_; + + if (exists $self->{link_task_for}{$file}) { + my $task_ref = $self->{link_task_for}{$file}; + if ($task_ref->{'action'} eq 'remove') { + debug(1, "UNLINK: $file (duplicates previous action)"); + return; + } + elsif ($task_ref->{'action'} eq 'create') { + # do need to create a link then remove it + debug(1, "UNLINK: $file (reverts previous action)"); + $self->{link_task_for}{$file}->{'action'} = 'skip'; + delete $self->{link_task_for}{$file}; + return; + } + else { + internal_error("bad task action: $task_ref->{'action'}"); + } + } + + if (exists $self->{dir_task_for}{$file} and $self->{dir_task_for}{$file} eq 'create') { + internal_error( + "new unlink operation clashes with planned operation: %s dir %s", + $self->{dir_task_for}{$file}->{'action'}, + $file + ); + } + + # remove the link + #debug(1, "UNLINK: $file (" . (caller())[2] . ")"); + debug(1, "UNLINK: $file"); + + my $source = readlink $file or error("could not readlink $file"); + + my $task = { + action => 'remove', + type => 'link', + path => $file, + source => $source, + }; + push @{ $self->{tasks} }, $task; + $self->{link_task_for}{$file} = $task; + + return; +} + +#===== METHOD =============================================================== +# Name : do_mkdir() +# Purpose : wrap 'mkdir' operation +# Parameters: $dir => the directory to remove +# Returns : n/a +# Throws : fatal exception if operation fails +# Comments : outputs a message if 'verbose' option is set +# : does not perform operation if 'simulate' option is set +# Comments : cleans up operations that undo previous operations +#============================================================================ +sub do_mkdir { + my $self = shift; + my ($dir) = @_; + + if (exists $self->{link_task_for}{$dir}) { + my $task_ref = $self->{link_task_for}{$dir}; + + if ($task_ref->{'action'} eq 'create') { + internal_error( + "new dir clashes with planned new link (%s => %s)", + $task_ref->{'path'}, + $task_ref->{'source'}, + ); + } + elsif ($task_ref->{'action'} eq 'remove') { + # may need to remove a link before creating a directory so continue + } + else { + internal_error("bad task action: $task_ref->{'action'}"); + } + } + + if (exists $self->{dir_task_for}{$dir}) { + my $task_ref = $self->{dir_task_for}{$dir}; + + if ($task_ref->{'action'} eq 'create') { + debug(1, "MKDIR: $dir (duplicates previous action)"); + return; + } + elsif ($task_ref->{'action'} eq 'remove') { + debug(1, "MKDIR: $dir (reverts previous action)"); + $self->{dir_task_for}{$dir}->{'action'} = 'skip'; + delete $self->{dir_task_for}{$dir}; + return; + } + else { + internal_error("bad task action: $task_ref->{'action'}"); + } + } + + debug(1, "MKDIR: $dir"); + my $task = { + action => 'create', + type => 'dir', + path => $dir, + source => undef, + }; + push @{ $self->{tasks} }, $task; + $self->{dir_task_for}{$dir} = $task; + + return; +} + +#===== METHOD =============================================================== +# Name : do_rmdir() +# Purpose : wrap 'rmdir' operation +# Parameters: $dir => the directory to remove +# Returns : n/a +# Throws : fatal exception if operation fails +# Comments : outputs a message if 'verbose' option is set +# : does not perform operation if 'simulate' option is set +#============================================================================ +sub do_rmdir { + my $self = shift; + my ($dir) = @_; + + if (exists $self->{link_task_for}{$dir}) { + my $task_ref = $self->{link_task_for}{$dir}; + internal_error( + "rmdir clashes with planned operation: %s link %s => %s", + $task_ref->{'action'}, + $task_ref->{'path'}, + $task_ref->{'source'} + ); + } + + if (exists $self->{dir_task_for}{$dir}) { + my $task_ref = $self->{link_task_for}{$dir}; + + if ($task_ref->{'action'} eq 'remove') { + debug(1, "RMDIR $dir (duplicates previous action)"); + return; + } + elsif ($task_ref->{'action'} eq 'create') { + debug(1, "MKDIR $dir (reverts previous action)"); + $self->{link_task_for}{$dir}->{'action'} = 'skip'; + delete $self->{link_task_for}{$dir}; + return; + } + else { + internal_error("bad task action: $task_ref->{'action'}"); + } + } + + debug(1, "RMDIR $dir"); + my $task = { + action => 'remove', + type => 'dir', + path => $dir, + source => '', + }; + push @{ $self->{tasks} }, $task; + $self->{dir_task_for}{$dir} = $task; + + return; +} + + +############################################################################# +# +# End of methods; subroutines follow. +# FIXME: Ideally these should be in a separate module. + + +#===== PRIVATE SUBROUTINE =================================================== +# Name : internal_error() +# Purpose : output internal error message in a consistent form and die +# Parameters: $message => error message to output +# Returns : n/a +# Throws : n/a +# Comments : none +#============================================================================ +sub internal_error { + my ($format, @args) = @_; + die "$ProgramName: INTERNAL ERROR: " . sprintf($format, @args) . "\n", + "This _is_ a bug. Please submit a bug report so we can fix it:-)\n"; +} + +=head1 BUGS + +=head1 SEE ALSO + +=cut + +1; + +# Local variables: +# mode: perl +# cperl-indent-level: 4 +# end: +# vim: ft=perl diff --git a/lib/Stow/Util.pm b/lib/Stow/Util.pm new file mode 100644 index 0000000..0effc35 --- /dev/null +++ b/lib/Stow/Util.pm @@ -0,0 +1,202 @@ +package Stow::Util; + +=head1 NAME + +Stow::Util - general utilities + +=head1 SYNOPSIS + + use Stow::Util qw(debug set_debug_level error ...); + +=head1 DESCRIPTION + +Supporting utility routines for L. + +=cut + +use strict; +use warnings; + +use POSIX qw(getcwd); + +use base qw(Exporter); +our @EXPORT_OK = qw( + error debug set_debug_level set_test_mode + join_paths parent canon_path restore_cwd +); + +our $ProgramName = 'stow'; + +############################################################################# +# +# General Utilities: nothing stow specific here. +# +############################################################################# + +=head1 IMPORTABLE SUBROUTINES + +=head2 error($format, @args) + +Outputs an error message in a consistent form and then dies. + +=cut + +sub error { + my ($format, @args) = @_; + die "$ProgramName: ERROR: " . sprintf($format, @args) . " ($!)\n"; +} + +=head2 set_debug_level($level) + +Sets verbosity level for C. + +=cut + +our $debug_level = 0; + +sub set_debug_level { + my ($level) = @_; + $debug_level = $level; +} + +=head2 set_test_mode($on_or_off) + +Sets testmode on or off. + +=cut + +our $test_mode = 0; + +sub set_test_mode { + my ($on_or_off) = @_; + if ($on_or_off) { + $test_mode = 1; + } + else { + $test_mode = 0; + } +} + +=head2 debug($level, $msg) + +Logs to STDERR based on C<$debug_level> setting. C<$level> is the +minimum verbosity level required to output C<$msg>. All output is to +STDERR to preserve backward compatibility, except for in test mode, +when STDOUT is used instead. In test mode, the verbosity can be +overridden via the C environment variable. + +Verbosity rules: + +=over 4 + +=item 0: errors only + +=item >= 1: print operations: LINK/UNLINK/MKDIR/RMDIR + +=item >= 2: print trace: stow/unstow package/contents/node + +=item >= 3: print trace detail: "_this_ already points to _that_" + +=item >= 4: debug helper routines + +=back + +=cut + +sub debug { + my ($level, $msg) = @_; + if ($debug_level >= $level) { + if ($test_mode) { + print "# $msg\n"; + } + else { + warn "$msg\n"; + } + } +} + +#===== METHOD =============================================================== +# Name : join_paths() +# Purpose : concatenates given paths +# Parameters: path1, path2, ... => paths +# Returns : concatenation of given paths +# Throws : n/a +# Comments : factors out redundant path elements: +# : '//' => '/' and 'a/b/../c' => 'a/c' +#============================================================================ +sub join_paths { + my @paths = @_; + + # weed out empty components and concatenate + my $result = join '/', grep {!/\A\z/} @paths; + + # factor out back references and remove redundant /'s) + my @result = (); + PART: + for my $part (split m{/+}, $result) { + next PART if $part eq '.'; + if (@result && $part eq '..' && $result[-1] ne '..') { + pop @result; + } + else { + push @result, $part; + } + } + + return join '/', @result; +} + +#===== METHOD =============================================================== +# Name : parent +# Purpose : find the parent of the given path +# Parameters: @path => components of the path +# Returns : returns a path string +# Throws : n/a +# Comments : allows you to send multiple chunks of the path +# : (this feature is currently not used) +#============================================================================ +sub parent { + my @path = @_; + my $path = join '/', @_; + my @elts = split m{/+}, $path; + pop @elts; + return join '/', @elts; +} + +#===== METHOD =============================================================== +# Name : canon_path +# Purpose : find absolute canonical path of given path +# Parameters: $path +# Returns : absolute canonical path +# Throws : n/a +# Comments : is this significantly different from File::Spec->rel2abs? +#============================================================================ +sub canon_path { + my ($path) = @_; + + my $cwd = getcwd(); + chdir($path) or error("canon_path: cannot chdir to $path from $cwd"); + my $canon_path = getcwd(); + restore_cwd($cwd); + + return $canon_path; +} + +sub restore_cwd { + my ($prev) = @_; + chdir($prev) or error("Your current directory $prev seems to have vanished"); +} + +=head1 BUGS + +=head1 SEE ALSO + +=cut + +1; + +# Local variables: +# mode: perl +# cperl-indent-level: 4 +# end: +# vim: ft=perl diff --git a/stow.in b/stow.in index df58cc8..34cb13a 100755 --- a/stow.in +++ b/stow.in @@ -24,272 +24,170 @@ use warnings; require 5.6.1; -use File::Spec; use POSIX qw(getcwd); use Getopt::Long; -my $Version = '@VERSION@'; +use Stow; +use Stow::Util qw(parent); + my $ProgramName = $0; $ProgramName =~ s{.*/}{}; -# Verbosity rules: -# -# 0: errors only -# >= 1: print operations: LINK/UNLINK/MKDIR/RMDIR -# >= 2: print trace: stow/unstow package/contents/node -# >= 3: print trace detail: "_this_ already points to _that_" -# >= 4: debug helper routines -# -# All output (except for version() and usage()) is to stderr to preserve -# backward compatibility. +main() unless caller(); -# These are the defaults for command line options -our %Option = ( - help => 0, - conflicts => 0, - action => 'stow', - simulate => 0, - verbose => 0, - paranoid => 0, - dir => undef, - target => undef, - ignore => [], - override => [], - defer => [], -); +sub main { + my ($options, $pkgs_to_unstow, $pkgs_to_stow) = process_options(); -# This becomes static after option processing -our $Stow_Path; # only use in main loop and find_stowed_path() - -# Store conflicts during pre-processing -our @Conflicts = (); - -# Store command line packages to stow (-S and -R) -our @Pkgs_To_Stow = (); - -# Store command line packages to unstow (-D and -R) -our @Pkgs_To_Delete = (); - -# The following structures are used by the abstractions that allow us to -# defer operating on the filesystem until after all potential conflicts have -# been assessed. - -# our @Tasks: list of operations to be performed (in order) -# each element is a hash ref of the form -# { -# action => ... -# type => ... -# path => ... (unique) -# source => ... (only for links) -# } -our @Tasks = (); - -# my %Dir_Task_For: map a path to the corresponding directory task reference -# This structure allows us to quickly determine if a path has an existing -# directory task associated with it. -our %Dir_Task_For = (); - -# my %Link_Task_For: map a path to the corresponding directory task reference -# This structure allows us to quickly determine if a path has an existing -# directory task associated with it. -our %Link_Task_For = (); - -# N.B.: directory tasks and link tasks are NOT mutually exclusive due -# to tree splitting (which involves a remove link task followed by -# a create directory task). - -# put the main loop in this block so we can load the -# rest of the code as a module for testing -if (not caller()) { - - process_options(); - set_stow_path(); - + my $stow = new Stow(%$options); # current dir is now the target directory - - for my $package (@Pkgs_To_Delete) { - if (not -d join_paths($Stow_Path, $package)) { - error("The given package name ($package) is not in your stow path"); - } - debug(2, "Unstowing package $package..."); - if ($Option{'compat'}) { - unstow_contents_orig( - join_paths($Stow_Path, $package), # path to package - '.', # target is current_dir - ); - } - else { - unstow_contents( - join_paths($Stow_Path, $package), # path to package - '.', # target is current_dir - ); - } - debug(2, "Unstowing package $package... done"); - } - for my $package (@Pkgs_To_Stow) { - if (not -d join_paths($Stow_Path, $package)) { - error("The given package name ($package) is not in your stow path"); - } - debug(2, "Stowing package $package..."); - stow_contents( - join_paths($Stow_Path, $package), # path package - '.', # target is current dir - join_paths($Stow_Path, $package), # source from target - ); - debug(2, "Stowing package $package... done"); - } + $stow->plan_unstow(@$pkgs_to_unstow); + $stow->plan_stow (@$pkgs_to_stow); + + my @conflicts = $stow->get_conflicts; # --verbose: tell me what you are planning to do # --simulate: don't execute planned operations # --conflicts: just list any detected conflicts - if (scalar @Conflicts) { + if (scalar @conflicts) { warn "WARNING: conflicts detected.\n"; - if ($Option{'conflicts'}) { - map { warn $_ } @Conflicts; + if ($options->{'conflicts'}) { + map { warn $_ } @conflicts; } warn "WARNING: all operations aborted.\n"; } else { - process_tasks(); + $stow->process_tasks(); } } #===== SUBROUTINE =========================================================== # Name : process_options() -# Purpose : parse command line options and update the %Option hash +# Purpose : parse command line options # Parameters: none -# Returns : n/a +# Returns : (\%options, \@pkgs_to_unstow, \@pkgs_to_stow) # Throws : a fatal error if a bad command line option is given # Comments : checks @ARGV for valid package names #============================================================================ sub process_options { - get_defaults(); + my %options = (); + my @pkgs_to_unstow = (); + my @pkgs_to_stow = (); + my $action = 'stow'; + + unshift @ARGV, get_config_file_options(); #$,="\n"; print @ARGV,"\n"; # for debugging rc file Getopt::Long::config('no_ignore_case', 'bundling', 'permute'); GetOptions( - \%Option, + \%options, 'verbose|v:+', 'help|h', 'simulate|n|no', 'conflicts|c', 'version|V', 'compat|p', 'dir|d=s', 'target|t=s', # clean and pre-compile any regex's at parse time 'ignore=s' => - sub { + sub { + # FIXME: do we really need strip_quotes here? my $regex = strip_quotes($_[1]); - push @{$Option{'ignore'}}, qr($regex\z) + push @{$options{'ignore'}}, qr($regex\z); }, 'override=s' => sub { my $regex = strip_quotes($_[1]); - push @{$Option{'override'}}, qr(\A$regex) + push @{$options{'override'}}, qr(\A$regex); }, 'defer=s' => sub { my $regex = strip_quotes($_[1]); - push @{$Option{'defer'}}, qr(\A$regex) ; + push @{$options{'defer'}}, qr(\A$regex); }, # a little craziness so we can do different actions on the same line: # a -D, -S, or -R changes the action that will be performed on the # package arguments that follow it. - 'D|delete' => sub { $Option{'action'} = 'delete' }, - 'S|stow' => sub { $Option{'action'} = 'stow' }, - 'R|restow' => sub { $Option{'action'} = 'restow' }, + 'D|delete' => sub { $action = 'unstow' }, + 'S|stow' => sub { $action = 'stow' }, + 'R|restow' => sub { $action = 'restow' }, + + # Handler for non-option arguments '<>' => sub { - if ($Option{'action'} eq 'restow') { - push @Pkgs_To_Delete, $_[0]; - push @Pkgs_To_Stow, $_[0]; + if ($action eq 'restow') { + push @pkgs_to_unstow, $_[0]; + push @pkgs_to_stow, $_[0]; } - elsif ($Option{'action'} eq 'delete') { - push @Pkgs_To_Delete, $_[0]; + elsif ($action eq 'unstow') { + push @pkgs_to_unstow, $_[0]; } else { - push @Pkgs_To_Stow, $_[0]; + push @pkgs_to_stow, $_[0]; } }, ) or usage(); - #print "$Option{'dir'}\n"; print "$Option{'target'}\n"; exit; + usage() if $options{'help'}; + version() if $options{'version'}; - # clean any leading and trailing whitespace in paths - if ($Option{'dir'}) { - $Option{'dir'} =~ s/\A +//; - $Option{'dir'} =~ s/ +\z//; + sanitize_path_options(\%options); + check_packages(\@pkgs_to_unstow, \@pkgs_to_stow); + + return (\%options, \@pkgs_to_unstow, \@pkgs_to_stow); +} + +sub sanitize_path_options { + my ($options) = @_; + + if (exists $options->{'dir'}) { + $options->{'dir'} =~ s/\A +//; + $options->{'dir'} =~ s/ +\z//; } - if ($Option{'target'}) { - $Option{'target'} =~ s/\A +//; - $Option{'target'} =~ s/ +\z//; + else { + $options->{'dir'} = exists $ENV{STOW_DIR} ? $ENV{STOW_DIR} : getcwd(); } - if ($Option{'help'}) { - usage(); - } - if ($Option{'version'}) { - version(); + if (exists $options->{'target'}) { + $options->{'target'} =~ s/\A +//; + $options->{'target'} =~ s/ +\z//; } - if ($Option{'conflicts'}) { - $Option{'simulate'} = 1; + else { + $options->{'target'} = parent($options->{'dir'}); } +} - if (not scalar @Pkgs_To_Stow and not scalar @Pkgs_To_Delete) { - usage("No packages named"); +sub check_packages { + my ($pkgs_to_stow, $pkgs_to_unstow) = @_; + + if (not @$pkgs_to_stow and not @$pkgs_to_unstow) { + usage("No packages to stow or unstow"); } # check package arguments - for my $package ((@Pkgs_To_Stow, @Pkgs_To_Delete)) { + for my $package (@$pkgs_to_stow, @$pkgs_to_unstow) { $package =~ s{/+$}{}; # delete trailing slashes if ($package =~ m{/}) { error("Slashes are not permitted in package names"); } } - - return; } -#===== SUBROUTINE ============================================================ -# Name : debug() -# Purpose : log to STDERR based on verbosity setting -# Parameters: $level => minimum verbosity level required to output this message -# : $msg => the message -# Returns : n/a -# Throws : no exceptions -# Comments : none -#============================================================================= -sub debug { - my ($level, $msg) = @_; - if ($Option{'testmode'}) { - # Convert TEST_VERBOSE=y into numeric value - $ENV{TEST_VERBOSE} = 3 - if $ENV{TEST_VERBOSE} && $ENV{TEST_VERBOSE} !~ /^\d+$/; - - my $verbose = exists $Option{'verbose'} ? $Option{'verbose'} : - length $ENV{TEST_VERBOSE} ? $ENV{TEST_VERBOSE} : 0; - print "# $msg\n" if $verbose >= $level; - } - elsif ($Option{'verbose'} >= $level) { - warn "$msg\n"; - } -} #===== SUBROUTINE ============================================================ -# Name : get_defaults() -# Purpose : search for default settings in any .stow files +# Name : get_config_file_options() +# Purpose : search for default settings in any .stowrc files # Parameters: none -# Returns : n/a +# Returns : a list of default options # Throws : no exceptions -# Comments : prepends the contents '~/.stowrc' and '.stowrc' to the command +# Comments : prepends the contents of '~/.stowrc' and '.stowrc' to the command # : line so they get parsed just like normal arguments. (This was # : hacked in so that Emil and I could set different preferences). #============================================================================= -sub get_defaults { +sub get_config_file_options { my @defaults = (); - for my $file ($ENV{'HOME'}.'/.stowrc', '.stowrc') { + for my $file ("$ENV{'HOME'}/.stowrc", '.stowrc') { if (-r $file) { warn "Loading defaults from $file\n"; open my $FILE, '<', $file @@ -301,9 +199,7 @@ sub get_defaults { close $FILE or die "Could not close open file: $file\n"; } } - # doing this inline does not seem to work - unshift @ARGV, @defaults; - return; + return @defaults; } #===== SUBROUTINE =========================================================== @@ -322,7 +218,7 @@ sub usage { } print <<"EOT"; -$ProgramName (GNU Stow) version $Version +$ProgramName (GNU Stow) version $Stow::VERSION SYNOPSIS: @@ -350,1317 +246,15 @@ OPTIONS: -V, --version Show stow version number -h, --help Show this help EOT - exit $msg ? 1 : 0; + exit defined $msg ? 1 : 0; } -#===== SUBROUTINE =========================================================== -# Name : set_stow_path() -# Purpose : find the relative path to the stow directory -# Parameters: none -# Returns : a relative path -# Throws : fatal error if either default directories or those set by the -# : the command line flags are not valid. -# Comments : This sets the current working directory to $Option{target} -#============================================================================ -sub set_stow_path { - # Changing dirs helps a lot when soft links are used - # Also prevents problems when 'stow_dir' or 'target' are - # supplied as relative paths (FIXME: examples?) - - my $current_dir = getcwd(); - - # default stow dir is $STOW_DIR if set, otherwise the current - # directory - if (not $Option{'dir'}) { - $Option{'dir'} = exists $ENV{STOW_DIR} ? $ENV{STOW_DIR} : getcwd(); - } - if (not chdir($Option{'dir'})) { - error("Cannot chdir to target tree: '$Option{'dir'}'"); - } - my $stow_dir = getcwd(); - - # back to start in case target is relative - if (not chdir($current_dir)) { - error("Your directory does not seem to exist anymore"); - } - - # default target is the parent of the stow directory - if (not $Option{'target'}) { - $Option{'target'} = parent($Option{'dir'}); - } - if (not chdir($Option{'target'})) { - error("Cannot chdir to target tree: $Option{'target'}"); - } - - # set our one global - $Stow_Path = File::Spec->abs2rel($stow_dir); - - debug(2, "current dir is " . getcwd()); - debug(2, "stow dir path relative to cwd is $Stow_Path"); +sub version { + print "$ProgramName (GNU Stow) version $Stow::VERSION\n"; + exit 0; } -#===== SUBROUTINE =========================================================== -# Name : stow_contents() -# Purpose : stow the contents of the given directory -# Parameters: $path => relative path to source dir from current directory -# : $target => relative path to symlink target from the current directory -# : $source => relative path to symlink source from the dir of target -# Returns : n/a -# Throws : a fatal error if directory cannot be read -# Comments : stow_node() and stow_contents() are mutually recursive -# : $source and $target are used for creating the symlink -# : $path is used for folding/unfolding trees as necessary -#============================================================================ -sub stow_contents { - my ($path, $target, $source) = @_; - - return if should_skip_stow_dir_target($target); - - my $cwd = getcwd(); - my $msg = "Stowing contents of $path (cwd=$cwd, stow dir=$Stow_Path)"; - $msg =~ s!$ENV{HOME}/!~/!g; - debug(2, $msg); - debug(3, "--- $target => $source"); - - error("stow_contents() called with non-directory path: $path") - unless -d $path; - error("stow_contents() called with non-directory target: $target") - unless is_a_node($target); - - opendir my $DIR, $path - or error("cannot read directory: $path"); - my @listing = readdir $DIR; - closedir $DIR; - - NODE: - for my $node (@listing) { - next NODE if $node eq '.'; - next NODE if $node eq '..'; - next NODE if ignore($node); - stow_node( - join_paths($path, $node), # path - join_paths($target, $node), # target - join_paths($source, $node), # source - ); - } -} - -#===== SUBROUTINE =========================================================== -# Name : stow_node() -# Purpose : stow the given node -# Parameters: $path => relative path to source node from the current directory -# : $target => relative path to symlink target from the current directory -# : $source => relative path to symlink source from the dir of target -# Returns : n/a -# Throws : fatal exception if a conflict arises -# Comments : stow_node() and stow_contents() are mutually recursive -# : $source and $target are used for creating the symlink -# : $path is used for folding/unfolding trees as necessary -#============================================================================ -sub stow_node { - my ($path, $target, $source) = @_; - - debug(2, "Stowing from $path"); - debug(3, "--- $target => $source"); - - # don't try to stow absolute symlinks (they can't be unstowed) - if (-l $source) { - my $second_source = read_a_link($source); - if ($second_source =~ m{\A/}) { - conflict("source is an absolute symlink $source => $second_source"); - debug(3, "absolute symlinks cannot be unstowed"); - return; - } - } - - # does the target already exist? - if (is_a_link($target)) { - - # where is the link pointing? - my $old_source = read_a_link($target); - if (not $old_source) { - error("Could not read link: $target"); - } - debug(3, "--- Evaluate existing link: $target => $old_source"); - - # does it point to a node under our stow directory? - my $old_path = find_stowed_path($target, $old_source); - if (not $old_path) { - conflict("existing target is not owned by stow: $target"); - return; # XXX # - } - - # does the existing $target actually point to anything? - if (is_a_node($old_path)) { - if ($old_source eq $source) { - debug(3, "--- Skipping $target as it already points to $source"); - } - elsif (defer($target)) { - debug(3, "--- deferring installation of: $target"); - } - elsif (override($target)) { - debug(3, "--- overriding installation of: $target"); - do_unlink($target); - do_link($source, $target); - } - elsif (is_a_dir(join_paths(parent($target), $old_source)) && - is_a_dir(join_paths(parent($target), $source)) ) { - - # if the existing link points to a directory, - # and the proposed new link points to a directory, - # then we can unfold (split open) the tree at that point - - debug(3, "--- Unfolding $target"); - do_unlink($target); - do_mkdir($target); - stow_contents($old_path, $target, join_paths('..', $old_source)); - stow_contents($path, $target, join_paths('..', $source)); - } - else { - conflict( - q{existing target is stowed to a different package: %s => %s}, - $target, - $old_source, - ); - } - } - else { - # the existing link is invalid, so replace it with a good link - debug(3, "--- replacing invalid link: $path"); - do_unlink($target); - do_link($source, $target); - } - } - elsif (is_a_node($target)) { - debug(3, "--- Evaluate existing node: $target"); - if (is_a_dir($target)) { - stow_contents($path, $target, join_paths('..', $source)); - } - else { - conflict( - qq{existing target is neither a link nor a directory: $target} - ); - } - } - else { - do_link($source, $target); - } - return; -} - -#===== SUBROUTINE =========================================================== -# Name : should_skip_stow_dir_target() -# Purpose : determine whether target is a stow directory and should be skipped -# Parameters: $target => relative path to symlink target from the current directory -# Returns : true iff target is a stow directory -# Throws : n/a -# Comments : none -#============================================================================ -sub should_skip_stow_dir_target { - my ($target) = @_; - - # don't try to remove anything under a stow directory - if ($target eq $Stow_Path) { - debug(2, "Skipping target which was current stow directory $target"); - return 1; - } - for my $f (".stow", ".nonstow") { - if (-e join_paths($target, $f)) { - debug(2, "Skipping $target which contained $f"); - return 1; - } - } - - debug (4, "$target not protected"); - return 0; -} - -#===== SUBROUTINE =========================================================== -# Name : unstow_contents_orig() -# Purpose : unstow the contents of the given directory -# Parameters: $path => relative path to source dir from current directory -# : $target => relative path to symlink target from the current directory -# Returns : n/a -# Throws : a fatal error if directory cannot be read -# Comments : unstow_node_orig() and unstow_contents_orig() are mutually recursive -# : Here we traverse the target tree, rather than the source tree. -#============================================================================ -sub unstow_contents_orig { - my ($path, $target) = @_; - - return if should_skip_stow_dir_target($target); - - my $cwd = getcwd(); - my $msg = "Unstowing from $target (compat mode, cwd=$cwd, stow dir=$Stow_Path)"; - $msg =~ s!$ENV{HOME}/!~/!g; - debug(2, $msg); - debug(3, "--- source path is $path"); - # In compat mode we traverse the target tree not the source tree, - # so we're unstowing the contents of /target/foo, there's no - # guarantee that the corresponding /stow/mypkg/foo exists. - error("unstow_contents_orig() called with non-directory target: $target") - unless -d $target; - - opendir my $DIR, $target - or error("cannot read directory: $target"); - my @listing = readdir $DIR; - closedir $DIR; - - NODE: - for my $node (@listing) { - next NODE if $node eq '.'; - next NODE if $node eq '..'; - next NODE if ignore($node); - unstow_node_orig( - join_paths($path, $node), # path - join_paths($target, $node), # target - ); - } -} - -#===== SUBROUTINE =========================================================== -# Name : unstow_node_orig() -# Purpose : unstow the given node -# Parameters: $path => relative path to source node from the current directory -# : $target => relative path to symlink target from the current directory -# Returns : n/a -# Throws : fatal error if a conflict arises -# Comments : unstow_node() and unstow_contents() are mutually recursive -#============================================================================ -sub unstow_node_orig { - my ($path, $target) = @_; - - debug(2, "Unstowing $target (compat mode)"); - debug(3, "--- source path is $path"); - - # does the target exist - if (is_a_link($target)) { - debug(3, "Evaluate existing link: $target"); - - # where is the link pointing? - my $old_source = read_a_link($target); - if (not $old_source) { - error("Could not read link: $target"); - } - - # does it point to a node under our stow directory? - my $old_path = find_stowed_path($target, $old_source); - if (not $old_path) { - # skip links not owned by stow - return; # XXX # - } - - # does the existing $target actually point to anything? - if (-e $old_path) { - # does link point to the right place? - if ($old_path eq $path) { - do_unlink($target); - } - elsif (override($target)) { - debug(3, "--- overriding installation of: $target"); - do_unlink($target); - } - # else leave it alone - } - else { - debug(3, "--- removing invalid link into a stow directory: $path"); - do_unlink($target); - } - } - elsif (-d $target) { - unstow_contents_orig($path, $target); - - # this action may have made the parent directory foldable - if (my $parent = foldable($target)) { - fold_tree($target, $parent); - } - } - elsif (-e $target) { - conflict( - qq{existing target is neither a link nor a directory: $target}, - ); - } - else { - debug(3, "$target did not exist to be unstowed"); - } - return; -} - -#===== SUBROUTINE =========================================================== -# Name : unstow_contents() -# Purpose : unstow the contents of the given directory -# Parameters: $path => relative path to source dir from current directory -# : $target => relative path to symlink target from the current directory -# Returns : n/a -# Throws : a fatal error if directory cannot be read -# Comments : unstow_node() and unstow_contents() are mutually recursive -# : Here we traverse the source tree, rather than the target tree. -#============================================================================ -sub unstow_contents { - my ($path, $target) = @_; - - return if should_skip_stow_dir_target($target); - - my $cwd = getcwd(); - my $msg = "Unstowing from $target (cwd=$cwd, stow dir=$Stow_Path)"; - $msg =~ s!$ENV{HOME}/!~/!g; - debug(2, $msg); - debug(3, "--- source path is $path"); - # We traverse the source tree not the target tree, so $path must exist. - error("unstow_contents() called with non-directory path: $path") - unless -d $path; - # When called at the top level, $target should exist. And - # unstow_node() should only call this via mutual recursion if - # $target exists. - error("unstow_contents() called with invalid target: $target") - unless is_a_node($target); - - opendir my $DIR, $path - or error("cannot read directory: $path"); - my @listing = readdir $DIR; - closedir $DIR; - - NODE: - for my $node (@listing) { - next NODE if $node eq '.'; - next NODE if $node eq '..'; - next NODE if ignore($node); - unstow_node( - join_paths($path, $node), # path - join_paths($target, $node), # target - ); - } - if (-d $target) { - cleanup_invalid_links($target); - } -} - -#===== SUBROUTINE =========================================================== -# Name : unstow_node() -# Purpose : unstow the given node -# Parameters: $path => relative path to source node from the current directory -# : $target => relative path to symlink target from the current directory -# Returns : n/a -# Throws : fatal error if a conflict arises -# Comments : unstow_node() and unstow_contents() are mutually recursive -#============================================================================ -sub unstow_node { - my ($path, $target) = @_; - - debug(2, "Unstowing $path"); - debug(3, "--- target is $target"); - - # does the target exist - if (is_a_link($target)) { - debug(3, "Evaluate existing link: $target"); - - # where is the link pointing? - my $old_source = read_a_link($target); - if (not $old_source) { - error("Could not read link: $target"); - } - - if ($old_source =~ m{\A/}) { - warn "ignoring a absolute symlink: $target => $old_source\n"; - return; # XXX # - } - - # does it point to a node under our stow directory? - my $old_path = find_stowed_path($target, $old_source); - if (not $old_path) { - conflict( - qq{existing target is not owned by stow: $target => $old_source} - ); - return; # XXX # - } - - # does the existing $target actually point to anything - if (-e $old_path) { - # does link points to the right place - if ($old_path eq $path) { - do_unlink($target); - } - - # XXX we quietly ignore links that are stowed to a different - # package. - - #elsif (defer($target)) { - # debug(3, "--- deferring to installation of: $target"); - #} - #elsif (override($target)) { - # debug(3, "--- overriding installation of: $target"); - # do_unlink($target); - #} - #else { - # conflict( - # q{existing target is stowed to a different package: %s => %s}, - # $target, - # $old_source - # ); - #} - } - else { - debug(3, "--- removing invalid link into a stow directory: $path"); - do_unlink($target); - } - } - elsif (-e $target) { - debug(3, "Evaluate existing node: $target"); - if (-d $target) { - unstow_contents($path, $target); - - # this action may have made the parent directory foldable - if (my $parent = foldable($target)) { - fold_tree($target, $parent); - } - } - else { - conflict( - qq{existing target is neither a link nor a directory: $target}, - ); - } - } - else { - debug(3, "$target did not exist to be unstowed"); - } - return; -} - -#===== SUBROUTINE =========================================================== -# Name : find_stowed_path() -# Purpose : determine if the given link points to a member of a -# : stowed package -# Parameters: $target => path to a symbolic link under current directory -# : $source => where that link points to -# Returns : relative path to stowed node (from the current directory) -# : or '' if link is not owned by stow -# Throws : fatal exception if link is unreadable -# Comments : allow for stow dir not being under target dir -# : we could put more logic under here for multiple stow dirs -#============================================================================ -sub find_stowed_path { - my ($target, $source) = @_; - - # evaluate softlink relative to its target - my $path = join_paths(parent($target), $source); - - # search for .stow files - my $dir = ''; - for my $part (split m{/+}, $path) { - $dir = join_paths($dir, $part); - if (-f "$dir/.stow") { - return $path; - } - } - - # compare with $Stow_Path - my @path = split m{/+}, $path; - my @stow_path = split m{/+}, $Stow_Path; - - # strip off common prefixes - while (@path && @stow_path) { - if ((shift @path) ne (shift @stow_path)) { - return ''; - } - } - if (@stow_path) { - # @path is not under @stow_dir - return ''; - } - - return $path -} - -#===== SUBROUTINE ============================================================ -# Name : cleanup_invalid_links() -# Purpose : clean up invalid links that may block folding -# Parameters: $dir => path to directory to check -# Returns : n/a -# Throws : no exceptions -# Comments : removing files from a stowed package is probably a bad practice -# : so this kind of clean up is not _really_ stow's responsibility; -# : however, failing to clean up can block tree folding, so we'll do -# : it anyway -#============================================================================= -sub cleanup_invalid_links { - my ($dir) = @_; - - if (not -d $dir) { - error("cleanup_invalid_links() called with a non-directory: $dir"); - } - - opendir my $DIR, $dir - or error("cannot read directory: $dir"); - my @listing = readdir $DIR; - closedir $DIR; - - NODE: - for my $node (@listing) { - next NODE if $node eq '.'; - next NODE if $node eq '..'; - - my $node_path = join_paths($dir, $node); - - if (-l $node_path and not exists $Link_Task_For{$node_path}) { - - # where is the link pointing? - # (dont use read_a_link here) - my $source = readlink($node_path); - if (not $source) { - error("Could not read link $node_path"); - } - - if ( - not -e join_paths($dir, $source) and # bad link - find_stowed_path($node_path, $source) # owned by stow - ){ - debug(3, "--- removing stale link: $node_path => " . - join_paths($dir, $source)); - do_unlink($node_path); - } - } - } - return; -} - - -#===== SUBROUTINE =========================================================== -# Name : foldable() -# Purpose : determine if a tree can be folded -# Parameters: $target => path to a directory -# Returns : path to the parent dir iff the tree can be safely folded -# Throws : n/a -# Comments : the path returned is relative to the parent of $target, -# : that is, it can be used as the source for a replacement symlink -#============================================================================ -sub foldable { - my ($target) = @_; - - debug(3, "--- Is $target foldable?"); - - opendir my $DIR, $target - or error(qq{Cannot read directory "$target" ($!)\n}); - my @listing = readdir $DIR; - closedir $DIR; - - my $parent = ''; - NODE: - for my $node (@listing) { - - next NODE if $node eq '.'; - next NODE if $node eq '..'; - - my $path = join_paths($target, $node); - - # skip nodes scheduled for removal - next NODE if not is_a_node($path); - - # if its not a link then we can't fold its parent - return '' if not is_a_link($path); - - # where is the link pointing? - my $source = read_a_link($path); - if (not $source) { - error("Could not read link $path"); - } - if ($parent eq '') { - $parent = parent($source) - } - elsif ($parent ne parent($source)) { - return ''; - } - } - return '' if not $parent; - - # if we get here then all nodes inside $target are links, and those links - # point to nodes inside the same directory. - - # chop of leading '..' to get the path to the common parent directory - # relative to the parent of our $target - $parent =~ s{\A\.\./}{}; - - # if the resulting path is owned by stow, we can fold it - if (find_stowed_path($target, $parent)) { - debug(3, "--- $target is foldable"); - return $parent; - } - else { - return ''; - } -} - -#===== SUBROUTINE =========================================================== -# Name : fold_tree() -# Purpose : fold the given tree -# Parameters: $source => link to the folded tree source -# : $target => directory that we will replace with a link to $source -# Returns : n/a -# Throws : none -# Comments : only called iff foldable() is true so we can remove some checks -#============================================================================ -sub fold_tree { - my ($target, $source) = @_; - - debug(3, "--- Folding tree: $target => $source"); - - opendir my $DIR, $target - or error(qq{Cannot read directory "$target" ($!)\n}); - my @listing = readdir $DIR; - closedir $DIR; - - NODE: - for my $node (@listing) { - next NODE if $node eq '.'; - next NODE if $node eq '..'; - next NODE if not is_a_node(join_paths($target, $node)); - do_unlink(join_paths($target, $node)); - } - do_rmdir($target); - do_link($source, $target); - return; -} - - -#===== SUBROUTINE =========================================================== -# Name : conflict() -# Purpose : handle conflicts in stow operations -# Parameters: $format => message printf format -# : @args => paths that conflict -# Returns : n/a -# Throws : fatal exception unless 'conflicts' option is set -# Comments : indicates what type of conflict it is -#============================================================================ -sub conflict { - my ($format, @args) = @_; - - my $message = sprintf($format, @args); - - debug(1, "CONFLICT: $message"); - push @Conflicts, "CONFLICT: $message\n"; - return; -} - -#===== SUBROUTINE ============================================================ -# Name : ignore -# Purpose : determine if the given path matches a regex in our ignore list -# Parameters: $path -# Returns : Boolean -# Throws : no exceptions -# Comments : none -#============================================================================= -sub ignore { - my ($path) = @_; - - for my $suffix (@{$Option{'ignore'}}) { - return 1 if $path =~ m/$suffix/; - } - return 0; -} - -#===== SUBROUTINE ============================================================ -# Name : defer -# Purpose : determine if the given path matches a regex in our defer list -# Parameters: $path -# Returns : Boolean -# Throws : no exceptions -# Comments : none -#============================================================================= -sub defer { - my ($path) = @_; - - for my $prefix (@{$Option{'defer'}}) { - return 1 if $path =~ m/$prefix/; - } - return 0; -} - -#===== SUBROUTINE ============================================================ -# Name : overide -# Purpose : determine if the given path matches a regex in our override list -# Parameters: $path -# Returns : Boolean -# Throws : no exceptions -# Comments : none -#============================================================================= -sub override { - my ($path) = @_; - - for my $regex (@{$Option{'override'}}) { - return 1 if $path =~ m/$regex/; - } - return 0; -} - -############################################################################## -# -# The following code provides the abstractions that allow us to defer operating -# on the filesystem until after all potential conflcits have been assessed. -# -############################################################################## - -#===== SUBROUTINE =========================================================== -# Name : process_tasks() -# Purpose : process each task in the @Tasks list -# Parameters: none -# Returns : n/a -# Throws : fatal error if @Tasks is corrupted or a task fails -# Comments : task involve either creating or deleting dirs and symlinks -# : an action is set to 'skip' if it is found to be redundant -#============================================================================ -sub process_tasks { - debug(2, "Processing tasks..."); - - # strip out all tasks with a skip action - @Tasks = grep { $_->{'action'} ne 'skip' } @Tasks; - - if (not scalar @Tasks) { - warn "There are no outstanding operations to perform.\n"; - return; - } - if ($Option{'simulate'}) { - warn "WARNING: simulating so all operations are deferred.\n"; - return; - } - - for my $task (@Tasks) { - - if ($task->{'action'} eq 'create') { - if ($task->{'type'} eq 'dir') { - mkdir($task->{'path'}, 0777) - or error(qq(Could not create directory: $task->{'path'})); - } - elsif ($task->{'type'} eq 'link') { - symlink $task->{'source'}, $task->{'path'} - or error( - q(Could not create symlink: %s => %s), - $task->{'path'}, - $task->{'source'} - ); - } - else { - internal_error(qq(bad task type: $task->{'type'})); - } - } - elsif ($task->{'action'} eq 'remove') { - if ($task->{'type'} eq 'dir') { - rmdir $task->{'path'} - or error(qq(Could not remove directory: $task->{'path'})); - } - elsif ($task->{'type'} eq 'link') { - unlink $task->{'path'} - or error(qq(Could not remove link: $task->{'path'})); - } - else { - internal_error(qq(bad task type: $task->{'type'})); - } - } - else { - internal_error(qq(bad task action: $task->{'action'})); - } - } - debug(2, "Processing tasks... done"); - return; -} - -#===== SUBROUTINE =========================================================== -# Name : link_task_action() -# Purpose : finds the link task action for the given path, if there is one -# Parameters: $path -# Returns : 'remove', 'create', or '' if there is no action -# Throws : a fatal exception if an invalid action is found -# Comments : none -#============================================================================ -sub link_task_action { - my ($path) = @_; - - if (! exists $Link_Task_For{$path}) { - debug(4, " link_task_action($path): no task"); - return ''; - } - - my $action = $Link_Task_For{$path}->{'action'}; - internal_error("bad task action: $action") - unless $action eq 'remove' or $action eq 'create'; - - debug(4, " link_task_action($path): link task exists with action $action"); - return $action; -} - -#===== SUBROUTINE =========================================================== -# Name : dir_task_action() -# Purpose : finds the dir task action for the given path, if there is one -# Parameters: $path -# Returns : 'remove', 'create', or '' if there is no action -# Throws : a fatal exception if an invalid action is found -# Comments : none -#============================================================================ -sub dir_task_action { - my ($path) = @_; - - if (! exists $Dir_Task_For{$path}) { - debug(4, " dir_task_action($path): no task"); - return ''; - } - - my $action = $Dir_Task_For{$path}->{'action'}; - internal_error("bad task action: $action") - unless $action eq 'remove' or $action eq 'create'; - - debug(4, " dir_task_action($path): dir task exists with action $action"); - return $action; -} - -#===== SUBROUTINE =========================================================== -# Name : parent_link_scheduled_for_removal() -# Purpose : determines whether the given path or any parent thereof -# : is a link scheduled for removal -# Parameters: $path -# Returns : Boolean -# Throws : none -# Comments : none -#============================================================================ -sub parent_link_scheduled_for_removal { - my ($path) = @_; - - my $prefix = ''; - for my $part (split m{/+}, $path) { - $prefix = join_paths($prefix, $part); - debug(4, " parent_link_scheduled_for_removal($path): prefix $prefix"); - if (exists $Link_Task_For{$prefix} and - $Link_Task_For{$prefix}->{'action'} eq 'remove') { - debug(4, " parent_link_scheduled_for_removal($path): link scheduled for removal"); - return 1; - } - } - - debug(4, " parent_link_scheduled_for_removal($path): returning false"); - return 0; -} - -#===== SUBROUTINE =========================================================== -# Name : is_a_link() -# Purpose : is the given path a current or planned link -# Parameters: $path -# Returns : Boolean -# Throws : none -# Comments : returns false if an existing link is scheduled for removal -# : and true if a non-existent link is scheduled for creation -#============================================================================ -sub is_a_link { - my ($path) = @_; - debug(4, " is_a_link($path)"); - - if (my $action = link_task_action($path)) { - if ($action eq 'remove') { - return 0; - } - elsif ($action eq 'create') { - return 1; - } - } - - if (-l $path) { - # check if any of its parent are links scheduled for removal - # (need this for edge case during unfolding) - debug(4, " is_a_link($path): is a real link"); - return parent_link_scheduled_for_removal($path) ? 0 : 1; - } - - debug(4, " is_a_link($path): returning false"); - return 0; -} - -#===== SUBROUTINE =========================================================== -# Name : is_a_dir() -# Purpose : is the given path a current or planned directory -# Parameters: $path -# Returns : Boolean -# Throws : none -# Comments : returns false if an existing directory is scheduled for removal -# : and true if a non-existent directory is scheduled for creation -# : we also need to be sure we are not just following a link -#============================================================================ -sub is_a_dir { - my ($path) = @_; - debug(4, " is_a_dir($path)"); - - if (my $action = dir_task_action($path)) { - if ($action eq 'remove') { - return 0; - } - elsif ($action eq 'create') { - return 1; - } - } - - return 0 if parent_link_scheduled_for_removal($path); - - if (-d $path) { - debug(4, " is_a_dir($path): real dir"); - return 1; - } - - debug(4, " is_a_dir($path): returning false"); - return 0; -} - -#===== SUBROUTINE =========================================================== -# Name : is_a_node() -# Purpose : is the given path a current or planned node -# Parameters: $path -# Returns : Boolean -# Throws : none -# Comments : returns false if an existing node is scheduled for removal -# : true if a non-existent node is scheduled for creation -# : we also need to be sure we are not just following a link -#============================================================================ -sub is_a_node { - my ($path) = @_; - debug(4, " is_a_node($path)"); - - my $laction = link_task_action($path); - my $daction = dir_task_action($path); - - if ($laction eq 'remove') { - if ($daction eq 'remove') { - internal_error("removing link and dir: $path"); - return 0; - } - elsif ($daction eq 'create') { - # Assume that we're unfolding $path, and that the link - # removal action is earlier than the dir creation action - # in the task queue. FIXME: is this a safe assumption? - return 1; - } - else { # no dir action - return 0; - } - } - elsif ($laction eq 'create') { - if ($daction eq 'remove') { - # Assume that we're folding $path, and that the dir - # removal action is earlier than the link creation action - # in the task queue. FIXME: is this a safe assumption? - return 1; - } - elsif ($daction eq 'create') { - internal_error("creating link and dir: $path"); - return 1; - } - else { # no dir action - return 1; - } - } - else { - # No link action - if ($daction eq 'remove') { - return 0; - } - elsif ($daction eq 'create') { - return 1; - } - else { # no dir action - # fall through to below - } - } - - return 0 if parent_link_scheduled_for_removal($path); - - if (-e $path) { - debug(4, " is_a_node($path): really exists"); - return 1; - } - - debug(4, " is_a_node($path): returning false"); - return 0; -} - -#===== SUBROUTINE =========================================================== -# Name : read_a_link() -# Purpose : return the source of a current or planned link -# Parameters: $path => path to the link target -# Returns : a string -# Throws : fatal exception if the given path is not a current or planned -# : link -# Comments : none -#============================================================================ -sub read_a_link { - my ($path) = @_; - - if (my $action = link_task_action($path)) { - debug(4, " read_a_link($path): task exists with action $action"); - - if ($action eq 'create') { - return $Link_Task_For{$path}->{'source'}; - } - elsif ($action eq 'remove') { - internal_error( - "read_a_link() passed a path that is scheduled for removal: $path" - ); - } - } - elsif (-l $path) { - debug(4, " read_a_link($path): real link"); - return readlink $path - or error("Could not read link: $path"); - } - internal_error("read_a_link() passed a non link path: $path\n"); -} - -#===== SUBROUTINE =========================================================== -# Name : do_link() -# Purpose : wrap 'link' operation for later processing -# Parameters: $oldfile => the existing file to link to -# : $newfile => the file to link -# Returns : n/a -# Throws : error if this clashes with an existing planned operation -# Comments : cleans up operations that undo previous operations -#============================================================================ -sub do_link { - my ($oldfile, $newfile) = @_; - - if (exists $Dir_Task_For{$newfile}) { - my $task_ref = $Dir_Task_For{$newfile}; - - if ($task_ref->{'action'} eq 'create') { - if ($task_ref->{'type'} eq 'dir') { - internal_error( - "new link (%s => %s) clashes with planned new directory", - $newfile, - $oldfile, - ); - } - } - elsif ($task_ref->{'action'} eq 'remove') { - # we may need to remove a directory before creating a link so continue; - } - else { - internal_error("bad task action: $task_ref->{'action'}"); - } - } - - if (exists $Link_Task_For{$newfile}) { - my $task_ref = $Link_Task_For{$newfile}; - - if ($task_ref->{'action'} eq 'create') { - if ($task_ref->{'source'} ne $oldfile) { - internal_error( - "new link clashes with planned new link: %s => %s", - $task_ref->{'path'}, - $task_ref->{'source'}, - ) - } - else { - debug(1, "LINK: $newfile => $oldfile (duplicates previous action)"); - return; - } - } - elsif ($task_ref->{'action'} eq 'remove') { - if ($task_ref->{'source'} eq $oldfile) { - # no need to remove a link we are going to recreate - debug(1, "LINK: $newfile => $oldfile (reverts previous action)"); - $Link_Task_For{$newfile}->{'action'} = 'skip'; - delete $Link_Task_For{$newfile}; - return; - } - # we may need to remove a link to replace it so continue - } - else { - internal_error("bad task action: $task_ref->{'action'}"); - } - } - - # creating a new link - debug(1, "LINK: $newfile => $oldfile"); - my $task = { - action => 'create', - type => 'link', - path => $newfile, - source => $oldfile, - }; - push @Tasks, $task; - $Link_Task_For{$newfile} = $task; - - return; -} - -#===== SUBROUTINE =========================================================== -# Name : do_unlink() -# Purpose : wrap 'unlink' operation for later processing -# Parameters: $file => the file to unlink -# Returns : n/a -# Throws : error if this clashes with an existing planned operation -# Comments : will remove an existing planned link -#============================================================================ -sub do_unlink { - my ($file) = @_; - - if (exists $Link_Task_For{$file}) { - my $task_ref = $Link_Task_For{$file}; - if ($task_ref->{'action'} eq 'remove') { - debug(1, "UNLINK: $file (duplicates previous action)"); - return; - } - elsif ($task_ref->{'action'} eq 'create') { - # do need to create a link then remove it - debug(1, "UNLINK: $file (reverts previous action)"); - $Link_Task_For{$file}->{'action'} = 'skip'; - delete $Link_Task_For{$file}; - return; - } - else { - internal_error("bad task action: $task_ref->{'action'}"); - } - } - - if (exists $Dir_Task_For{$file} and $Dir_Task_For{$file} eq 'create') { - internal_error( - "new unlink operation clashes with planned operation: %s dir %s", - $Dir_Task_For{$file}->{'action'}, - $file - ); - } - - # remove the link - #debug(1, "UNLINK: $file (" . (caller())[2] . ")"); - debug(1, "UNLINK: $file"); - - my $source = readlink $file or error("could not readlink $file"); - - my $task = { - action => 'remove', - type => 'link', - path => $file, - source => $source, - }; - push @Tasks, $task; - $Link_Task_For{$file} = $task; - - return; -} - -#===== SUBROUTINE =========================================================== -# Name : do_mkdir() -# Purpose : wrap 'mkdir' operation -# Parameters: $dir => the directory to remove -# Returns : n/a -# Throws : fatal exception if operation fails -# Comments : outputs a message if 'verbose' option is set -# : does not perform operation if 'simulate' option is set -# Comments : cleans up operations that undo previous operations -#============================================================================ -sub do_mkdir { - my ($dir) = @_; - - if (exists $Link_Task_For{$dir}) { - my $task_ref = $Link_Task_For{$dir}; - - if ($task_ref->{'action'} eq 'create') { - internal_error( - "new dir clashes with planned new link (%s => %s)", - $task_ref->{'path'}, - $task_ref->{'source'}, - ); - } - elsif ($task_ref->{'action'} eq 'remove') { - # may need to remove a link before creating a directory so continue - } - else { - internal_error("bad task action: $task_ref->{'action'}"); - } - } - - if (exists $Dir_Task_For{$dir}) { - my $task_ref = $Dir_Task_For{$dir}; - - if ($task_ref->{'action'} eq 'create') { - debug(1, "MKDIR: $dir (duplicates previous action)"); - return; - } - elsif ($task_ref->{'action'} eq 'remove') { - debug(1, "MKDIR: $dir (reverts previous action)"); - $Dir_Task_For{$dir}->{'action'} = 'skip'; - delete $Dir_Task_For{$dir}; - return; - } - else { - internal_error("bad task action: $task_ref->{'action'}"); - } - } - - debug(1, "MKDIR: $dir"); - my $task = { - action => 'create', - type => 'dir', - path => $dir, - source => undef, - }; - push @Tasks, $task; - $Dir_Task_For{$dir} = $task; - - return; -} - -#===== SUBROUTINE =========================================================== -# Name : do_rmdir() -# Purpose : wrap 'rmdir' operation -# Parameters: $dir => the directory to remove -# Returns : n/a -# Throws : fatal exception if operation fails -# Comments : outputs a message if 'verbose' option is set -# : does not perform operation if 'simulate' option is set -#============================================================================ -sub do_rmdir { - my ($dir) = @_; - - if (exists $Link_Task_For{$dir}) { - my $task_ref = $Link_Task_For{$dir}; - internal_error( - "rmdir clashes with planned operation: %s link %s => %s", - $task_ref->{'action'}, - $task_ref->{'path'}, - $task_ref->{'source'} - ); - } - - if (exists $Dir_Task_For{$dir}) { - my $task_ref = $Link_Task_For{$dir}; - - if ($task_ref->{'action'} eq 'remove') { - debug(1, "RMDIR $dir (duplicates previous action)"); - return; - } - elsif ($task_ref->{'action'} eq 'create') { - debug(1, "MKDIR $dir (reverts previous action)"); - $Link_Task_For{$dir}->{'action'} = 'skip'; - delete $Link_Task_For{$dir}; - return; - } - else { - internal_error("bad task action: $task_ref->{'action'}"); - } - } - - debug(1, "RMDIR $dir"); - my $task = { - action => 'remove', - type => 'dir', - path => $dir, - source => '', - }; - push @Tasks, $task; - $Dir_Task_For{$dir} = $task; - - return; -} - -############################################################################# -# -# General Utilities: nothing stow specific here. -# -############################################################################# - -#===== SUBROUTINE ============================================================ +#===== METHOD ================================================================ # Name : strip_quotes # Purpose : remove matching outer quotes from the given string # Parameters: none @@ -1680,95 +274,6 @@ sub strip_quotes { return $string; } -#===== SUBROUTINE =========================================================== -# Name : join_paths() -# Purpose : concatenates given paths -# Parameters: path1, path2, ... => paths -# Returns : concatenation of given paths -# Throws : n/a -# Comments : factors out redundant path elements: -# : '//' => '/' and 'a/b/../c' => 'a/c' -#============================================================================ -sub join_paths { - my @paths = @_; - - # weed out empty components and concatenate - my $result = join '/', grep {!/\A\z/} @paths; - - # factor out back references and remove redundant /'s) - my @result = (); - PART: - for my $part (split m{/+}, $result) { - next PART if $part eq '.'; - if (@result && $part eq '..' && $result[-1] ne '..') { - pop @result; - } - else { - push @result, $part; - } - } - - return join '/', @result; -} - -#===== SUBROUTINE =========================================================== -# Name : parent -# Purpose : find the parent of the given path -# Parameters: @path => components of the path -# Returns : returns a path string -# Throws : n/a -# Comments : allows you to send multiple chunks of the path -# : (this feature is currently not used) -#============================================================================ -sub parent { - my @path = @_; - my $path = join '/', @_; - my @elts = split m{/+}, $path; - pop @elts; - return join '/', @elts; -} - -#===== SUBROUTINE =========================================================== -# Name : internal_error() -# Purpose : output internal error message in a consistent form and die -# Parameters: $message => error message to output -# Returns : n/a -# Throws : n/a -# Comments : none -#============================================================================ -sub internal_error { - my ($format, @args) = @_; - die "$ProgramName: INTERNAL ERROR: " . sprintf($format, @args) . "\n", - "This _is_ a bug. Please submit a bug report so we can fix it:-)\n"; -} - -#===== SUBROUTINE =========================================================== -# Name : error() -# Purpose : output error message in a consistent form and die -# Parameters: $message => error message to output -# Returns : n/a -# Throws : n/a -# Comments : none -#============================================================================ -sub error { - my ($format, @args) = @_; - die "$ProgramName: ERROR: " . sprintf($format, @args) . " ($!)\n"; -} - -#===== SUBROUTINE =========================================================== -# Name : version() -# Purpose : print this programs verison and exit -# Parameters: none -# Returns : n/a -# Throws : n/a -# Comments : none -#============================================================================ -sub version { - print "$ProgramName (GNU Stow) version $Version\n"; - exit 0; -} - -1; # return true so we can load this script as a module during unit testing # Local variables: # mode: perl diff --git a/t/chkstow.t b/t/chkstow.t index f38de57..b182fd9 100755 --- a/t/chkstow.t +++ b/t/chkstow.t @@ -4,22 +4,18 @@ # Testing cleanup_invalid_links() # -# load as a library -BEGIN { - use lib qw(.); - require "t/util.pm"; - require "chkstow"; -} +use strict; +use warnings; + +use testutil; +require "chkstow"; use Test::More tests => 7; use Test::Output; use English qw(-no_match_vars); -### setup -eval { remove_dir('t/target'); }; -make_dir('t/target'); - -chdir 't/target'; +make_fresh_stow_and_target_dirs(); +cd('t/target'); # setup stow directory make_dir('stow'); @@ -111,5 +107,6 @@ stdout_like( @ARGV = ('-b',); process_options(); -ok($::Target == q{/usr/local}, +our $Target; +ok($Target == q{/usr/local}, "Default target is /usr/local/"); diff --git a/t/cleanup_invalid_links.t b/t/cleanup_invalid_links.t index 69efbe8..f5802dd 100755 --- a/t/cleanup_invalid_links.t +++ b/t/cleanup_invalid_links.t @@ -4,64 +4,55 @@ # Testing cleanup_invalid_links() # -# load as a library -BEGIN { use lib qw(.); require "t/util.pm"; require "stow"; } +use strict; +use warnings; -use Test::More tests => 3; +use Test::More tests => 6; use English qw(-no_match_vars); -### setup -eval { remove_dir('t/target'); }; -eval { remove_dir('t/stow'); }; -make_dir('t/target'); -make_dir('t/stow'); +use testutil; -chdir 't/target'; -$Stow_Path= '../stow'; +make_fresh_stow_and_target_dirs(); +cd('t/target'); + +my $stow; # Note that each of the following tests use a distinct set of files # # nothing to clean in a simple tree # -reset_state(); + make_dir('../stow/pkg1/bin1'); make_file('../stow/pkg1/bin1/file1'); make_link('bin1','../stow/pkg1/bin1'); -cleanup_invalid_links('./'); +$stow = new_Stow(); +$stow->cleanup_invalid_links('./'); is( - scalar @Tasks, 0 + scalar($stow->get_tasks), 0 => 'nothing to clean' ); # # cleanup a bad link in a simple tree # -reset_state(); - make_dir('bin2'); make_dir('../stow/pkg2/bin2'); make_file('../stow/pkg2/bin2/file2a'); make_link('bin2/file2a','../../stow/pkg2/bin2/file2a'); make_link('bin2/file2b','../../stow/pkg2/bin2/file2b'); -cleanup_invalid_links('bin2'); -ok( - scalar(@Conflicts) == 0 && - scalar @Tasks == 1 && - $Link_Task_For{'bin2/file2b'}->{'action'} eq 'remove' - => 'cleanup a bad link' -); - -#use Data::Dumper; -#print Dumper(\@Tasks,\%Link_Task_For,\%Dir_Task_For); +$stow = new_Stow(); +$stow->cleanup_invalid_links('bin2'); +is(scalar($stow->get_conflicts), 0, 'no conflicts cleaning up bad link'); +is(scalar($stow->get_tasks), 1, 'one task cleaning up bad link'); +is($stow->link_task_action('bin2/file2b'), 'remove', 'removal task for bad link'); # # dont cleanup a bad link not owned by stow # -reset_state(); make_dir('bin3'); make_dir('../stow/pkg3/bin3'); @@ -69,11 +60,7 @@ make_file('../stow/pkg3/bin3/file3a'); make_link('bin3/file3a','../../stow/pkg3/bin3/file3a'); make_link('bin3/file3b','../../empty'); -cleanup_invalid_links('bin3'); -ok( - scalar(@Conflicts) == 0 && - scalar @Tasks == 0 - => 'dont cleanup a bad link not owned by stow' -); - - +$stow = new_Stow(); +$stow->cleanup_invalid_links('bin3'); +is(scalar($stow->get_conflicts), 0, 'no conflicts cleaning up bad link not owned by stow'); +is(scalar($stow->get_tasks), 0, 'no tasks cleaning up bad link not owned by stow'); diff --git a/t/defer.t b/t/defer.t old mode 100644 new mode 100755 index a4f8cf7..24d4d5f --- a/t/defer.t +++ b/t/defer.t @@ -4,19 +4,23 @@ # Testing defer(). # -# load as a library -BEGIN { use lib qw(. ..); require "stow"; } +use strict; +use warnings; + +use testutil; use Test::More tests => 4; -$Option{'defer'} = [ 'man' ]; -ok(defer('man/man1/file.1') => 'simple success'); +my $stow; -$Option{'defer'} = [ 'lib' ]; -ok(!defer('man/man1/file.1') => 'simple failure'); +$stow = new_Stow(defer => [ 'man' ]); +ok($stow->defer('man/man1/file.1') => 'simple success'); -$Option{'defer'} = [ 'lib', 'man', 'share' ]; -ok(defer('man/man1/file.1') => 'complex success'); +$stow = new_Stow(defer => [ 'lib' ]); +ok(! $stow->defer('man/man1/file.1') => 'simple failure'); -$Option{'defer'} = [ 'lib', 'man', 'share' ]; -ok(!defer('bin/file') => 'complex failure'); +$stow = new_Stow(defer => [ 'lib', 'man', 'share' ]); +ok($stow->defer('man/man1/file.1') => 'complex success'); + +$stow = new_Stow(defer => [ 'lib', 'man', 'share' ]); +ok(! $stow->defer('bin/file') => 'complex failure'); diff --git a/t/examples.t b/t/examples.t index adcaa97..381f9ad 100755 --- a/t/examples.t +++ b/t/examples.t @@ -4,18 +4,18 @@ # Testing examples from the documentation # -# load as a library -BEGIN { use lib qw(.); require "t/util.pm"; require "stow"; } +use strict; +use warnings; -use Test::More tests => 4; +use testutil; + +use Test::More tests => 10; use English qw(-no_match_vars); -### setup -eval { remove_dir('t/target'); }; -make_dir('t/target/stow'); +make_fresh_stow_and_target_dirs(); +cd('t/target'); -chdir 't/target'; -$Stow_Path= 'stow'; +my $stow; ## set up some fake packages to stow @@ -42,8 +42,6 @@ make_file('stow/emacs/man/man1/emacs.1'); # # stow perl into an empty target # -reset_state(); - make_dir('stow/perl/bin'); make_file('stow/perl/bin/perl'); make_file('stow/perl/bin/a2p'); @@ -52,10 +50,11 @@ make_dir('stow/perl/lib/perl'); make_dir('stow/perl/man/man1'); make_file('stow/perl/man/man1/perl.1'); -stow_contents('stow/perl','./','stow/perl'); -process_tasks(); +$stow = new_Stow(dir => 'stow'); +$stow->plan_stow('perl'); +$stow->process_tasks(); ok( - scalar(@Conflicts) == 0 && + scalar($stow->get_conflicts) == 0 && -l 'bin' && -l 'info' && -l 'lib' && -l 'man' && readlink('bin') eq 'stow/perl/bin' && readlink('info') eq 'stow/perl/info' && @@ -64,11 +63,9 @@ ok( => 'stow perl into an empty target' ); - # # stow perl into a non-empty target # -reset_state(); # clean up previous stow remove_link('bin'); @@ -80,10 +77,11 @@ make_dir('bin'); make_dir('lib'); make_dir('man/man1'); -stow_contents('stow/perl','./','stow/perl'); -process_tasks(); +$stow = new_Stow(dir => 'stow'); +$stow->plan_stow('perl'); +$stow->process_tasks(); ok( - scalar(@Conflicts) == 0 && + scalar($stow->get_conflicts) == 0 && -d 'bin' && -d 'lib' && -d 'man' && -d 'man/man1' && -l 'info' && -l 'bin/perl' && -l 'bin/a2p' && -l 'lib/perl' && -l 'man/man1/perl.1' && @@ -99,7 +97,6 @@ ok( # # Install perl into an empty target and then install emacs # -reset_state(); # clean up previous stow remove_link('info'); @@ -107,11 +104,11 @@ remove_dir('bin'); remove_dir('lib'); remove_dir('man'); -stow_contents('stow/perl', './','stow/perl'); -stow_contents('stow/emacs','./','stow/emacs'); -process_tasks(); +$stow = new_Stow(dir => 'stow'); +$stow->plan_stow('perl', 'emacs'); +$stow->process_tasks(); +is(scalar($stow->get_conflicts), 0, 'no conflicts'); ok( - scalar(@Conflicts) == 0 && -d 'bin' && -l 'bin/perl' && -l 'bin/emacs' && @@ -151,30 +148,22 @@ ok( # Q. the original empty directory should remain # behaviour is the same as if the empty directory had nothing to do with stow # -reset_state(); make_dir('stow/pkg1a/bin1'); make_dir('stow/pkg1b/bin1'); make_file('stow/pkg1b/bin1/file1b'); -stow_contents('stow/pkg1a', './', 'stow/pkg1a'); -stow_contents('stow/pkg1b', './', 'stow/pkg1b'); -unstow_contents('stow/pkg1b', './', 'stow/pkg1b'); -process_tasks(); - -ok( - scalar(@Conflicts) == 0 && - -d 'bin1' - => 'bug 1: stowing empty dirs' -); - +$stow = new_Stow(dir => 'stow'); +$stow->plan_stow('pkg1a', 'pkg1b'); +$stow->plan_unstow('pkg1b'); +$stow->process_tasks(); +is(scalar($stow->get_conflicts), 0, 'no conflicts stowing empty dirs'); +ok(-d 'bin1' => 'bug 1: stowing empty dirs'); # # BUG 2: split open tree-folding symlinks pointing inside different stow # directories # -reset_state(); - make_dir('stow2a/pkg2a/bin2'); make_file('stow2a/pkg2a/bin2/file2a'); make_file('stow2a/.stow'); @@ -182,8 +171,15 @@ make_dir('stow2b/pkg2b/bin2'); make_file('stow2b/pkg2b/bin2/file2b'); make_file('stow2b/.stow'); -stow_contents('stow2a/pkg2a','./', 'stow2a/pkg2a'); -stow_contents('stow2b/pkg2b','./', 'stow2b/pkg2b'); -process_tasks(); +$stow = new_Stow(dir => 'stow2a'); +$stow->plan_stow('pkg2a'); +$stow->set_stow_dir('stow2b'); +$stow->plan_stow('pkg2b'); +$stow->process_tasks(); + +is(scalar($stow->get_conflicts), 0, 'no conflicts splitting tree-folding symlinks'); +ok(-d 'bin2' => 'tree got split by packages from multiple stow directories'); +ok(-f 'bin2/file2a' => 'file from 1st stow dir'); +ok(-f 'bin2/file2b' => 'file from 2nd stow dir'); ## Finish this test diff --git a/t/find_stowed_path.t b/t/find_stowed_path.t old mode 100644 new mode 100755 index 03a7c73..199a534 --- a/t/find_stowed_path.t +++ b/t/find_stowed_path.t @@ -4,39 +4,43 @@ # Testing find_stowed_path() # -BEGIN { require "t/util.pm"; require "stow"; } +use strict; +use warnings; -use Test::More tests => 5; +use testutil; -eval { remove_dir('t/target'); }; -eval { remove_dir('t/stow'); }; -make_dir('t/target'); -make_dir('t/stow'); +use Test::More tests => 6; + +make_fresh_stow_and_target_dirs(); + +my $stow = new_Stow(dir => 't/stow'); -$Stow_Path = 't/stow'; is( - find_stowed_path('t/target/a/b/c', '../../../stow/a/b/c'), + $stow->find_stowed_path('t/target/a/b/c', '../../../stow/a/b/c'), 't/stow/a/b/c', => 'from root' ); -$Stow_Path = '../stow'; +cd('t/target'); +$stow->set_stow_dir('../stow'); is( - find_stowed_path('a/b/c','../../../stow/a/b/c'), + $stow->find_stowed_path('a/b/c','../../../stow/a/b/c'), '../stow/a/b/c', => 'from target directory' ); -$Stow_Path = 't/target/stow'; +make_dir('stow'); +cd('../..'); +$stow->set_stow_dir('t/target/stow'); is( - find_stowed_path('t/target/a/b/c', '../../stow/a/b/c'), + $stow->find_stowed_path('t/target/a/b/c', '../../stow/a/b/c'), 't/target/stow/a/b/c', => 'stow is subdir of target directory' ); is( - find_stowed_path('t/target/a/b/c','../../empty'), + $stow->find_stowed_path('t/target/a/b/c','../../empty'), '', => 'target is not stowed' ); @@ -45,7 +49,15 @@ make_dir('t/target/stow2'); make_file('t/target/stow2/.stow'); is( - find_stowed_path('t/target/a/b/c','../../stow2/a/b/c'), + $stow->find_stowed_path('t/target/a/b/c','../../stow2/a/b/c'), 't/target/stow2/a/b/c' => q(detect alternate stow directory) ); + +# Possible corner case with rogue symlink pointing to ancestor of +# stow dir. +is( + $stow->find_stowed_path('t/target/a/b/c','../../..'), + '' + => q(corner case - link points to ancestor of stow dir) +); diff --git a/t/foldable.t b/t/foldable.t index 171907c..6815ec7 100755 --- a/t/foldable.t +++ b/t/foldable.t @@ -4,21 +4,18 @@ # Testing foldable() # -# load as a library -BEGIN { use lib qw(.); require "t/util.pm"; require "stow"; } +use strict; +use warnings; + +use testutil; use Test::More tests => 4; use English qw(-no_match_vars); -### setup -# be very careful with these -eval { remove_dir('t/target'); }; -eval { remove_dir('t/stow'); }; -make_dir('t/target'); -make_dir('t/stow'); +make_fresh_stow_and_target_dirs(); +cd('t/target'); -chdir 't/target'; -$Stow_Path= '../stow'; +my $stow = new_Stow(dir => '../stow'); # Note that each of the following tests use a distinct set of files @@ -31,7 +28,7 @@ make_file('../stow/pkg1/bin1/file1'); make_dir('bin1'); make_link('bin1/file1','../../stow/pkg1/bin1/file1'); -is( foldable('bin1'), '../stow/pkg1/bin1' => q(can fold a simple tree) ); +is( $stow->foldable('bin1'), '../stow/pkg1/bin1' => q(can fold a simple tree) ); # # can't fold an empty directory @@ -41,7 +38,7 @@ make_dir('../stow/pkg2/bin2'); make_file('../stow/pkg2/bin2/file2'); make_dir('bin2'); -is( foldable('bin2'), '' => q(can't fold an empty directory) ); +is( $stow->foldable('bin2'), '' => q(can't fold an empty directory) ); # # can't fold if dir contains a non-link @@ -53,7 +50,7 @@ make_dir('bin3'); make_link('bin3/file3','../../stow/pkg3/bin3/file3'); make_file('bin3/non-link'); -is( foldable('bin3'), '' => q(can't fold a dir containing non-links) ); +is( $stow->foldable('bin3'), '' => q(can't fold a dir containing non-links) ); # # can't fold if links point to different directories @@ -67,4 +64,4 @@ make_dir('../stow/pkg4b/bin4'); make_file('../stow/pkg4b/bin4/file4b'); make_link('bin4/file4b','../../stow/pkg4b/bin4/file4b'); -is( foldable('bin4'), '' => q(can't fold if links point to different dirs) ); +is( $stow->foldable('bin4'), '' => q(can't fold if links point to different dirs) ); diff --git a/t/join_paths.t b/t/join_paths.t old mode 100644 new mode 100755 index 1fc6b24..b310416 --- a/t/join_paths.t +++ b/t/join_paths.t @@ -4,8 +4,10 @@ # Testing join_paths(); # -# load as a library -BEGIN { use lib qw(. ..); require "stow"; } +use strict; +use warnings; + +use Stow::Util qw(join_paths); use Test::More tests => 13; diff --git a/t/parent.t b/t/parent.t old mode 100644 new mode 100755 index 52a4bea..52a99bc --- a/t/parent.t +++ b/t/parent.t @@ -4,8 +4,10 @@ # Testing parent() # -# load as a library -BEGIN { use lib qw(. ..); require "stow"; } +use strict; +use warnings; + +use Stow::Util qw(parent); use Test::More tests => 5; diff --git a/t/stow.t b/t/stow.t index 49d671a..2ad0fc8 100755 --- a/t/stow.t +++ b/t/stow.t @@ -4,11 +4,17 @@ # Testing core application # -# load as a library -BEGIN { use lib qw(.); require "t/util.pm"; require "stow"; } +use strict; +use warnings; use Test::More tests => 10; +use testutil; + +require 'stow'; + +make_fresh_stow_and_target_dirs(); + local @ARGV = ( '-v', '-d t/stow', @@ -16,23 +22,19 @@ local @ARGV = ( 'dummy' ); -### setup -eval { remove_dir('t/target'); }; -eval { remove_dir('t/stow'); }; -make_dir('t/target'); -make_dir('t/stow'); +my ($options, $pkgs_to_delete, $pkgs_to_stow) = process_options(); -ok eval {process_options(); 1} => 'process options'; -ok eval {set_stow_path(); 1} => 'set stow path'; +is($options->{verbose}, 1, 'verbose option'); +is($options->{dir}, 't/stow', 'stow dir option'); -is($Stow_Path,"../stow" => 'stow dir'); -is_deeply(\@Pkgs_To_Stow, [ 'dummy' ] => 'default to stow'); +my $stow = new_Stow(%$options); +is($stow->{stow_path}, "../stow" => 'stow dir'); +is_deeply($pkgs_to_stow, [ 'dummy' ] => 'default to stow'); # # Check mixed up package options # -%Option=(); local @ARGV = ( '-v', '-D', 'd1', 'd2', @@ -43,55 +45,53 @@ local @ARGV = ( '-R', 'r2', ); -@Pkgs_To_Stow = (); -@Pkgs_To_Delete = (); -process_options(); -is_deeply(\@Pkgs_To_Delete, [ 'd1', 'd2', 'r1', 'd3', 'r2' ] => 'mixed deletes'); -is_deeply(\@Pkgs_To_Stow, [ 's1', 'r1', 's2', 's3', 'r2' ] => 'mixed stows'); +($options, $pkgs_to_delete, $pkgs_to_stow) = process_options(); +is_deeply($pkgs_to_delete, [ 'd1', 'd2', 'r1', 'd3', 'r2' ] => 'mixed deletes'); +is_deeply($pkgs_to_stow, [ 's1', 'r1', 's2', 's3', 'r2' ] => 'mixed stows'); # -# Check setting defered paths +# Check setting deferred paths # -%Option=(); local @ARGV = ( '--defer=man', - '--defer=info' + '--defer=info', + 'dummy' ); -process_options(); -is_deeply($Option{'defer'}, [ qr(\Aman), qr(\Ainfo) ] => 'defer man and info'); +($options, $pkgs_to_delete, $pkgs_to_stow) = process_options(); +is_deeply($options->{'defer'}, [ qr(\Aman), qr(\Ainfo) ] => 'defer man and info'); # # Check setting override paths # -%Option=(); local @ARGV = ( '--override=man', - '--override=info' + '--override=info', + 'dummy' ); -process_options(); -is_deeply($Option{'override'}, [qr(\Aman), qr(\Ainfo)] => 'override man and info'); +($options, $pkgs_to_delete, $pkgs_to_stow) = process_options(); +is_deeply($options->{'override'}, [qr(\Aman), qr(\Ainfo)] => 'override man and info'); # # Check stripping any matched quotes # -%Option=(); local @ARGV = ( "--override='man'", '--override="info"', + 'dummy' ); -process_options(); -is_deeply($Option{'override'}, [qr(\Aman), qr(\Ainfo)] => 'strip shell quoting'); +($options, $pkgs_to_delete, $pkgs_to_stow) = process_options(); +is_deeply($options->{'override'}, [qr(\Aman), qr(\Ainfo)] => 'strip shell quoting'); # # Check setting ignored paths # -%Option=(); local @ARGV = ( '--ignore="~"', - '--ignore="\.#.*"' + '--ignore="\.#.*"', + 'dummy' ); -process_options(); -is_deeply($Option{'ignore'}, [ qr(~\z), qr(\.#.*\z) ] => 'ignore temp files'); +($options, $pkgs_to_delete, $pkgs_to_stow) = process_options(); +is_deeply($options->{'ignore'}, [ qr(~\z), qr(\.#.*\z) ] => 'ignore temp files'); # vim:ft=perl diff --git a/t/stow_contents.t b/t/stow_contents.t index 7cae0df..ad3b47f 100755 --- a/t/stow_contents.t +++ b/t/stow_contents.t @@ -1,36 +1,37 @@ #!/usr/local/bin/perl # -# Testing +# Testing stow_contents() # -# load as a library -BEGIN { use lib qw(.); require "t/util.pm"; require "stow"; } +use strict; +use warnings; -use Test::More tests => 16; +use Test::More tests => 19; use Test::Output; use English qw(-no_match_vars); -### setup -eval { remove_dir('t/target'); }; -eval { remove_dir('t/stow'); }; -make_dir('t/target'); -make_dir('t/stow'); +use testutil; -chdir 't/target'; -$Stow_Path= '../stow'; +make_fresh_stow_and_target_dirs(); +cd('t/target'); + +my $stow; +my @conflicts; # Note that each of the following tests use a distinct set of files # # stow a simple tree minimally # -reset_state(); +$stow = new_Stow(dir => '../stow'); make_dir('../stow/pkg1/bin1'); make_file('../stow/pkg1/bin1/file1'); -stow_contents('../stow/pkg1', './', '../stow/pkg1'); -process_tasks(); + +$stow->plan_stow('pkg1'); +$stow->process_tasks(); +is($stow->get_conflicts(), 0, 'no conflicts with minimal stow'); is( readlink('bin1'), '../stow/pkg1/bin1', @@ -40,13 +41,13 @@ is( # # stow a simple tree into an existing directory # -reset_state(); +$stow = new_Stow(); make_dir('../stow/pkg2/lib2'); make_file('../stow/pkg2/lib2/file2'); make_dir('lib2'); -stow_contents('../stow/pkg2', '.', '../stow/pkg2'); -process_tasks(); +$stow->plan_stow('pkg2'); +$stow->process_tasks(); is( readlink('lib2/file2'), '../../stow/pkg2/lib2/file2', @@ -56,7 +57,7 @@ is( # # unfold existing tree # -reset_state(); +$stow = new_Stow(); make_dir('../stow/pkg3a/bin3'); make_file('../stow/pkg3a/bin3/file3a'); @@ -64,8 +65,8 @@ make_link('bin3' => '../stow/pkg3a/bin3'); # emulate stow make_dir('../stow/pkg3b/bin3'); make_file('../stow/pkg3b/bin3/file3b'); -stow_contents('../stow/pkg3b', './', '../stow/pkg3b'); -process_tasks(); +$stow->plan_stow('pkg3b'); +$stow->process_tasks(); ok( -d 'bin3' && readlink('bin3/file3a') eq '../../stow/pkg3a/bin3/file3a' && @@ -74,42 +75,45 @@ ok( ); # -# Link to a new dir conflicts with existing non-dir (can't unfold) +# Link to a new dir conflicts with existing non-dir (can't unfold) # -reset_state(); +$stow = new_Stow(); make_file('bin4'); # this is a file but named like a directory make_dir('../stow/pkg4/bin4'); make_file('../stow/pkg4/bin4/file4'); -stow_contents('../stow/pkg4', './', '../stow/pkg4'); -like( - $Conflicts[-1], qr(CONFLICT:.*existing target is neither a link nor a directory) +$stow->plan_stow('pkg4'); +@conflicts = $stow->get_conflicts(); +like( + $conflicts[-1], qr(CONFLICT:.*existing target is neither a link nor a directory) => 'link to new dir conflicts with existing non-directory' ); # # Target already exists but is not owned by stow # -reset_state(); +$stow = new_Stow(); make_dir('bin5'); make_link('bin5/file5','../../empty'); make_dir('../stow/pkg5/bin5/file5'); -stow_contents('../stow/pkg5', './', '../stow/pkg5'); +$stow->plan_stow('pkg5'); +@conflicts = $stow->get_conflicts(); like( - $Conflicts[-1], qr(CONFLICT:.*not owned by stow) + $conflicts[-1], qr(CONFLICT:.*not owned by stow) => 'target already exists but is not owned by stow' ); # # Replace existing but invalid target # -reset_state(); +$stow = new_Stow(); make_link('file6','../stow/path-does-not-exist'); make_dir('../stow/pkg6'); make_file('../stow/pkg6/file6'); -eval{ stow_contents('../stow/pkg6', './', '../stow/pkg6'); process_tasks() }; +$stow->plan_stow('pkg6'); +$stow->process_tasks(); is( readlink('file6'), '../stow/pkg6/file6' @@ -120,7 +124,7 @@ is( # Target already exists, is owned by stow, but points to a non-directory # (can't unfold) # -reset_state(); +$stow = new_Stow(); make_dir('bin7'); make_dir('../stow/pkg7a/bin7'); @@ -128,16 +132,17 @@ make_file('../stow/pkg7a/bin7/node7'); make_link('bin7/node7','../../stow/pkg7a/bin7/node7'); make_dir('../stow/pkg7b/bin7/node7'); make_file('../stow/pkg7b/bin7/node7/file7'); -stow_contents('../stow/pkg7b', './', '../stow/pkg7b'); -like( - $Conflicts[-1], qr(CONFLICT:.*existing target is stowed to a different package) +$stow->plan_stow('pkg7b'); +@conflicts = $stow->get_conflicts(); +like( + $conflicts[-1], qr(CONFLICT:.*existing target is stowed to a different package) => 'link to new dir conflicts with existing stowed non-directory' ); # # stowing directories named 0 # -reset_state(); +$stow = new_Stow(); make_dir('../stow/pkg8a/0'); make_file('../stow/pkg8a/0/file8a'); @@ -145,10 +150,10 @@ make_link('0' => '../stow/pkg8a/0'); # emulate stow make_dir('../stow/pkg8b/0'); make_file('../stow/pkg8b/0/file8b'); -stow_contents('../stow/pkg8b', './', '../stow/pkg8b'); -process_tasks(); +$stow->plan_stow('pkg8b'); +$stow->process_tasks(); ok( - scalar(@Conflicts) == 0 && + scalar($stow->get_conflicts) == 0 && -d '0' && readlink('0/file8a') eq '../../stow/pkg8a/0/file8a' && readlink('0/file8b') eq '../../stow/pkg8b/0/file8b' @@ -158,8 +163,7 @@ ok( # # overriding already stowed documentation # -reset_state(); -$Option{'override'} = ['man9', 'info9']; +$stow = new_Stow(override => ['man9', 'info9']); make_dir('../stow/pkg9a/man9/man1'); make_file('../stow/pkg9a/man9/man1/file9.1'); @@ -168,10 +172,10 @@ make_link('man9/man1/file9.1' => '../../../stow/pkg9a/man9/man1/file9.1'); # emu make_dir('../stow/pkg9b/man9/man1'); make_file('../stow/pkg9b/man9/man1/file9.1'); -stow_contents('../stow/pkg9b', './', '../stow/pkg9b'); -process_tasks(); +$stow->plan_stow('pkg9b'); +$stow->process_tasks(); ok( - scalar(@Conflicts) == 0 && + scalar($stow->get_conflicts) == 0 && readlink('man9/man1/file9.1') eq '../../../stow/pkg9b/man9/man1/file9.1' => 'overriding existing documentation files' ); @@ -179,8 +183,7 @@ ok( # # deferring to already stowed documentation # -reset_state(); -$Option{'defer'} = ['man10', 'info10']; +$stow = new_Stow(defer => ['man10', 'info10']); make_dir('../stow/pkg10a/man10/man1'); make_file('../stow/pkg10a/man10/man1/file10.1'); @@ -189,14 +192,15 @@ make_link('man10/man1/file10.1' => '../../../stow/pkg10a/man10/man1/file10.1'); make_dir('../stow/pkg10b/man10/man1'); make_file('../stow/pkg10b/man10/man1/file10.1'); -stow_contents('../stow/pkg10b', './', '../stow/pkg10b'); +$stow->plan_stow('pkg10b'); + stderr_like( - sub { process_tasks(); }, + sub { $stow->process_tasks(); }, qr/There are no outstanding operations to perform/, 'no tasks to process' ); ok( - scalar(@Conflicts) == 0 && + scalar($stow->get_conflicts) == 0 && readlink('man10/man1/file10.1') eq '../../../stow/pkg10a/man10/man1/file10.1' => 'defer to existing documentation files' ); @@ -204,8 +208,7 @@ ok( # # Ignore temp files # -reset_state(); -$Option{'ignore'} = ['~', '\.#.*']; +$stow = new_Stow(ignore => ['~', '\.#.*']); make_dir('../stow/pkg11/man11/man1'); make_file('../stow/pkg11/man11/man1/file11.1'); @@ -213,10 +216,10 @@ make_file('../stow/pkg11/man11/man1/file11.1~'); make_file('../stow/pkg11/man11/man1/.#file11.1'); make_dir('man11/man1'); -stow_contents('../stow/pkg11', './', '../stow/pkg11'); -process_tasks(); +$stow->plan_stow('pkg11'); +$stow->process_tasks(); ok( - scalar(@Conflicts) == 0 && + scalar($stow->get_conflicts) == 0 && readlink('man11/man1/file11.1') eq '../../../stow/pkg11/man11/man1/file11.1' && !-e 'man11/man1/file11.1~' && !-e 'man11/man1/.#file11.1' @@ -226,17 +229,17 @@ ok( # # stowing links library files # -reset_state(); +$stow = new_Stow(); make_dir('../stow/pkg12/lib12/'); make_file('../stow/pkg12/lib12/lib.so'); make_link('../stow/pkg12/lib12/lib.so.1','lib.so'); make_dir('lib12/'); -stow_contents('../stow/pkg12', './', '../stow/pkg12'); -process_tasks(); +$stow->plan_stow('pkg12'); +$stow->process_tasks(); ok( - scalar(@Conflicts) == 0 && + scalar($stow->get_conflicts) == 0 && readlink('lib12/lib.so.1') eq '../../stow/pkg12/lib12/lib.so.1' => 'stow links to libraries' ); @@ -244,7 +247,7 @@ ok( # # unfolding to stow links to library files # -reset_state(); +$stow = new_Stow(); make_dir('../stow/pkg13a/lib13/'); make_file('../stow/pkg13a/lib13/liba.so'); @@ -255,10 +258,10 @@ make_dir('../stow/pkg13b/lib13/'); make_file('../stow/pkg13b/lib13/libb.so'); make_link('../stow/pkg13b/lib13/libb.so.1', 'libb.so'); -stow_contents('../stow/pkg13b', './', '../stow/pkg13b'); -process_tasks(); +$stow->plan_stow('pkg13b'); +$stow->process_tasks(); ok( - scalar(@Conflicts) == 0 && + scalar($stow->get_conflicts) == 0 && readlink('lib13/liba.so.1') eq '../../stow/pkg13a/lib13/liba.so.1' && readlink('lib13/libb.so.1') eq '../../stow/pkg13b/lib13/libb.so.1' => 'unfolding to stow links to libraries' @@ -267,20 +270,38 @@ ok( # # stowing to stow dir should fail # -reset_state(); -$Stow_Path= 'stow'; +make_dir('stow'); +$stow = new_Stow(dir => 'stow'); make_dir('stow/pkg14/stow/pkg15'); make_file('stow/pkg14/stow/pkg15/node15'); -stow_contents('stow/pkg14', '.', 'stow/pkg14'); +$stow->plan_stow('pkg14'); stderr_like( - sub { process_tasks(); }, + sub { $stow->process_tasks(); }, qr/There are no outstanding operations to perform/, 'no tasks to process' ); ok( - scalar(@Conflicts) == 0 && + scalar($stow->get_conflicts) == 0 && ! -l 'stow/pkg15' => "stowing to stow dir should fail" ); + +# +# stow a simple tree minimally when cwd isn't target +# +cd('../..'); +$stow = new_Stow(dir => 't/stow', target => 't/target'); + +make_dir('t/stow/pkg16/bin16'); +make_file('t/stow/pkg16/bin16/file16'); + +$stow->plan_stow('pkg16'); +$stow->process_tasks(); +is($stow->get_conflicts(), 0, 'no conflicts with minimal stow'); +is( + readlink('t/target/bin16'), + '../stow/pkg16/bin16', + => 'minimal stow of a simple tree' +); diff --git a/t/util.pm b/t/testutil.pm similarity index 83% rename from t/util.pm rename to t/testutil.pm index 7241cf6..5c71a20 100755 --- a/t/util.pm +++ b/t/testutil.pm @@ -7,22 +7,31 @@ use strict; use warnings; +use Stow; +use Stow::Util qw(parent); -#===== SUBROUTINE =========================================================== -# Name : reset_state() -# Purpose : reset internal state machine -# Parameters: none -# Returns : n/a -# Throws : n/a -# Comments : none -#============================================================================ -sub reset_state { - @::Tasks = (); - @::Conflicts = (); - %::Link_Task_For = (); - %::Dir_Task_For = (); - %::Option = ( testmode => 1 ); - return; +sub make_fresh_stow_and_target_dirs { + die "t/ didn't exist; are you running the tests from the root of the tree?\n" + unless -d 't'; + + for my $dir ('t/target', 't/stow') { + eval { remove_dir($dir); }; + make_dir($dir); + } +} + +sub new_Stow { + my %opts = @_; + $opts{dir} ||= '../stow'; + $opts{target} ||= '.'; + $opts{test_mode} = 1; + return new Stow(%opts); +} + +sub new_compat_Stow { + my %opts = @_; + $opts{compat} = 1; + return new_Stow(%opts); } #===== SUBROUTINE =========================================================== @@ -38,13 +47,13 @@ sub make_link { my ($target, $source) = @_; if (-l $target) { - my $old_source = readlink join('/',parent($target),$source) + my $old_source = readlink join('/', parent($target), $source) or die "could not read link $target/$source"; if ($old_source ne $source) { die "$target already exists but points elsewhere\n"; } } - elsif (-e $target ) { + elsif (-e $target) { die "$target already exists and is not a link\n"; } else { @@ -56,7 +65,7 @@ sub make_link { #===== SUBROUTINE =========================================================== # Name : make_dir() -# Purpose : create a directory and any requiste parents +# Purpose : create a directory and any requisite parents # Parameters: $dir => path to the new directory # Returns : n/a # Throws : fatal error if the directory or any of its parents cannot be @@ -174,4 +183,23 @@ sub remove_dir { return; } +#===== SUBROUTINE =========================================================== +# Name : cd() +# Purpose : wrapper around chdir +# Parameters: $dir => path to chdir to +# Returns : n/a +# Throws : fatal error if the chdir fails +# Comments : none +#============================================================================ +sub cd { + my ($dir) = @_; + chdir $dir or die "Failed to chdir($dir): $!\n"; +} + 1; + +# Local variables: +# mode: perl +# cperl-indent-level: 4 +# end: +# vim: ft=perl diff --git a/t/unstow_contents.t b/t/unstow_contents.t index 80fccc5..cd5fd3a 100755 --- a/t/unstow_contents.t +++ b/t/unstow_contents.t @@ -4,38 +4,36 @@ # Testing unstow_contents() # -# load as a library -BEGIN { use lib qw(.); require "t/util.pm"; require "stow"; } +use strict; +use warnings; -use Test::More tests => 20; +use testutil; + +use Test::More tests => 21; use Test::Output; use English qw(-no_match_vars); -### setup -eval { remove_dir('t/target'); }; -eval { remove_dir('t/stow'); }; -make_dir('t/target'); -make_dir('t/stow'); - -chdir 't/target'; -$Stow_Path= '../stow'; +make_fresh_stow_and_target_dirs(); +cd('t/target'); # Note that each of the following tests use a distinct set of files +my $stow; +my @conflicts; + # # unstow a simple tree minimally # - -reset_state(); +$stow = new_Stow(); make_dir('../stow/pkg1/bin1'); make_file('../stow/pkg1/bin1/file1'); -make_link('bin1','../stow/pkg1/bin1'); +make_link('bin1', '../stow/pkg1/bin1'); -unstow_contents('../stow/pkg1','.'); -process_tasks(); +$stow->plan_unstow('pkg1'); +$stow->process_tasks(); ok( - scalar(@Conflicts) == 0 && + scalar($stow->get_conflicts) == 0 && -f '../stow/pkg1/bin1/file1' && ! -e 'bin1' => 'unstow a simple tree' ); @@ -43,16 +41,16 @@ ok( # # unstow a simple tree from an existing directory # -reset_state(); +$stow = new_Stow(); make_dir('lib2'); make_dir('../stow/pkg2/lib2'); make_file('../stow/pkg2/lib2/file2'); make_link('lib2/file2', '../../stow/pkg2/lib2/file2'); -unstow_contents('../stow/pkg2','.'); -process_tasks(); +$stow->plan_unstow('pkg2'); +$stow->process_tasks(); ok( - scalar(@Conflicts) == 0 && + scalar($stow->get_conflicts) == 0 && -f '../stow/pkg2/lib2/file2' && -d 'lib2' => 'unstow simple tree from a pre-existing directory' ); @@ -60,7 +58,7 @@ ok( # # fold tree after unstowing # -reset_state(); +$stow = new_Stow(); make_dir('bin3'); @@ -71,10 +69,10 @@ make_link('bin3/file3a' => '../../stow/pkg3a/bin3/file3a'); # emulate stow make_dir('../stow/pkg3b/bin3'); make_file('../stow/pkg3b/bin3/file3b'); make_link('bin3/file3b' => '../../stow/pkg3b/bin3/file3b'); # emulate stow -unstow_contents('../stow/pkg3b', '.'); -process_tasks(); +$stow->plan_unstow('pkg3b'); +$stow->process_tasks(); ok( - scalar(@Conflicts) == 0 && + scalar($stow->get_conflicts) == 0 && -l 'bin3' && readlink('bin3') eq '../stow/pkg3a/bin3' => 'fold tree after unstowing' @@ -83,17 +81,17 @@ ok( # # existing link is owned by stow but is invalid so it gets removed anyway # -reset_state(); +$stow = new_Stow(); make_dir('bin4'); make_dir('../stow/pkg4/bin4'); make_file('../stow/pkg4/bin4/file4'); make_link('bin4/file4', '../../stow/pkg4/bin4/does-not-exist'); -unstow_contents('../stow/pkg4', '.'); -process_tasks(); +$stow->plan_unstow('pkg4'); +$stow->process_tasks(); ok( - scalar(@Conflicts) == 0 && + scalar($stow->get_conflicts) == 0 && ! -e 'bin4/file4' => q(remove invalid link owned by stow) ); @@ -101,20 +99,22 @@ ok( # # Existing link is not owned by stow # -reset_state(); +$stow = new_Stow(); make_dir('../stow/pkg5/bin5'); make_link('bin5', '../not-stow'); -unstow_contents('../stow/pkg5', '.'); +$stow->plan_unstow('pkg5'); +@conflicts = $stow->get_conflicts; like( - $Conflicts[-1], qr(CONFLICT:.*existing target is not owned by stow) + $conflicts[-1], qr(CONFLICT:.*existing target is not owned by stow) => q(existing link not owned by stow) ); + # # Target already exists, is owned by stow, but points to a different package # -reset_state(); +$stow = new_Stow(); make_dir('bin6'); make_dir('../stow/pkg6a/bin6'); @@ -124,10 +124,10 @@ make_link('bin6/file6', '../../stow/pkg6a/bin6/file6'); make_dir('../stow/pkg6b/bin6'); make_file('../stow/pkg6b/bin6/file6'); -unstow_contents('../stow/pkg6b', '.'); +$stow->plan_unstow('pkg6b'); ok( - scalar(@Conflicts) == 0 && - -l 'bin6/file6' && + scalar($stow->get_conflicts) == 0 && + -l 'bin6/file6' && readlink('bin6/file6') eq '../../stow/pkg6a/bin6/file6' => q(ignore existing link that points to a different package) ); @@ -135,24 +135,22 @@ ok( # # Don't unlink anything under the stow directory # -reset_state(); - make_dir('stow'); # make out stow dir a subdir of target -$Stow_Path = 'stow'; +$stow = new_Stow(dir => 'stow'); # emulate stowing into ourself (bizarre corner case or accident) make_dir('stow/pkg7a/stow/pkg7b'); make_file('stow/pkg7a/stow/pkg7b/file7b'); make_link('stow/pkg7b', '../stow/pkg7a/stow/pkg7b'); -unstow_contents('stow/pkg7b', '.'); +$stow->plan_unstow('pkg7b'); stderr_like( - sub { process_tasks(); }, + sub { $stow->process_tasks(); }, qr/There are no outstanding operations to perform/, 'no tasks to process when unstowing pkg7b' ); ok( - scalar(@Conflicts) == 0 && + scalar($stow->get_conflicts) == 0 && -l 'stow/pkg7b' && readlink('stow/pkg7b') eq '../stow/pkg7a/stow/pkg7b' => q(don't unlink any nodes under the stow directory) @@ -161,10 +159,7 @@ ok( # # Don't unlink any nodes under another stow directory # -reset_state(); - -make_dir('stow'); # make out stow dir a subdir of target -$Stow_Path = 'stow'; +$stow = new_Stow(dir => 'stow'); make_dir('stow2'); # make our alternate stow dir a subdir of target make_file('stow2/.stow'); @@ -174,14 +169,14 @@ make_dir('stow/pkg8a/stow2/pkg8b'); make_file('stow/pkg8a/stow2/pkg8b/file8b'); make_link('stow2/pkg8b', '../stow/pkg8a/stow2/pkg8b'); -unstow_contents('stow/pkg8a', '.'); +$stow->plan_unstow('pkg8a'); stderr_like( - sub { process_tasks(); }, + sub { $stow->process_tasks(); }, qr/There are no outstanding operations to perform/, 'no tasks to process when unstowing pkg8a' ); ok( - scalar(@Conflicts) == 0 && + scalar($stow->get_conflicts) == 0 && -l 'stow2/pkg8b' && readlink('stow2/pkg8b') eq '../stow/pkg8a/stow2/pkg8b' => q(don't unlink any nodes under another stow directory) @@ -190,10 +185,8 @@ ok( # # overriding already stowed documentation # -reset_state(); +$stow = new_Stow(override => ['man9', 'info9']); make_file('stow/.stow'); -$Stow_Path = '../stow'; -$Option{'override'} = ['man9', 'info9']; make_dir('../stow/pkg9a/man9/man1'); make_file('../stow/pkg9a/man9/man1/file9.1'); @@ -202,10 +195,10 @@ make_link('man9/man1/file9.1' => '../../../stow/pkg9a/man9/man1/file9.1'); # emu make_dir('../stow/pkg9b/man9/man1'); make_file('../stow/pkg9b/man9/man1/file9.1'); -unstow_contents('../stow/pkg9b', '.'); -process_tasks(); +$stow->plan_unstow('pkg9b'); +$stow->process_tasks(); ok( - scalar(@Conflicts) == 0 && + scalar($stow->get_conflicts) == 0 && !-l 'man9/man1/file9.1' => 'overriding existing documentation files' ); @@ -213,8 +206,7 @@ ok( # # deferring to already stowed documentation # -reset_state(); -$Option{'defer'} = ['man10', 'info10']; +$stow = new_Stow(defer => ['man10', 'info10']); make_dir('../stow/pkg10a/man10/man1'); make_file('../stow/pkg10a/man10/man1/file10a.1'); @@ -229,14 +221,14 @@ make_link('man10/man1/file10b.1' => '../../../stow/pkg10b/man10/man1/file10b.1' make_dir('../stow/pkg10c/man10/man1'); make_file('../stow/pkg10c/man10/man1/file10a.1'); -unstow_contents('../stow/pkg10c', '.'); +$stow->plan_unstow('pkg10c'); stderr_like( - sub { process_tasks(); }, + sub { $stow->process_tasks(); }, qr/There are no outstanding operations to perform/, 'no tasks to process when unstowing pkg10c' ); ok( - scalar(@Conflicts) == 0 && + scalar($stow->get_conflicts) == 0 && readlink('man10/man1/file10a.1') eq '../../../stow/pkg10a/man10/man1/file10a.1' => 'defer to existing documentation files' ); @@ -244,8 +236,7 @@ ok( # # Ignore temp files # -reset_state(); -$Option{'ignore'} = ['~', '\.#.*']; +$stow = new_Stow(ignore => ['~', '\.#.*']); make_dir('../stow/pkg12/man12/man1'); make_file('../stow/pkg12/man12/man1/file12.1'); @@ -254,10 +245,10 @@ make_file('../stow/pkg12/man12/man1/.#file12.1'); make_dir('man12/man1'); make_link('man12/man1/file12.1' => '../../../stow/pkg12/man12/man1/file12.1'); -unstow_contents('../stow/pkg12', '.'); -process_tasks(); +$stow->plan_unstow('pkg12'); +$stow->process_tasks(); ok( - scalar(@Conflicts) == 0 && + scalar($stow->get_conflicts) == 0 && !-e 'man12/man1/file12.1' => 'ignore temp files' ); @@ -265,15 +256,15 @@ ok( # # Unstow an already unstowed package # -reset_state(); -unstow_contents('../stow/pkg12', '.'); +$stow = new_Stow(); +$stow->plan_unstow('pkg12'); stderr_like( - sub { process_tasks(); }, + sub { $stow->process_tasks(); }, qr/There are no outstanding operations to perform/, 'no tasks to process when unstowing pkg12' ); ok( - scalar(@Conflicts) == 0 + scalar($stow->get_conflicts) == 0 => 'unstow already unstowed package pkg12' ); @@ -284,15 +275,15 @@ ok( eval { remove_dir('t/target'); }; mkdir('t/target'); -reset_state(); -unstow_contents('../stow/pkg12', '.'); +$stow = new_Stow(); +$stow->plan_unstow('pkg12'); stderr_like( - sub { process_tasks(); }, + sub { $stow->process_tasks(); }, qr/There are no outstanding operations to perform/, 'no tasks to process when unstowing pkg12 which was never stowed' ); ok( - scalar(@Conflicts) == 0 + scalar($stow->get_conflicts) == 0 => 'unstow never stowed package pkg12' ); @@ -301,19 +292,38 @@ ok( # make_file('man12/man1/file12.1'); -reset_state(); -unstow_contents('../stow/pkg12', '.'); +$stow = new_Stow(); +$stow->plan_unstow('pkg12'); stderr_like( - sub { process_tasks(); }, + sub { $stow->process_tasks(); }, qr/There are no outstanding operations to perform/, 'no tasks to process when unstowing pkg12 for third time' ); +@conflicts = $stow->get_conflicts; ok( - scalar(@Conflicts) == 1 && - $Conflicts[0] =~ m!existing target is neither a link nor a directory: man12/man1/file12\.1! + @conflicts == 1 && + $conflicts[0] =~ m!existing target is neither a link nor a directory: man12/man1/file12\.1! => 'unstow pkg12 for third time' ); +# +# unstow a simple tree minimally when cwd isn't target +# +cd('../..'); +$stow = new_Stow(dir => 't/stow', target => 't/target'); + +make_dir('t/stow/pkg13/bin13'); +make_file('t/stow/pkg13/bin13/file13'); +make_link('t/target/bin13', '../stow/pkg13/bin13'); + +$stow->plan_unstow('pkg13'); +$stow->process_tasks(); +ok( + scalar($stow->get_conflicts) == 0 && + -f 't/stow/pkg13/bin13/file13' && ! -e 't/target/bin13' + => 'unstow a simple tree' +); + # Todo # diff --git a/t/unstow_contents_orig.t b/t/unstow_contents_orig.t index d41d9c1..e120480 100755 --- a/t/unstow_contents_orig.t +++ b/t/unstow_contents_orig.t @@ -4,38 +4,37 @@ # Testing unstow_contents_orig() # -# load as a library -BEGIN { use lib qw(.); require "t/util.pm"; require "stow"; } +use strict; +use warnings; -use Test::More tests => 20; +use testutil; + +use Test::More tests => 21; use Test::Output; use English qw(-no_match_vars); -### setup -eval { remove_dir('t/target'); }; -eval { remove_dir('t/stow'); }; -make_dir('t/target'); -make_dir('t/stow'); - -chdir 't/target'; -$Stow_Path= '../stow'; +make_fresh_stow_and_target_dirs(); +cd('t/target'); # Note that each of the following tests use a distinct set of files +my $stow; +my @conflicts; + # # unstow a simple tree minimally # -reset_state(); +$stow = new_compat_Stow(); make_dir('../stow/pkg1/bin1'); make_file('../stow/pkg1/bin1/file1'); -make_link('bin1','../stow/pkg1/bin1'); +make_link('bin1', '../stow/pkg1/bin1'); -unstow_contents_orig('../stow/pkg1','.'); -process_tasks(); +$stow->plan_unstow('pkg1'); +$stow->process_tasks(); ok( - scalar(@Conflicts) == 0 && + scalar($stow->get_conflicts) == 0 && -f '../stow/pkg1/bin1/file1' && ! -e 'bin1' => 'unstow a simple tree' ); @@ -43,16 +42,16 @@ ok( # # unstow a simple tree from an existing directory # -reset_state(); +$stow = new_compat_Stow(); make_dir('lib2'); make_dir('../stow/pkg2/lib2'); make_file('../stow/pkg2/lib2/file2'); make_link('lib2/file2', '../../stow/pkg2/lib2/file2'); -unstow_contents_orig('../stow/pkg2','.'); -process_tasks(); +$stow->plan_unstow('pkg2'); +$stow->process_tasks(); ok( - scalar(@Conflicts) == 0 && + scalar($stow->get_conflicts) == 0 && -f '../stow/pkg2/lib2/file2' && -d 'lib2' => 'unstow simple tree from a pre-existing directory' ); @@ -60,7 +59,7 @@ ok( # # fold tree after unstowing # -reset_state(); +$stow = new_compat_Stow(); make_dir('bin3'); @@ -71,10 +70,10 @@ make_link('bin3/file3a' => '../../stow/pkg3a/bin3/file3a'); # emulate stow make_dir('../stow/pkg3b/bin3'); make_file('../stow/pkg3b/bin3/file3b'); make_link('bin3/file3b' => '../../stow/pkg3b/bin3/file3b'); # emulate stow -unstow_contents_orig('../stow/pkg3b', '.'); -process_tasks(); +$stow->plan_unstow('pkg3b'); +$stow->process_tasks(); ok( - scalar(@Conflicts) == 0 && + scalar($stow->get_conflicts) == 0 && -l 'bin3' && readlink('bin3') eq '../stow/pkg3a/bin3' => 'fold tree after unstowing' @@ -83,17 +82,17 @@ ok( # # existing link is owned by stow but is invalid so it gets removed anyway # -reset_state(); +$stow = new_compat_Stow(); make_dir('bin4'); make_dir('../stow/pkg4/bin4'); make_file('../stow/pkg4/bin4/file4'); make_link('bin4/file4', '../../stow/pkg4/bin4/does-not-exist'); -unstow_contents_orig('../stow/pkg4', '.'); -process_tasks(); +$stow->plan_unstow('pkg4'); +$stow->process_tasks(); ok( - scalar(@Conflicts) == 0 && + scalar($stow->get_conflicts) == 0 && ! -e 'bin4/file4' => q(remove invalid link owned by stow) ); @@ -101,12 +100,12 @@ ok( # # Existing link is not owned by stow # -reset_state(); +$stow = new_compat_Stow(); make_dir('../stow/pkg5/bin5'); make_link('bin5', '../not-stow'); -unstow_contents_orig('../stow/pkg5', '.'); +$stow->plan_unstow('pkg5'); #like( # $Conflicts[-1], qr(CONFLICT:.*can't unlink.*not owned by stow) # => q(existing link not owned by stow) @@ -115,10 +114,11 @@ ok( -l 'bin5' && readlink('bin5') eq '../not-stow' => q(existing link not owned by stow) ); + # # Target already exists, is owned by stow, but points to a different package # -reset_state(); +$stow = new_compat_Stow(); make_dir('bin6'); make_dir('../stow/pkg6a/bin6'); @@ -128,9 +128,9 @@ make_link('bin6/file6', '../../stow/pkg6a/bin6/file6'); make_dir('../stow/pkg6b/bin6'); make_file('../stow/pkg6b/bin6/file6'); -unstow_contents_orig('../stow/pkg6b', '.'); +$stow->plan_unstow('pkg6b'); ok( - scalar(@Conflicts) == 0 && + scalar($stow->get_conflicts) == 0 && -l 'bin6/file6' && readlink('bin6/file6') eq '../../stow/pkg6a/bin6/file6' => q(ignore existing link that points to a different package) @@ -139,24 +139,22 @@ ok( # # Don't unlink anything under the stow directory # -reset_state(); - make_dir('stow'); # make out stow dir a subdir of target -$Stow_Path = 'stow'; +$stow = new_compat_Stow(dir => 'stow'); # emulate stowing into ourself (bizarre corner case or accident) make_dir('stow/pkg7a/stow/pkg7b'); make_file('stow/pkg7a/stow/pkg7b/file7b'); make_link('stow/pkg7b', '../stow/pkg7a/stow/pkg7b'); -unstow_contents_orig('stow/pkg7b', '.'); +$stow->plan_unstow('pkg7b'); stderr_like( - sub { process_tasks(); }, + sub { $stow->process_tasks(); }, qr/There are no outstanding operations to perform/, 'no tasks to process when unstowing pkg7b' ); ok( - scalar(@Conflicts) == 0 && + scalar($stow->get_conflicts) == 0 && -l 'stow/pkg7b' && readlink('stow/pkg7b') eq '../stow/pkg7a/stow/pkg7b' => q(don't unlink any nodes under the stow directory) @@ -165,10 +163,7 @@ ok( # # Don't unlink any nodes under another stow directory # -reset_state(); - -make_dir('stow'); # make out stow dir a subdir of target -$Stow_Path = 'stow'; +$stow = new_compat_Stow(dir => 'stow'); make_dir('stow2'); # make our alternate stow dir a subdir of target make_file('stow2/.stow'); @@ -178,14 +173,14 @@ make_dir('stow/pkg8a/stow2/pkg8b'); make_file('stow/pkg8a/stow2/pkg8b/file8b'); make_link('stow2/pkg8b', '../stow/pkg8a/stow2/pkg8b'); -unstow_contents_orig('stow/pkg8a', '.'); +$stow->plan_unstow('pkg8a'); stderr_like( - sub { process_tasks(); }, + sub { $stow->process_tasks(); }, qr/There are no outstanding operations to perform/, 'no tasks to process when unstowing pkg8a' ); ok( - scalar(@Conflicts) == 0 && + scalar($stow->get_conflicts) == 0 && -l 'stow2/pkg8b' && readlink('stow2/pkg8b') eq '../stow/pkg8a/stow2/pkg8b' => q(don't unlink any nodes under another stow directory) @@ -194,10 +189,8 @@ ok( # # overriding already stowed documentation # -reset_state(); +$stow = new_compat_Stow(override => ['man9', 'info9']); make_file('stow/.stow'); -$Stow_Path = '../stow'; -$Option{'override'} = ['man9', 'info9']; make_dir('../stow/pkg9a/man9/man1'); make_file('../stow/pkg9a/man9/man1/file9.1'); @@ -206,10 +199,10 @@ make_link('man9/man1/file9.1' => '../../../stow/pkg9a/man9/man1/file9.1'); # emu make_dir('../stow/pkg9b/man9/man1'); make_file('../stow/pkg9b/man9/man1/file9.1'); -unstow_contents_orig('../stow/pkg9b', '.'); -process_tasks(); +$stow->plan_unstow('pkg9b'); +$stow->process_tasks(); ok( - scalar(@Conflicts) == 0 && + scalar($stow->get_conflicts) == 0 && !-l 'man9/man1/file9.1' => 'overriding existing documentation files' ); @@ -217,8 +210,7 @@ ok( # # deferring to already stowed documentation # -reset_state(); -$Option{'defer'} = ['man10', 'info10']; +$stow = new_compat_Stow(defer => ['man10', 'info10']); make_dir('../stow/pkg10a/man10/man1'); make_file('../stow/pkg10a/man10/man1/file10a.1'); @@ -233,14 +225,14 @@ make_link('man10/man1/file10b.1' => '../../../stow/pkg10b/man10/man1/file10b.1' make_dir('../stow/pkg10c/man10/man1'); make_file('../stow/pkg10c/man10/man1/file10a.1'); -unstow_contents_orig('../stow/pkg10c', '.'); +$stow->plan_unstow('pkg10c'); stderr_like( - sub { process_tasks(); }, + sub { $stow->process_tasks(); }, qr/There are no outstanding operations to perform/, 'no tasks to process when unstowing pkg10c' ); ok( - scalar(@Conflicts) == 0 && + scalar($stow->get_conflicts) == 0 && readlink('man10/man1/file10a.1') eq '../../../stow/pkg10a/man10/man1/file10a.1' => 'defer to existing documentation files' ); @@ -248,8 +240,7 @@ ok( # # Ignore temp files # -reset_state(); -$Option{'ignore'} = ['~', '\.#.*']; +$stow = new_compat_Stow(ignore => ['~', '\.#.*']); make_dir('../stow/pkg12/man12/man1'); make_file('../stow/pkg12/man12/man1/file12.1'); @@ -258,10 +249,10 @@ make_file('../stow/pkg12/man12/man1/.#file12.1'); make_dir('man12/man1'); make_link('man12/man1/file12.1' => '../../../stow/pkg12/man12/man1/file12.1'); -unstow_contents_orig('../stow/pkg12', '.'); -process_tasks(); +$stow->plan_unstow('pkg12'); +$stow->process_tasks(); ok( - scalar(@Conflicts) == 0 && + scalar($stow->get_conflicts) == 0 && !-e 'man12/man1/file12.1' => 'ignore temp files' ); @@ -269,15 +260,15 @@ ok( # # Unstow an already unstowed package # -reset_state(); -unstow_contents_orig('../stow/pkg12', '.'); +$stow = new_compat_Stow(); +$stow->plan_unstow('pkg12'); stderr_like( - sub { process_tasks(); }, + sub { $stow->process_tasks(); }, qr/There are no outstanding operations to perform/, 'no tasks to process when unstowing pkg12' ); ok( - scalar(@Conflicts) == 0 + scalar($stow->get_conflicts) == 0 => 'unstow already unstowed package pkg12' ); @@ -288,15 +279,15 @@ ok( eval { remove_dir('t/target'); }; mkdir('t/target'); -reset_state(); -unstow_contents_orig('../stow/pkg12', '.'); +$stow = new_compat_Stow(); +$stow->plan_unstow('pkg12'); stderr_like( - sub { process_tasks(); }, + sub { $stow->process_tasks(); }, qr/There are no outstanding operations to perform/, 'no tasks to process when unstowing pkg12 which was never stowed' ); ok( - scalar(@Conflicts) == 0 + scalar($stow->get_conflicts) == 0 => 'unstow never stowed package pkg12' ); @@ -305,19 +296,38 @@ ok( # make_file('man12/man1/file12.1'); -reset_state(); -unstow_contents('../stow/pkg12', '.'); +$stow = new_compat_Stow(); +$stow->plan_unstow('pkg12'); stderr_like( - sub { process_tasks(); }, + sub { $stow->process_tasks(); }, qr/There are no outstanding operations to perform/, 'no tasks to process when unstowing pkg12 for third time' ); +@conflicts = $stow->get_conflicts; ok( - scalar(@Conflicts) == 1 && - $Conflicts[0] =~ m!existing target is neither a link nor a directory: man12/man1/file12\.1! + @conflicts == 1 && + $conflicts[0] =~ m!existing target is neither a link nor a directory: man12/man1/file12\.1! => 'unstow pkg12 for third time' ); +# +# unstow a simple tree minimally when cwd isn't target +# +cd('../..'); +$stow = new_Stow(dir => 't/stow', target => 't/target'); + +make_dir('t/stow/pkg13/bin13'); +make_file('t/stow/pkg13/bin13/file13'); +make_link('t/target/bin13', '../stow/pkg13/bin13'); + +$stow->plan_unstow('pkg13'); +$stow->process_tasks(); +ok( + scalar($stow->get_conflicts) == 0 && + -f 't/stow/pkg13/bin13/file13' && ! -e 't/target/bin13' + => 'unstow a simple tree' +); + # Todo # From 382ad5c58d70f957c0ae07349af2aebbcf71da4f Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Mon, 21 Nov 2011 14:07:39 +0000 Subject: [PATCH 053/482] Add myself (Adam) to AUTHORS and THANKS ;-) --- AUTHORS | 5 +++++ THANKS | 1 + 2 files changed, 6 insertions(+) diff --git a/AUTHORS b/AUTHORS index c2f7fd5..b2ca1ed 100644 --- a/AUTHORS +++ b/AUTHORS @@ -32,4 +32,9 @@ Austin Wood and Chris Hoobin helped clean up the documentation for version 2 and created the texi2man script. +Adam Spiers refactored the backend code into new +Stow.pm and Stow/Util.pm modules providing an OO interface, tightened +up the test suite, added support for `make test' and distribution via +CPAN, and cleaned up numerous other minor issues. + Stow is currently maintained by Troy Mill. diff --git a/THANKS b/THANKS index e874eb1..f40e883 100644 --- a/THANKS +++ b/THANKS @@ -20,3 +20,4 @@ Geoffrey Giesemann Emil Mikulic Austin Wood Christopher Hoobin +Adam Spiers From 58625800eed76e9d4a5c6d003ef0c16d5b8dbb83 Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Mon, 21 Nov 2011 13:59:36 +0000 Subject: [PATCH 054/482] Reorganise more files into subdirectories and add CPAN support via Module::Build --- Build.PL | 58 ++++++++++++++++++++ MANIFEST | 46 ++++++++++++++++ MANIFEST.SKIP | 78 +++++++++++++++++++++++++++ META.json | 52 ++++++++++++++++++ META.yml | 31 +++++++++++ Makefile.am | 30 +++++++---- install-sh => automake/install-sh | 0 mdate-sh => automake/mdate-sh | 0 missing => automake/missing | 0 chkstow.in => bin/chkstow.in | 12 ++--- stow.in => bin/stow.in | 26 ++++----- configure.ac | 1 + stow.8 => doc/stow.8 | 2 +- stow.texi => doc/stow.texi | 40 +++++++------- texinfo.tex => doc/texinfo.tex | 88 +++++++++++++++---------------- 15 files changed, 369 insertions(+), 95 deletions(-) create mode 100644 Build.PL create mode 100644 MANIFEST create mode 100644 MANIFEST.SKIP create mode 100644 META.json create mode 100644 META.yml rename install-sh => automake/install-sh (100%) rename mdate-sh => automake/mdate-sh (100%) rename missing => automake/missing (100%) rename chkstow.in => bin/chkstow.in (91%) rename stow.in => bin/stow.in (96%) rename stow.8 => doc/stow.8 (99%) rename stow.texi => doc/stow.texi (99%) rename texinfo.tex => doc/texinfo.tex (99%) diff --git a/Build.PL b/Build.PL new file mode 100644 index 0000000..e5d11c0 --- /dev/null +++ b/Build.PL @@ -0,0 +1,58 @@ +use strict; +use warnings; + +use Module::Build; + +# These are required by the test suite. +use lib "t"; +use lib "bin"; + +my $build = Module::Build->new( + module_name => 'Stow', + keywords => [ qw/stow symlink software package management install/ ], + license => 'gpl', + + # Module::Build forces us to use v1.4 of the CPAN Meta Spec: + # https://rt.cpan.org/Ticket/Display.html?id=71502 + # 'meta-spec' => { + # version => '2.0', + # url => 'http://search.cpan.org/perldoc?CPAN::Meta::Spec', + # }, + meta_add => { + resources => { + license => 'http://www.gnu.org/licenses/gpl-2.0.html' , + homepage => 'https://savannah.gnu.org/projects/stow', + + # Module::Build forces us to use v1.4 of the CPAN Meta Spec: + # https://rt.cpan.org/Ticket/Display.html?id=71502 + # bugtracker => { + # web => 'http://rt.cpan.org/Public/Dist/Display.html?Name=Stow', + # mailto => 'mysqldiff@adamspiers.org', + # }, + #bugtracker => 'http://rt.cpan.org/Public/Dist/Display.html?Name=Stow', + + # Module::Build forces us to use v1.4 of the CPAN Meta Spec: + # https://rt.cpan.org/Ticket/Display.html?id=71502 + # repository => { + # url => 'git:github.com/aspiers/stow.git', + # web => 'http://github.com/aspiers/stow', + # type => 'git', + # }, + repository => 'http://github.com/aspiers/stow', + #repository => 'https://savannah.gnu.org/git/?group=stow', + }, + }, + requires => { + 'perl' => '5.006', + 'Carp' => 0, + 'File::Slurp' => 0, + 'IO::File' => 0, + }, + script_files => [ 'bin/stow' ], + all_from => 'lib/Stow.pm', + configure_requires => { + 'Module::Build' => 0, + }, +); + +$build->create_build_script(); diff --git a/MANIFEST b/MANIFEST new file mode 100644 index 0000000..c063667 --- /dev/null +++ b/MANIFEST @@ -0,0 +1,46 @@ +aclocal.m4 +AUTHORS +automake/install-sh +automake/mdate-sh +automake/missing +automake/stamp-vti +bin/chkstow +bin/chkstow.in +bin/stow +bin/stow.in +Build.PL +ChangeLog +configure +configure.ac +COPYING +doc/stow.8 +doc/stow.info +doc/stow.texi +doc/texinfo.tex +doc/version.texi +INSTALL +lib/Stow.pm +lib/Stow.pm.in +lib/Stow/Util.pm +Makefile.am +Makefile.in +MANIFEST This list of files +NEWS +README +t/chkstow.t +t/cleanup_invalid_links.t +t/defer.t +t/examples.t +t/find_stowed_path.t +t/foldable.t +t/join_paths.t +t/parent.t +t/stow.t +t/stow_contents.t +t/testutil.pm +t/unstow_contents.t +t/unstow_contents_orig.t +THANKS +TODO +META.yml +META.json diff --git a/MANIFEST.SKIP b/MANIFEST.SKIP new file mode 100644 index 0000000..c8beef8 --- /dev/null +++ b/MANIFEST.SKIP @@ -0,0 +1,78 @@ + +#!start included /usr/share/perl5/ExtUtils/MANIFEST.SKIP +# Avoid version control files. +\bRCS\b +\bCVS\b +\bSCCS\b +,v$ +\B\.svn\b +\B\.git\b +\B\.gitignore\b +\b_darcs\b +\B\.cvsignore$ + +# Avoid VMS specific MakeMaker generated files +\bDescrip.MMS$ +\bDESCRIP.MMS$ +\bdescrip.mms$ + +# Avoid Makemaker generated and utility files. +\bMANIFEST\.bak +\bMakefile$ +\bblib/ +\bMakeMaker-\d +\bpm_to_blib\.ts$ +\bpm_to_blib$ +\bblibdirs\.ts$ # 6.18 through 6.25 generated this + +# Avoid Module::Build generated and utility files. +\bBuild$ +\b_build/ +\bBuild.bat$ +\bBuild.COM$ +\bBUILD.COM$ +\bbuild.com$ + +# Avoid temp and backup files. +~$ +\.old$ +\#$ +\b\.# +\.bak$ +\.tmp$ +\.# +\.rej$ + +# Avoid OS-specific files/dirs +# Mac OSX metadata +\B\.DS_Store +# Mac OSX SMB mount metadata files +\B\._ + +# Avoid Devel::Cover files. +\bcover_db\b +#!end included /usr/share/perl5/ExtUtils/MANIFEST.SKIP + +# Avoid configuration metadata file +^MYMETA\. + +# Avoid Module::Build generated and utility files. +\bBuild$ +\bBuild.bat$ +\b_build +\bBuild.COM$ +\bBUILD.COM$ +\bbuild.com$ +^MANIFEST\.SKIP + +# Avoid archives of this distribution +\bStow-[\d\.\_]+ + +# Avoid autotools stuff +^autom4te\.cache/.+$ +^config\.(log|status)$ +^doc/\.dirstamp$ +^doc/stamp-vti$ + +# Avoid test files +^t/(stow|target)/.+$ diff --git a/META.json b/META.json new file mode 100644 index 0000000..c622c81 --- /dev/null +++ b/META.json @@ -0,0 +1,52 @@ +{ + "abstract" : "manage the installation of multiple software packages", + "author" : [ + "unknown" + ], + "dynamic_config" : 1, + "generated_by" : "Module::Build version 0.38, CPAN::Meta::Converter version 2.112621", + "license" : [ + "open_source" + ], + "meta-spec" : { + "url" : "http://search.cpan.org/perldoc?CPAN::Meta::Spec", + "version" : "2" + }, + "name" : "Stow", + "prereqs" : { + "configure" : { + "requires" : { + "Module::Build" : 0 + } + }, + "runtime" : { + "requires" : { + "Carp" : 0, + "File::Slurp" : 0, + "IO::File" : 0, + "perl" : "5.006" + } + } + }, + "provides" : { + "Stow" : { + "file" : "lib/Stow.pm", + "version" : "v2.0.2" + }, + "Stow::Util" : { + "file" : "lib/Stow/Util.pm", + "version" : 0 + } + }, + "release_status" : "stable", + "resources" : { + "homepage" : "https://savannah.gnu.org/projects/stow", + "license" : [ + "http://www.gnu.org/licenses/gpl-2.0.html" + ], + "repository" : { + "url" : "http://github.com/aspiers/stow" + } + }, + "version" : "v2.0.2" +} diff --git a/META.yml b/META.yml new file mode 100644 index 0000000..d1d2748 --- /dev/null +++ b/META.yml @@ -0,0 +1,31 @@ +--- +abstract: 'manage the installation of multiple software packages' +author: + - unknown +build_requires: {} +configure_requires: + Module::Build: 0 +dynamic_config: 1 +generated_by: 'Module::Build version 0.38, CPAN::Meta::Converter version 2.112621' +license: open_source +meta-spec: + url: http://module-build.sourceforge.net/META-spec-v1.4.html + version: 1.4 +name: Stow +provides: + Stow: + file: lib/Stow.pm + version: v2.0.2 + Stow::Util: + file: lib/Stow/Util.pm + version: 0 +requires: + Carp: 0 + File::Slurp: 0 + IO::File: 0 + perl: 5.006 +resources: + homepage: https://savannah.gnu.org/projects/stow + license: http://www.gnu.org/licenses/gpl-2.0.html + repository: http://github.com/aspiers/stow +version: v2.0.2 diff --git a/Makefile.am b/Makefile.am index e72767e..bf11f6d 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1,11 +1,14 @@ ## Process this file with Automake to produce Makefile.in -bin_SCRIPTS = stow chkstow -info_TEXINFOS = stow.texi -dist_man_MANS = stow.8 +dist_bin_SCRIPTS = bin/stow bin/chkstow +info_TEXINFOS = doc/stow.texi +TEXINFO_TEX = doc/texinfo.tex +dist_man_MANS = doc/stow.8 dist_doc_DATA = README pmdir = $(libdir)/perl5 -pm_DATA = lib/Stow.pm lib/Stow/Util.pm +dist_pm_DATA = lib/Stow.pm +pmstowdir = $(pmdir)/Stow +dist_pmstow_DATA = lib/Stow/Util.pm TESTS_ENVIRONMENT=$(PERL) -I $(top_srcdir) TESTS = \ @@ -23,8 +26,13 @@ TESTS = \ t/chkstow.t AUTOMAKE_OPTIONS = dist-shar -EXTRA_DIST = $(TESTS) t/testutil.pm -CLEANFILES = $(bin_SCRIPTS) +CPAN_FILES = MANIFEST MANIFEST.SKIP Build.PL META.yml META.json +EXTRA_DIST = \ + bin/stow.in bin/chkstow.in lib/Stow.pm.in \ + $(TESTS) t/testutil.pm \ + $(TEXINFO_TEX) \ + $(CPAN_FILES) +CLEANFILES = $(bin_SCRIPTS) $(dist_pm_DATA) # clean up files left behind by test suite clean-local: @@ -34,11 +42,11 @@ clean-local: edit = sed -e 's|[@]PERL[@]|$(PERL)|g' \ -e 's|[@]VERSION[@]|$(VERSION)|g' -stow: stow.in Makefile +bin/stow: bin/stow.in Makefile $(edit) < $< > $@ chmod +x $@ -chkstow: chkstow.in Makefile +bin/chkstow: bin/chkstow.in Makefile $(edit) < $< > $@ chmod +x $@ @@ -47,15 +55,15 @@ lib/Stow.pm: lib/Stow.pm.in # The rules for manual.html and manual.texi are only used by # the developer -manual.html: manual.texi +doc/manual.html: doc/manual.texi -rm -f $@ texi2html -expandinfo -menu -monolithic -verbose $< -manual.texi: stow.texi +doc/manual.texi: doc/stow.texi -rm -f $@ cp $< $@ MODULES = lib/Stow.pm lib/Stow/Util.pm -test: stow chkstow $(MODULES) +test: bin/stow bin/chkstow $(MODULES) perl -MTest::Harness -Ilib -It -Ibin -e 'runtests(@ARGV)' t/*.t diff --git a/install-sh b/automake/install-sh similarity index 100% rename from install-sh rename to automake/install-sh diff --git a/mdate-sh b/automake/mdate-sh similarity index 100% rename from mdate-sh rename to automake/mdate-sh diff --git a/missing b/automake/missing similarity index 100% rename from missing rename to automake/missing diff --git a/chkstow.in b/bin/chkstow.in similarity index 91% rename from chkstow.in rename to bin/chkstow.in index 3fe1741..caf50bb 100755 --- a/chkstow.in +++ b/bin/chkstow.in @@ -37,11 +37,11 @@ sub usage { print <<"EOT"; USAGE: chkstow [options] -Options: +Options: -b, --badlinks Report symlinks that point to non-existant files. -a, --aliens Report non-symlinks in the target directory. -l, --list List packages in the target directory. - -t DIR, --target=DIR Set the target directory to DIR (default + -t DIR, --target=DIR Set the target directory to DIR (default is /usr/local) EOT exit(0); @@ -51,7 +51,7 @@ sub check_stow { #my ($Target, $Wanted) = @_; my (%options) = ( - wanted => $Wanted, + wanted => $Wanted, preprocess => \&skip_dirs, ); @@ -81,12 +81,12 @@ sub skip_dirs { # checking for files that do not link to anything sub bad_links { - -l && !-e && print "Bogus link: $File::Find::name\n"; + -l && !-e && print "Bogus link: $File::Find::name\n"; } # checking for files that are not owned by stow -sub aliens { - !-l && !-d && print "Unstowed file: $File::Find::name\n"; +sub aliens { + !-l && !-d && print "Unstowed file: $File::Find::name\n"; } # just list the packages in the the target directory diff --git a/stow.in b/bin/stow.in similarity index 96% rename from stow.in rename to bin/stow.in index 34cb13a..320711a 100755 --- a/stow.in +++ b/bin/stow.in @@ -87,34 +87,34 @@ sub process_options { 'version|V', 'compat|p', 'dir|d=s', 'target|t=s', # clean and pre-compile any regex's at parse time - 'ignore=s' => + 'ignore=s' => sub { # FIXME: do we really need strip_quotes here? my $regex = strip_quotes($_[1]); push @{$options{'ignore'}}, qr($regex\z); }, - 'override=s' => - sub { + 'override=s' => + sub { my $regex = strip_quotes($_[1]); push @{$options{'override'}}, qr(\A$regex); }, - 'defer=s' => - sub { + 'defer=s' => + sub { my $regex = strip_quotes($_[1]); push @{$options{'defer'}}, qr(\A$regex); }, # a little craziness so we can do different actions on the same line: - # a -D, -S, or -R changes the action that will be performed on the + # a -D, -S, or -R changes the action that will be performed on the # package arguments that follow it. 'D|delete' => sub { $action = 'unstow' }, 'S|stow' => sub { $action = 'stow' }, 'R|restow' => sub { $action = 'restow' }, # Handler for non-option arguments - '<>' => + '<>' => sub { if ($action eq 'restow') { push @pkgs_to_unstow, $_[0]; @@ -146,7 +146,7 @@ sub sanitize_path_options { $options->{'dir'} =~ s/ +\z//; } else { - $options->{'dir'} = exists $ENV{STOW_DIR} ? $ENV{STOW_DIR} : getcwd(); + $options->{'dir'} = exists $ENV{STOW_DIR} ? $ENV{STOW_DIR} : getcwd(); } if (exists $options->{'target'}) { @@ -176,7 +176,7 @@ sub check_packages { #===== SUBROUTINE ============================================================ -# Name : get_config_file_options() +# Name : get_config_file_options() # Purpose : search for default settings in any .stowrc files # Parameters: none # Returns : a list of default options @@ -190,7 +190,7 @@ sub get_config_file_options { for my $file ("$ENV{'HOME'}/.stowrc", '.stowrc') { if (-r $file) { warn "Loading defaults from $file\n"; - open my $FILE, '<', $file + open my $FILE, '<', $file or die "Could not open $file for reading\n"; while (my $line = <$FILE>){ chomp $line; @@ -200,13 +200,13 @@ sub get_config_file_options { } } return @defaults; -} +} #===== SUBROUTINE =========================================================== # Name : usage() # Purpose : print program usage message and exit # Parameters: $msg => string to prepend to the usage message -# Returns : n/a +# Returns : n/a # Throws : n/a # Comments : if 'msg' is given, then exit with non-zero status #============================================================================ @@ -255,7 +255,7 @@ sub version { } #===== METHOD ================================================================ -# Name : strip_quotes +# Name : strip_quotes # Purpose : remove matching outer quotes from the given string # Parameters: none # Returns : n/a diff --git a/configure.ac b/configure.ac index 063733e..a9b6fa7 100644 --- a/configure.ac +++ b/configure.ac @@ -2,6 +2,7 @@ dnl Process this file with Autoconf to produce configure dnl AC_INIT([stow], [2.0.2], [bug-stow@gnu.org]) AC_PREREQ([2.61]) +AC_CONFIG_AUX_DIR([automake]) AM_INIT_AUTOMAKE([-Wall -Werror]) AC_PROG_INSTALL diff --git a/stow.8 b/doc/stow.8 similarity index 99% rename from stow.8 rename to doc/stow.8 index 38de9d6..3e59c62 100644 --- a/stow.8 +++ b/doc/stow.8 @@ -146,7 +146,7 @@ The target of a relative symlink is computed starting from the symlink's own directory. Stow only creates relative symlinks. .SH OPTIONS -The stow directory is assumed to be the value of the 'STOW_DIR' environment +The stow directory is assumed to be the value of the 'STOW_DIR' environment variable or if unset the current directory, and the target directory is assumed to be the parent of the current directory (so it is typical to execute diff --git a/stow.texi b/doc/stow.texi similarity index 99% rename from stow.texi rename to doc/stow.texi index 5286e13..79cc3d3 100644 --- a/stow.texi +++ b/doc/stow.texi @@ -129,7 +129,7 @@ remove files in independent packages without confusing them with other files sharing the same file system space. For instance, it is common to install Perl and Emacs in @file{/usr/local}. When one does so, one winds up with the following files@footnote{As of Perl 4.036 and Emacs -19.22.} in @file{/usr/local/man/man1}: +19.22.} in @file{/usr/local/man/man1}: @example a2p.1 @@ -138,7 +138,7 @@ emacs.1 etags.1 h2ph.1 perl.1 -s2p.1 +s2p.1 @end example @noindent @@ -269,7 +269,7 @@ given perl regular expression. For example, using the options @end example @noindent -will cause stow to ignore emacs and CVS backup files. +will cause stow to ignore emacs and CVS backup files. Note that the regular expression is anchored to the end of the filename, because this is what you will want to do most of the time. @@ -299,7 +299,7 @@ a Perl regex. Note that the regular expression is anchored to the beginning of the path relative to the target directory, because this is what you will want to do most -of the time. +of the time. @item --override='' This (repeatable) option forces any file matching the regular expression to be @@ -312,7 +312,7 @@ the following options @noindent will permit stow to overwrite links that point to pre-existing man and info -pages that are owned by stow and would otherwise cause a conflict. +pages that are owned by stow and would otherwise cause a conflict. The regular expression is anchored to the beginning of the path relative to the target directory, because this is what you will want to do most of the time. @@ -321,7 +321,7 @@ the target directory, because this is what you will want to do most of the time. @itemx --no @itemx --simulate Do not perform any operations that modify the file system; in combination with -@samp{-v} can be used to merely show what would happen. +@samp{-v} can be used to merely show what would happen. @item -v @itemx --verbose[=@var{n}] @@ -335,8 +335,8 @@ doing. Verbosity levels are 0, 1, 2, and 3; 0 is the default. Using Scan the whole target tree when unstowing. By default, only directories specified in the @dfn{installation image} are scanned during an unstow operation. Scanning the whole tree can be prohibitive if your target tree is -very large. This option restores the legacy behaviour; however, the -@samp{--badlinks} option may be a better way of ensuring that your +very large. This option restores the legacy behaviour; however, the +@samp{--badlinks} option may be a better way of ensuring that your installation does not have any dangling symlinks. @item -V @@ -377,7 +377,7 @@ The following options are useful for cleaning up your target tree: @item -b @itemx --badlinks Checks target directory for bogus symbolic links. That is, links that point to -non-existent files. +non-existent files. @item -a @itemx --aliens @@ -387,7 +387,7 @@ contain a @file{.stow} file. @item -l @itemx --list -Will display the target package for every symbolic link in the stow target +Will display the target package for every symbolic link in the stow target directory. The following options are deprecated: @end table @@ -398,9 +398,9 @@ The following options are deprecated as of Stow version 2: @itemx --conflicts Print any conflicts that are encountered. This option implies @samp{-n}, and is used to search for all conflicts that might -arise from an actual Stow operation. +arise from an actual Stow operation. -This option is deprecated as conflicts are now printed by default and no +This option is deprecated as conflicts are now printed by default and no operations will be performed if any conflicts are detected. @end table @@ -460,8 +460,8 @@ tree-folding symlink. @cindex unfolding trees The time often comes when a tree-folding symlink has to be undone because another package uses one or more of the folded subdirectories in -its installation image. This operation is called @dfn{splitting open} or -@dfn{unfolding} a folded tree. It involves removing the original symlink from +its installation image. This operation is called @dfn{splitting open} or +@dfn{unfolding} a folded tree. It involves removing the original symlink from the target tree, creating a true directory in its place, and then populating the new directory with symlinks to the newly-installed package @emph{and} to the old package that used the old symlink. For example, suppose that @@ -561,7 +561,7 @@ un-populatable symlink. For complex packages, scanning the stow and target trees in tandem, and deciding whether to make directories or links, split-open or fold directories, -can actually take a long time (a number of seconds). Moreover, an accurate +can actually take a long time (a number of seconds). Moreover, an accurate analysis of potential conflicts requires us to take into account all of these operations. @@ -585,7 +585,7 @@ stow -D emacs-21.3 -S emacs-21.4a @end example @noindent -which will replace emacs-21.3 with emacs-21.4a using a single invocation. +which will replace emacs-21.3 with emacs-21.4a using a single invocation. This is much faster and cleaner than performing two separate invocations of stow, because redundant folding/unfolding operations can be factored out. In @@ -593,7 +593,7 @@ addition, all the operations are calculated and merged before being executed @pxref{Deferred Operation}, so the amount of of time in which GNU Emacs is unavailable is minimised. -You can mix and match any number of actions, for example, +You can mix and match any number of actions, for example, @example stow -S pkg1 pkg2 -D pkg3 pkg4 -S pkg5 -R pkg6 @@ -631,7 +631,7 @@ symlink, and thus cannot remove it). @chapter Target Maintenance From time to time you will need to clean up your target tree. -Stow includes three operational modes that performs checks that +Stow includes three operational modes that performs checks that would generally be too expensive to performed during normal stow execution. @@ -1020,8 +1020,8 @@ the output from the command (preferably verbose output, obtained by adding @samp{--verbose=3} to the Stow command line). @end itemize -If you are really keen, consider developing a minimal test case and creating a -new test. See the @file{t/} for lots of examples. +If you are really keen, consider developing a minimal test case and +creating a new test. See the @file{t/} for lots of examples. Before reporting a bug, please read the manual carefully, especially @ref{Known Bugs}, to see whether you're encountering diff --git a/texinfo.tex b/doc/texinfo.tex similarity index 99% rename from texinfo.tex rename to doc/texinfo.tex index 8083622..f15767d 100644 --- a/texinfo.tex +++ b/doc/texinfo.tex @@ -3,7 +3,7 @@ % Load plain if necessary, i.e., if running under initex. \expandafter\ifx\csname fmtname\endcsname\relax\input plain\fi % -\def\texinfoversion{2006-10-04.17} +\def\texinfoversion{2011-11-21.13} % % Copyright (C) 1985, 1986, 1988, 1990, 1991, 1992, 1993, 1994, 1995, % 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006 Free @@ -310,7 +310,7 @@ % We don't want .vr (or whatever) entries like this: % \entry{{\tt \indexbackslash }acronym}{32}{\code {\acronym}} % "\acronym" won't work when it's read back in; - % it needs to be + % it needs to be % {\code {{\tt \backslashcurfont }acronym} \shipout\vbox{% % Do this early so pdf references go to the beginning of the page. @@ -661,7 +661,7 @@ \def\?{?\spacefactor=\endofsentencespacefactor\space} % @frenchspacing on|off says whether to put extra space after punctuation. -% +% \def\onword{on} \def\offword{off} % @@ -1216,7 +1216,7 @@ where each line of input produces a line of output.} % that's what we do). % double active backslashes. -% +% {\catcode`\@=0 \catcode`\\=\active @gdef@activebackslashdouble{% @catcode`@\=@active @@ -1227,11 +1227,11 @@ where each line of input produces a line of output.} % not active characters. hyperref.dtx (which has the same problem as % us) handles it with this amazing macro to replace tokens. I've % tinkered with it a little for texinfo, but it's definitely from there. -% +% % #1 is the tokens to replace. % #2 is the replacement. % #3 is the control sequence with the string. -% +% \def\HyPsdSubst#1#2#3{% \def\HyPsdReplace##1#1##2\END{% ##1% @@ -1420,7 +1420,7 @@ where each line of input produces a line of output.} % tried to figure out what each command should do in the context % of @url. for now, just make @/ a no-op, that's the only one % people have actually reported a problem with. - % + % \normalturnoffactive \def\@{@}% \let\/=\empty @@ -1547,7 +1547,7 @@ where each line of input produces a line of output.} % Definitions for a main text size of 11pt. This is the default in % Texinfo. -% +% \def\definetextfontsizexi{ % Text fonts (11.2pt, magstep1). \def\textnominalsize{11pt} @@ -1672,7 +1672,7 @@ where each line of input produces a line of output.} % section, chapter, etc., sizes following suit. This is for the GNU % Press printing of the Emacs 22 manual. Maybe other manuals in the % future. Used with @smallbook, which sets the leading to 12pt. -% +% \def\definetextfontsizex{% % Text fonts (10pt). \def\textnominalsize{10pt} @@ -1758,7 +1758,7 @@ where each line of input produces a line of output.} \setfont\secsf\sfbshape{12}{1000} \let\secbf\secrm \setfont\secsc\scbshape{10}{\magstep1} -\font\seci=cmmi12 +\font\seci=cmmi12 \font\secsy=cmsy10 scaled \magstep1 % Subsection fonts (10pt). @@ -1799,7 +1799,7 @@ where each line of input produces a line of output.} % We provide the user-level command % @fonttextsize 10 % (or 11) to redefine the text font size. pt is assumed. -% +% \def\xword{10} \def\xiword{11} % @@ -1809,7 +1809,7 @@ where each line of input produces a line of output.} % % Set \globaldefs so that documents can use this inside @tex, since % makeinfo 4.8 does not support it, but we need it nonetheless. - % + % \begingroup \globaldefs=1 \ifx\textsizearg\xword \definetextfontsizex \else \ifx\textsizearg\xiword \definetextfontsizexi @@ -2094,7 +2094,7 @@ where each line of input produces a line of output.} % each of the four underscores in __typeof__. This is undesirable in % some manuals, especially if they don't have long identifiers in % general. @allowcodebreaks provides a way to control this. -% +% \newif\ifallowcodebreaks \allowcodebreakstrue \def\keywordtrue{true} @@ -2225,7 +2225,7 @@ where each line of input produces a line of output.} % @acronym for "FBI", "NATO", and the like. % We print this one point size smaller, since it's intended for % all-uppercase. -% +% \def\acronym#1{\doacronym #1,,\finish} \def\doacronym#1,#2,#3\finish{% {\selectfonts\lsize #1}% @@ -2237,7 +2237,7 @@ where each line of input produces a line of output.} % @abbr for "Comput. J." and the like. % No font change, but don't do end-of-sentence spacing. -% +% \def\abbr#1{\doabbr #1,,\finish} \def\doabbr#1,#2,#3\finish{% {\plainfrenchspacing #1}% @@ -2256,43 +2256,43 @@ where each line of input produces a line of output.} % Theiling, which support regular, slanted, bold and bold slanted (and % "outlined" (blackboard board, sort of) versions, which we don't need). % It is available from http://www.ctan.org/tex-archive/fonts/eurosym. -% +% % Although only regular is the truly official Euro symbol, we ignore % that. The Euro is designed to be slightly taller than the regular % font height. -% +% % feymr - regular % feymo - slanted % feybr - bold % feybo - bold slanted -% +% % There is no good (free) typewriter version, to my knowledge. % A feymr10 euro is ~7.3pt wide, while a normal cmtt10 char is ~5.25pt wide. % Hmm. -% +% % Also doesn't work in math. Do we need to do math with euro symbols? % Hope not. -% -% +% +% \def\euro{{\eurofont e}} \def\eurofont{% % We set the font at each command, rather than predefining it in % \textfonts and the other font-switching commands, so that % installations which never need the symbol don't have to have the % font installed. - % + % % There is only one designed size (nominal 10pt), so we always scale % that to the current nominal size. - % + % % By the way, simply using "at 1em" works for cmr10 and the like, but % does not work for cmbx10 and other extended/shrunken fonts. - % + % \def\eurosize{\csname\curfontsize nominalsize\endcsname}% % - \ifx\curfontstyle\bfstylename + \ifx\curfontstyle\bfstylename % bold: \font\thiseurofont = \ifusingit{feybo10}{feybr10} at \eurosize - \else + \else % regular: \font\thiseurofont = \ifusingit{feymo10}{feymr10} at \eurosize \fi @@ -2316,7 +2316,7 @@ where each line of input produces a line of output.} % Laurent Siebenmann reports \Orb undefined with: % Textures 1.7.7 (preloaded format=plain 93.10.14) (68K) 16 APR 2004 02:38 % so we'll define it if necessary. -% +% \ifx\Orb\undefined \def\Orb{\mathhexbox20D} \fi @@ -2632,7 +2632,7 @@ where each line of input produces a line of output.} % cause the example and the item to crash together. So we use this % bizarre value of 10001 as a signal to \aboveenvbreak to insert % \parskip glue after all. Section titles are handled this way also. - % + % \penalty 10001 \endgroup \itemxneedsnegativevskipfalse @@ -3428,7 +3428,7 @@ where each line of input produces a line of output.} % processing continues to some further point. On the other hand, it % seems \endinput does not hurt in the printed index arg, since that % is still getting written without apparent harm. - % + % % Sample source (mac-idx3.tex, reported by Graham Percival to % help-texinfo, 22may06): % @macro funindex {WORD} @@ -3436,12 +3436,12 @@ where each line of input produces a line of output.} % @end macro % ... % @funindex commtest - % + % % The above is not enough to reproduce the bug, but it gives the flavor. - % + % % Sample whatsit resulting: % .@write3{\entry{xyz}{@folio }{@code {xyz@endinput }}} - % + % % So: \let\endinput = \empty % @@ -3677,11 +3677,11 @@ where each line of input produces a line of output.} % makeinfo does not expand macros in the argument to @deffn, which ends up % writing an index entry, and texindex isn't prepared for an index sort entry % that starts with \. - % + % % Since macro invocations are followed by braces, we can just redefine them % to take a single TeX argument. The case of a macro invocation that % goes to end-of-line is not handled. - % + % \macrolist } @@ -3807,7 +3807,7 @@ where each line of input produces a line of output.} % to re-insert the same penalty (values >10000 are used for various % signals); since we just inserted a non-discardable item, any % following glue (such as a \parskip) would be a breakpoint. For example: - % + % % @deffn deffn-whatever % @vindex index-whatever % Description. @@ -4759,11 +4759,11 @@ where each line of input produces a line of output.} % glue accumulate. (Not a breakpoint because it's preceded by a % discardable item.) \vskip-\parskip - % + % % This is purely so the last item on the list is a known \penalty > % 10000. This is so \startdefun can avoid allowing breakpoints after % section headings. Otherwise, it would insert a valid breakpoint between: - % + % % @section sec-whatever % @deffn def-whatever \penalty 10001 @@ -4821,7 +4821,7 @@ where each line of input produces a line of output.} % These characters do not print properly in the Computer Modern roman % fonts, so we must take special care. This is more or less redundant % with the Texinfo input format setup at the end of this file. -% +% \def\activecatcodes{% \catcode`\"=\active \catcode`\$=\active @@ -5416,8 +5416,8 @@ where each line of input produces a line of output.} % from cmtt (char 0x0d). The undirected quote is ugly, so don't make it % the default, but it works for pasting with more pdf viewers (at least % evince), the lilypond developers report. xpdf does work with the -% regular 0x27. -% +% regular 0x27. +% \def\codequoteright{% \expandafter\ifx\csname SETcodequoteundirected\endcsname\relax '% @@ -5429,7 +5429,7 @@ where each line of input produces a line of output.} % and a similar option for the left quote char vs. a grave accent. % Modern fonts display ASCII 0x60 as a grave accent, so some people like % the code environments to do likewise. -% +% \def\codequoteleft{% \expandafter\ifx\csname SETcodequotebacktick\endcsname\relax `% @@ -5572,7 +5572,7 @@ where each line of input produces a line of output.} % by \defargscommonending, instead of 10000, since the sectioning % commands also insert a nobreak penalty, and we don't want to allow % a break between a section heading and a defun. - % + % \ifnum\lastpenalty=10002 \penalty2000 \fi % % Similarly, after a section heading, do not allow a break. @@ -5950,7 +5950,7 @@ where each line of input produces a line of output.} % This does \let #1 = #2, with \csnames; that is, % \let \csname#1\endcsname = \csname#2\endcsname % (except of course we have to play expansion games). -% +% \def\cslet#1#2{% \expandafter\let \csname#1\expandafter\endcsname @@ -7420,7 +7420,7 @@ should work if nowhere else does.} % Same as @turnoffactive except outputs \ as {\tt\char`\\} instead of % the literal character `\'. -% +% @def@normalturnoffactive{% @let\=@normalbackslash @let"=@normaldoublequote From a84ba4c16db0a8ec991184ace41748c85b4879ad Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Thu, 24 Nov 2011 16:52:50 +0000 Subject: [PATCH 055/482] Convert man page to POD format which is easier to maintain within stow.in. --- .gitignore | 1 + Makefile.am | 5 +- bin/stow.in | 385 +++++++++++++++++++++++++++++++++++++++++++- doc/stow.8 | 449 ---------------------------------------------------- 4 files changed, 388 insertions(+), 452 deletions(-) delete mode 100644 doc/stow.8 diff --git a/.gitignore b/.gitignore index fffadc6..3653e53 100644 --- a/.gitignore +++ b/.gitignore @@ -10,3 +10,4 @@ stow.info t/target/ version.texi lib/Stow.pm +doc/stow.8 diff --git a/Makefile.am b/Makefile.am index bf11f6d..07e8a69 100644 --- a/Makefile.am +++ b/Makefile.am @@ -50,7 +50,7 @@ bin/chkstow: bin/chkstow.in Makefile $(edit) < $< > $@ chmod +x $@ -lib/Stow.pm: lib/Stow.pm.in +lib/Stow.pm: lib/Stow.pm.in Makefile $(edit) < $< > $@ # The rules for manual.html and manual.texi are only used by @@ -63,6 +63,9 @@ doc/manual.texi: doc/stow.texi -rm -f $@ cp $< $@ +doc/stow.8: bin/stow Makefile + pod2man $< > $@ + MODULES = lib/Stow.pm lib/Stow/Util.pm test: bin/stow bin/chkstow $(MODULES) diff --git a/bin/stow.in b/bin/stow.in index 320711a..c10baf7 100755 --- a/bin/stow.in +++ b/bin/stow.in @@ -4,6 +4,7 @@ # Copyright (C) 1993, 1994, 1995, 1996 by Bob Glickstein # Copyright (C) 2000, 2001 Guillaume Morin # Copyright (C) 2007 Kahlil Hodgson +# Copyright (C) 2011 Adam Spiers # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -19,6 +20,386 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +=head1 NAME + +stow - software package installation manager + +=head1 SYNOPSIS + +stow [ options ] package ... + +=head1 DESCRIPTION + +This manual page describes GNU Stow @VERSION@, a program for managing +the installation of software packages. This is not the definitive +documentation for stow; for that, see the info manual. + +Stow is a tool for managing the installation of multiple software +packages in the same run-time directory tree. One historical +difficulty of this task has been the need to administer, upgrade, +install, and remove files in independent packages without confusing +them with other files sharing the same filesystem space. For instance, +it is common to install Perl and Emacs in F. When one +does so, one winds up (as of Perl 4.036 and Emacs 19.22) with the +following files in F: F; F; +F; F; F; F; and F. Now +suppose it's time to uninstall Perl. Which man pages get removed? +Obviously F is one of them, but it should not be the +administrator's responsibility to memorize the ownership of individual +files by separate packages. + +The approach used by Stow is to install each package into its own +tree, then use symbolic links to make it appear as though the files +are installed in the common tree. Administration can be performed in +the package's private tree in isolation from clutter from other +packages. Stow can then be used to update the symbolic links. The +structure of each private tree should reflect the desired structure in +the common tree; i.e. (in the typical case) there should be a F +directory containing executables, a F directory containing +section 1 man pages, and so on. + +Stow was inspired by Carnegie Mellon's Depot program, but is +substantially simpler and safer. Whereas Depot required database files +to keep things in sync, Stow stores no extra state between runs, so +there's no danger (as there was in Depot) of mangling directories when +file hierarchies don't match the database. Also unlike Depot, Stow +will never delete any files, directories, or links that appear in a +Stow directory (e.g., F), so it's always +possible to rebuild the target tree (e.g., F). + +=head1 TERMINOLOGY + +A "package" is a related collection of files and directories that +you wish to administer as a unit -- e.g., Perl or Emacs -- and that +needs to be installed in a particular directory structure -- e.g., +with F, F, and F subdirectories. + +A "target directory" is the root of a tree in which one or more +packages wish to B to be installed. A common, but by no means +the only such location is F. The examples in this manual +page will use F as the target directory. + +A "stow directory" is the root of a tree containing separate +packages in private subtrees. When Stow runs, it uses the current +directory as the default stow directory. The examples in this manual +page will use F as the stow directory, so that +individual packages will be, for example, F and +F. + +An "installation image" is the layout of files and directories +required by a package, relative to the target directory. Thus, the +installation image for Perl includes: a F directory containing +F and F (among others); an F directory containing +Texinfo documentation; a F directory containing Perl +libraries; and a F directory containing man pages. + +A "package directory" is the root of a tree containing the +installation image for a particular package. Each package directory +must reside in a stow directory -- e.g., the package directory +F must reside in the stow directory +F. The "name" of a package is the name of its +directory within the stow directory -- e.g., F. + +Thus, the Perl executable might reside in +F, where F is the target +directory, F is the stow directory, +F is the package directory, and F +within is part of the installation image. + +A "symlink" is a symbolic link. A symlink can be "relative" or +"absolute". An absolute symlink names a full path; that is, one +starting from F. A relative symlink names a relative path; that +is, one not starting from F. The target of a relative symlink is +computed starting from the symlink's own directory. Stow only creates +relative symlinks. + +=head1 OPTIONS + +The stow directory is assumed to be the value of the C +environment variable or if unset the current directory, and the target +directory is assumed to be the parent of the current directory (so it +is typical to execute F from the directory F). +Each F given on the command line is the name of a package in +the stow directory (e.g., F). By default, they are installed +into the target directory (but they can be deleted instead using +C<-D>). + +=over 4 + +=item -n + +=item --no + +Do not perform any operations that modify the filesystem; merely show +what would happen. Since no actual operations are performed, C could report conflicts when none would actually take place (see +"Conflicts" in the info manual); but it won't fail to report +conflicts that B take place. + +=item -c + +=item --conflicts + +Do not exit immediately when a conflict is encountered. This option +implies C<-n>, and is used to search for all conflicts that might +arise from an actual Stow operation. As with C<-n>, however, false +conflicts might be reported (see the "Conflicts" section in the info +manual). + +=item -d DIR + +=item --dir=DIR + +Set the stow directory to C instead of the current directory. +This also has the effect of making the default target directory be the +parent of C. + +=item -t DIR + +=item --target=DIR + +Set the target directory to C instead of the parent of the stow +directory. + +=item -v + +=item --verbose[=N] + +Send verbose output to standard error describing what Stow is +doing. Verbosity levels are 0, 1, 2, 3, and 4; 0 is the default. +Using C<-v> or C<--verbose> increases the verbosity by one; using +`--verbose=N' sets it to N. + +=item -S + +=item --stow + +Stow the packages that follow this option into the target directory. +This is the default action and so can be omitted if you are only +stowing packages rather than performing a mixture of +stow/delete/restow actions. + +=item -D + +=item --delete + +Unstow the packages that follow this option from the target directory rather +than installing them. + +=item -R + +=item --restow + +Restow packages (first unstow, then stow again). This is useful +for pruning obsolete symlinks from the target tree after updating +the software in a package. + +=item --ignore=REGEX + +Ignore files ending in this Perl regex. + +=item --defer=REGEX + +Don't stow files beginning with this Perl regex if the file is already +stowed to another package. + +=item --override=REGEX + +Force stowing files beginning with this Perl regex if the file is +already stowed to another package. + +=item -V + +=item --version + +Show Stow version number, and exit. + +=item -h + +=item --help + +Show Stow command syntax, and exit. + +=back + +=head1 INSTALLING PACKAGES + +The default action of Stow is to install a package. This means +creating symlinks in the target tree that point into the package tree. +Stow attempts to do this with as few symlinks as possible; in other +words, if Stow can create a single symlink that points to an entire +subtree within the package tree, it will choose to do that rather than +create a directory in the target tree and populate it with symlinks. + +For example, suppose that no packages have yet been installed in +F; it's completely empty (except for the F +subdirectory, of course). Now suppose the Perl package is installed. +Recall that it includes the following directories in its installation +image: F; F; F; F. Rather than +creating the directory F and populating it with +symlinks to F<../stow/perl/bin/perl> and F<../stow/perl/bin/a2p> (and +so on), Stow will create a single symlink, F, which +points to F. In this way, it still works to refer to +F and F, and fewer symlinks +have been created. This is called "tree folding", since an entire +subtree is "folded" into a single symlink. + +To complete this example, Stow will also create the symlink +F pointing to F; the symlink +F pointing to F; and the symlink +F pointing to F. + +Now suppose that instead of installing the Perl package into an empty +target tree, the target tree is not empty to begin with. Instead, it +contains several files and directories installed under a different +system-administration philosophy. In particular, F +already exists and is a directory, as are F and +F. In this case, Stow will descend into +F and create symlinks to F<../stow/perl/bin/perl> and +F<../stow/perl/bin/a2p> (etc.), and it will descend into +F and create the tree-folding symlink F pointing +to F<../stow/perl/lib/perl>, and so on. As a rule, Stow only descends +as far as necessary into the target tree when it can create a +tree-folding symlink. + +The time often comes when a tree-folding symlink has to be undone +because another package uses one or more of the folded subdirectories +in its installation image. This operation is called "splitting open" +a folded tree. It involves removing the original symlink from the +target tree, creating a true directory in its place, and then +populating the new directory with symlinks to the newly-installed +package B to the old package that used the old symlink. For +example, suppose that after installing Perl into an empty +F, we wish to install Emacs. Emacs's installation image +includes a F directory containing the F and F +executables, among others. Stow must make these files appear to be +installed in F, but presently F is a +symlink to F. Stow therefore takes the following +steps: the symlink F is deleted; the directory +F is created; links are made from F to +F<../stow/emacs/bin/emacs> and F<../stow/emacs/bin/etags>; and links +are made from F to F<../stow/perl/bin/perl> and +F<../stow/perl/bin/a2p>. + +When splitting open a folded tree, Stow makes sure that the symlink +it is about to remove points inside a valid package in the current stow +directory. + +=head2 Stow will never delete anything that it doesn't own. + +Stow "owns" everything living in the target tree that points into a +package in the stow directory. Anything Stow owns, it can recompute if +lost. Note that by this definition, Stow doesn't "own" anything +B the stow directory or in any of the packages. + +If Stow needs to create a directory or a symlink in the target tree +and it cannot because that name is already in use and is not owned by +Stow, then a conflict has arisen. See the "Conflicts" section in the +info manual. + +=head1 DELETING PACKAGES + +When the C<-D> option is given, the action of Stow is to delete a +package from the target tree. Note that Stow will not delete anything +it doesn't "own". Deleting a package does B mean removing it from +the stow directory or discarding the package tree. + +To delete a package, Stow recursively scans the target tree, skipping +over the stow directory (since that is usually a subdirectory of the +target tree) and any other stow directories it encounters (see +"Multiple stow directories" in the info manual). Any symlink it +finds that points into the package being deleted is removed. Any +directory that contained only symlinks to the package being deleted is +removed. Any directory that, after removing symlinks and empty +subdirectories, contains only symlinks to a single other package, is +considered to be a previously "folded" tree that was "split open." +Stow will re-fold the tree by removing the symlinks to the surviving +package, removing the directory, then linking the directory back to +the surviving package. + +=head1 SEE ALSO + +The full documentation for F is maintained as a Texinfo manual. +If the F and F programs are properly installed at your site, the command + + info stow + +should give you access to the complete manual. + +=head1 BUGS + +Please report bugs in Stow using the Debian bug tracking system. + +Currently known bugs include: + +=over 4 + +=item * The empty-directory problem. + +If package F includes an empty directory -- say, F -- +then if no other package has a F subdirectory, everything's fine. +If another stowed package F, has a F subdirectory, then +when stowing, F will be "split open" and the contents +of F will be individually stowed. So far, so good. But when +unstowing F, F will be removed, even though +F needs it to remain. A workaround for this problem is to +create a file in F as a placeholder. If you name that file +F<.placeholder>, it will be easy to find and remove such files when +this bug is fixed. + +=item * + +When using multiple stow directories (see "Multiple stow directories" +in the info manual), Stow fails to "split open" tree-folding symlinks +(see "Installing packages" in the info manual) that point into a stow +directory which is not the one in use by the current Stow +command. Before failing, it should search the target of the link to +see whether any element of the path contains a F<.stow> file. If it +finds one, it can "learn" about the cooperating stow directory to +short-circuit the F<.stow> search the next time it encounters a +tree-folding symlink. + +=back + +=head1 AUTHOR + +This man page was originally constructed by Charles Briscoe-Smith from +parts of Stow's info manual, and then converted to POD format by Adam +Spiers. The info manual contains the following notice, which, as it +says, applies to this manual page, too. The text of the section +entitled "GNU General Public License" can be found in the file +F on any Debian GNU/Linux system. If +you don't have access to a Debian system, or the GPL is not there, +write to the Free Software Foundation, Inc., 59 Temple Place, Suite +330, Boston, MA, 02111-1307, USA. + +=head1 COPYRIGHT + +Copyright (C) +1993, 1994, 1995, 1996 by Bob Glickstein ; +2000, 2001 by Guillaume Morin; +2007 by Kahlil Hodgson; +2011 by Adam Spiers; +and others. + +Permission is granted to make and distribute verbatim copies of this +manual provided the copyright notice and this permission notice are +preserved on all copies. + +Permission is granted to copy and distribute modified versions of this +manual under the conditions for verbatim copying, provided also that +the section entitled "GNU General Public License" is included with the +modified manual, and provided that the entire resulting derived work +is distributed under the terms of a permission notice identical to +this one. + +Permission is granted to copy and distribute translations of this +manual into another language, under the above conditions for modified +versions, except that this permission notice may be stated in a +translation approved by the Free Software Foundation. + +=cut + use strict; use warnings; @@ -239,9 +620,9 @@ OPTIONS: -p, --compat use legacy algorithm for unstowing --ignore=REGEX ignore files ending in this perl regex - --defer=REGEX defer stowing files begining with this perl regex + --defer=REGEX don't stow files beginning with this perl regex if the file is already stowed to another package - --override=REGEX force stowing files begining with this perl regex + --override=REGEX force stowing files beginning with this perl regex if the file is already stowed to another package -V, --version Show stow version number -h, --help Show this help diff --git a/doc/stow.8 b/doc/stow.8 deleted file mode 100644 index 3e59c62..0000000 --- a/doc/stow.8 +++ /dev/null @@ -1,449 +0,0 @@ -.TH STOW 8 "28 March 1998" -.SH NAME -stow \- software package installation manager -.SH SYNOPSIS -.B stow -.RI [ options ] -.IR package ... -.SH DESCRIPTION -This manual page describes GNU Stow 1.3.3, a program for managing the -installation of software packages. This is not the definitive -documentation for stow; for that, see the info manual. -.PP -Stow is a tool for managing the installation of multiple software -packages in the same run-time directory tree. One historical difficulty -of this task has been the need to administer, upgrade, install, and -remove files in independent packages without confusing them with other -files sharing the same filesystem space. For instance, it is common to -install Perl and Emacs in -.IR /usr/local . -When one does so, one winds up -(as of Perl 4.036 and Emacs 19.22) -with the following files in -.IR /usr/local/man/man1 : -.IR a2p.1 ; -.IR ctags.1 ; -.IR emacs.1 ; -.IR etags.1 ; -.IR h2ph.1 ; -.IR perl.1 ; -and -.IR s2p.1 . -Now -suppose it's time to uninstall Perl. Which man pages get removed? -Obviously -.I perl.1 -is one of them, but it should not be the -administrator's responsibility to memorize the ownership of individual -files by separate packages. -.PP -The approach used by Stow is to install each package into its own -tree, then use symbolic links to make it appear as though the files are -installed in the common tree. Administration can be performed in the -package's private tree in isolation from clutter from other packages. -Stow can then be used to update the symbolic links. The structure of -each private tree should reflect the desired structure in the common -tree; i.e. (in the typical case) there should be a -.I bin -directory -containing executables, a -.I man/man1 -directory containing section 1 man -pages, and so on. -.PP -Stow was inspired by Carnegie Mellon's Depot program, but is -substantially simpler and safer. Whereas Depot required database files -to keep things in sync, Stow stores no extra state between runs, so -there's no danger (as there was in Depot) of mangling directories when -file hierarchies don't match the database. Also unlike Depot, Stow will -never delete any files, directories, or links that appear in a Stow -directory (e.g., -.IR /usr/local/stow/emacs ), -so it's always possible to -rebuild the target tree (e.g., -.IR /usr/local ). -.SH TERMINOLOGY -A ``package'' is a related collection of files and directories that -you wish to administer as a unit--e.g., Perl or Emacs--and that needs -to be installed in a particular directory structure--e.g., with -.IR bin , -.IR lib , -and -.I man -subdirectories. -.PP -A ``target directory'' is the root of a tree in which one or more -packages wish to -.B appear -to be installed. A common, but by no means -the only such location is -.IR /usr/local . -The examples in this manual page -will use -.I /usr/local -as the target directory. -.PP -A ``stow directory'' is the root of a tree containing separate -packages in private subtrees. When Stow runs, it uses the current -directory as the default stow directory. The examples in this manual -page will use -.I /usr/local/stow -as the stow directory, so that individual -packages will be, for example, -.I /usr/local/stow/perl -and -.IR /usr/local/stow/emacs . -.PP -An ``installation image'' is the layout of files and directories -required by a package, relative to the target directory. Thus, the -installation image for Perl includes: a -.I bin -directory containing -.I perl -and -.I a2p -(among others); an -.I info -directory containing Texinfo -documentation; a -.I lib/perl -directory containing Perl libraries; and a -.I man/man1 -directory containing man pages. -.PP -A ``package directory'' is the root of a tree containing the -installation image for a particular package. Each package directory -must reside in a stow directory--e.g., the package directory -.I /usr/local/stow/perl -must reside in the stow directory -.IR /usr/local/stow . -The ``name'' of a package is the name of its -directory within the stow directory--e.g., -.IR perl . -.PP -Thus, the Perl executable might reside in -.IR /usr/local/stow/perl/bin/perl , -where -.I /usr/local -is the target -directory, -.I /usr/local/stow -is the stow directory, -.I /usr/local/stow/perl -is the package directory, and -.I bin/perl -within -is part of the installation image. -.PP -A ``symlink'' is a symbolic link. A symlink can be ``relative'' or -``absolute''. An absolute symlink names a full path; that is, one -starting from -.IR / . -A relative symlink names a relative path; that is, -one not starting from -.IR / . -The target of a relative symlink is -computed starting from the symlink's own directory. Stow only creates -relative symlinks. -.SH OPTIONS -The stow directory is assumed to be the value of the 'STOW_DIR' environment -variable or if unset the current directory, and the -target directory is assumed to be the parent of the current directory -(so it is typical to execute -.I stow -from the directory -.IR /usr/local/stow ). -Each -.I package -given on the command line is the name of a package in the stow -directory (e.g., -.IR perl ). -By default, they are installed into the -target directory (but they can be deleted instead using `-D'). -.TP -.I -n -.TP -.I --no -Do not perform any operations that modify the filesystem; merely -show what would happen. Since no actual operations are performed, -.I stow -n -could report conflicts when none would actually take -place (see ``Conflicts'' in the info manual); -but it won't fail to report conflicts -that -.B would -take place. -.TP -.I -c -.TP -.I --conflicts -Do not exit immediately when a conflict is encountered. This -option implies `-n', and is used to search for all conflicts that -might arise from an actual Stow operation. As with `-n', however, -false conflicts might be reported (see ``Conflicts'' in the info manual). -.TP -.I "-d DIR" -.TP -.I --dir=DIR -Set the stow directory to DIR instead of the current directory. -This also has the effect of making the default target directory be -the parent of DIR. -.TP -.I "-t DIR" -.TP -.I --target=DIR -Set the target directory to DIR instead of the parent of the stow -directory. -.TP -.I -v -.TP -.I --verbose[=N] -Send verbose output to standard error describing what Stow is -doing. Verbosity levels are 0, 1, 2, and 3; 0 is the default. -Using `-v' or `--verbose' increases the verbosity by one; using -`--verbose=N' sets it to N. -.TP -.I -D -.TP -.I --delete -Delete packages from the target directory rather than installing -them. -.TP -.I -R -.TP -.I --restow -Restow packages (first unstow, then stow again). This is useful -for pruning obsolete symlinks from the target tree after updating -the software in a package. -.TP -.I -V -.TP -.I --version -Show Stow version number, and exit. -.TP -.I -h -.TP -.I --help -Show Stow command syntax, and exit. -.SH "INSTALLING PACKAGES" -The default action of Stow is to install a package. This means -creating symlinks in the target tree that point into the package tree. -Stow attempts to do this with as few symlinks as possible; in other -words, if Stow can create a single symlink that points to an entire -subtree within the package tree, it will choose to do that rather than -create a directory in the target tree and populate it with symlinks. -.PP -For example, suppose that no packages have yet been installed in -.IR /usr/local ; -it's completely empty (except for the -.I stow -subdirectory, of course). Now suppose the Perl package is installed. -Recall that it includes the following directories in its installation -image: -.IR bin ; -.IR info ; -.IR lib/perl ; -.IR man/man1 . -Rather than creating -the directory -.I /usr/local/bin -and populating it with symlinks to -.I ../stow/perl/bin/perl -and -.I ../stow/perl/bin/a2p -(and so on), Stow -will create a single symlink, -.IR /usr/local/bin , -which points to -.IR stow/perl/bin . -In this way, it still works to refer to -.I /usr/local/bin/perl -and -.IR /usr/local/bin/a2p , -and fewer symlinks have -been created. This is called ``tree folding'', since an entire subtree -is ``folded'' into a single symlink. -.PP -To complete this example, Stow will also create the symlink -.I /usr/local/info -pointing to -.IR stow/perl/info ; -the symlink -.I /usr/local/lib -pointing to -.IR stow/perl/lib ; -and the symlink -.I /usr/local/man -pointing to -.IR stow/perl/man . -.PP -Now suppose that instead of installing the Perl package into an empty -target tree, the target tree is not empty to begin with. Instead, it -contains several files and directories installed under a different -system-administration philosophy. In particular, -.I /usr/local/bin -already exists and is a directory, as are -.I /usr/local/lib -and -.IR /usr/local/man/man1 . -In this case, Stow will descend into -.I /usr/local/bin -and create symlinks to -.I ../stow/perl/bin/perl -and -.I ../stow/perl/bin/a2p -(etc.), and it will descend into -.I /usr/local/lib -and create the tree-folding symlink -.I perl -pointing to -.IR ../stow/perl/lib/perl , -and so on. As a rule, Stow only descends as -far as necessary into the target tree when it can create a tree-folding -symlink. -.PP -The time often comes when a tree-folding symlink has to be undone -because another package uses one or more of the folded subdirectories in -its installation image. This operation is called ``splitting open'' a -folded tree. It involves removing the original symlink from the target -tree, creating a true directory in its place, and then populating the -new directory with symlinks to the newly-installed package -.B and -to the -old package that used the old symlink. For example, suppose that after -installing Perl into an empty -.IR /usr/local , -we wish to install Emacs. -Emacs's installation image includes a -.I bin -directory containing the -.I emacs -and -.I etags -executables, among others. Stow must make these -files appear to be installed in -.IR /usr/local/bin , -but presently -.I /usr/local/bin -is a symlink to -.IR stow/perl/bin . -Stow therefore takes -the following steps: the symlink -.I /usr/local/bin -is deleted; the -directory -.I /usr/local/bin -is created; links are made from -.I /usr/local/bin -to -.I ../stow/emacs/bin/emacs -and -.IR ../stow/emacs/bin/etags ; -and links are made from -.I /usr/local/bin -to -.I ../stow/perl/bin/perl -and -.IR ../stow/perl/bin/a2p . -.PP -When splitting open a folded tree, Stow makes sure that the symlink -it is about to remove points inside a valid package in the current stow -directory. -.BR "Stow will never delete anything that it doesn't own" . -Stow ``owns'' everything living in the target tree that points into a -package in the stow directory. Anything Stow owns, it can recompute if -lost. Note that by this definition, Stow doesn't ``own'' anything -.B in -the stow directory or in any of the packages. -.PP -If Stow needs to create a directory or a symlink in the target tree -and it cannot because that name is already in use and is not owned by -Stow, then a conflict has arisen. See ``Conflicts'' in the info manual. -.SH "DELETING PACKAGES" -When the `-D' option is given, the action of Stow is to delete a -package from the target tree. Note that Stow will not delete anything -it doesn't ``own''. Deleting a package does -.B not -mean removing it from -the stow directory or discarding the package tree. -.PP -To delete a package, Stow recursively scans the target tree, -skipping over the stow directory (since that is usually a subdirectory -of the target tree) and any other stow directories it encounters (see -``Multiple stow directories'' in the info manual). Any symlink it finds that points into -the package being deleted is removed. Any directory that contained -only symlinks to the package being deleted is removed. Any directory -that, after removing symlinks and empty subdirectories, contains only -symlinks to a single other package, is considered to be a previously -``folded'' tree that was ``split open.'' Stow will re-fold the tree by -removing the symlinks to the surviving package, removing the directory, -then linking the directory back to the surviving package. -.SH "SEE ALSO" -The info manual ``Stow 1.3.3: -Managing the installation of software packages'' -by Bob Glickstein, Zanshin Software, Inc. -.SH BUGS -Please report bugs in Stow using the Debian bug tracking system. -.PP -Currently known bugs include: -.IP * -The empty-directory problem. If package FOO includes an empty -directory--say, FOO/BAR--then: -.IP -1. -if no other package has a BAR subdirectory, everything's fine. -.IP -2. -if another stowed package, QUUX, has a BAR subdirectory, then -when stowing, TARGETDIR/BAR will be ``split open'' and the -contents of QUUX/BAR will be individually stowed. So far, so -good. But when unstowing QUUX, TARGETDIR/BAR will be -removed, even though FOO/BAR needs it to remain. A -workaround for this problem is to create a file in FOO/BAR as -a placeholder. If you name that file -.IR .placeholder , -it will -be easy to find and remove such files when this bug is fixed. -.IP * -When using multiple stow directories (see ``Multiple stow -directories'' in the info manual), Stow fails to ``split open'' tree-folding symlinks -(see ``Installing packages'' in the info manual) that point into a stow directory -which is not the one in use by the current Stow command. Before -failing, it should search the target of the link to see whether -any element of the path contains a -.I .stow -file. If it finds one, -it can ``learn'' about the cooperating stow directory to -short-circuit the -.I .stow -search the next time it encounters a -tree-folding symlink. -.SH AUTHOR -This man page was constructed by Charles Briscoe-Smith from -parts of Stow's info manual. That manual contained the following -notice, which, as it says, applied to this manual page, too. The text -of the section entitled ``GNU General Public License'' can be found in -the file -.I /usr/share/common-licenses/GPL -on any Debian GNU/Linux system. If you don't have access to a Debian -system, or the GPL is not there, write to the Free Software Foundation, -Inc., 59 Temple Place, Suite 330, Boston, MA, 02111-1307, USA. -.IP -Software and documentation Copyright (C) 1993, 1994, 1995, 1996 by -Bob Glickstein . -.IP -Permission is granted to make and distribute verbatim copies of this -manual provided the copyright notice and this permission notice are -preserved on all copies. -.IP -Permission is granted to copy and distribute modified versions of -this manual under the conditions for verbatim copying, provided also -that the section entitled ``GNU General Public License'' is included with -the modified manual, and provided that the entire resulting derived -work is distributed under the terms of a permission notice identical to -this one. -.IP -Permission is granted to copy and distribute translations of this -manual into another language, under the above conditions for modified -versions, except that this permission notice may be stated in a -translation approved by the Free Software Foundation. From 0cd971d3a11a04268147d01af0d0eea38331d21b Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Mon, 21 Nov 2011 14:46:27 +0000 Subject: [PATCH 056/482] Add .dirstamp and stamp-vti to .gitignore --- .gitignore | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.gitignore b/.gitignore index 3653e53..c15e394 100644 --- a/.gitignore +++ b/.gitignore @@ -11,3 +11,5 @@ t/target/ version.texi lib/Stow.pm doc/stow.8 +.dirstamp +stamp-vti From f93796dce3b30513b845f6d636c51184328776e1 Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Mon, 21 Nov 2011 14:48:58 +0000 Subject: [PATCH 057/482] Add MYMETA.* to .gitignore --- .gitignore | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.gitignore b/.gitignore index c15e394..508d516 100644 --- a/.gitignore +++ b/.gitignore @@ -13,3 +13,5 @@ lib/Stow.pm doc/stow.8 .dirstamp stamp-vti +MYMETA.json +MYMETA.yml From 59fa7ae4a668aab227c0ececf62361a0c05b1d26 Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Mon, 21 Nov 2011 18:04:58 +0000 Subject: [PATCH 058/482] Add build-time dependencies on Test::More and Test::Output. --- Build.PL | 4 ++++ META.json | 6 ++++++ META.yml | 4 +++- TODO | 2 -- 4 files changed, 13 insertions(+), 3 deletions(-) diff --git a/Build.PL b/Build.PL index e5d11c0..255bc5e 100644 --- a/Build.PL +++ b/Build.PL @@ -53,6 +53,10 @@ my $build = Module::Build->new( configure_requires => { 'Module::Build' => 0, }, + build_requires => { + 'Test::More' => 0, + 'Test::Output' => 0, + }, ); $build->create_build_script(); diff --git a/META.json b/META.json index c622c81..637c9f1 100644 --- a/META.json +++ b/META.json @@ -14,6 +14,12 @@ }, "name" : "Stow", "prereqs" : { + "build" : { + "requires" : { + "Test::More" : 0, + "Test::Output" : 0 + } + }, "configure" : { "requires" : { "Module::Build" : 0 diff --git a/META.yml b/META.yml index d1d2748..f09bef9 100644 --- a/META.yml +++ b/META.yml @@ -2,7 +2,9 @@ abstract: 'manage the installation of multiple software packages' author: - unknown -build_requires: {} +build_requires: + Test::More: 0 + Test::Output: 0 configure_requires: Module::Build: 0 dynamic_config: 1 diff --git a/TODO b/TODO index b873238..b15186f 100644 --- a/TODO +++ b/TODO @@ -22,8 +22,6 @@ * Add semi-automatic conflict resolution *** STOW_RESOLVE_CONFLICTS="non_stow_symlinks=t stow_symlinks=r" *** Add documentation about conflict resolution -* Make CPAN-friendly via Module::Build -*** Include test-time dependencies on Test::More and Test::Output * get account on fencepost.gnu.org (email accounts@gnu.org) set up copyright papers? 'assign.future' and 'request-assign.future.manual' From 1f9c5bed1af8dc166859be373aa662da5cb4523e Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Mon, 21 Nov 2011 22:08:52 +0000 Subject: [PATCH 059/482] Fix/remove some outdated TODOs --- TODO | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/TODO b/TODO index b15186f..92ca05b 100644 --- a/TODO +++ b/TODO @@ -26,9 +26,7 @@ set up copyright papers? 'assign.future' and 'request-assign.future.manual' -* Figure out what needs the option 'nostow' 'notstowed'. Can they be removed? - -* _texi2man_ needs author/copyright/license to be completed +* Figure out what needs the files '.nonstow' and '.notstowed'. Can they be removed? * Update http://directory.fsf.org/project/stow/ From b8942c9f797a7f292472fe89b66022ee1037ff69 Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Mon, 21 Nov 2011 23:15:47 +0000 Subject: [PATCH 060/482] Fix typos --- lib/Stow.pm.in | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/Stow.pm.in b/lib/Stow.pm.in index ecc4087..4d049fb 100755 --- a/lib/Stow.pm.in +++ b/lib/Stow.pm.in @@ -683,7 +683,7 @@ sub unstow_node { } if ($old_source =~ m{\A/}) { - warn "ignoring a absolute symlink: $target => $old_source\n"; + warn "ignoring an absolute symlink: $target => $old_source\n"; return; # XXX # } @@ -1028,7 +1028,7 @@ sub defer { } #===== METHOD ================================================================ -# Name : overide +# Name : override # Purpose : determine if the given path matches a regex in our override list # Parameters: $path # Returns : Boolean From 4d45d3e0c7bc218ceb281c6f06aa12269ccc6c8f Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Mon, 21 Nov 2011 23:21:48 +0000 Subject: [PATCH 061/482] Fix more inconsistencies in coding style. --- lib/Stow.pm.in | 83 +++++++++++++++++++++++++------------------------- 1 file changed, 41 insertions(+), 42 deletions(-) diff --git a/lib/Stow.pm.in b/lib/Stow.pm.in index 4d049fb..65ecd7d 100755 --- a/lib/Stow.pm.in +++ b/lib/Stow.pm.in @@ -369,7 +369,7 @@ sub stow_node { debug(2, "Stowing from $path"); debug(3, "--- $target => $source"); - # don't try to stow absolute symlinks (they can't be unstowed) + # Don't try to stow absolute symlinks (they can't be unstowed) if (-l $source) { my $second_source = $self->read_a_link($source); if ($second_source =~ m{\A/}) { @@ -379,24 +379,24 @@ sub stow_node { } } - # does the target already exist? + # Does the target already exist? if ($self->is_a_link($target)) { - # where is the link pointing? + # Where is the link pointing? my $old_source = $self->read_a_link($target); if (not $old_source) { error("Could not read link: $target"); } debug(3, "--- Evaluate existing link: $target => $old_source"); - # does it point to a node under our stow directory? + # Does it point to a node under our stow directory? my $old_path = $self->find_stowed_path($target, $old_source); if (not $old_path) { $self->conflict("existing target is not owned by stow: $target"); return; # XXX # } - # does the existing $target actually point to anything? + # Does the existing $target actually point to anything? if ($self->is_a_node($old_path)) { if ($old_source eq $source) { debug(3, "--- Skipping $target as it already points to $source"); @@ -412,7 +412,7 @@ sub stow_node { elsif ($self->is_a_dir(join_paths(parent($target), $old_source)) && $self->is_a_dir(join_paths(parent($target), $source)) ) { - # if the existing link points to a directory, + # If the existing link points to a directory, # and the proposed new link points to a directory, # then we can unfold (split open) the tree at that point @@ -431,7 +431,7 @@ sub stow_node { } } else { - # the existing link is invalid, so replace it with a good link + # The existing link is invalid, so replace it with a good link debug(3, "--- replacing invalid link: $path"); $self->do_unlink($target); $self->do_link($source, $target); @@ -466,7 +466,7 @@ sub should_skip_stow_dir_target { my $self = shift; my ($target) = @_; - # don't try to remove anything under a stow directory + # Don't try to remove anything under a stow directory if ($target eq $self->{stow_path}) { debug(2, "Skipping target which was current stow directory $target"); return 1; @@ -553,26 +553,26 @@ sub unstow_node_orig { debug(2, "Unstowing $target (compat mode)"); debug(3, "--- source path is $path"); - # does the target exist + # Does the target exist? if ($self->is_a_link($target)) { debug(3, "Evaluate existing link: $target"); - # where is the link pointing? + # Where is the link pointing? my $old_source = $self->read_a_link($target); if (not $old_source) { error("Could not read link: $target"); } - # does it point to a node under our stow directory? + # Does it point to a node under our stow directory? my $old_path = $self->find_stowed_path($target, $old_source); if (not $old_path) { # skip links not owned by stow return; # XXX # } - # does the existing $target actually point to anything? - if (-e $old_path) { - # does link point to the right place? + # Does the existing $target actually point to anything? + if (-e $old_path) { + # Does link point to the right place? if ($old_path eq $path) { $self->do_unlink($target); } @@ -590,7 +590,7 @@ sub unstow_node_orig { elsif (-d $target) { $self->unstow_contents_orig($path, $target); - # this action may have made the parent directory foldable + # This action may have made the parent directory foldable if (my $parent = $self->foldable($target)) { $self->fold_tree($target, $parent); } @@ -672,11 +672,11 @@ sub unstow_node { debug(2, "Unstowing $path"); debug(3, "--- target is $target"); - # does the target exist + # Does the target exist? if ($self->is_a_link($target)) { debug(3, "Evaluate existing link: $target"); - # where is the link pointing? + # Where is the link pointing? my $old_source = $self->read_a_link($target); if (not $old_source) { error("Could not read link: $target"); @@ -687,7 +687,7 @@ sub unstow_node { return; # XXX # } - # does it point to a node under our stow directory? + # Does it point to a node under our stow directory? my $old_path = $self->find_stowed_path($target, $old_source); if (not $old_path) { $self->conflict( @@ -696,9 +696,9 @@ sub unstow_node { return; # XXX # } - # does the existing $target actually point to anything + # Does the existing $target actually point to anything? if (-e $old_path) { - # does link points to the right place + # Does link points to the right place? if ($old_path eq $path) { $self->do_unlink($target); } @@ -731,7 +731,7 @@ sub unstow_node { if (-d $target) { $self->unstow_contents($path, $target); - # this action may have made the parent directory foldable + # This action may have made the parent directory foldable if (my $parent = $self->foldable($target)) { $self->fold_tree($target, $parent); } @@ -764,22 +764,22 @@ sub find_stowed_path { my $self = shift; my ($target, $source) = @_; - # evaluate softlink relative to its target + # Evaluate softlink relative to its target my $path = join_paths(parent($target), $source); debug(4, " is path $path under $self->{stow_path} ?"); - # search for .stow files + # Search for .stow files my $dir = ''; for my $part (split m{/+}, $path) { $dir = join_paths($dir, $part); return $path if $self->protected_dir($dir); } - # compare with $self->{stow_path} + # Compare with $self->{stow_path} my @path = split m{/+}, $path; my @stow_path = split m{/+}, $self->{stow_path}; - # strip off common prefixes until one is empty + # Strip off common prefixes until one is empty while (@path && @stow_path) { if ((shift @path) ne (shift @stow_path)) { debug(4, " no - either $path not under $self->{stow_path} or vice-versa"); @@ -829,8 +829,8 @@ sub cleanup_invalid_links { if (-l $node_path and not exists $self->{link_task_for}{$node_path}) { - # where is the link pointing? - # (dont use read_a_link here) + # Where is the link pointing? + # (don't use read_a_link() here) my $source = readlink($node_path); if (not $source) { error("Could not read link $node_path"); @@ -879,13 +879,13 @@ sub foldable { my $path = join_paths($target, $node); - # skip nodes scheduled for removal + # Skip nodes scheduled for removal next NODE if not $self->is_a_node($path); - # if its not a link then we can't fold its parent + # If it's not a link then we can't fold its parent return '' if not $self->is_a_link($path); - # where is the link pointing? + # Where is the link pointing? my $source = $self->read_a_link($path); if (not $source) { error("Could not read link $path"); @@ -899,14 +899,14 @@ sub foldable { } return '' if not $parent; - # if we get here then all nodes inside $target are links, and those links + # If we get here then all nodes inside $target are links, and those links # point to nodes inside the same directory. # chop of leading '..' to get the path to the common parent directory # relative to the parent of our $target $parent =~ s{\A\.\./}{}; - # if the resulting path is owned by stow, we can fold it + # If the resulting path is owned by stow, we can fold it if ($self->find_stowed_path($target, $parent)) { debug(3, "--- $target is foldable"); return $parent; @@ -1070,7 +1070,7 @@ sub process_tasks { return; } - # strip out all tasks with a skip action + # Strip out all tasks with a skip action $self->{tasks} = [ grep { $_->{'action'} ne 'skip' } @{ $self->{tasks} } ]; if (not @{ $self->{tasks} }) { @@ -1238,7 +1238,7 @@ sub is_a_link { } if (-l $path) { - # check if any of its parent are links scheduled for removal + # Check if any of its parent are links scheduled for removal # (need this for edge case during unfolding) debug(4, " is_a_link($path): is a real link"); return $self->parent_link_scheduled_for_removal($path) ? 0 : 1; @@ -1414,7 +1414,7 @@ sub do_link { } } elsif ($task_ref->{'action'} eq 'remove') { - # we may need to remove a directory before creating a link so continue; + # We may need to remove a directory before creating a link so continue. } else { internal_error("bad task action: $task_ref->{'action'}"); @@ -1439,20 +1439,20 @@ sub do_link { } elsif ($task_ref->{'action'} eq 'remove') { if ($task_ref->{'source'} eq $oldfile) { - # no need to remove a link we are going to recreate + # No need to remove a link we are going to recreate debug(1, "LINK: $newfile => $oldfile (reverts previous action)"); $self->{link_task_for}{$newfile}->{'action'} = 'skip'; delete $self->{link_task_for}{$newfile}; return; } - # we may need to remove a link to replace it so continue + # We may need to remove a link to replace it so continue } else { internal_error("bad task action: $task_ref->{'action'}"); } } - # creating a new link + # Creating a new link debug(1, "LINK: $newfile => $oldfile"); my $task = { action => 'create', @@ -1485,7 +1485,7 @@ sub do_unlink { return; } elsif ($task_ref->{'action'} eq 'create') { - # do need to create a link then remove it + # Do need to create a link then remove it debug(1, "UNLINK: $file (reverts previous action)"); $self->{link_task_for}{$file}->{'action'} = 'skip'; delete $self->{link_task_for}{$file}; @@ -1504,8 +1504,7 @@ sub do_unlink { ); } - # remove the link - #debug(1, "UNLINK: $file (" . (caller())[2] . ")"); + # Remove the link debug(1, "UNLINK: $file"); my $source = readlink $file or error("could not readlink $file"); @@ -1547,7 +1546,7 @@ sub do_mkdir { ); } elsif ($task_ref->{'action'} eq 'remove') { - # may need to remove a link before creating a directory so continue + # May need to remove a link before creating a directory so continue } else { internal_error("bad task action: $task_ref->{'action'}"); From 2244539b6b21639bce8497bacab334fd1e47b107 Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Mon, 21 Nov 2011 23:23:43 +0000 Subject: [PATCH 062/482] Test stow/unstow with stow dir / target dir as absolute paths. --- t/stow_contents.t | 43 ++++++++++++++++++++++++++++++++-- t/unstow_contents.t | 45 +++++++++++++++++++++++++++++++++--- t/unstow_contents_orig.t | 50 ++++++++++++++++++++++++++++++++++++---- 3 files changed, 129 insertions(+), 9 deletions(-) diff --git a/t/stow_contents.t b/t/stow_contents.t index ad3b47f..b8a0eff 100755 --- a/t/stow_contents.t +++ b/t/stow_contents.t @@ -7,10 +7,11 @@ use strict; use warnings; -use Test::More tests => 19; +use Test::More tests => 23; use Test::Output; use English qw(-no_match_vars); +use Stow::Util qw(canon_path); use testutil; make_fresh_stow_and_target_dirs(); @@ -303,5 +304,43 @@ is($stow->get_conflicts(), 0, 'no conflicts with minimal stow'); is( readlink('t/target/bin16'), '../stow/pkg16/bin16', - => 'minimal stow of a simple tree' + => "minimal stow of a simple tree when cwd isn't target" +); + +# +# stow a simple tree minimally to absolute stow dir when cwd isn't +# target +# +$stow = new_Stow(dir => canon_path('t/stow'), + target => 't/target'); + +make_dir('t/stow/pkg17/bin17'); +make_file('t/stow/pkg17/bin17/file17'); + +$stow->plan_stow('pkg17'); +$stow->process_tasks(); +is($stow->get_conflicts(), 0, 'no conflicts with minimal stow'); +is( + readlink('t/target/bin17'), + '../stow/pkg17/bin17', + => "minimal stow of a simple tree with absolute stow dir" +); + +# +# stow a simple tree minimally with absolute stow AND target dirs when +# cwd isn't target +# +$stow = new_Stow(dir => canon_path('t/stow'), + target => canon_path('t/target')); + +make_dir('t/stow/pkg18/bin18'); +make_file('t/stow/pkg18/bin18/file18'); + +$stow->plan_stow('pkg18'); +$stow->process_tasks(); +is($stow->get_conflicts(), 0, 'no conflicts with minimal stow'); +is( + readlink('t/target/bin18'), + '../stow/pkg18/bin18', + => "minimal stow of a simple tree with absolute stow and target dirs" ); diff --git a/t/unstow_contents.t b/t/unstow_contents.t index cd5fd3a..cb9707d 100755 --- a/t/unstow_contents.t +++ b/t/unstow_contents.t @@ -7,12 +7,13 @@ use strict; use warnings; -use testutil; - -use Test::More tests => 21; +use Test::More tests => 23; use Test::Output; use English qw(-no_match_vars); +use testutil; +use Stow::Util qw(canon_path); + make_fresh_stow_and_target_dirs(); cd('t/target'); @@ -324,6 +325,44 @@ ok( => 'unstow a simple tree' ); +# +# unstow a simple tree minimally with absolute stow dir when cwd isn't +# target +# +$stow = new_Stow(dir => canon_path('t/stow'), + target => 't/target'); + +make_dir('t/stow/pkg14/bin14'); +make_file('t/stow/pkg14/bin14/file14'); +make_link('t/target/bin14', '../stow/pkg14/bin14'); + +$stow->plan_unstow('pkg14'); +$stow->process_tasks(); +ok( + scalar($stow->get_conflicts) == 0 && + -f 't/stow/pkg14/bin14/file14' && ! -e 't/target/bin14' + => 'unstow a simple tree with absolute stow dir' +); + +# +# unstow a simple tree minimally with absolute stow AND target dirs +# when cwd isn't target +# +$stow = new_Stow(dir => canon_path('t/stow'), + target => canon_path('t/target')); + +make_dir('t/stow/pkg15/bin15'); +make_file('t/stow/pkg15/bin15/file15'); +make_link('t/target/bin15', '../stow/pkg15/bin15'); + +$stow->plan_unstow('pkg15'); +$stow->process_tasks(); +ok( + scalar($stow->get_conflicts) == 0 && + -f 't/stow/pkg15/bin15/file15' && ! -e 't/target/bin15' + => 'unstow a simple tree with absolute stow and target dirs' +); + # Todo # diff --git a/t/unstow_contents_orig.t b/t/unstow_contents_orig.t index e120480..85214c5 100755 --- a/t/unstow_contents_orig.t +++ b/t/unstow_contents_orig.t @@ -7,12 +7,13 @@ use strict; use warnings; -use testutil; - -use Test::More tests => 21; +use Test::More tests => 23; use Test::Output; use English qw(-no_match_vars); +use testutil; +use Stow::Util qw(canon_path); + make_fresh_stow_and_target_dirs(); cd('t/target'); @@ -106,6 +107,9 @@ make_dir('../stow/pkg5/bin5'); make_link('bin5', '../not-stow'); $stow->plan_unstow('pkg5'); +# Unlike the corresponding stow_contents.t test, this doesn't +# cause any conflicts. +# #like( # $Conflicts[-1], qr(CONFLICT:.*can't unlink.*not owned by stow) # => q(existing link not owned by stow) @@ -312,7 +316,7 @@ ok( # # unstow a simple tree minimally when cwd isn't target -# +# cd('../..'); $stow = new_Stow(dir => 't/stow', target => 't/target'); @@ -328,6 +332,44 @@ ok( => 'unstow a simple tree' ); +# +# unstow a simple tree minimally with absolute stow dir when cwd isn't +# target +# +$stow = new_Stow(dir => canon_path('t/stow'), + target => 't/target'); + +make_dir('t/stow/pkg14/bin14'); +make_file('t/stow/pkg14/bin14/file14'); +make_link('t/target/bin14', '../stow/pkg14/bin14'); + +$stow->plan_unstow('pkg14'); +$stow->process_tasks(); +ok( + scalar($stow->get_conflicts) == 0 && + -f 't/stow/pkg14/bin14/file14' && ! -e 't/target/bin14' + => 'unstow a simple tree with absolute stow dir' +); + +# +# unstow a simple tree minimally with absolute stow AND target dirs +# when cwd isn't target +# +$stow = new_Stow(dir => canon_path('t/stow'), + target => canon_path('t/target')); + +make_dir('t/stow/pkg15/bin15'); +make_file('t/stow/pkg15/bin15/file15'); +make_link('t/target/bin15', '../stow/pkg15/bin15'); + +$stow->plan_unstow('pkg15'); +$stow->process_tasks(); +ok( + scalar($stow->get_conflicts) == 0 && + -f 't/stow/pkg15/bin15/file15' && ! -e 't/target/bin15' + => 'unstow a simple tree with absolute stow and target dirs' +); + # Todo # From 1873e4b4ef5daba4803a9e9077174d497a111a2f Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Mon, 21 Nov 2011 23:24:02 +0000 Subject: [PATCH 063/482] Add a comment about a relative weakness of compat mode. --- lib/Stow.pm.in | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/Stow.pm.in b/lib/Stow.pm.in index 65ecd7d..113dec7 100755 --- a/lib/Stow.pm.in +++ b/lib/Stow.pm.in @@ -566,7 +566,9 @@ sub unstow_node_orig { # Does it point to a node under our stow directory? my $old_path = $self->find_stowed_path($target, $old_source); if (not $old_path) { - # skip links not owned by stow + # We're traversing the target tree not the package tree, + # so we definitely expect to find stuff not owned by stow. + # Therefore we can't flag a conflict. return; # XXX # } From a7262a98bc6f3082f51f7c59fe1d2e466f50c06d Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Tue, 22 Nov 2011 14:28:37 +0000 Subject: [PATCH 064/482] Avoid use of map in void context --- bin/stow.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/stow.in b/bin/stow.in index c10baf7..de9c569 100755 --- a/bin/stow.in +++ b/bin/stow.in @@ -434,7 +434,7 @@ sub main { if (scalar @conflicts) { warn "WARNING: conflicts detected.\n"; if ($options->{'conflicts'}) { - map { warn $_ } @conflicts; + warn $_ foreach @conflicts; } warn "WARNING: all operations aborted.\n"; } From 7bef0fb700671841b70b9c9b1da40794c21212e6 Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Tue, 22 Nov 2011 14:29:42 +0000 Subject: [PATCH 065/482] Clean up coding style in tests --- t/chkstow.t | 14 +++++++------- t/cleanup_invalid_links.t | 10 +++++----- t/find_stowed_path.t | 8 ++++---- t/join_paths.t | 26 +++++++++++++------------- t/parent.t | 8 ++++---- 5 files changed, 33 insertions(+), 33 deletions(-) diff --git a/t/chkstow.t b/t/chkstow.t index b182fd9..711c33b 100755 --- a/t/chkstow.t +++ b/t/chkstow.t @@ -63,7 +63,7 @@ sub run_chkstow() { check_stow(); } -local @ARGV = ('-t', '.', '-b',); +local @ARGV = ('-t', '.', '-b'); stderr_like( \&run_chkstow, qr{\Askipping .*stow.*\z}xms, @@ -72,19 +72,19 @@ stderr_like( # squelch warn so that check_stow doesn't carp about skipping .stow all the time $SIG{'__WARN__'} = sub { }; -@ARGV = ('-t', '.', '-l',); +@ARGV = ('-t', '.', '-l'); stdout_like( \&run_chkstow, qr{emacs\nperl\nstow\n}xms, "List packages"); -@ARGV = ('-t', '.', '-b',); +@ARGV = ('-t', '.', '-b'); stdout_like( \&run_chkstow, qr{\A\z}xms, "No bogus links exist"); -@ARGV = ('-t', '.', '-a',); +@ARGV = ('-t', '.', '-a'); stdout_like( \&run_chkstow, qr{\A\z}xms, @@ -92,20 +92,20 @@ stdout_like( # Create an alien make_file('bin/alien'); -@ARGV = ('-t', '.', '-a',); +@ARGV = ('-t', '.', '-a'); stdout_like( \&run_chkstow, qr{Unstowed\ file:\ ./bin/alien}xms, "Aliens exist"); make_link('bin/link', 'ireallyhopethisfiledoesn/t.exist'); -@ARGV = ('-t', '.', '-b',); +@ARGV = ('-t', '.', '-b'); stdout_like( \&run_chkstow, qr{Bogus\ link:\ ./bin/link}xms, "Bogus links exist"); -@ARGV = ('-b',); +@ARGV = ('-b'); process_options(); our $Target; ok($Target == q{/usr/local}, diff --git a/t/cleanup_invalid_links.t b/t/cleanup_invalid_links.t index f5802dd..9882487 100755 --- a/t/cleanup_invalid_links.t +++ b/t/cleanup_invalid_links.t @@ -26,7 +26,7 @@ my $stow; make_dir('../stow/pkg1/bin1'); make_file('../stow/pkg1/bin1/file1'); -make_link('bin1','../stow/pkg1/bin1'); +make_link('bin1', '../stow/pkg1/bin1'); $stow = new_Stow(); $stow->cleanup_invalid_links('./'); @@ -41,8 +41,8 @@ is( make_dir('bin2'); make_dir('../stow/pkg2/bin2'); make_file('../stow/pkg2/bin2/file2a'); -make_link('bin2/file2a','../../stow/pkg2/bin2/file2a'); -make_link('bin2/file2b','../../stow/pkg2/bin2/file2b'); +make_link('bin2/file2a', '../../stow/pkg2/bin2/file2a'); +make_link('bin2/file2b', '../../stow/pkg2/bin2/file2b'); $stow = new_Stow(); $stow->cleanup_invalid_links('bin2'); @@ -57,8 +57,8 @@ is($stow->link_task_action('bin2/file2b'), 'remove', 'removal task for bad link' make_dir('bin3'); make_dir('../stow/pkg3/bin3'); make_file('../stow/pkg3/bin3/file3a'); -make_link('bin3/file3a','../../stow/pkg3/bin3/file3a'); -make_link('bin3/file3b','../../empty'); +make_link('bin3/file3a', '../../stow/pkg3/bin3/file3a'); +make_link('bin3/file3b', '../../empty'); $stow = new_Stow(); $stow->cleanup_invalid_links('bin3'); diff --git a/t/find_stowed_path.t b/t/find_stowed_path.t index 199a534..7fac9f0 100755 --- a/t/find_stowed_path.t +++ b/t/find_stowed_path.t @@ -17,7 +17,7 @@ my $stow = new_Stow(dir => 't/stow'); is( $stow->find_stowed_path('t/target/a/b/c', '../../../stow/a/b/c'), - 't/stow/a/b/c', + 't/stow/a/b/c' => 'from root' ); @@ -25,7 +25,7 @@ cd('t/target'); $stow->set_stow_dir('../stow'); is( $stow->find_stowed_path('a/b/c','../../../stow/a/b/c'), - '../stow/a/b/c', + '../stow/a/b/c' => 'from target directory' ); @@ -35,13 +35,13 @@ $stow->set_stow_dir('t/target/stow'); is( $stow->find_stowed_path('t/target/a/b/c', '../../stow/a/b/c'), - 't/target/stow/a/b/c', + 't/target/stow/a/b/c' => 'stow is subdir of target directory' ); is( $stow->find_stowed_path('t/target/a/b/c','../../empty'), - '', + '' => 'target is not stowed' ); diff --git a/t/join_paths.t b/t/join_paths.t index b310416..37157a5 100755 --- a/t/join_paths.t +++ b/t/join_paths.t @@ -13,79 +13,79 @@ use Test::More tests => 13; is( join_paths('a/b/c', 'd/e/f'), - 'a/b/c/d/e/f', + 'a/b/c/d/e/f' => 'simple' ); is( join_paths('/a/b/c', '/d/e/f'), - '/a/b/c/d/e/f', + '/a/b/c/d/e/f' => 'leading /' ); is( join_paths('/a/b/c/', '/d/e/f/'), - '/a/b/c/d/e/f', + '/a/b/c/d/e/f' => 'trailing /' ); is( join_paths('///a/b///c//', '/d///////e/f'), - '/a/b/c/d/e/f', + '/a/b/c/d/e/f' => 'mltiple /\'s' ); is( join_paths('', 'a/b/c'), - 'a/b/c', + 'a/b/c' => 'first empty' ); is( join_paths('a/b/c', ''), - 'a/b/c', + 'a/b/c' => 'second empty' ); is( join_paths('/', 'a/b/c'), - '/a/b/c', + '/a/b/c' => 'first is /' ); is( join_paths('a/b/c', '/'), - 'a/b/c', + 'a/b/c' => 'second is /' ); is( join_paths('///a/b///c//', '/d///////e/f'), - '/a/b/c/d/e/f', + '/a/b/c/d/e/f' => 'multiple /\'s' ); is( join_paths('../a1/b1/../c1/', '/a2/../b2/e2'), - '../a1/c1/b2/e2', + '../a1/c1/b2/e2' => 'simple deref ".."' ); is( join_paths('../a1/b1/../c1/d1/e1', '../a2/../b2/c2/d2/../e2'), - '../a1/c1/d1/b2/c2/e2', + '../a1/c1/d1/b2/c2/e2' => 'complex deref ".."' ); is( join_paths('../a1/../../c1', 'a2/../../'), - '../..', + '../..' => 'too many ".."' ); is( join_paths('./a1', '../../a2'), - '../a2', + '../a2' => 'drop any "./"' ); diff --git a/t/parent.t b/t/parent.t index 52a99bc..2265f88 100755 --- a/t/parent.t +++ b/t/parent.t @@ -13,25 +13,25 @@ use Test::More tests => 5; is( parent('a/b/c'), - 'a/b', + 'a/b' => 'no leading or trailing /' ); is( parent('/a/b/c'), - '/a/b', + '/a/b' => 'leading /' ); is( parent('a/b/c/'), - 'a/b', + 'a/b' => 'trailing /' ); is( parent('/////a///b///c///'), - '/a/b', + '/a/b' => 'multiple /' ); From 8960a4f1fbdbb39efad4d53f2a0ffdcda5ecfc1c Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Tue, 22 Nov 2011 14:29:52 +0000 Subject: [PATCH 066/482] Add another test to join_paths.t --- t/join_paths.t | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/t/join_paths.t b/t/join_paths.t index 37157a5..585cae9 100755 --- a/t/join_paths.t +++ b/t/join_paths.t @@ -9,7 +9,7 @@ use warnings; use Stow::Util qw(join_paths); -use Test::More tests => 13; +use Test::More tests => 14; is( join_paths('a/b/c', 'd/e/f'), @@ -89,3 +89,9 @@ is( '../a2' => 'drop any "./"' ); + +is( + join_paths('a/b/c', '.'), + 'a/b/c' + => '. on RHS' +); From 7c0bb53bffd474baf23efcedc1cb16d72c0e4954 Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Tue, 22 Nov 2011 15:46:05 +0000 Subject: [PATCH 067/482] Be clearer when we're not actually (un)stowing, just planning. --- lib/Stow.pm.in | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/Stow.pm.in b/lib/Stow.pm.in index 113dec7..d25fecd 100755 --- a/lib/Stow.pm.in +++ b/lib/Stow.pm.in @@ -232,7 +232,7 @@ sub plan_unstow { if (not -d join_paths($self->{stow_path}, $package)) { error("The given package name ($package) is not in your stow path $self->{stow_path}"); } - debug(2, "Unstowing package $package..."); + debug(2, "Planning unstow of package $package..."); if ($self->{'compat'}) { $self->unstow_contents_orig( join_paths($self->{stow_path}, $package), # path to package @@ -245,7 +245,7 @@ sub plan_unstow { '.', # target is current_dir ); } - debug(2, "Unstowing package $package... done"); + debug(2, "Planning unstow of package $package... done"); } }); } @@ -267,13 +267,13 @@ sub plan_stow { if (not -d join_paths($self->{stow_path}, $package)) { error("The given package name ($package) is not in your stow path $self->{stow_path}"); } - debug(2, "Stowing package $package..."); + debug(2, "Planning stow of package $package..."); $self->stow_contents( join_paths($self->{stow_path}, $package), # path package '.', # target is current dir join_paths($self->{stow_path}, $package), # source from target ); - debug(2, "Stowing package $package... done"); + debug(2, "Planning stow of package $package... done"); } }); } From d8a4cda11b4fd9cbd528d0befa2c733e14e0fa55 Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Tue, 22 Nov 2011 15:48:08 +0000 Subject: [PATCH 068/482] Rename should_skip_stow_dir_target() to should_skip_target_which_is_stow_dir() --- lib/Stow.pm.in | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/lib/Stow.pm.in b/lib/Stow.pm.in index d25fecd..4bfffe9 100755 --- a/lib/Stow.pm.in +++ b/lib/Stow.pm.in @@ -319,7 +319,7 @@ sub stow_contents { my $self = shift; my ($path, $target, $source) = @_; - return if $self->should_skip_stow_dir_target($target); + return if $self->should_skip_target_which_is_stow_dir($target); my $cwd = getcwd(); my $msg = "Stowing contents of $path (cwd=$cwd, stow dir=$self->{stow_path})"; @@ -455,14 +455,15 @@ sub stow_node { } #===== METHOD =============================================================== -# Name : should_skip_stow_dir_target() -# Purpose : determine whether target is a stow directory and should be skipped +# Name : should_skip_target_which_is_stow_dir() +# Purpose : determine whether target is a stow directory which should +# : not be stowed to or unstowed from # Parameters: $target => relative path to symlink target from the current directory # Returns : true iff target is a stow directory # Throws : n/a # Comments : none #============================================================================ -sub should_skip_stow_dir_target { +sub should_skip_target_which_is_stow_dir { my $self = shift; my ($target) = @_; @@ -507,7 +508,7 @@ sub unstow_contents_orig { my $self = shift; my ($path, $target) = @_; - return if $self->should_skip_stow_dir_target($target); + return if $self->should_skip_target_which_is_stow_dir($target); my $cwd = getcwd(); my $msg = "Unstowing from $target (compat mode, cwd=$cwd, stow dir=$self->{stow_path})"; @@ -622,7 +623,7 @@ sub unstow_contents { my $self = shift; my ($path, $target) = @_; - return if $self->should_skip_stow_dir_target($target); + return if $self->should_skip_target_which_is_stow_dir($target); my $cwd = getcwd(); my $msg = "Unstowing from $target (cwd=$cwd, stow dir=$self->{stow_path})"; From b20228721e1a0ced9de9423b9bc9a835421f136f Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Tue, 22 Nov 2011 15:50:12 +0000 Subject: [PATCH 069/482] Rename protected_dir() to marked_stow_dir(). --- lib/Stow.pm.in | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/Stow.pm.in b/lib/Stow.pm.in index 4bfffe9..9b8367f 100755 --- a/lib/Stow.pm.in +++ b/lib/Stow.pm.in @@ -473,7 +473,7 @@ sub should_skip_target_which_is_stow_dir { return 1; } - if ($self->protected_dir($target)) { + if ($self->marked_stow_dir($target)) { debug(2, "Skipping protected directory $target"); return 1; } @@ -482,7 +482,7 @@ sub should_skip_target_which_is_stow_dir { return 0; } -sub protected_dir { +sub marked_stow_dir { my $self = shift; my ($target) = @_; for my $f (".stow", ".nonstow") { @@ -775,7 +775,7 @@ sub find_stowed_path { my $dir = ''; for my $part (split m{/+}, $path) { $dir = join_paths($dir, $part); - return $path if $self->protected_dir($dir); + return $path if $self->marked_stow_dir($dir); } # Compare with $self->{stow_path} From 7777e181a86a2729203e7ecbbeaa8658f6cdd267 Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Tue, 22 Nov 2011 15:59:07 +0000 Subject: [PATCH 070/482] Rename $old_* to $existing_* --- lib/Stow.pm.in | 52 +++++++++++++++++++++++++------------------------- 1 file changed, 26 insertions(+), 26 deletions(-) diff --git a/lib/Stow.pm.in b/lib/Stow.pm.in index 9b8367f..b76e187 100755 --- a/lib/Stow.pm.in +++ b/lib/Stow.pm.in @@ -383,22 +383,22 @@ sub stow_node { if ($self->is_a_link($target)) { # Where is the link pointing? - my $old_source = $self->read_a_link($target); - if (not $old_source) { + my $existing_source = $self->read_a_link($target); + if (not $existing_source) { error("Could not read link: $target"); } - debug(3, "--- Evaluate existing link: $target => $old_source"); + debug(3, "--- Evaluate existing link: $target => $existing_source"); # Does it point to a node under our stow directory? - my $old_path = $self->find_stowed_path($target, $old_source); - if (not $old_path) { + my $existing_path = $self->find_stowed_path($target, $existing_source); + if (not $existing_path) { $self->conflict("existing target is not owned by stow: $target"); return; # XXX # } # Does the existing $target actually point to anything? - if ($self->is_a_node($old_path)) { - if ($old_source eq $source) { + if ($self->is_a_node($existing_path)) { + if ($existing_source eq $source) { debug(3, "--- Skipping $target as it already points to $source"); } elsif ($self->defer($target)) { @@ -409,7 +409,7 @@ sub stow_node { $self->do_unlink($target); $self->do_link($source, $target); } - elsif ($self->is_a_dir(join_paths(parent($target), $old_source)) && + elsif ($self->is_a_dir(join_paths(parent($target), $existing_source)) && $self->is_a_dir(join_paths(parent($target), $source)) ) { # If the existing link points to a directory, @@ -419,14 +419,14 @@ sub stow_node { debug(3, "--- Unfolding $target"); $self->do_unlink($target); $self->do_mkdir($target); - $self->stow_contents($old_path, $target, join_paths('..', $old_source)); + $self->stow_contents($existing_path, $target, join_paths('..', $existing_source)); $self->stow_contents($path, $target, join_paths('..', $source)); } else { $self->conflict( q{existing target is stowed to a different package: %s => %s}, $target, - $old_source, + $existing_source, ); } } @@ -559,14 +559,14 @@ sub unstow_node_orig { debug(3, "Evaluate existing link: $target"); # Where is the link pointing? - my $old_source = $self->read_a_link($target); - if (not $old_source) { + my $existing_source = $self->read_a_link($target); + if (not $existing_source) { error("Could not read link: $target"); } # Does it point to a node under our stow directory? - my $old_path = $self->find_stowed_path($target, $old_source); - if (not $old_path) { + my $existing_path = $self->find_stowed_path($target, $existing_source); + if (not $existing_path) { # We're traversing the target tree not the package tree, # so we definitely expect to find stuff not owned by stow. # Therefore we can't flag a conflict. @@ -574,9 +574,9 @@ sub unstow_node_orig { } # Does the existing $target actually point to anything? - if (-e $old_path) { + if (-e $existing_path) { # Does link point to the right place? - if ($old_path eq $path) { + if ($existing_path eq $path) { $self->do_unlink($target); } elsif ($self->override($target)) { @@ -680,29 +680,29 @@ sub unstow_node { debug(3, "Evaluate existing link: $target"); # Where is the link pointing? - my $old_source = $self->read_a_link($target); - if (not $old_source) { + my $existing_source = $self->read_a_link($target); + if (not $existing_source) { error("Could not read link: $target"); } - if ($old_source =~ m{\A/}) { - warn "ignoring an absolute symlink: $target => $old_source\n"; + if ($existing_source =~ m{\A/}) { + warn "ignoring an absolute symlink: $target => $existing_source\n"; return; # XXX # } # Does it point to a node under our stow directory? - my $old_path = $self->find_stowed_path($target, $old_source); - if (not $old_path) { + my $existing_path = $self->find_stowed_path($target, $existing_source); + if (not $existing_path) { $self->conflict( - qq{existing target is not owned by stow: $target => $old_source} + qq{existing target is not owned by stow: $target => $existing_source} ); return; # XXX # } # Does the existing $target actually point to anything? - if (-e $old_path) { + if (-e $existing_path) { # Does link points to the right place? - if ($old_path eq $path) { + if ($existing_path eq $path) { $self->do_unlink($target); } @@ -720,7 +720,7 @@ sub unstow_node { # $self->conflict( # q{existing target is stowed to a different package: %s => %s}, # $target, - # $old_source + # $existing_source # ); #} } From ea82ef5b8b450985e768b38be84afa9a40fc0902 Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Wed, 23 Nov 2011 23:45:48 +0000 Subject: [PATCH 071/482] Add support for ignore lists. --- AUTHORS | 4 +- Makefile.am | 9 +- TODO | 21 +- default-ignore-list | 18 ++ doc/stow.texi | 219 ++++++++++++++++++--- lib/Stow.pm.in | 405 +++++++++++++++++++++++++++++++------- lib/Stow/Util.pm | 2 +- t/chkstow.t | 2 +- t/cleanup_invalid_links.t | 2 +- t/examples.t | 2 +- t/find_stowed_path.t | 38 ++-- t/foldable.t | 2 +- t/ignore.t | 291 +++++++++++++++++++++++++++ t/stow.t | 2 +- t/stow_contents.t | 2 +- t/testutil.pm | 25 +-- t/unstow_contents.t | 2 +- t/unstow_contents_orig.t | 2 +- 18 files changed, 881 insertions(+), 167 deletions(-) create mode 100644 default-ignore-list create mode 100755 t/ignore.t diff --git a/AUTHORS b/AUTHORS index b2ca1ed..5694873 100644 --- a/AUTHORS +++ b/AUTHORS @@ -34,7 +34,7 @@ version 2 and created the texi2man script. Adam Spiers refactored the backend code into new Stow.pm and Stow/Util.pm modules providing an OO interface, tightened -up the test suite, added support for `make test' and distribution via -CPAN, and cleaned up numerous other minor issues. +up the test suite, added support for ignore lists, `make test', and +distribution via CPAN, and cleaned up numerous other minor issues. Stow is currently maintained by Troy Mill. diff --git a/Makefile.am b/Makefile.am index 07e8a69..40dcba3 100644 --- a/Makefile.am +++ b/Makefile.am @@ -10,6 +10,8 @@ dist_pm_DATA = lib/Stow.pm pmstowdir = $(pmdir)/Stow dist_pmstow_DATA = lib/Stow/Util.pm +DEFAULT_IGNORE_LIST = default-ignore-list + TESTS_ENVIRONMENT=$(PERL) -I $(top_srcdir) TESTS = \ t/cleanup_invalid_links.t \ @@ -17,7 +19,7 @@ TESTS = \ t/examples.t \ t/find_stowed_path.t \ t/foldable.t \ - t/join_paths.t \ + t/ignore.t \ t/parent.t \ t/stow_contents.t \ t/stow.t \ @@ -31,6 +33,7 @@ EXTRA_DIST = \ bin/stow.in bin/chkstow.in lib/Stow.pm.in \ $(TESTS) t/testutil.pm \ $(TEXINFO_TEX) \ + default-ignore-list \ $(CPAN_FILES) CLEANFILES = $(bin_SCRIPTS) $(dist_pm_DATA) @@ -50,8 +53,8 @@ bin/chkstow: bin/chkstow.in Makefile $(edit) < $< > $@ chmod +x $@ -lib/Stow.pm: lib/Stow.pm.in Makefile - $(edit) < $< > $@ +lib/Stow.pm: lib/Stow.pm.in Makefile $(DEFAULT_IGNORE_LIST) + ( $(edit) < $<; cat $(DEFAULT_IGNORE_LIST) ) > $@ # The rules for manual.html and manual.texi are only used by # the developer diff --git a/TODO b/TODO index 92ca05b..01d6fda 100644 --- a/TODO +++ b/TODO @@ -1,24 +1,5 @@ +* Prevent folding of directories which contain ignored files * Honour .no-stow-folding and --no-folding -* Support ignore lists in files -*** Implement. -*** Add documentation about ignore lists. -***** Justification for having stow ignore lists independently of VCS ignore lists -******* If a file is in the VCS ignore list for its containing repo -********* generated during development - probably shouldn't be stowed -********* generated during compilation / install -*********** could be an intermediary file - again, probably shouldn't be stowed -*********** but most likely a file to install - e.g. compiled binary/library/docs - should be stowed -******* If a file is not in the VCS ignore list for its containing repo -********* it's probably tracked by the VCS - part of the repo -********* could intended for end use -*********** e.g. script/config file requiring no modifications, docs - should be stowed -********* or intended only to be used during compilation / build phase - shouldn't be stowed -*** (Eventually) rsync-like include/exclude lists instead of ignore lists * Add semi-automatic conflict resolution *** STOW_RESOLVE_CONFLICTS="non_stow_symlinks=t stow_symlinks=r" *** Add documentation about conflict resolution diff --git a/default-ignore-list b/default-ignore-list new file mode 100644 index 0000000..351480f --- /dev/null +++ b/default-ignore-list @@ -0,0 +1,18 @@ +# Comments and blank lines are allowed. + +RCS +.+,v + +CVS +\.\#.+ # CVS conflict files / emacs lock files +\.cvsignore + +\.svn +_darcs +\.hg + +\.git +\.gitignore + +.+~ # emacs backup files +\#.*\# # emacs autosave files diff --git a/doc/stow.texi b/doc/stow.texi index 79cc3d3..06a6bd4 100644 --- a/doc/stow.texi +++ b/doc/stow.texi @@ -82,6 +82,7 @@ approved by the Free Software Foundation. @c ========================================================================== @node Top, Introduction, (dir), (dir) +@top @ifinfo This manual describes GNU Stow @value{VERSION}, a program for managing @@ -89,35 +90,44 @@ the installation of software packages. @end ifinfo @menu -* Introduction:: Description of Stow. -* Terminology:: Terms used by this manual. -* Invoking Stow:: Option summary. -* Installing Packages:: Using Stow to install. -* Deleting Packages:: Using Stow to uninstall. -* Conflicts:: When Stow can't stow. -* Deferred Operation:: Using two passes to stow. -* Mixing Operations:: Multiple actions per invocation. -* Multiple Stow Directories:: Further segregating software. -* Target Maintenance:: Cleaning up mistakes. -* Resource Files:: Setting default command line options. +* Introduction:: Description of Stow. +* Terminology:: Terms used by this manual. +* Invoking Stow:: Option summary. +* Ignore Lists:: Controlling what gets stowed. +* Installing Packages:: Using Stow to install. +* Deleting Packages:: Using Stow to uninstall. +* Conflicts:: When Stow can't stow. +* Deferred Operation:: Using two passes to stow. +* Mixing Operations:: Multiple actions per invocation. +* Multiple Stow Directories:: Further segregating software. +* Target Maintenance:: Cleaning up mistakes. +* Resource Files:: Setting default command line options. * Compile-time vs Install-time:: Faking out `make install'. -* Bootstrapping:: When stow and perl are not yet stowed. -* Reporting Bugs:: How, what, where, and when to report. -* Known Bugs:: Don't report any of these. -* GNU General Public License:: Copying terms. -* Index:: Index of concepts. +* Bootstrapping:: When stow and perl are not yet stowed. +* Reporting Bugs:: How, what, where, and when to report. +* Known Bugs:: Don't report any of these. +* GNU General Public License:: Copying terms. +* Index:: Index of concepts. +@detailmenu --- The Detailed Node Listing --- -Compile-time and install-time +Ignore Lists -* GNU Emacs:: -* Other FSF Software:: -* Cygnus Software:: -* Perl and Perl 5 Modules:: +* Motivation For Ignore Lists:: +* Types And Syntax Of Ignore Lists:: +* Justification For Yet Another Set Of Ignore Files:: + +Compile-time vs Install-time + +* GNU Emacs:: +* Other FSF Software:: +* Cygnus Software:: +* Perl and Perl 5 Modules:: + +@end detailmenu @end menu - @c =========================================================================== @node Introduction, Terminology, Top, Top @chapter Introduction @@ -229,7 +239,7 @@ computed starting from the symlink's own directory. Stow only creates relative symlinks. @c =========================================================================== -@node Invoking Stow, Installing Packages, Terminology, Top +@node Invoking Stow, Ignore Lists, Terminology, Top @chapter Invoking Stow The syntax of the @code{stow} command is: @@ -265,15 +275,19 @@ This (repeatable) option lets you suppress acting on files that match the given perl regular expression. For example, using the options @example ---ignore='~' --ignore='\.#.*' +--ignore='*.orig' --ignore='*.dist' @end example @noindent -will cause stow to ignore emacs and CVS backup files. +will cause stow to ignore files ending in @file{.orig} or @file{.dist}. Note that the regular expression is anchored to the end of the filename, because this is what you will want to do most of the time. +Also note that by default Stow automatically ignores a ``sensible'' +built-in list of files and directories such as @file{CVS}, editor +backup files, and so on. @xref{Ignore Lists}, for more details. + @item --defer='' This (repeatable) option avoids stowing a file matching the given regular expression, if that file is already stowed by another package. @@ -407,9 +421,152 @@ operations will be performed if any conflicts are detected. @ref{Resource Files} for a way to set default values for any of these options. +@c =========================================================================== +@node Ignore Lists, Installing Packages, Invoking Stow, Top +@chapter Ignore Lists + +@cindex ignore lists +@cindex ignoring files and directories + +@menu +* Motivation For Ignore Lists:: +* Types And Syntax Of Ignore Lists:: +* Justification For Yet Another Set Of Ignore Files:: +@end menu @c =========================================================================== -@node Installing Packages, Deleting Packages, Invoking Stow, Top +@node Motivation For Ignore Lists, Types And Syntax Of Ignore Lists, Ignore Lists, Ignore Lists +@section Motivation For Ignore Lists + +In many situations, there will exist files under the package +directories which it would be undesirable to stow into the target +directory. For example, files related version control such as +@file{.gitignore}, @file{CVS}, @file{*,v} (RCS files) should typically +not have symlinks from the target tree pointing to them. Also there +may be files or directories relating to the build of the package which +are not needed at run-time. + +In these cases, it can be rather cumbersome to specify a +@samp{--ignore} parameter for each file or directory to be ignored. +This could be worked around by ensuring the existence of +@file{~/.stowrc} containing multiple @samp{--ignore} lines, or if a +different set of files/directories should be ignored depending on +which stow package is involved, a @file{.stowrc} file for each stow +package, but this would require the user to ensure that they were in +the correct directory before invoking stow, which would be tedious and +error-prone. Furthermore, since Stow shifts parameters from +@file{.stowrc} onto ARGV at run-time, it could clutter up the process +table with excessively long parameter lists, or even worse, exceed the +operating system's limit for process arguments. + +@cindex ignore lists +Therefore in addition to @samp{--ignore} parameters, Stow provides a +way to specify lists of files and directories to ignore. + +@c =========================================================================== +@node Types And Syntax Of Ignore Lists, Justification For Yet Another Set Of Ignore Files, Motivation For Ignore Lists, Ignore Lists +@section Types And Syntax Of Ignore Lists + +If you put Perl regular expressions, one per line, in a +@file{.stow-local-ignore} file within any top level package directory, +in which case any file or directory within that package matching any +of these regular expressions will be ignored. In the absence of this +package-specific ignore list, Stow will instead use the contents of +@file{~/.stow-global-ignore}, if it exists. If neither the +package-local or global ignore list exist, Stow will use its own +built-in default ignore list, which serves as a useful example of the +format of these ignore list files: + +@example +@verbatiminclude default-ignore-list +@end example + +Stow first iterates through the chosen ignore list (built-in, global, +or package-local) as per above, stripping out comments (if you want to +include the @samp{#} symbol in a regular expression, escape it with a +blackslash) and blank lines, placing each regular expressions into one +of two sets depending on whether it contains the @samp{/} forward +slash symbol. + +Then in order to determine whether a file or directory should be +ignored: + +@enumerate +@item +Stow calculates its path relative to the top-level package directory, +prefixing that with @samp{/}. If any of the regular expressions +containing a @samp{/} @emph{exactly}@footnote{Exact matching means the +regular expression is anchored at the beginning and end, in contrast +to unanchored regular expressions which will match a substring.} match +a subpath@footnote{In this context, ``subpath'' means a contiguous +subset of path segments; e.g for the relative path +@file{one/two/three/four}, the following are examples of valid +subpaths: @file{one}, @file{two}, @file{two/three}, +@file{two/three/four}.} of this relative path, then the file or +directory will be ignored. + +@item +If none of the regular expressions containing a @samp{/} match in the +manner described above, Stow checks whether the +@emph{basename}@footnote{The ``basename'' is the name of the file or +directory itself, excluding any directory path prefix - as returned by +the @command{basename} command.} of the file or directory matches +@emph{exactly} against the remaining regular expressions which do not +contain a @samp{/}, and if so, ignores the file or directory. + +@item +Otherwise, the file or directory is not ignored. +@end enumerate + +For example, if a file @file{bazqux} is in the @file{foo/bar} +subdirectory of the package directory, Stow would use +@code{/foo/bar/bazqux} as the text for matching against regular +expressions which contain @samp{/}, and @code{bazqux} as the text for +matching against regular expressions which don't contain @samp{/}. +Then regular expressions @code{bazqux}, @code{baz.*}, @code{.*qux}, +@code{bar/.*x}, and @code{^/foo/.*qux} would all match (causing the +file to be ignored), whereas @code{bar}, @code{baz}, and @code{qux} +would not (although @code{bar} would cause its parent directory to be +ignored and prevent Stow from recursing into that anyway, in which +case the file @file{bazqux} would not even be considered for +stowing). + +As a special exception to the above algorithm, any +@file{.stow-local-ignore} present in the top-level package directory +is @emph{always} ignored, regardless of the contents of any ignore +list, because this file serves no purpose outside the stow directory. + +@c =========================================================================== +@node Justification For Yet Another Set Of Ignore Files, , Types And Syntax Of Ignore Lists, Ignore Lists +@section Justification For Yet Another Set Of Ignore Files + +The reader may note that this format is very similar to existing +ignore list file formats, such as those for @code{CVS}, @code{git}, +@code{rsync} etc., and wonder if another set of ignore lists is +justified. However there are good reasons why Stow does not simply +check for the presence of say, @code{.cvsignore}, and use that if it +exists. Firstly, there is no guarantee that a stow package would +contain any version control meta-data, or permit introducing this if +it didn't already exist. + +Secondly even if it did, version control system ignore lists generally +reflect @emph{build-time} ignores rather than @emph{install-time}, and +there may be some intermediate or temporary files on those ignore +lists generated during development or at build-time which it would be +inappropriate to stow, even though many files generated at build-time +(binaries, libraries, documentation etc.) certainly do need to be +stowed. Similarly, if a file is @emph{not} in the version control +system's ignore list, there is no way of knowing whether the file is +intended for end use, let alone whether the version control system is +tracking it or not. + +Therefore it seems clear that ignore lists provided by version control +systems do not provide sufficient information for Stow to determine +which files and directories to stow, and so it makes sense for Stow to +support independent ignore lists. + +@c =========================================================================== +@node Installing Packages, Deleting Packages, Ignore Lists, Top @chapter Installing Packages @cindex installation @@ -532,7 +689,7 @@ package. @c =========================================================================== @node Conflicts, Deferred Operation, Deleting Packages, Top -@section Conflicts +@chapter Conflicts If, during installation, a file or symlink exists in the target tree and has the same name as something Stow needs to create, and if the @@ -766,10 +923,10 @@ The details of stowing some specific packages are described in the following sections. @menu -* GNU Emacs:: -* Other FSF Software:: -* Cygnus Software:: -* Perl and Perl 5 Modules:: +* GNU Emacs:: +* Other FSF Software:: +* Cygnus Software:: +* Perl and Perl 5 Modules:: @end menu @c --------------------------------------------------------------------------- diff --git a/lib/Stow.pm.in b/lib/Stow.pm.in index b76e187..21832cd 100755 --- a/lib/Stow.pm.in +++ b/lib/Stow.pm.in @@ -45,6 +45,12 @@ use Stow::Util qw(set_debug_level debug error set_test_mode our $ProgramName = 'stow'; our $VERSION = '@VERSION@'; +our $LOCAL_IGNORE_FILE = '.stow-local-ignore'; +our $GLOBAL_IGNORE_FILE = '.stow-global-ignore'; + +our @default_global_ignore_regexps = + __PACKAGE__->get_default_global_ignore_regexps(); + # These are the default options for each Stow instance. our %DEFAULT_OPTIONS = ( conflicts => 0, @@ -235,14 +241,16 @@ sub plan_unstow { debug(2, "Planning unstow of package $package..."); if ($self->{'compat'}) { $self->unstow_contents_orig( - join_paths($self->{stow_path}, $package), # path to package - '.', # target is current_dir + $self->{stow_path}, + $package, + '.', ); } else { $self->unstow_contents( - join_paths($self->{stow_path}, $package), # path to package - '.', # target is current_dir + $self->{stow_path}, + $package, + '.', ); } debug(2, "Planning unstow of package $package... done"); @@ -269,8 +277,9 @@ sub plan_stow { } debug(2, "Planning stow of package $package..."); $self->stow_contents( - join_paths($self->{stow_path}, $package), # path package - '.', # target is current dir + $self->{stow_path}, + $package, + '.', join_paths($self->{stow_path}, $package), # source from target ); debug(2, "Planning stow of package $package... done"); @@ -306,23 +315,29 @@ sub within_target_do { #===== METHOD =============================================================== # Name : stow_contents() # Purpose : stow the contents of the given directory -# Parameters: $path => relative path to source dir from current directory -# : $target => relative path to symlink target from the current directory -# : $source => relative path to symlink source from the dir of target +# Parameters: $stow_path => relative path from current (i.e. target) directory +# : to the stow dir containing the package to be stowed +# : $package => the package whose contents are being stowed +# : $target => subpath relative to package and target directories +# : $source => relative path from the (sub)dir of target +# : to symlink source # Returns : n/a # Throws : a fatal error if directory cannot be read -# Comments : stow_node() and stow_contents() are mutually recursive +# Comments : stow_node() and stow_contents() are mutually recursive. # : $source and $target are used for creating the symlink # : $path is used for folding/unfolding trees as necessary #============================================================================ sub stow_contents { my $self = shift; - my ($path, $target, $source) = @_; + my ($stow_path, $package, $target, $source) = @_; + + my $path = join_paths($stow_path, $package, $target); return if $self->should_skip_target_which_is_stow_dir($target); my $cwd = getcwd(); - my $msg = "Stowing contents of $path (cwd=$cwd, stow dir=$self->{stow_path})"; + my $msg = "Stowing contents of $path in package $package " + . "(cwd=$cwd, stow dir=$self->{stow_path})"; $msg =~ s!$ENV{HOME}/!~/!g; debug(2, $msg); debug(3, "--- $target => $source"); @@ -341,10 +356,12 @@ sub stow_contents { for my $node (@listing) { next NODE if $node eq '.'; next NODE if $node eq '..'; - next NODE if $self->ignore($node); + my $node_target = join_paths($target, $node); + next NODE if $self->ignore($stow_path, $package, $node_target); $self->stow_node( - join_paths($path, $node), # path - join_paths($target, $node), # target + $stow_path, + $package, + $node_target, # target join_paths($source, $node), # source ); } @@ -353,8 +370,10 @@ sub stow_contents { #===== METHOD =============================================================== # Name : stow_node() # Purpose : stow the given node -# Parameters: $path => relative path to source node from the current directory -# : $target => relative path to symlink target from the current directory +# Parameters: $stow_path => relative path from current (i.e. target) directory +# : to the stow dir containing the node to be stowed +# : $package => the package containing the node being stowed +# : $target => subpath relative to package and target directories # : $source => relative path to symlink source from the dir of target # Returns : n/a # Throws : fatal exception if a conflict arises @@ -364,7 +383,9 @@ sub stow_contents { #============================================================================ sub stow_node { my $self = shift; - my ($path, $target, $source) = @_; + my ($stow_path, $package, $target, $source) = @_; + + my $path = join_paths($stow_path, $package, $target); debug(2, "Stowing from $path"); debug(3, "--- $target => $source"); @@ -381,7 +402,6 @@ sub stow_node { # Does the target already exist? if ($self->is_a_link($target)) { - # Where is the link pointing? my $existing_source = $self->read_a_link($target); if (not $existing_source) { @@ -390,7 +410,8 @@ sub stow_node { debug(3, "--- Evaluate existing link: $target => $existing_source"); # Does it point to a node under our stow directory? - my $existing_path = $self->find_stowed_path($target, $existing_source); + my ($existing_path, $existing_stow_path, $existing_package) = + $self->find_stowed_path($target, $existing_source); if (not $existing_path) { $self->conflict("existing target is not owned by stow: $target"); return; # XXX # @@ -416,11 +437,21 @@ sub stow_node { # and the proposed new link points to a directory, # then we can unfold (split open) the tree at that point - debug(3, "--- Unfolding $target"); + debug(3, "--- Unfolding $target which was already owned by $existing_package"); $self->do_unlink($target); $self->do_mkdir($target); - $self->stow_contents($existing_path, $target, join_paths('..', $existing_source)); - $self->stow_contents($path, $target, join_paths('..', $source)); + $self->stow_contents( + $existing_stow_path, + $existing_package, + $target, + join_paths('..', $existing_source), + ); + $self->stow_contents( + $self->{stow_path}, + $package, + $target, + join_paths('..', $source), + ); } else { $self->conflict( @@ -440,7 +471,12 @@ sub stow_node { elsif ($self->is_a_node($target)) { debug(3, "--- Evaluate existing node: $target"); if ($self->is_a_dir($target)) { - $self->stow_contents($path, $target, join_paths('..', $source)); + $self->stow_contents( + $self->{stow_path}, + $package, + $target, + join_paths('..', $source), + ); } else { $self->conflict( @@ -497,7 +533,9 @@ sub marked_stow_dir { #===== METHOD =============================================================== # Name : unstow_contents_orig() # Purpose : unstow the contents of the given directory -# Parameters: $path => relative path to source dir from current directory +# Parameters: $stow_path => relative path from current (i.e. target) directory +# : to the stow dir containing the package to be unstowed +# : $package => the package whose contents are being unstowed # : $target => relative path to symlink target from the current directory # Returns : n/a # Throws : a fatal error if directory cannot be read @@ -506,7 +544,9 @@ sub marked_stow_dir { #============================================================================ sub unstow_contents_orig { my $self = shift; - my ($path, $target) = @_; + my ($stow_path, $package, $target) = @_; + + my $path = join_paths($stow_path, $package, $target); return if $self->should_skip_target_which_is_stow_dir($target); @@ -530,18 +570,18 @@ sub unstow_contents_orig { for my $node (@listing) { next NODE if $node eq '.'; next NODE if $node eq '..'; - next NODE if $self->ignore($node); - $self->unstow_node_orig( - join_paths($path, $node), # path - join_paths($target, $node), # target - ); + my $node_target = join_paths($target, $node); + next NODE if $self->ignore($stow_path, $package, $node_target); + $self->unstow_node_orig($stow_path, $package, $node_target); } } #===== METHOD =============================================================== # Name : unstow_node_orig() # Purpose : unstow the given node -# Parameters: $path => relative path to source node from the current directory +# Parameters: $stow_path => relative path from current (i.e. target) directory +# : to the stow dir containing the node to be stowed +# : $package => the package containing the node being stowed # : $target => relative path to symlink target from the current directory # Returns : n/a # Throws : fatal error if a conflict arises @@ -549,7 +589,9 @@ sub unstow_contents_orig { #============================================================================ sub unstow_node_orig { my $self = shift; - my ($path, $target) = @_; + my ($stow_path, $package, $target) = @_; + + my $path = join_paths($stow_path, $package, $target); debug(2, "Unstowing $target (compat mode)"); debug(3, "--- source path is $path"); @@ -565,7 +607,8 @@ sub unstow_node_orig { } # Does it point to a node under our stow directory? - my $existing_path = $self->find_stowed_path($target, $existing_source); + my ($existing_path, $existing_stow_path, $existing_package) = + $self->find_stowed_path($target, $existing_source); if (not $existing_path) { # We're traversing the target tree not the package tree, # so we definitely expect to find stuff not owned by stow. @@ -591,7 +634,7 @@ sub unstow_node_orig { } } elsif (-d $target) { - $self->unstow_contents_orig($path, $target); + $self->unstow_contents_orig($stow_path, $package, $target); # This action may have made the parent directory foldable if (my $parent = $self->foldable($target)) { @@ -612,7 +655,9 @@ sub unstow_node_orig { #===== METHOD =============================================================== # Name : unstow_contents() # Purpose : unstow the contents of the given directory -# Parameters: $path => relative path to source dir from current directory +# Parameters: $stow_path => relative path from current (i.e. target) directory +# : to the stow dir containing the package to be unstowed +# : $package => the package whose contents are being unstowed # : $target => relative path to symlink target from the current directory # Returns : n/a # Throws : a fatal error if directory cannot be read @@ -621,7 +666,9 @@ sub unstow_node_orig { #============================================================================ sub unstow_contents { my $self = shift; - my ($path, $target) = @_; + my ($stow_path, $package, $target) = @_; + + my $path = join_paths($stow_path, $package, $target); return if $self->should_skip_target_which_is_stow_dir($target); @@ -648,11 +695,9 @@ sub unstow_contents { for my $node (@listing) { next NODE if $node eq '.'; next NODE if $node eq '..'; - next NODE if $self->ignore($node); - $self->unstow_node( - join_paths($path, $node), # path - join_paths($target, $node), # target - ); + my $node_target = join_paths($target, $node); + next NODE if $self->ignore($stow_path, $package, $node_target); + $self->unstow_node($stow_path, $package, $node_target); } if (-d $target) { $self->cleanup_invalid_links($target); @@ -662,7 +707,9 @@ sub unstow_contents { #===== METHOD =============================================================== # Name : unstow_node() # Purpose : unstow the given node -# Parameters: $path => relative path to source node from the current directory +# Parameters: $stow_path => relative path from current (i.e. target) directory +# : to the stow dir containing the node to be stowed +# : $package => the package containing the node being unstowed # : $target => relative path to symlink target from the current directory # Returns : n/a # Throws : fatal error if a conflict arises @@ -670,7 +717,9 @@ sub unstow_contents { #============================================================================ sub unstow_node { my $self = shift; - my ($path, $target) = @_; + my ($stow_path, $package, $target) = @_; + + my $path = join_paths($stow_path, $package, $target); debug(2, "Unstowing $path"); debug(3, "--- target is $target"); @@ -686,12 +735,13 @@ sub unstow_node { } if ($existing_source =~ m{\A/}) { - warn "ignoring an absolute symlink: $target => $existing_source\n"; + warn "Ignoring an absolute symlink: $target => $existing_source\n"; return; # XXX # } # Does it point to a node under our stow directory? - my $existing_path = $self->find_stowed_path($target, $existing_source); + my ($existing_path, $existing_stow_path, $existing_package) = + $self->find_stowed_path($target, $existing_source); if (not $existing_path) { $self->conflict( qq{existing target is not owned by stow: $target => $existing_source} @@ -732,7 +782,7 @@ sub unstow_node { elsif (-e $target) { debug(3, "Evaluate existing node: $target"); if (-d $target) { - $self->unstow_contents($path, $target); + $self->unstow_contents($stow_path, $package, $target); # This action may have made the parent directory foldable if (my $parent = $self->foldable($target)) { @@ -752,16 +802,39 @@ sub unstow_node { } #===== METHOD =============================================================== -# Name : find_stowed_path() +# Name : path_owned_by_package() # Purpose : determine if the given link points to a member of a # : stowed package # Parameters: $target => path to a symbolic link under current directory # : $source => where that link points to -# Returns : relative path to stowed node (from the current directory) -# : or '' if link is not owned by stow -# Throws : fatal exception if link is unreadable -# Comments : allow for stow dir not being under target dir -# : we could put more logic under here for multiple stow dirs +# Returns : the package iff link is owned by stow, otherwise '' +# Throws : n/a +# Comments : lossy wrapper around find_stowed_path() +#============================================================================ +sub path_owned_by_package { + my $self = shift; + my ($target, $source) = @_; + + my ($path, $stow_path, $package) = + $self->find_stowed_path($target, $source); + return $package; +} + +#===== METHOD =============================================================== +# Name : find_stowed_path() +# Purpose : determine if the given link points to a member of a +# : stowed package +# Parameters: $target => path to a symbolic link under current directory +# : $source => where that link points to (needed because link +# : might not exist yet due to two-phase approach, +# : so we can't just call readlink()) +# Returns : ($path, $stow_path, $package) where $path and $stow_path are +# : relative from the current (i.e. target) directory +# : or ('', '', '') if link is not owned by stow +# Throws : n/a +# Comments : Needs +# : Allow for stow dir not being under target dir. +# : We could put more logic under here for multiple stow dirs. #============================================================================ sub find_stowed_path { my $self = shift; @@ -769,34 +842,48 @@ sub find_stowed_path { # Evaluate softlink relative to its target my $path = join_paths(parent($target), $source); - debug(4, " is path $path under $self->{stow_path} ?"); + debug(4, " is path $path owned by stow?"); - # Search for .stow files + # Search for .stow files - this allows us to detect links + # owned by stow directories other than the current one. my $dir = ''; - for my $part (split m{/+}, $path) { + my @path = split m{/+}, $path; + for my $i (0 .. $#path) { + my $part = $path[$i]; $dir = join_paths($dir, $part); - return $path if $self->marked_stow_dir($dir); + if ($self->marked_stow_dir($dir)) { + # FIXME - not sure if this can ever happen + internal_error("find_stowed_path() called directly on stow dir") + if $i == $#path; + + debug(4, " yes - $dir was marked as a stow dir"); + my $package = $path[$i + 1]; + return ($path, $dir, $package); + } } - # Compare with $self->{stow_path} - my @path = split m{/+}, $path; + # If no .stow file was found, we need to find out whether it's + # owned by the current stow directory, in which case $path will be + # a prefix of $self->{stow_path}. my @stow_path = split m{/+}, $self->{stow_path}; # Strip off common prefixes until one is empty while (@path && @stow_path) { if ((shift @path) ne (shift @stow_path)) { debug(4, " no - either $path not under $self->{stow_path} or vice-versa"); - return ''; + return ('', '', ''); } } if (@stow_path) { # @path must be empty debug(4, " no - $path is not under $self->{stow_path}"); - return ''; + return ('', '', ''); } - debug(4, " yes - in " . join_paths(@path)); - return $path; + my $package = shift @path; + + debug(4, " yes - by $package in " . join_paths(@path)); + return ($path, $self->{stow_path}, $package); } #===== METHOD ================================================================ @@ -841,7 +928,7 @@ sub cleanup_invalid_links { if ( not -e join_paths($dir, $source) and # bad link - $self->find_stowed_path($node_path, $source) # owned by stow + $self->path_owned_by_package($node_path, $source) # owned by stow ){ debug(3, "--- removing stale link: $node_path => " . join_paths($dir, $source)); @@ -910,7 +997,7 @@ sub foldable { $parent =~ s{\A\.\./}{}; # If the resulting path is owned by stow, we can fold it - if ($self->find_stowed_path($target, $parent)) { + if ($self->path_owned_by_package($target, $parent)) { debug(3, "--- $target is foldable"); return $parent; } @@ -997,21 +1084,189 @@ sub get_tasks { #===== METHOD ================================================================ # Name : ignore # Purpose : determine if the given path matches a regex in our ignore list -# Parameters: $path -# Returns : Boolean +# Parameters: $stow_path => the stow directory containing the package +# : $package => the package containing the path +# : $target => the path to check against the ignore list +# : relative to its package directory +# Returns : true iff the path should be ignored # Throws : no exceptions # Comments : none #============================================================================= sub ignore { my $self = shift; - my ($path) = @_; + my ($stow_path, $package, $target) = @_; - for my $suffix (@{$self->{'ignore'}}) { - return 1 if $path =~ m/$suffix/; + internal_error(__PACKAGE__ . "::ignore() called with empty target") + unless length $target; + + for my $suffix (@{ $self->{'ignore'} }) { + if ($target =~ m/$suffix/) { + debug(4, " Ignoring path $target due to --ignore=$suffix"); + return 1; + } } + + my $package_dir = join_paths($stow_path, $package); + my ($path_regexp, $segment_regexp) = + $self->get_ignore_regexps($package_dir); + debug(3, " Ignore list regexp for paths: " . + (defined $path_regexp ? "/$path_regexp/" : "none")); + debug(3, " Ignore list regexp for segments: " . + (defined $segment_regexp ? "/$segment_regexp/" : "none")); + + if (defined $path_regexp and "/$target" =~ $path_regexp) { + debug(4, " Ignoring path /$target"); + return 1; + } + + (my $basename = $target) =~ s!.+/!!; + if (defined $segment_regexp and $basename =~ $segment_regexp) { + debug(4, " Ignoring path segment $basename"); + return 1; + } + + debug(5, " Not ignoring $target"); return 0; } +sub get_ignore_regexps { + my $self = shift; + my ($dir) = @_; + + # N.B. the local and global stow ignore files have to have different + # names so that: + # 1. the global one can be a symlink to within a stow + # package, managed by stow itself, and + # 2. the local ones can be ignored via hardcoded logic in + # GlobsToRegexp(), so that they always stay within their stow packages. + + my $local_stow_ignore = join_paths($dir, $LOCAL_IGNORE_FILE); + my $global_stow_ignore = join_paths($ENV{HOME}, $GLOBAL_IGNORE_FILE); + + for my $file ($local_stow_ignore, $global_stow_ignore) { + if (-e $file) { + debug(3, " Using ignore file: $file"); + return $self->get_ignore_regexps_from_file($file); + } + else { + debug(4, " $file didn't exist"); + } + } + + debug(4, " Using built-in ignore list"); + return @default_global_ignore_regexps; +} + +my %ignore_file_regexps; + +sub get_ignore_regexps_from_file { + my $self = shift; + my ($file) = @_; + + if (exists $ignore_file_regexps{$file}) { + debug(4, " Using memoized regexps from $file"); + return @{ $ignore_file_regexps{$file} }; + } + + if (! open(REGEXPS, $file)) { + debug(4, " Failed to open $file: $!"); + return undef; + } + + my @regexps = $self->get_ignore_regexps_from_fh(\*REGEXPS); + close(REGEXPS); + + $ignore_file_regexps{$file} = [ @regexps ]; + return @regexps; +} + +=head2 invalidate_memoized_regexp($file) + +For efficiency of performance, regular expressions are compiled from +each ignore list file the first time it is used by the Stow process, +and then memoized for future use. If you expect the contents of these +files to change during a single run, you will need to invalidate the +memoized value from this cache. This method allows you to do that. + +=cut + +sub invalidate_memoized_regexp { + my $self = shift; + my ($file) = @_; + if (exists $ignore_file_regexps{$file}) { + debug(4, " Invalidated memoized regexp for $file"); + delete $ignore_file_regexps{$file}; + } + else { + debug(2, " WARNING: no memoized regexp for $file to invalidate"); + } +} + +sub get_ignore_regexps_from_fh { + my $self = shift; + my ($fh) = @_; + my %regexps; + while (<$fh>) { + chomp; + s/^\s+//; + s/\s+$//; + next if /^#/ or length($_) == 0; + s/\s+#.+//; # strip comments to right of pattern + s/\\#/#/g; + $regexps{$_}++; + } + + # Local ignore lists should *always* stay within the stow directory, + # because this is the only place stow looks for them. + $regexps{"^/\Q$LOCAL_IGNORE_FILE\E\$"}++; + + return $self->compile_ignore_regexps(%regexps); +} + +sub compile_ignore_regexps { + my $self = shift; + my (%regexps) = @_; + + my @segment_regexps; + my @path_regexps; + for my $regexp (keys %regexps) { + if (index($regexp, '/') < 0) { + # No / found in regexp, so use it for matching against basename + push @segment_regexps, $regexp; + } + else { + # / found in regexp, so use it for matching against full path + push @path_regexps, $regexp; + } + } + + my $segment_regexp = join '|', @segment_regexps; + my $path_regexp = join '|', @path_regexps; + $segment_regexp = @segment_regexps ? + $self->compile_regexp("^($segment_regexp)\$") : undef; + $path_regexp = @path_regexps ? + $self->compile_regexp("(^|/)($path_regexp)(/|\$)") : undef; + + return ($path_regexp, $segment_regexp); +} + +sub compile_regexp { + my $self = shift; + my ($regexp) = @_; + my $compiled = eval { qr/$regexp/ }; + die "Failed to compile regexp: $@\n" if $@; + return $compiled; +} + +sub get_default_global_ignore_regexps { + my $class = shift; + # Bootstrap issue - first time we stow, we will be stowing + # .cvsignore so it might not exist in ~ yet, or if it does, it could + # be an old version missing the entries we need. So we make sure + # they are there by hardcoding some crucial entries. + return $class->get_ignore_regexps_from_fh(\*DATA); +} + #===== METHOD ================================================================ # Name : defer # Purpose : determine if the given path matches a regex in our defer list @@ -1024,7 +1279,7 @@ sub defer { my $self = shift; my ($path) = @_; - for my $prefix (@{$self->{'defer'}}) { + for my $prefix (@{ $self->{'defer'} }) { return 1 if $path =~ m/$prefix/; } return 0; @@ -1042,7 +1297,7 @@ sub override { my $self = shift; my ($path) = @_; - for my $regex (@{$self->{'override'}}) { + for my $regex (@{ $self->{'override'} }) { return 1 if $path =~ m/$regex/; } return 0; @@ -1675,3 +1930,9 @@ sub internal_error { # cperl-indent-level: 4 # end: # vim: ft=perl + +############################################################################# +# Default global list of ignore regexps follows +# (automatically appended by the Makefile) + +__DATA__ diff --git a/lib/Stow/Util.pm b/lib/Stow/Util.pm index 0effc35..885269b 100644 --- a/lib/Stow/Util.pm +++ b/lib/Stow/Util.pm @@ -128,7 +128,7 @@ sub join_paths { my @paths = @_; # weed out empty components and concatenate - my $result = join '/', grep {!/\A\z/} @paths; + my $result = join '/', grep {! /\A\z/} @paths; # factor out back references and remove redundant /'s) my @result = (); diff --git a/t/chkstow.t b/t/chkstow.t index 711c33b..0b8027f 100755 --- a/t/chkstow.t +++ b/t/chkstow.t @@ -14,7 +14,7 @@ use Test::More tests => 7; use Test::Output; use English qw(-no_match_vars); -make_fresh_stow_and_target_dirs(); +init_test_dirs(); cd('t/target'); # setup stow directory diff --git a/t/cleanup_invalid_links.t b/t/cleanup_invalid_links.t index 9882487..99bfdf3 100755 --- a/t/cleanup_invalid_links.t +++ b/t/cleanup_invalid_links.t @@ -12,7 +12,7 @@ use English qw(-no_match_vars); use testutil; -make_fresh_stow_and_target_dirs(); +init_test_dirs(); cd('t/target'); my $stow; diff --git a/t/examples.t b/t/examples.t index 381f9ad..67d72aa 100755 --- a/t/examples.t +++ b/t/examples.t @@ -12,7 +12,7 @@ use testutil; use Test::More tests => 10; use English qw(-no_match_vars); -make_fresh_stow_and_target_dirs(); +init_test_dirs(); cd('t/target'); my $stow; diff --git a/t/find_stowed_path.t b/t/find_stowed_path.t index 7fac9f0..c632d5d 100755 --- a/t/find_stowed_path.t +++ b/t/find_stowed_path.t @@ -11,21 +11,21 @@ use testutil; use Test::More tests => 6; -make_fresh_stow_and_target_dirs(); +init_test_dirs(); my $stow = new_Stow(dir => 't/stow'); -is( - $stow->find_stowed_path('t/target/a/b/c', '../../../stow/a/b/c'), - 't/stow/a/b/c' +is_deeply( + [ $stow->find_stowed_path('t/target/a/b/c', '../../../stow/a/b/c') ], + [ 't/stow/a/b/c', 't/stow', 'a' ] => 'from root' ); cd('t/target'); $stow->set_stow_dir('../stow'); -is( - $stow->find_stowed_path('a/b/c','../../../stow/a/b/c'), - '../stow/a/b/c' +is_deeply( + [ $stow->find_stowed_path('a/b/c','../../../stow/a/b/c') ], + [ '../stow/a/b/c', '../stow', 'a' ] => 'from target directory' ); @@ -33,31 +33,31 @@ make_dir('stow'); cd('../..'); $stow->set_stow_dir('t/target/stow'); -is( - $stow->find_stowed_path('t/target/a/b/c', '../../stow/a/b/c'), - 't/target/stow/a/b/c' +is_deeply( + [ $stow->find_stowed_path('t/target/a/b/c', '../../stow/a/b/c') ], + [ 't/target/stow/a/b/c', 't/target/stow', 'a' ] => 'stow is subdir of target directory' ); -is( - $stow->find_stowed_path('t/target/a/b/c','../../empty'), - '' +is_deeply( + [ $stow->find_stowed_path('t/target/a/b/c','../../empty') ], + [ '', '', '' ] => 'target is not stowed' ); make_dir('t/target/stow2'); make_file('t/target/stow2/.stow'); -is( - $stow->find_stowed_path('t/target/a/b/c','../../stow2/a/b/c'), - 't/target/stow2/a/b/c' +is_deeply( + [ $stow->find_stowed_path('t/target/a/b/c','../../stow2/a/b/c') ], + [ 't/target/stow2/a/b/c', 't/target/stow2', 'a' ] => q(detect alternate stow directory) ); # Possible corner case with rogue symlink pointing to ancestor of # stow dir. -is( - $stow->find_stowed_path('t/target/a/b/c','../../..'), - '' +is_deeply( + [ $stow->find_stowed_path('t/target/a/b/c','../../..') ], + [ '', '', '' ] => q(corner case - link points to ancestor of stow dir) ); diff --git a/t/foldable.t b/t/foldable.t index 6815ec7..1d0446f 100755 --- a/t/foldable.t +++ b/t/foldable.t @@ -12,7 +12,7 @@ use testutil; use Test::More tests => 4; use English qw(-no_match_vars); -make_fresh_stow_and_target_dirs(); +init_test_dirs(); cd('t/target'); my $stow = new_Stow(dir => '../stow'); diff --git a/t/ignore.t b/t/ignore.t new file mode 100755 index 0000000..5d23bba --- /dev/null +++ b/t/ignore.t @@ -0,0 +1,291 @@ +#!/usr/local/bin/perl + +# +# Testing ignore lists. +# + +use strict; +use warnings; + +use File::Temp qw(tempdir); +use Test::More tests => 286; + +use testutil; +use Stow::Util qw(join_paths); + +init_test_dirs(); +cd('t/target'); + +my $stow = new_Stow(); + +sub test_ignores { + my ($stow_path, $package, $context, @tests) = @_; + $context ||= ''; + while (@tests) { + my $path = shift @tests; + my $should_ignore = shift @tests; + my $not = $should_ignore ? '' : ' not'; + my $was_ignored = $stow->ignore($stow_path, $package, $path); + is( + $was_ignored, $should_ignore, + "Should$not ignore $path $context" + ); + } +} + +sub test_local_ignore_list_always_ignored_at_top_level { + my ($stow_path, $package, $context) = @_; + test_ignores( + $stow_path, $package, $context, + $Stow::LOCAL_IGNORE_FILE => 1, + "subdir/" . $Stow::LOCAL_IGNORE_FILE => 0, + ); +} + +sub test_built_in_list { + my ($stow_path, $package, $context, $expect_ignores) = @_; + + for my $ignored ('CVS', '.cvsignore', '#autosave#') { + for my $path ($ignored, "foo/bar/$ignored") { + my $suffix = "$path.suffix"; + (my $prefix = $path) =~ s!([^/]+)$!prefix.$1!; + + test_ignores( + $stow_path, $package, $context, + $path => $expect_ignores, + $prefix => 0, + $suffix => 0, + ); + } + } + + # The pattern catching lock files allows suffixes but not prefixes + for my $ignored ('.#lock-file') { + for my $path ($ignored, "foo/bar/$ignored") { + my $suffix = "$path.suffix"; + (my $prefix = $path) =~ s!([^/]+)$!prefix.$1!; + + test_ignores( + $stow_path, $package, $context, + $path => $expect_ignores, + $prefix => 0, + $suffix => $expect_ignores, + ); + } + } +} + +sub test_user_global_list { + my ($stow_path, $package, $context, $expect_ignores) = @_; + + for my $path ('', 'foo/bar/') { + test_ignores( + $stow_path, $package, $context, + $path . 'exact' => $expect_ignores, + $path . '0exact' => 0, + $path . 'exact1' => 0, + $path . '0exact1' => 0, + + $path . 'substring' => 0, + $path . '0substring' => 0, + $path . 'substring1' => 0, + $path . '0substring1' => $expect_ignores, + ); + } +} + +sub setup_user_global_list { + # Now test with global ignore list in home directory + $ENV{HOME} = tempdir(); + make_file(join_paths($ENV{HOME}, $Stow::GLOBAL_IGNORE_FILE), <invalidate_memoized_regexp($local_ignore); + return $local_ignore; +} + +sub main { + my $stow_path = '../stow'; + my $package; + my $context; + + # Test built-in list first. init_test_dirs() already set + # $ENV{HOME} to ensure that we're not using the user's global + # ignore list. + $package = 'non-existent-package'; + $context = "when using built-in list"; + test_local_ignore_list_always_ignored_at_top_level($stow_path, $package, $context); + test_built_in_list($stow_path, $package, $context, 1); + + # Test ~/.stow-global-ignore + setup_user_global_list(); + $context = "when using ~/$Stow::GLOBAL_IGNORE_FILE"; + test_local_ignore_list_always_ignored_at_top_level($stow_path, $package, $context); + test_built_in_list($stow_path, $package, $context, 0); + test_user_global_list($stow_path, $package, $context, 1); + + # Test empty package-local .stow-local-ignore + $package = 'ignorepkg'; + my $local_ignore = setup_package_local_list($stow_path, $package, ""); + $context = "when using empty $local_ignore"; + test_local_ignore_list_always_ignored_at_top_level($stow_path, $package, $context); + test_built_in_list($stow_path, $package, $context, 0); + test_user_global_list($stow_path, $package, $context, 0); + test_ignores( + $stow_path, $package, $context, + 'random' => 0, + 'foo2/bar' => 0, + 'foo2/bars' => 0, + 'foo2/bar/random' => 0, + 'foo2/bazqux' => 0, + 'xfoo2/bazqux' => 0, + ); + + # Test package-local .stow-local-ignore with only path segment regexps + $local_ignore = setup_package_local_list($stow_path, $package, < 1, + 'foo2/bar' => 0, + 'foo2/bars' => 0, + 'foo2/bar/random' => 1, + 'foo2/bazqux' => 0, + 'xfoo2/bazqux' => 0, + ); + + # Test package-local .stow-local-ignore with only full path regexps + $local_ignore = setup_package_local_list($stow_path, $package, < 0, + 'foo2/bar' => 1, + 'foo2/bars' => 0, + 'foo2/bar/random' => 1, + 'foo2/bazqux' => 0, + 'xfoo2/bazqux' => 0, + ); + + # Test package-local .stow-local-ignore with a mixture of regexps + $local_ignore = setup_package_local_list($stow_path, $package, < 1, + 'foo2/bar' => 1, + 'foo2/bars' => 0, + 'foo2/bar/random' => 1, + 'foo2/bazqux' => 1, + 'xfoo2/bazqux' => 0, + ); + + test_examples_in_manual($stow_path); + test_invalid_regexp($stow_path, "Invalid segment regexp in list", < 1, + ); + } + + for my $re ('bar', 'baz', 'qux') { + my $local_ignore = setup_package_local_list($stow_path, $package, "$re\n"); + test_ignores( + $stow_path, $package, $context, + "foo/bar/bazqux" => 0, + ); + } +} + +sub test_invalid_regexp { + my ($stow_path, $context, $list) = @_; + my $package = 'ignorepkg'; + + my $local_ignore = setup_package_local_list($stow_path, $package, $list); + eval { + test_ignores( + $stow_path, $package, $context, + "foo/bar/bazqux" => 1, + ); + }; + like($@, qr/^Failed to compile regexp: Quantifier follows nothing in regex;/, + $context); +} + +sub test_ignore_via_stow { + my ($stow_path) = @_; + + my $package = 'pkg1'; + make_dir("$stow_path/$package/foo/bar"); + make_file("$stow_path/$package/foo/bar/baz"); + + setup_package_local_list($stow_path, $package, 'foo'); + $stow->plan_stow($package); + is($stow->get_tasks(), 0, 'top dir ignored'); + is($stow->get_conflicts(), 0, 'top dir ignored, no conflicts'); + + make_dir("foo"); + for my $ignore ('bar', 'foo/bar', '/foo/bar', '^/foo/bar', '^/fo.+ar') { + setup_package_local_list($stow_path, $package, $ignore); + $stow->plan_stow($package); + is($stow->get_tasks(), 0, "bar ignored via $ignore"); + is($stow->get_conflicts(), 0, 'bar ignored, no conflicts'); + } + + make_file("$stow_path/$package/foo/qux"); + $stow->plan_stow($package); + $stow->process_tasks(); + is($stow->get_conflicts(), 0, 'no conflicts stowing qux'); + ok(! -e "foo/bar", "bar ignore prevented stow"); + ok(-l "foo/qux", "qux not ignored and stowed"); + is(readlink("foo/qux"), "../$stow_path/$package/foo/qux", "qux stowed correctly"); +} + +main(); diff --git a/t/stow.t b/t/stow.t index 2ad0fc8..902bb50 100755 --- a/t/stow.t +++ b/t/stow.t @@ -13,7 +13,7 @@ use testutil; require 'stow'; -make_fresh_stow_and_target_dirs(); +init_test_dirs(); local @ARGV = ( '-v', diff --git a/t/stow_contents.t b/t/stow_contents.t index b8a0eff..30cfa64 100755 --- a/t/stow_contents.t +++ b/t/stow_contents.t @@ -14,7 +14,7 @@ use English qw(-no_match_vars); use Stow::Util qw(canon_path); use testutil; -make_fresh_stow_and_target_dirs(); +init_test_dirs(); cd('t/target'); my $stow; diff --git a/t/testutil.pm b/t/testutil.pm index 5c71a20..2efe72e 100755 --- a/t/testutil.pm +++ b/t/testutil.pm @@ -10,14 +10,17 @@ use warnings; use Stow; use Stow::Util qw(parent); -sub make_fresh_stow_and_target_dirs { +sub init_test_dirs { die "t/ didn't exist; are you running the tests from the root of the tree?\n" unless -d 't'; for my $dir ('t/target', 't/stow') { - eval { remove_dir($dir); }; + -d $dir and remove_dir($dir); make_dir($dir); } + + # Don't let user's ~/.stow-global-ignore affect test results + $ENV{HOME} = '/tmp/fake/home'; } sub new_Stow { @@ -90,22 +93,22 @@ sub make_dir { # Name : create_file() # Purpose : create an empty file # Parameters: $path => proposed path to the file +# : $contents => (optional) contents to write to file # Returns : n/a # Throws : fatal error if the file could not be created # Comments : detects clash with an existing non-file #============================================================================ sub make_file { - my ($path) =@_; + my ($path, $contents) =@_; - if (not -e $path) { - open my $FILE ,'>', $path - or die "could not create file: $path ($!)\n"; - close $FILE; - } - elsif (not -f $path) { + if (-e $path and ! -f $path) { die "a non-file already exists at $path\n"; } - return; + + open my $FILE ,'>', $path + or die "could not create file: $path ($!)\n"; + print $FILE $contents if defined $contents; + close $FILE; } #===== SUBROUTINE =========================================================== @@ -168,7 +171,7 @@ sub remove_dir { next NODE if $node eq '..'; my $path = "$dir/$node"; - if (-l $path or -z $path) { + if (-l $path or -z $path or $node eq $Stow::LOCAL_IGNORE_FILE) { unlink $path or die "cannot unlink $path ($!)\n"; } elsif (-d "$path") { diff --git a/t/unstow_contents.t b/t/unstow_contents.t index cb9707d..45ad7d6 100755 --- a/t/unstow_contents.t +++ b/t/unstow_contents.t @@ -14,7 +14,7 @@ use English qw(-no_match_vars); use testutil; use Stow::Util qw(canon_path); -make_fresh_stow_and_target_dirs(); +init_test_dirs(); cd('t/target'); # Note that each of the following tests use a distinct set of files diff --git a/t/unstow_contents_orig.t b/t/unstow_contents_orig.t index 85214c5..61b1a45 100755 --- a/t/unstow_contents_orig.t +++ b/t/unstow_contents_orig.t @@ -14,7 +14,7 @@ use English qw(-no_match_vars); use testutil; use Stow::Util qw(canon_path); -make_fresh_stow_and_target_dirs(); +init_test_dirs(); cd('t/target'); # Note that each of the following tests use a distinct set of files From ad77ca6db78e78ffdd37f1772f670daca53e1294 Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Thu, 24 Nov 2011 17:33:36 +0000 Subject: [PATCH 072/482] Add HTML and PDF versions of manual to distribution. --- .gitignore | 5 +++++ Makefile.am | 40 +++++++++++++++++++++++++++++----------- 2 files changed, 34 insertions(+), 11 deletions(-) diff --git a/.gitignore b/.gitignore index 508d516..21808c7 100644 --- a/.gitignore +++ b/.gitignore @@ -11,6 +11,11 @@ t/target/ version.texi lib/Stow.pm doc/stow.8 +doc/stow.pdf +doc/manual.pdf +doc/manual.texi +doc/manual.html +doc/stow.html .dirstamp stamp-vti MYMETA.json diff --git a/Makefile.am b/Makefile.am index 40dcba3..916c82f 100644 --- a/Makefile.am +++ b/Makefile.am @@ -2,14 +2,16 @@ dist_bin_SCRIPTS = bin/stow bin/chkstow info_TEXINFOS = doc/stow.texi -TEXINFO_TEX = doc/texinfo.tex dist_man_MANS = doc/stow.8 -dist_doc_DATA = README +dist_doc_DATA = README doc/manual.html doc/manual.pdf pmdir = $(libdir)/perl5 dist_pm_DATA = lib/Stow.pm pmstowdir = $(pmdir)/Stow dist_pmstow_DATA = lib/Stow/Util.pm +TEXINFO_TEX = doc/texinfo.tex +export TEXI2DVI_BUILD_MODE = clean + DEFAULT_IGNORE_LIST = default-ignore-list TESTS_ENVIRONMENT=$(PERL) -I $(top_srcdir) @@ -39,7 +41,9 @@ CLEANFILES = $(bin_SCRIPTS) $(dist_pm_DATA) # clean up files left behind by test suite clean-local: - -rm -rf t/target t/stow + -rm -rf t/target t/stow \ + bin/stow bin/chkstow doc/stow.8 ChangeLog \ + doc/manual.* # this is more explicit and reliable than the config file trick edit = sed -e 's|[@]PERL[@]|$(PERL)|g' \ @@ -56,20 +60,34 @@ bin/chkstow: bin/chkstow.in Makefile lib/Stow.pm: lib/Stow.pm.in Makefile $(DEFAULT_IGNORE_LIST) ( $(edit) < $<; cat $(DEFAULT_IGNORE_LIST) ) > $@ -# The rules for manual.html and manual.texi are only used by -# the developer +############################################################################## +# The below rules are only used by the developer. +############################################################################## + +# It's conventional to generate $project.info, but it's also nicer to +# generate manual.html and manual.pdf (which ultimately go somewhere +# like /usr/share/doc/stow/) rather than stow.html and stow.pdf, to +# make it obvious that these files contain the manual. So we have to +# jump through a few extra hoops. We preserve timestamps to avoid any +# unnecessary rebuilds, since not everyone has texinfo installed. +doc/manual.texi: doc/stow.texi doc/version.texi + [ -d doc ] || mkdir doc # required in vpath mode + cp --preserve=timestamps $< $@ + +doc/manual.pdf: doc/stow.pdf doc/version.texi + [ -d doc ] || mkdir doc # required in vpath mode + cp --preserve=timestamps $< $@ + +# It's easier to calculate the absolute path to $(srcdir) rather than +# the relative path to it from the doc/ build subdirectory. doc/manual.html: doc/manual.texi -rm -f $@ - texi2html -expandinfo -menu -monolithic -verbose $< - -doc/manual.texi: doc/stow.texi - -rm -f $@ - cp $< $@ + srcdir=$$( cd $(srcdir); pwd ); \ + cd doc && texi2html -I $$srcdir -expandinfo -menu -monolithic -verbose manual.texi doc/stow.8: bin/stow Makefile pod2man $< > $@ MODULES = lib/Stow.pm lib/Stow/Util.pm - test: bin/stow bin/chkstow $(MODULES) perl -MTest::Harness -Ilib -It -Ibin -e 'runtests(@ARGV)' t/*.t From b87ca607bac895052e116038de36d63297d044ee Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Thu, 24 Nov 2011 17:14:51 +0000 Subject: [PATCH 073/482] Fix some minor issues in the manual. --- doc/stow.texi | 39 ++++++++++++++++++++------------------- 1 file changed, 20 insertions(+), 19 deletions(-) diff --git a/doc/stow.texi b/doc/stow.texi index 06a6bd4..d18dfaf 100644 --- a/doc/stow.texi +++ b/doc/stow.texi @@ -262,7 +262,7 @@ The following options are supported: @item -d @var{dir} @itemx --dir=@var{dir} Set the stow directory to @var{dir}. Defaults to the value of the environment -variable @code{STOW_DIR} if set, or the current directory otherwise. +variable @env{STOW_DIR} if set, or the current directory otherwise. @item -t @var{dir} @itemx --target=@var{dir} @@ -294,10 +294,10 @@ regular expression, if that file is already stowed by another package. This is effectively the opposite of @code{--override}. (N.B. the name @code{--defer} was chosen in the sense that the package -currently being stowed is treated with lower precedence than any already -installed package, not in the sense that the operation is being -postponed to be run at a later point in time; do not confuse this -nomenclature with the wording used in @xref{Deferred Operation}.) +currently being stowed is treated with lower precedence than any +already installed package, not in the sense that the operation is +being postponed to be run at a later point in time; do not confuse +this nomenclature with the wording used in @ref{Deferred Operation}.) For example, the following options @@ -308,8 +308,8 @@ For example, the following options @noindent will cause stow to skip over pre-existing man and info pages. -Equivalently, you could use --defer='man|info' since the argument is just -a Perl regex. +Equivalently, you could use @code{--defer='man|info'} since the +argument is just a Perl regex. Note that the regular expression is anchored to the beginning of the path relative to the target directory, because this is what you will want to do most @@ -379,10 +379,11 @@ number of times. @item -S @item --stow -explictly stow the package name(s) that follow this option. May be omitted if -you are not using the @samp{-D} or @samp{-R} options in the same invocation. -See @xref{Mixing Operations}, for details of when you might like to use this -feature. This option may be repeated any number of times. +explictly stow the package name(s) that follow this option. May be +omitted if you are not using the @samp{-D} or @samp{-R} options in the +same invocation. @xref{Mixing Operations}, for details of when you +might like to use this feature. This option may be repeated any number +of times. @end table The following options are useful for cleaning up your target tree: @@ -418,7 +419,7 @@ This option is deprecated as conflicts are now printed by default and no operations will be performed if any conflicts are detected. @end table -@ref{Resource Files} for a way to set default values for any of these +@xref{Resource Files}, for a way to set default values for any of these options. @c =========================================================================== @@ -744,11 +745,11 @@ stow -D emacs-21.3 -S emacs-21.4a @noindent which will replace emacs-21.3 with emacs-21.4a using a single invocation. -This is much faster and cleaner than performing two separate invocations of -stow, because redundant folding/unfolding operations can be factored out. In -addition, all the operations are calculated and merged before being executed -@pxref{Deferred Operation}, so the amount of of time in which GNU Emacs is -unavailable is minimised. +This is much faster and cleaner than performing two separate +invocations of stow, because redundant folding/unfolding operations +can be factored out. In addition, all the operations are calculated +and merged before being executed (@pxref{Deferred Operation}), so the +amount of of time in which GNU Emacs is unavailable is minimised. You can mix and match any number of actions, for example, @@ -872,11 +873,11 @@ must place it in the stow tree. Some software packages allow you to specify, at compile-time, separate locations for installation and for run-time. Perl is one such package; -@xref{Perl and Perl 5 Modules}. Others allow you to compile the +see @ref{Perl and Perl 5 Modules}. Others allow you to compile the package, then give a different destination in the @samp{make install} step without causing the binaries or other files to get rebuilt. Most GNU software falls into this category; Emacs is a notable exception. -See @ref{GNU Emacs}, and @ref{Other FSF Software}. +@xref{GNU Emacs}, and @ref{Other FSF Software}. Still other software packages cannot abide the idea of separate installation and run-time locations at all. If you try to @samp{make From 6534b21d290c0a83db330c0fd979242c4a75a849 Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Thu, 24 Nov 2011 17:15:02 +0000 Subject: [PATCH 074/482] Tidy up the copyright attributions in the manual. --- doc/stow.texi | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/doc/stow.texi b/doc/stow.texi index d18dfaf..668cb27 100644 --- a/doc/stow.texi +++ b/doc/stow.texi @@ -18,10 +18,15 @@ This file describes GNU Stow version @value{VERSION}, a program for managing the installation of software packages. -Software and documentation Copyright @copyright{} 1993, 1994, 1995, 1996 -by Bob Glickstein . -Copyright @copyright{} 2000, 2001 Guillaume Morin . -Copyright @copyright{} 2007 Kahlil (Kal) Hodgson . +Software and documentation is copyrighted by the following: + +@copyright{} 1993, 1994, 1995, 1996 Bob Glickstein +@* +@copyright{} 2000, 2001 Guillaume Morin +@* +@copyright{} 2007 Kahlil (Kal) Hodgson +@* +@copyright{} 2011 Adam Spiers Permission is granted to make and distribute verbatim copies of this manual provided the copyright notice and this permission notice are @@ -57,10 +62,15 @@ approved by the Free Software Foundation. This manual describes GNU Stow version @value{VERSION}, a program for managing the installation of software packages. -Software and documentation Copyright @copyright{} 1993, 1994, 1995, 1996 -by Bob Glickstein . -Copyright @copyright{} 2000,2001 Guillaume Morin -Copyright @copyright{} 2007 Kahlil (Kal) Hodgson +Software and documentation is copyrighted by the following: + +@copyright{} 1993, 1994, 1995, 1996 Bob Glickstein +@* +@copyright{} 2000, 2001 Guillaume Morin +@* +@copyright{} 2007 Kahlil (Kal) Hodgson +@* +@copyright{} 2011 Adam Spiers Permission is granted to make and distribute verbatim copies of this manual provided the copyright notice and this permission notice are From 0db112441f364d5b32a4b7ddab75f5655fbc87fb Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Thu, 24 Nov 2011 00:45:29 +0000 Subject: [PATCH 075/482] Strip superfluous quotes from $hash{'lookups'} --- bin/stow.in | 30 ++++++------ lib/Stow.pm.in | 128 ++++++++++++++++++++++++------------------------- t/chkstow.t | 2 +- t/stow.t | 8 ++-- 4 files changed, 84 insertions(+), 84 deletions(-) diff --git a/bin/stow.in b/bin/stow.in index de9c569..ecc3c3f 100755 --- a/bin/stow.in +++ b/bin/stow.in @@ -433,7 +433,7 @@ sub main { if (scalar @conflicts) { warn "WARNING: conflicts detected.\n"; - if ($options->{'conflicts'}) { + if ($options->{conflicts}) { warn $_ foreach @conflicts; } warn "WARNING: all operations aborted.\n"; @@ -472,19 +472,19 @@ sub process_options { sub { # FIXME: do we really need strip_quotes here? my $regex = strip_quotes($_[1]); - push @{$options{'ignore'}}, qr($regex\z); + push @{$options{ignore}}, qr($regex\z); }, 'override=s' => sub { my $regex = strip_quotes($_[1]); - push @{$options{'override'}}, qr(\A$regex); + push @{$options{override}}, qr(\A$regex); }, 'defer=s' => sub { my $regex = strip_quotes($_[1]); - push @{$options{'defer'}}, qr(\A$regex); + push @{$options{defer}}, qr(\A$regex); }, # a little craziness so we can do different actions on the same line: @@ -510,8 +510,8 @@ sub process_options { }, ) or usage(); - usage() if $options{'help'}; - version() if $options{'version'}; + usage() if $options{help}; + version() if $options{version}; sanitize_path_options(\%options); check_packages(\@pkgs_to_unstow, \@pkgs_to_stow); @@ -522,20 +522,20 @@ sub process_options { sub sanitize_path_options { my ($options) = @_; - if (exists $options->{'dir'}) { - $options->{'dir'} =~ s/\A +//; - $options->{'dir'} =~ s/ +\z//; + if (exists $options->{dir}) { + $options->{dir} =~ s/\A +//; + $options->{dir} =~ s/ +\z//; } else { - $options->{'dir'} = exists $ENV{STOW_DIR} ? $ENV{STOW_DIR} : getcwd(); + $options->{dir} = exists $ENV{STOW_DIR} ? $ENV{STOW_DIR} : getcwd(); } - if (exists $options->{'target'}) { - $options->{'target'} =~ s/\A +//; - $options->{'target'} =~ s/ +\z//; + if (exists $options->{target}) { + $options->{target} =~ s/\A +//; + $options->{target} =~ s/ +\z//; } else { - $options->{'target'} = parent($options->{'dir'}); + $options->{target} = parent($options->{dir}); } } @@ -568,7 +568,7 @@ sub check_packages { #============================================================================= sub get_config_file_options { my @defaults = (); - for my $file ("$ENV{'HOME'}/.stowrc", '.stowrc') { + for my $file ("$ENV{HOME}/.stowrc", '.stowrc') { if (-r $file) { warn "Loading defaults from $file\n"; open my $FILE, '<', $file diff --git a/lib/Stow.pm.in b/lib/Stow.pm.in index 21832cd..6aff678 100755 --- a/lib/Stow.pm.in +++ b/lib/Stow.pm.in @@ -125,7 +125,7 @@ sub new { join(", ", keys %opts), "\n"; } - $opts{'simulate'} = 1 if $opts{'conflicts'}; + $opts{simulate} = 1 if $opts{conflicts}; set_debug_level($new->get_verbosity()); set_test_mode($new->{test_mode}); @@ -239,7 +239,7 @@ sub plan_unstow { error("The given package name ($package) is not in your stow path $self->{stow_path}"); } debug(2, "Planning unstow of package $package..."); - if ($self->{'compat'}) { + if ($self->{compat}) { $self->unstow_contents_orig( $self->{stow_path}, $package, @@ -302,8 +302,8 @@ sub within_target_do { my ($code) = @_; my $cwd = getcwd(); - chdir($self->{'target'}) - or error("Cannot chdir to target tree: $self->{'target'}"); + chdir($self->{target}) + or error("Cannot chdir to target tree: $self->{target}"); debug(3, "cwd now $self->{target}"); $self->$code(); @@ -1099,7 +1099,7 @@ sub ignore { internal_error(__PACKAGE__ . "::ignore() called with empty target") unless length $target; - for my $suffix (@{ $self->{'ignore'} }) { + for my $suffix (@{ $self->{ignore} }) { if ($target =~ m/$suffix/) { debug(4, " Ignoring path $target due to --ignore=$suffix"); return 1; @@ -1279,7 +1279,7 @@ sub defer { my $self = shift; my ($path) = @_; - for my $prefix (@{ $self->{'defer'} }) { + for my $prefix (@{ $self->{defer} }) { return 1 if $path =~ m/$prefix/; } return 0; @@ -1297,7 +1297,7 @@ sub override { my $self = shift; my ($path) = @_; - for my $regex (@{ $self->{'override'} }) { + for my $regex (@{ $self->{override} }) { return 1 if $path =~ m/$regex/; } return 0; @@ -1323,13 +1323,13 @@ sub process_tasks { debug(2, "Processing tasks..."); - if ($self->{'simulate'}) { + if ($self->{simulate}) { warn "WARNING: simulating so all operations are deferred.\n"; return; } # Strip out all tasks with a skip action - $self->{tasks} = [ grep { $_->{'action'} ne 'skip' } @{ $self->{tasks} } ]; + $self->{tasks} = [ grep { $_->{action} ne 'skip' } @{ $self->{tasks} } ]; if (not @{ $self->{tasks} }) { warn "There are no outstanding operations to perform.\n"; @@ -1359,38 +1359,38 @@ sub process_task { my $self = shift; my ($task) = @_; - if ($task->{'action'} eq 'create') { - if ($task->{'type'} eq 'dir') { - mkdir($task->{'path'}, 0777) - or error(qq(Could not create directory: $task->{'path'})); + if ($task->{action} eq 'create') { + if ($task->{type} eq 'dir') { + mkdir($task->{path}, 0777) + or error(qq(Could not create directory: $task->{path})); } - elsif ($task->{'type'} eq 'link') { - symlink $task->{'source'}, $task->{'path'} + elsif ($task->{type} eq 'link') { + symlink $task->{source}, $task->{path} or error( q(Could not create symlink: %s => %s), - $task->{'path'}, - $task->{'source'} + $task->{path}, + $task->{source} ); } else { - internal_error(qq(bad task type: $task->{'type'})); + internal_error(qq(bad task type: $task->{type})); } } - elsif ($task->{'action'} eq 'remove') { - if ($task->{'type'} eq 'dir') { - rmdir $task->{'path'} - or error(qq(Could not remove directory: $task->{'path'})); + elsif ($task->{action} eq 'remove') { + if ($task->{type} eq 'dir') { + rmdir $task->{path} + or error(qq(Could not remove directory: $task->{path})); } - elsif ($task->{'type'} eq 'link') { - unlink $task->{'path'} - or error(qq(Could not remove link: $task->{'path'})); + elsif ($task->{type} eq 'link') { + unlink $task->{path} + or error(qq(Could not remove link: $task->{path})); } else { - internal_error(qq(bad task type: $task->{'type'})); + internal_error(qq(bad task type: $task->{type})); } } else { - internal_error(qq(bad task action: $task->{'action'})); + internal_error(qq(bad task action: $task->{action})); } } @@ -1411,7 +1411,7 @@ sub link_task_action { return ''; } - my $action = $self->{link_task_for}{$path}->{'action'}; + my $action = $self->{link_task_for}{$path}->{action}; internal_error("bad task action: $action") unless $action eq 'remove' or $action eq 'create'; @@ -1436,7 +1436,7 @@ sub dir_task_action { return ''; } - my $action = $self->{dir_task_for}{$path}->{'action'}; + my $action = $self->{dir_task_for}{$path}->{action}; internal_error("bad task action: $action") unless $action eq 'remove' or $action eq 'create'; @@ -1462,7 +1462,7 @@ sub parent_link_scheduled_for_removal { $prefix = join_paths($prefix, $part); debug(4, " parent_link_scheduled_for_removal($path): prefix $prefix"); if (exists $self->{link_task_for}{$prefix} and - $self->{link_task_for}{$prefix}->{'action'} eq 'remove') { + $self->{link_task_for}{$prefix}->{action} eq 'remove') { debug(4, " parent_link_scheduled_for_removal($path): link scheduled for removal"); return 1; } @@ -1630,7 +1630,7 @@ sub read_a_link { debug(4, " read_a_link($path): task exists with action $action"); if ($action eq 'create') { - return $self->{link_task_for}{$path}->{'source'}; + return $self->{link_task_for}{$path}->{source}; } elsif ($action eq 'remove') { internal_error( @@ -1662,8 +1662,8 @@ sub do_link { if (exists $self->{dir_task_for}{$newfile}) { my $task_ref = $self->{dir_task_for}{$newfile}; - if ($task_ref->{'action'} eq 'create') { - if ($task_ref->{'type'} eq 'dir') { + if ($task_ref->{action} eq 'create') { + if ($task_ref->{type} eq 'dir') { internal_error( "new link (%s => %s) clashes with planned new directory", $newfile, @@ -1671,23 +1671,23 @@ sub do_link { ); } } - elsif ($task_ref->{'action'} eq 'remove') { + elsif ($task_ref->{action} eq 'remove') { # We may need to remove a directory before creating a link so continue. } else { - internal_error("bad task action: $task_ref->{'action'}"); + internal_error("bad task action: $task_ref->{action}"); } } if (exists $self->{link_task_for}{$newfile}) { my $task_ref = $self->{link_task_for}{$newfile}; - if ($task_ref->{'action'} eq 'create') { - if ($task_ref->{'source'} ne $oldfile) { + if ($task_ref->{action} eq 'create') { + if ($task_ref->{source} ne $oldfile) { internal_error( "new link clashes with planned new link: %s => %s", - $task_ref->{'path'}, - $task_ref->{'source'}, + $task_ref->{path}, + $task_ref->{source}, ) } else { @@ -1695,18 +1695,18 @@ sub do_link { return; } } - elsif ($task_ref->{'action'} eq 'remove') { - if ($task_ref->{'source'} eq $oldfile) { + elsif ($task_ref->{action} eq 'remove') { + if ($task_ref->{source} eq $oldfile) { # No need to remove a link we are going to recreate debug(1, "LINK: $newfile => $oldfile (reverts previous action)"); - $self->{link_task_for}{$newfile}->{'action'} = 'skip'; + $self->{link_task_for}{$newfile}->{action} = 'skip'; delete $self->{link_task_for}{$newfile}; return; } # We may need to remove a link to replace it so continue } else { - internal_error("bad task action: $task_ref->{'action'}"); + internal_error("bad task action: $task_ref->{action}"); } } @@ -1738,26 +1738,26 @@ sub do_unlink { if (exists $self->{link_task_for}{$file}) { my $task_ref = $self->{link_task_for}{$file}; - if ($task_ref->{'action'} eq 'remove') { + if ($task_ref->{action} eq 'remove') { debug(1, "UNLINK: $file (duplicates previous action)"); return; } - elsif ($task_ref->{'action'} eq 'create') { + elsif ($task_ref->{action} eq 'create') { # Do need to create a link then remove it debug(1, "UNLINK: $file (reverts previous action)"); - $self->{link_task_for}{$file}->{'action'} = 'skip'; + $self->{link_task_for}{$file}->{action} = 'skip'; delete $self->{link_task_for}{$file}; return; } else { - internal_error("bad task action: $task_ref->{'action'}"); + internal_error("bad task action: $task_ref->{action}"); } } if (exists $self->{dir_task_for}{$file} and $self->{dir_task_for}{$file} eq 'create') { internal_error( "new unlink operation clashes with planned operation: %s dir %s", - $self->{dir_task_for}{$file}->{'action'}, + $self->{dir_task_for}{$file}->{action}, $file ); } @@ -1796,36 +1796,36 @@ sub do_mkdir { if (exists $self->{link_task_for}{$dir}) { my $task_ref = $self->{link_task_for}{$dir}; - if ($task_ref->{'action'} eq 'create') { + if ($task_ref->{action} eq 'create') { internal_error( "new dir clashes with planned new link (%s => %s)", - $task_ref->{'path'}, - $task_ref->{'source'}, + $task_ref->{path}, + $task_ref->{source}, ); } - elsif ($task_ref->{'action'} eq 'remove') { + elsif ($task_ref->{action} eq 'remove') { # May need to remove a link before creating a directory so continue } else { - internal_error("bad task action: $task_ref->{'action'}"); + internal_error("bad task action: $task_ref->{action}"); } } if (exists $self->{dir_task_for}{$dir}) { my $task_ref = $self->{dir_task_for}{$dir}; - if ($task_ref->{'action'} eq 'create') { + if ($task_ref->{action} eq 'create') { debug(1, "MKDIR: $dir (duplicates previous action)"); return; } - elsif ($task_ref->{'action'} eq 'remove') { + elsif ($task_ref->{action} eq 'remove') { debug(1, "MKDIR: $dir (reverts previous action)"); - $self->{dir_task_for}{$dir}->{'action'} = 'skip'; + $self->{dir_task_for}{$dir}->{action} = 'skip'; delete $self->{dir_task_for}{$dir}; return; } else { - internal_error("bad task action: $task_ref->{'action'}"); + internal_error("bad task action: $task_ref->{action}"); } } @@ -1859,27 +1859,27 @@ sub do_rmdir { my $task_ref = $self->{link_task_for}{$dir}; internal_error( "rmdir clashes with planned operation: %s link %s => %s", - $task_ref->{'action'}, - $task_ref->{'path'}, - $task_ref->{'source'} + $task_ref->{action}, + $task_ref->{path}, + $task_ref->{source} ); } if (exists $self->{dir_task_for}{$dir}) { my $task_ref = $self->{link_task_for}{$dir}; - if ($task_ref->{'action'} eq 'remove') { + if ($task_ref->{action} eq 'remove') { debug(1, "RMDIR $dir (duplicates previous action)"); return; } - elsif ($task_ref->{'action'} eq 'create') { + elsif ($task_ref->{action} eq 'create') { debug(1, "MKDIR $dir (reverts previous action)"); - $self->{link_task_for}{$dir}->{'action'} = 'skip'; + $self->{link_task_for}{$dir}->{action} = 'skip'; delete $self->{link_task_for}{$dir}; return; } else { - internal_error("bad task action: $task_ref->{'action'}"); + internal_error("bad task action: $task_ref->{action}"); } } diff --git a/t/chkstow.t b/t/chkstow.t index 0b8027f..4affd7f 100755 --- a/t/chkstow.t +++ b/t/chkstow.t @@ -70,7 +70,7 @@ stderr_like( "Skip directories containing .stow"); # squelch warn so that check_stow doesn't carp about skipping .stow all the time -$SIG{'__WARN__'} = sub { }; +$SIG{__WARN__} = sub { }; @ARGV = ('-t', '.', '-l'); stdout_like( diff --git a/t/stow.t b/t/stow.t index 902bb50..7057378 100755 --- a/t/stow.t +++ b/t/stow.t @@ -58,7 +58,7 @@ local @ARGV = ( 'dummy' ); ($options, $pkgs_to_delete, $pkgs_to_stow) = process_options(); -is_deeply($options->{'defer'}, [ qr(\Aman), qr(\Ainfo) ] => 'defer man and info'); +is_deeply($options->{defer}, [ qr(\Aman), qr(\Ainfo) ] => 'defer man and info'); # # Check setting override paths @@ -69,7 +69,7 @@ local @ARGV = ( 'dummy' ); ($options, $pkgs_to_delete, $pkgs_to_stow) = process_options(); -is_deeply($options->{'override'}, [qr(\Aman), qr(\Ainfo)] => 'override man and info'); +is_deeply($options->{override}, [qr(\Aman), qr(\Ainfo)] => 'override man and info'); # # Check stripping any matched quotes @@ -80,7 +80,7 @@ local @ARGV = ( 'dummy' ); ($options, $pkgs_to_delete, $pkgs_to_stow) = process_options(); -is_deeply($options->{'override'}, [qr(\Aman), qr(\Ainfo)] => 'strip shell quoting'); +is_deeply($options->{override}, [qr(\Aman), qr(\Ainfo)] => 'strip shell quoting'); # # Check setting ignored paths @@ -91,7 +91,7 @@ local @ARGV = ( 'dummy' ); ($options, $pkgs_to_delete, $pkgs_to_stow) = process_options(); -is_deeply($options->{'ignore'}, [ qr(~\z), qr(\.#.*\z) ] => 'ignore temp files'); +is_deeply($options->{ignore}, [ qr(~\z), qr(\.#.*\z) ] => 'ignore temp files'); # vim:ft=perl From 10ea9c6f4b0f0e517a69558431f2761709f4ff78 Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Thu, 24 Nov 2011 16:32:01 +0000 Subject: [PATCH 076/482] Numerous fixes so that `make distcheck' succeeds. Moves temporary test trees into a separate directory. --- .gitignore | 2 +- Makefile.am | 78 +++++++++++++++++++++++++++++---------- configure.ac | 5 ++- t/chkstow.t | 2 +- t/cleanup_invalid_links.t | 2 +- t/defer.t | 3 ++ t/examples.t | 2 +- t/find_stowed_path.t | 26 ++++++------- t/foldable.t | 2 +- t/ignore.t | 2 +- t/stow.t | 6 +-- t/stow_contents.t | 30 +++++++-------- t/testutil.pm | 21 ++++++++--- t/unstow_contents.t | 40 ++++++++++---------- t/unstow_contents_orig.t | 40 ++++++++++---------- 15 files changed, 158 insertions(+), 103 deletions(-) diff --git a/.gitignore b/.gitignore index 21808c7..f3ed09f 100644 --- a/.gitignore +++ b/.gitignore @@ -7,7 +7,6 @@ config.status configure stamp-vti stow.info -t/target/ version.texi lib/Stow.pm doc/stow.8 @@ -20,3 +19,4 @@ doc/stow.html stamp-vti MYMETA.json MYMETA.yml +tmp-testing-trees/ diff --git a/Makefile.am b/Makefile.am index 916c82f..7419305 100644 --- a/Makefile.am +++ b/Makefile.am @@ -11,37 +11,74 @@ dist_pmstow_DATA = lib/Stow/Util.pm TEXINFO_TEX = doc/texinfo.tex export TEXI2DVI_BUILD_MODE = clean +AM_MAKEINFOFLAGS = -I $(srcdir) -DEFAULT_IGNORE_LIST = default-ignore-list +# We require this -I parameter to ensure that the include of the +# default ignore list in the manual works. Unfortunately this is +# the only way to do it: +# +# http://article.gmane.org/gmane.comp.sysutils.automake.bugs/4334/match=passing+parameters +# +# even though it annoyingly produces a warning with the -Wall option +# to AM_INIT_AUTOMAKE which has to be silenced via -Wno-override. +TEXI2DVI = texi2dvi $(AM_MAKEINFOFLAGS) -TESTS_ENVIRONMENT=$(PERL) -I $(top_srcdir) -TESTS = \ - t/cleanup_invalid_links.t \ - t/defer.t \ - t/examples.t \ - t/find_stowed_path.t \ - t/foldable.t \ - t/ignore.t \ - t/parent.t \ - t/stow_contents.t \ - t/stow.t \ - t/unstow_contents_orig.t \ - t/unstow_contents.t \ - t/chkstow.t +DEFAULT_IGNORE_LIST = $(srcdir)/default-ignore-list + +TESTS_DIR = $(srcdir)/t +TESTS_OUT = tmp-testing-trees +TESTS_ENVIRONMENT = $(PERL) -I$(srcdir)/bin -I$(srcdir)/lib -I$(TESTS_DIR) + +# This is a kind of hack; TESTS needs to be set to ensure that the +# `check-am' target makes check-TESTS, but we override check-TESTS +# so it doesn't really matter what it's set to, as long as it already +# exists (otherwise automake will try to build it). +TESTS = t AUTOMAKE_OPTIONS = dist-shar + +# GNU autotools standardised on the 'check' target, but CPAN (and the +# rest of the world) standardised on the 'test' target. +test: check + +# required in vpath mode to ensure $build/t/ exists +check_DATA = $(TESTS_OUT) + +# Test::Harness produces cleaner output than automake's default test +# harness, albeit without the pretty colours provided by the +# `color-tests' AM_INIT_AUTOMAKE option. This also dodges having to +# set TESTS to the full list of tests, which is good because automake +# doesn't support wildcards, and so it would be too easy to forget to +# add a new one to the list. +# +# Note that automake's `check' rule cannot be overridden +# for some weird reason: +# +# http://thread.gmane.org/gmane.comp.sysutils.automake.general/13040/focus=13041 +# +# so we override check-TESTS instead which is where the real work is +# done anyway. Unfortunately this produces a warning with the -Wall +# option to AM_INIT_AUTOMAKE which has to be silenced via +# -Wno-override. +check-TESTS: + dir=$(TESTS_DIR); \ + $(TESTS_ENVIRONMENT) -MTest::Harness -e 'runtests(@ARGV)' "$${dir#./}"/*.t + +$(TESTS_OUT): + mkdir -p $@ + CPAN_FILES = MANIFEST MANIFEST.SKIP Build.PL META.yml META.json EXTRA_DIST = \ bin/stow.in bin/chkstow.in lib/Stow.pm.in \ $(TESTS) t/testutil.pm \ $(TEXINFO_TEX) \ - default-ignore-list \ + $(DEFAULT_IGNORE_LIST) \ $(CPAN_FILES) CLEANFILES = $(bin_SCRIPTS) $(dist_pm_DATA) # clean up files left behind by test suite clean-local: - -rm -rf t/target t/stow \ + -rm -rf $(TESTS_OUT) \ bin/stow bin/chkstow doc/stow.8 ChangeLog \ doc/manual.* @@ -50,14 +87,17 @@ edit = sed -e 's|[@]PERL[@]|$(PERL)|g' \ -e 's|[@]VERSION[@]|$(VERSION)|g' bin/stow: bin/stow.in Makefile + [ -d bin ] || mkdir bin # required in vpath mode $(edit) < $< > $@ chmod +x $@ bin/chkstow: bin/chkstow.in Makefile + [ -d bin ] || mkdir bin # required in vpath mode $(edit) < $< > $@ chmod +x $@ lib/Stow.pm: lib/Stow.pm.in Makefile $(DEFAULT_IGNORE_LIST) + [ -d lib ] || mkdir lib # required in vpath mode ( $(edit) < $<; cat $(DEFAULT_IGNORE_LIST) ) > $@ ############################################################################## @@ -86,8 +126,6 @@ doc/manual.html: doc/manual.texi cd doc && texi2html -I $$srcdir -expandinfo -menu -monolithic -verbose manual.texi doc/stow.8: bin/stow Makefile + [ -d doc ] || mkdir doc # required in vpath mode pod2man $< > $@ -MODULES = lib/Stow.pm lib/Stow/Util.pm -test: bin/stow bin/chkstow $(MODULES) - perl -MTest::Harness -Ilib -It -Ibin -e 'runtests(@ARGV)' t/*.t diff --git a/configure.ac b/configure.ac index a9b6fa7..65b5f32 100644 --- a/configure.ac +++ b/configure.ac @@ -3,7 +3,10 @@ dnl Process this file with Autoconf to produce configure dnl AC_INIT([stow], [2.0.2], [bug-stow@gnu.org]) AC_PREREQ([2.61]) AC_CONFIG_AUX_DIR([automake]) -AM_INIT_AUTOMAKE([-Wall -Werror]) +# Unfortunately we have to disable warnings for overrides, because we +# need to override the built-in `check' rule and also the TEXI2DVI +# variable. +AM_INIT_AUTOMAKE([-Wall -Werror -Wno-override]) AC_PROG_INSTALL AM_MAINTAINER_MODE([enable]) diff --git a/t/chkstow.t b/t/chkstow.t index 4affd7f..bb611d8 100755 --- a/t/chkstow.t +++ b/t/chkstow.t @@ -15,7 +15,7 @@ use Test::Output; use English qw(-no_match_vars); init_test_dirs(); -cd('t/target'); +cd("$OUT_DIR/target"); # setup stow directory make_dir('stow'); diff --git a/t/cleanup_invalid_links.t b/t/cleanup_invalid_links.t index 99bfdf3..e6edd9d 100755 --- a/t/cleanup_invalid_links.t +++ b/t/cleanup_invalid_links.t @@ -13,7 +13,7 @@ use English qw(-no_match_vars); use testutil; init_test_dirs(); -cd('t/target'); +cd("$OUT_DIR/target"); my $stow; diff --git a/t/defer.t b/t/defer.t index 24d4d5f..ca47fb3 100755 --- a/t/defer.t +++ b/t/defer.t @@ -11,6 +11,9 @@ use testutil; use Test::More tests => 4; +init_test_dirs(); +cd("$OUT_DIR/target"); + my $stow; $stow = new_Stow(defer => [ 'man' ]); diff --git a/t/examples.t b/t/examples.t index 67d72aa..42894ef 100755 --- a/t/examples.t +++ b/t/examples.t @@ -13,7 +13,7 @@ use Test::More tests => 10; use English qw(-no_match_vars); init_test_dirs(); -cd('t/target'); +cd("$OUT_DIR/target"); my $stow; diff --git a/t/find_stowed_path.t b/t/find_stowed_path.t index c632d5d..2d5425d 100755 --- a/t/find_stowed_path.t +++ b/t/find_stowed_path.t @@ -13,15 +13,15 @@ use Test::More tests => 6; init_test_dirs(); -my $stow = new_Stow(dir => 't/stow'); +my $stow = new_Stow(dir => "$OUT_DIR/stow"); is_deeply( - [ $stow->find_stowed_path('t/target/a/b/c', '../../../stow/a/b/c') ], - [ 't/stow/a/b/c', 't/stow', 'a' ] + [ $stow->find_stowed_path("$OUT_DIR/target/a/b/c", '../../../stow/a/b/c') ], + [ "$OUT_DIR/stow/a/b/c", "$OUT_DIR/stow", 'a' ] => 'from root' ); -cd('t/target'); +cd("$OUT_DIR/target"); $stow->set_stow_dir('../stow'); is_deeply( [ $stow->find_stowed_path('a/b/c','../../../stow/a/b/c') ], @@ -31,33 +31,33 @@ is_deeply( make_dir('stow'); cd('../..'); -$stow->set_stow_dir('t/target/stow'); +$stow->set_stow_dir("$OUT_DIR/target/stow"); is_deeply( - [ $stow->find_stowed_path('t/target/a/b/c', '../../stow/a/b/c') ], - [ 't/target/stow/a/b/c', 't/target/stow', 'a' ] + [ $stow->find_stowed_path("$OUT_DIR/target/a/b/c", '../../stow/a/b/c') ], + [ "$OUT_DIR/target/stow/a/b/c", "$OUT_DIR/target/stow", 'a' ] => 'stow is subdir of target directory' ); is_deeply( - [ $stow->find_stowed_path('t/target/a/b/c','../../empty') ], + [ $stow->find_stowed_path("$OUT_DIR/target/a/b/c",'../../empty') ], [ '', '', '' ] => 'target is not stowed' ); -make_dir('t/target/stow2'); -make_file('t/target/stow2/.stow'); +make_dir("$OUT_DIR/target/stow2"); +make_file("$OUT_DIR/target/stow2/.stow"); is_deeply( - [ $stow->find_stowed_path('t/target/a/b/c','../../stow2/a/b/c') ], - [ 't/target/stow2/a/b/c', 't/target/stow2', 'a' ] + [ $stow->find_stowed_path("$OUT_DIR/target/a/b/c",'../../stow2/a/b/c') ], + [ "$OUT_DIR/target/stow2/a/b/c", "$OUT_DIR/target/stow2", 'a' ] => q(detect alternate stow directory) ); # Possible corner case with rogue symlink pointing to ancestor of # stow dir. is_deeply( - [ $stow->find_stowed_path('t/target/a/b/c','../../..') ], + [ $stow->find_stowed_path("$OUT_DIR/target/a/b/c",'../../..') ], [ '', '', '' ] => q(corner case - link points to ancestor of stow dir) ); diff --git a/t/foldable.t b/t/foldable.t index 1d0446f..ebb3b82 100755 --- a/t/foldable.t +++ b/t/foldable.t @@ -13,7 +13,7 @@ use Test::More tests => 4; use English qw(-no_match_vars); init_test_dirs(); -cd('t/target'); +cd("$OUT_DIR/target"); my $stow = new_Stow(dir => '../stow'); diff --git a/t/ignore.t b/t/ignore.t index 5d23bba..83966fc 100755 --- a/t/ignore.t +++ b/t/ignore.t @@ -14,7 +14,7 @@ use testutil; use Stow::Util qw(join_paths); init_test_dirs(); -cd('t/target'); +cd("$OUT_DIR/target"); my $stow = new_Stow(); diff --git a/t/stow.t b/t/stow.t index 7057378..c9a021d 100755 --- a/t/stow.t +++ b/t/stow.t @@ -17,15 +17,15 @@ init_test_dirs(); local @ARGV = ( '-v', - '-d t/stow', - '-t t/target', + "-d $OUT_DIR/stow", + "-t $OUT_DIR/target", 'dummy' ); my ($options, $pkgs_to_delete, $pkgs_to_stow) = process_options(); is($options->{verbose}, 1, 'verbose option'); -is($options->{dir}, 't/stow', 'stow dir option'); +is($options->{dir}, "$OUT_DIR/stow", 'stow dir option'); my $stow = new_Stow(%$options); diff --git a/t/stow_contents.t b/t/stow_contents.t index 30cfa64..db0e9fc 100755 --- a/t/stow_contents.t +++ b/t/stow_contents.t @@ -15,7 +15,7 @@ use Stow::Util qw(canon_path); use testutil; init_test_dirs(); -cd('t/target'); +cd("$OUT_DIR/target"); my $stow; my @conflicts; @@ -293,16 +293,16 @@ ok( # stow a simple tree minimally when cwd isn't target # cd('../..'); -$stow = new_Stow(dir => 't/stow', target => 't/target'); +$stow = new_Stow(dir => "$OUT_DIR/stow", target => "$OUT_DIR/target"); -make_dir('t/stow/pkg16/bin16'); -make_file('t/stow/pkg16/bin16/file16'); +make_dir("$OUT_DIR/stow/pkg16/bin16"); +make_file("$OUT_DIR/stow/pkg16/bin16/file16"); $stow->plan_stow('pkg16'); $stow->process_tasks(); is($stow->get_conflicts(), 0, 'no conflicts with minimal stow'); is( - readlink('t/target/bin16'), + readlink("$OUT_DIR/target/bin16"), '../stow/pkg16/bin16', => "minimal stow of a simple tree when cwd isn't target" ); @@ -311,17 +311,17 @@ is( # stow a simple tree minimally to absolute stow dir when cwd isn't # target # -$stow = new_Stow(dir => canon_path('t/stow'), - target => 't/target'); +$stow = new_Stow(dir => canon_path("$OUT_DIR/stow"), + target => "$OUT_DIR/target"); -make_dir('t/stow/pkg17/bin17'); -make_file('t/stow/pkg17/bin17/file17'); +make_dir("$OUT_DIR/stow/pkg17/bin17"); +make_file("$OUT_DIR/stow/pkg17/bin17/file17"); $stow->plan_stow('pkg17'); $stow->process_tasks(); is($stow->get_conflicts(), 0, 'no conflicts with minimal stow'); is( - readlink('t/target/bin17'), + readlink("$OUT_DIR/target/bin17"), '../stow/pkg17/bin17', => "minimal stow of a simple tree with absolute stow dir" ); @@ -330,17 +330,17 @@ is( # stow a simple tree minimally with absolute stow AND target dirs when # cwd isn't target # -$stow = new_Stow(dir => canon_path('t/stow'), - target => canon_path('t/target')); +$stow = new_Stow(dir => canon_path("$OUT_DIR/stow"), + target => canon_path("$OUT_DIR/target")); -make_dir('t/stow/pkg18/bin18'); -make_file('t/stow/pkg18/bin18/file18'); +make_dir("$OUT_DIR/stow/pkg18/bin18"); +make_file("$OUT_DIR/stow/pkg18/bin18/file18"); $stow->plan_stow('pkg18'); $stow->process_tasks(); is($stow->get_conflicts(), 0, 'no conflicts with minimal stow'); is( - readlink('t/target/bin18'), + readlink("$OUT_DIR/target/bin18"), '../stow/pkg18/bin18', => "minimal stow of a simple tree with absolute stow and target dirs" ); diff --git a/t/testutil.pm b/t/testutil.pm index 2efe72e..67d4f45 100755 --- a/t/testutil.pm +++ b/t/testutil.pm @@ -4,17 +4,28 @@ # Utilities shared by test scripts # +package testutil; + use strict; use warnings; use Stow; -use Stow::Util qw(parent); +use Stow::Util qw(parent canon_path); + +use base qw(Exporter); +our @EXPORT = qw( + $OUT_DIR + init_test_dirs + cd + new_Stow new_compat_Stow + make_dir make_link make_file + remove_dir remove_link +); + +our $OUT_DIR = 'tmp-testing-trees'; sub init_test_dirs { - die "t/ didn't exist; are you running the tests from the root of the tree?\n" - unless -d 't'; - - for my $dir ('t/target', 't/stow') { + for my $dir ("$OUT_DIR/target", "$OUT_DIR/stow") { -d $dir and remove_dir($dir); make_dir($dir); } diff --git a/t/unstow_contents.t b/t/unstow_contents.t index 45ad7d6..6929a03 100755 --- a/t/unstow_contents.t +++ b/t/unstow_contents.t @@ -15,7 +15,7 @@ use testutil; use Stow::Util qw(canon_path); init_test_dirs(); -cd('t/target'); +cd("$OUT_DIR/target"); # Note that each of the following tests use a distinct set of files @@ -273,8 +273,8 @@ ok( # Unstow a never stowed package # -eval { remove_dir('t/target'); }; -mkdir('t/target'); +eval { remove_dir("$OUT_DIR/target"); }; +mkdir("$OUT_DIR/target"); $stow = new_Stow(); $stow->plan_unstow('pkg12'); @@ -311,17 +311,17 @@ ok( # unstow a simple tree minimally when cwd isn't target # cd('../..'); -$stow = new_Stow(dir => 't/stow', target => 't/target'); +$stow = new_Stow(dir => "$OUT_DIR/stow", target => "$OUT_DIR/target"); -make_dir('t/stow/pkg13/bin13'); -make_file('t/stow/pkg13/bin13/file13'); -make_link('t/target/bin13', '../stow/pkg13/bin13'); +make_dir("$OUT_DIR/stow/pkg13/bin13"); +make_file("$OUT_DIR/stow/pkg13/bin13/file13"); +make_link("$OUT_DIR/target/bin13", '../stow/pkg13/bin13'); $stow->plan_unstow('pkg13'); $stow->process_tasks(); ok( scalar($stow->get_conflicts) == 0 && - -f 't/stow/pkg13/bin13/file13' && ! -e 't/target/bin13' + -f "$OUT_DIR/stow/pkg13/bin13/file13" && ! -e "$OUT_DIR/target/bin13" => 'unstow a simple tree' ); @@ -329,18 +329,18 @@ ok( # unstow a simple tree minimally with absolute stow dir when cwd isn't # target # -$stow = new_Stow(dir => canon_path('t/stow'), - target => 't/target'); +$stow = new_Stow(dir => canon_path("$OUT_DIR/stow"), + target => "$OUT_DIR/target"); -make_dir('t/stow/pkg14/bin14'); -make_file('t/stow/pkg14/bin14/file14'); -make_link('t/target/bin14', '../stow/pkg14/bin14'); +make_dir("$OUT_DIR/stow/pkg14/bin14"); +make_file("$OUT_DIR/stow/pkg14/bin14/file14"); +make_link("$OUT_DIR/target/bin14", '../stow/pkg14/bin14'); $stow->plan_unstow('pkg14'); $stow->process_tasks(); ok( scalar($stow->get_conflicts) == 0 && - -f 't/stow/pkg14/bin14/file14' && ! -e 't/target/bin14' + -f "$OUT_DIR/stow/pkg14/bin14/file14" && ! -e "$OUT_DIR/target/bin14" => 'unstow a simple tree with absolute stow dir' ); @@ -348,18 +348,18 @@ ok( # unstow a simple tree minimally with absolute stow AND target dirs # when cwd isn't target # -$stow = new_Stow(dir => canon_path('t/stow'), - target => canon_path('t/target')); +$stow = new_Stow(dir => canon_path("$OUT_DIR/stow"), + target => canon_path("$OUT_DIR/target")); -make_dir('t/stow/pkg15/bin15'); -make_file('t/stow/pkg15/bin15/file15'); -make_link('t/target/bin15', '../stow/pkg15/bin15'); +make_dir("$OUT_DIR/stow/pkg15/bin15"); +make_file("$OUT_DIR/stow/pkg15/bin15/file15"); +make_link("$OUT_DIR/target/bin15", '../stow/pkg15/bin15'); $stow->plan_unstow('pkg15'); $stow->process_tasks(); ok( scalar($stow->get_conflicts) == 0 && - -f 't/stow/pkg15/bin15/file15' && ! -e 't/target/bin15' + -f "$OUT_DIR/stow/pkg15/bin15/file15" && ! -e "$OUT_DIR/target/bin15" => 'unstow a simple tree with absolute stow and target dirs' ); diff --git a/t/unstow_contents_orig.t b/t/unstow_contents_orig.t index 61b1a45..ec86dac 100755 --- a/t/unstow_contents_orig.t +++ b/t/unstow_contents_orig.t @@ -15,7 +15,7 @@ use testutil; use Stow::Util qw(canon_path); init_test_dirs(); -cd('t/target'); +cd("$OUT_DIR/target"); # Note that each of the following tests use a distinct set of files @@ -280,8 +280,8 @@ ok( # Unstow a never stowed package # -eval { remove_dir('t/target'); }; -mkdir('t/target'); +eval { remove_dir("$OUT_DIR/target"); }; +mkdir("$OUT_DIR/target"); $stow = new_compat_Stow(); $stow->plan_unstow('pkg12'); @@ -318,17 +318,17 @@ ok( # unstow a simple tree minimally when cwd isn't target # cd('../..'); -$stow = new_Stow(dir => 't/stow', target => 't/target'); +$stow = new_Stow(dir => "$OUT_DIR/stow", target => "$OUT_DIR/target"); -make_dir('t/stow/pkg13/bin13'); -make_file('t/stow/pkg13/bin13/file13'); -make_link('t/target/bin13', '../stow/pkg13/bin13'); +make_dir("$OUT_DIR/stow/pkg13/bin13"); +make_file("$OUT_DIR/stow/pkg13/bin13/file13"); +make_link("$OUT_DIR/target/bin13", '../stow/pkg13/bin13'); $stow->plan_unstow('pkg13'); $stow->process_tasks(); ok( scalar($stow->get_conflicts) == 0 && - -f 't/stow/pkg13/bin13/file13' && ! -e 't/target/bin13' + -f "$OUT_DIR/stow/pkg13/bin13/file13" && ! -e "$OUT_DIR/target/bin13" => 'unstow a simple tree' ); @@ -336,18 +336,18 @@ ok( # unstow a simple tree minimally with absolute stow dir when cwd isn't # target # -$stow = new_Stow(dir => canon_path('t/stow'), - target => 't/target'); +$stow = new_Stow(dir => canon_path("$OUT_DIR/stow"), + target => "$OUT_DIR/target"); -make_dir('t/stow/pkg14/bin14'); -make_file('t/stow/pkg14/bin14/file14'); -make_link('t/target/bin14', '../stow/pkg14/bin14'); +make_dir("$OUT_DIR/stow/pkg14/bin14"); +make_file("$OUT_DIR/stow/pkg14/bin14/file14"); +make_link("$OUT_DIR/target/bin14", '../stow/pkg14/bin14'); $stow->plan_unstow('pkg14'); $stow->process_tasks(); ok( scalar($stow->get_conflicts) == 0 && - -f 't/stow/pkg14/bin14/file14' && ! -e 't/target/bin14' + -f "$OUT_DIR/stow/pkg14/bin14/file14" && ! -e "$OUT_DIR/target/bin14" => 'unstow a simple tree with absolute stow dir' ); @@ -355,18 +355,18 @@ ok( # unstow a simple tree minimally with absolute stow AND target dirs # when cwd isn't target # -$stow = new_Stow(dir => canon_path('t/stow'), - target => canon_path('t/target')); +$stow = new_Stow(dir => canon_path("$OUT_DIR/stow"), + target => canon_path("$OUT_DIR/target")); -make_dir('t/stow/pkg15/bin15'); -make_file('t/stow/pkg15/bin15/file15'); -make_link('t/target/bin15', '../stow/pkg15/bin15'); +make_dir("$OUT_DIR/stow/pkg15/bin15"); +make_file("$OUT_DIR/stow/pkg15/bin15/file15"); +make_link("$OUT_DIR/target/bin15", '../stow/pkg15/bin15'); $stow->plan_unstow('pkg15'); $stow->process_tasks(); ok( scalar($stow->get_conflicts) == 0 && - -f 't/stow/pkg15/bin15/file15' && ! -e 't/target/bin15' + -f "$OUT_DIR/stow/pkg15/bin15/file15" && ! -e "$OUT_DIR/target/bin15" => 'unstow a simple tree with absolute stow and target dirs' ); From c019af00a0069f05b1fac985f0de4fab212ea452 Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Thu, 24 Nov 2011 16:22:11 +0000 Subject: [PATCH 077/482] Distribute .tar.gz and .tar.bz2 but not .shar.gz --- Makefile.am | 10 +++++++--- configure.ac | 2 +- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/Makefile.am b/Makefile.am index 7419305..3e4415c 100644 --- a/Makefile.am +++ b/Makefile.am @@ -4,6 +4,12 @@ dist_bin_SCRIPTS = bin/stow bin/chkstow info_TEXINFOS = doc/stow.texi dist_man_MANS = doc/stow.8 dist_doc_DATA = README doc/manual.html doc/manual.pdf + +# Would be nice to include the split page HTML version of the manual +# in the distribution, but automake doesn't support wildcards and I'm +# loathe to explicitly list every single page here :-( +#nobase_dist_doc_DATA = doc/stow.html/*.html + pmdir = $(libdir)/perl5 dist_pm_DATA = lib/Stow.pm pmstowdir = $(pmdir)/Stow @@ -35,8 +41,6 @@ TESTS_ENVIRONMENT = $(PERL) -I$(srcdir)/bin -I$(srcdir)/lib -I$(TESTS_DIR) # exists (otherwise automake will try to build it). TESTS = t -AUTOMAKE_OPTIONS = dist-shar - # GNU autotools standardised on the 'check' target, but CPAN (and the # rest of the world) standardised on the 'test' target. test: check @@ -76,7 +80,7 @@ EXTRA_DIST = \ $(CPAN_FILES) CLEANFILES = $(bin_SCRIPTS) $(dist_pm_DATA) -# clean up files left behind by test suite +# clean up auto-generated files clean-local: -rm -rf $(TESTS_OUT) \ bin/stow bin/chkstow doc/stow.8 ChangeLog \ diff --git a/configure.ac b/configure.ac index 65b5f32..1f1c468 100644 --- a/configure.ac +++ b/configure.ac @@ -6,7 +6,7 @@ AC_CONFIG_AUX_DIR([automake]) # Unfortunately we have to disable warnings for overrides, because we # need to override the built-in `check' rule and also the TEXI2DVI # variable. -AM_INIT_AUTOMAKE([-Wall -Werror -Wno-override]) +AM_INIT_AUTOMAKE([-Wall -Werror -Wno-override dist-bzip2]) AC_PROG_INSTALL AM_MAINTAINER_MODE([enable]) From 62c513d7bc7cc27221ebcdd9533d4283b1063f19 Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Thu, 24 Nov 2011 16:59:26 +0000 Subject: [PATCH 078/482] Add some missing stuff to .gitignore --- .gitignore | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/.gitignore b/.gitignore index f3ed09f..37818b8 100644 --- a/.gitignore +++ b/.gitignore @@ -19,4 +19,11 @@ doc/stow.html stamp-vti MYMETA.json MYMETA.yml +autom4te.cache/ +blib/ +Build +_build/ tmp-testing-trees/ + +stow-[0-9].[0-9].[0-9].tar.* +stow-[0-9].[0-9].[0-9]/ From 685d44996372272637d05c6402f4c4f61d9bd3f8 Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Thu, 24 Nov 2011 16:59:45 +0000 Subject: [PATCH 079/482] Sort .gitignore alphabetically --- .gitignore | 35 +++++++++++++++++------------------ 1 file changed, 17 insertions(+), 18 deletions(-) diff --git a/.gitignore b/.gitignore index 37818b8..4fd20b4 100644 --- a/.gitignore +++ b/.gitignore @@ -1,29 +1,28 @@ -stow -chkstow +.dirstamp +Build +MYMETA.json +MYMETA.yml Makefile Makefile.in +_build/ +autom4te.cache/ +blib/ +chkstow config.log config.status configure -stamp-vti -stow.info -version.texi -lib/Stow.pm -doc/stow.8 -doc/stow.pdf +doc/manual.html doc/manual.pdf doc/manual.texi -doc/manual.html +doc/stow.8 doc/stow.html -.dirstamp +doc/stow.pdf +lib/Stow.pm stamp-vti -MYMETA.json -MYMETA.yml -autom4te.cache/ -blib/ -Build -_build/ -tmp-testing-trees/ - +stamp-vti +stow stow-[0-9].[0-9].[0-9].tar.* stow-[0-9].[0-9].[0-9]/ +stow.info +tmp-testing-trees/ +version.texi From 00d4e684455844bdb9637743aebe6eac6096c68a Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Thu, 24 Nov 2011 17:00:33 +0000 Subject: [PATCH 080/482] Auto-generate ChangeLog from git --- .gitignore | 1 + Makefile.am | 19 ++++++++++++++++++- ChangeLog => doc/ChangeLog.OLD | 2 +- 3 files changed, 20 insertions(+), 2 deletions(-) rename ChangeLog => doc/ChangeLog.OLD (99%) diff --git a/.gitignore b/.gitignore index 4fd20b4..7bc03f1 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,6 @@ .dirstamp Build +ChangeLog MYMETA.json MYMETA.yml Makefile diff --git a/Makefile.am b/Makefile.am index 3e4415c..9da7140 100644 --- a/Makefile.am +++ b/Makefile.am @@ -3,7 +3,10 @@ dist_bin_SCRIPTS = bin/stow bin/chkstow info_TEXINFOS = doc/stow.texi dist_man_MANS = doc/stow.8 -dist_doc_DATA = README doc/manual.html doc/manual.pdf +dist_doc_DATA = \ + README \ + doc/manual.html doc/manual.pdf \ + ChangeLog doc/ChangeLog.OLD # Would be nice to include the split page HTML version of the manual # in the distribution, but automake doesn't support wildcards and I'm @@ -133,3 +136,17 @@ doc/stow.8: bin/stow Makefile [ -d doc ] || mkdir doc # required in vpath mode pod2man $< > $@ + +ChangeLog: doc/ChangeLog.OLD Makefile + @if [ -d .git ]; then \ + ( \ + git log \ + --format="format:%ad %aN <%aE>%n%n * %w(70,0,4)%s%+b%n" \ + --name-status \ + v2.0.2..HEAD \ + | sed 's/^\([A-Z]\)\t/ \1 /'; \ + cat $< \ + ) > $@; \ + else \ + echo "Not in a git repository; can't update ChangeLog."; \ + fi diff --git a/ChangeLog b/doc/ChangeLog.OLD similarity index 99% rename from ChangeLog rename to doc/ChangeLog.OLD index 636c7d4..ba07eb7 100644 --- a/ChangeLog +++ b/doc/ChangeLog.OLD @@ -1,4 +1,4 @@ -2008-01-31 Kahlil Hodgson +Thu Jan 31 2008 Kahlil Hodgson * stow.texi: Austin Wood and Chris Hoobin clean this up for version 2. From 55d3f05cf2e9604b1bce36055ae7a7c6438be738 Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Thu, 24 Nov 2011 20:47:39 +0000 Subject: [PATCH 081/482] Ditch obsolete --conflicts option and update misleading documentation. --- bin/stow.in | 31 ++++++++----------------- doc/stow.texi | 62 ++++++++++++++++---------------------------------- lib/Stow.pm.in | 5 ---- 3 files changed, 30 insertions(+), 68 deletions(-) diff --git a/bin/stow.in b/bin/stow.in index ecc3c3f..343cd32 100755 --- a/bin/stow.in +++ b/bin/stow.in @@ -131,20 +131,7 @@ C<-D>). =item --no Do not perform any operations that modify the filesystem; merely show -what would happen. Since no actual operations are performed, C could report conflicts when none would actually take place (see -"Conflicts" in the info manual); but it won't fail to report -conflicts that B take place. - -=item -c - -=item --conflicts - -Do not exit immediately when a conflict is encountered. This option -implies C<-n>, and is used to search for all conflicts that might -arise from an actual Stow operation. As with C<-n>, however, false -conflicts might be reported (see the "Conflicts" section in the info -manual). +what would happen. =item -d DIR @@ -429,16 +416,19 @@ sub main { # --verbose: tell me what you are planning to do # --simulate: don't execute planned operations - # --conflicts: just list any detected conflicts if (scalar @conflicts) { - warn "WARNING: conflicts detected.\n"; - if ($options->{conflicts}) { - warn $_ foreach @conflicts; - } + warn "WARNING: conflicts detected:\n"; + warn $_ foreach @conflicts; warn "WARNING: all operations aborted.\n"; + exit 1; } else { + if ($options->{simulate}) { + warn "WARNING: in simulation mode so not modifying filesystem.\n"; + return; + } + $stow->process_tasks(); } } @@ -464,7 +454,7 @@ sub process_options { Getopt::Long::config('no_ignore_case', 'bundling', 'permute'); GetOptions( \%options, - 'verbose|v:+', 'help|h', 'simulate|n|no', 'conflicts|c', + 'verbose|v:+', 'help|h', 'simulate|n|no', 'version|V', 'compat|p', 'dir|d=s', 'target|t=s', # clean and pre-compile any regex's at parse time @@ -608,7 +598,6 @@ SYNOPSIS: OPTIONS: -n, --no Do not actually make any filesystem changes - -c, --conflicts Scan for and print any conflicts, implies -n -d DIR, --dir=DIR Set stow dir to DIR (default is current dir) -t DIR, --target=DIR Set target to DIR (default is parent of stow dir) -v, --verbose[=N] Increase verbosity (levels are 0,1,2,3; diff --git a/doc/stow.texi b/doc/stow.texi index 668cb27..257b685 100644 --- a/doc/stow.texi +++ b/doc/stow.texi @@ -107,7 +107,6 @@ the installation of software packages. * Installing Packages:: Using Stow to install. * Deleting Packages:: Using Stow to uninstall. * Conflicts:: When Stow can't stow. -* Deferred Operation:: Using two passes to stow. * Mixing Operations:: Multiple actions per invocation. * Multiple Stow Directories:: Further segregating software. * Target Maintenance:: Cleaning up mistakes. @@ -417,18 +416,6 @@ directory. The following options are deprecated: @end table -The following options are deprecated as of Stow version 2: -@table @samp -@item -c -@itemx --conflicts -Print any conflicts that are encountered. This option -implies @samp{-n}, and is used to search for all conflicts that might -arise from an actual Stow operation. - -This option is deprecated as conflicts are now printed by default and no -operations will be performed if any conflicts are detected. -@end table - @xref{Resource Files}, for a way to set default values for any of these options. @@ -699,7 +686,7 @@ package. @c =========================================================================== -@node Conflicts, Deferred Operation, Deleting Packages, Top +@node Conflicts, Mixing Operations, Deleting Packages, Top @chapter Conflicts If, during installation, a file or symlink exists in the target tree and @@ -711,37 +698,28 @@ other hand, if the existing name is merely a symlink that already points where Stow needs it to, then no conflict has occurred. (Thus it is harmless to install a package that has already been installed.) -A conflict causes Stow to exit immediately and print a warning -(unless @samp{-c} is given), even if that means aborting an installation -in mid-package. +For complex packages, scanning the stow and target trees in tandem, +and deciding whether to make directories or links, split-open or fold +directories, can actually take a long time (a number of seconds). +Moreover, an accurate analysis of potential conflicts requires us to +take into account all of these operations. -@cindex false conflict -When running Stow with the @samp{-n} or @samp{-c} options, no actual -filesystem-modifying operations take place. Thus if a folded tree would -have been split open, but instead was left in place because @samp{-n} or -@samp{-c} was used, then Stow will report a @dfn{false conflict}, since -the directory that Stow was expecting to populate has remained an -un-populatable symlink. +@anchor{Deferred Operation} +@section Deferred Operation + +Since version 2.0, Stow now adopts a two-phase algorithm, first +scanning for any potential conflicts before any stowing or unstowing +operations are performed. If any conflicts are found, they are +displayed and then Stow terminates without making any modifications to +the filesystem. This means that there is much less risk of a package +being partially stowed or unstowed due to conflicts. + +Prior to version 2.0, if a conflict was discovered, the stow or unstow +operation could be aborted mid-flow, leaving the target tree in an +inconsistent state. @c =========================================================================== -@node Deferred Operation, Mixing Operations, Conflicts, Top -@chapter Deferred Operation - -For complex packages, scanning the stow and target trees in tandem, and -deciding whether to make directories or links, split-open or fold directories, -can actually take a long time (a number of seconds). Moreover, an accurate -analysis of potential conflicts requires us to take into account all of -these operations. - -Since version 2.0, Stow now adopts a two-phase algorithm, first scanning -for any potential conflicts before any stowing or unstowing operations -are performed. This means that there is much less risk of a package -being partially stowed or unstowed due to conflicts. Prior to version -2.0, if a conflict was discovered, the stow or unstow operation could be -aborted mid-flow, leaving the target tree in an inconsistent state. - -@c =========================================================================== -@node Mixing Operations, Multiple Stow Directories, Deferred Operation, Top +@node Mixing Operations, Multiple Stow Directories, Conflicts, Top @chapter Mixing Operations Since version 2.0, multiple distinct actions can be specified in a single diff --git a/lib/Stow.pm.in b/lib/Stow.pm.in index 6aff678..88623f3 100755 --- a/lib/Stow.pm.in +++ b/lib/Stow.pm.in @@ -1323,11 +1323,6 @@ sub process_tasks { debug(2, "Processing tasks..."); - if ($self->{simulate}) { - warn "WARNING: simulating so all operations are deferred.\n"; - return; - } - # Strip out all tasks with a skip action $self->{tasks} = [ grep { $_->{action} ne 'skip' } @{ $self->{tasks} } ]; From 81da7be357f554166e20ce57ad6f9e28d3e6e4aa Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Thu, 24 Nov 2011 18:05:57 +0000 Subject: [PATCH 082/482] Sync up .gitignore and MANIFEST* with recent changes. --- .gitignore | 37 ++++++++++++++++++------------------- MANIFEST | 10 +++++----- MANIFEST.SKIP | 8 ++++++-- 3 files changed, 29 insertions(+), 26 deletions(-) diff --git a/.gitignore b/.gitignore index 7bc03f1..ced8a07 100644 --- a/.gitignore +++ b/.gitignore @@ -1,29 +1,28 @@ .dirstamp -Build -ChangeLog -MYMETA.json -MYMETA.yml -Makefile -Makefile.in +/Build +/ChangeLog +/MYMETA.json +/MYMETA.yml +/Makefile +/Makefile.in +/bin/chkstow +/bin/stow +/doc/stow.info +/doc/version.texi +/tmp-testing-trees/ _build/ autom4te.cache/ blib/ -chkstow config.log config.status configure -doc/manual.html -doc/manual.pdf -doc/manual.texi -doc/stow.8 -doc/stow.html -doc/stow.pdf -lib/Stow.pm +/doc/ChangeLog.OLD +/doc/manual.html +/doc/manual.pdf +/doc/manual.texi +/doc/stow.pdf +/doc/stow.8 +/lib/Stow.pm stamp-vti -stamp-vti -stow stow-[0-9].[0-9].[0-9].tar.* stow-[0-9].[0-9].[0-9]/ -stow.info -tmp-testing-trees/ -version.texi diff --git a/MANIFEST b/MANIFEST index c063667..6454cf4 100644 --- a/MANIFEST +++ b/MANIFEST @@ -1,9 +1,4 @@ -aclocal.m4 AUTHORS -automake/install-sh -automake/mdate-sh -automake/missing -automake/stamp-vti bin/chkstow bin/chkstow.in bin/stow @@ -13,6 +8,10 @@ ChangeLog configure configure.ac COPYING +default-ignore-list +doc/ChangeLog.OLD +doc/manual.html +doc/manual.pdf doc/stow.8 doc/stow.info doc/stow.texi @@ -33,6 +32,7 @@ t/defer.t t/examples.t t/find_stowed_path.t t/foldable.t +t/ignore.t t/join_paths.t t/parent.t t/stow.t diff --git a/MANIFEST.SKIP b/MANIFEST.SKIP index c8beef8..fa9f287 100644 --- a/MANIFEST.SKIP +++ b/MANIFEST.SKIP @@ -66,13 +66,17 @@ ^MANIFEST\.SKIP # Avoid archives of this distribution -\bStow-[\d\.\_]+ +\b[sS]tow-[\d\.\_]+ # Avoid autotools stuff +^aclocal.m4$ +^automake/ ^autom4te\.cache/.+$ ^config\.(log|status)$ ^doc/\.dirstamp$ ^doc/stamp-vti$ +^doc/manual.texi +^doc/stow.pdf # Avoid test files -^t/(stow|target)/.+$ +^tmp-testing-trees From 3d414dc0711b20a983dbecea9577f83c9264881c Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Thu, 24 Nov 2011 22:49:22 +0000 Subject: [PATCH 083/482] Improve conflict reporting --- bin/stow.in | 21 ++++--- lib/Stow.pm.in | 116 +++++++++++++++++++++++++++++---------- t/stow_contents.t | 17 +++--- t/unstow_contents.t | 16 +++--- t/unstow_contents_orig.t | 13 +++-- 5 files changed, 125 insertions(+), 58 deletions(-) diff --git a/bin/stow.in b/bin/stow.in index 343cd32..0db7a07 100755 --- a/bin/stow.in +++ b/bin/stow.in @@ -412,15 +412,20 @@ sub main { $stow->plan_unstow(@$pkgs_to_unstow); $stow->plan_stow (@$pkgs_to_stow); - my @conflicts = $stow->get_conflicts; + my %conflicts = $stow->get_conflicts; - # --verbose: tell me what you are planning to do - # --simulate: don't execute planned operations - - if (scalar @conflicts) { - warn "WARNING: conflicts detected:\n"; - warn $_ foreach @conflicts; - warn "WARNING: all operations aborted.\n"; + if (%conflicts) { + foreach my $action ('unstow', 'stow') { + next unless $conflicts{$action}; + foreach my $package (sort keys %{ $conflicts{$action} }) { + warn "WARNING! ${action}ing $package would cause conflicts:\n"; + #if $stow->get_action_count > 1; + foreach my $message (sort @{ $conflicts{$action}{$package} }) { + warn " * $message\n"; + } + } + } + warn "All operations aborted.\n"; exit 1; } else { diff --git a/lib/Stow.pm.in b/lib/Stow.pm.in index 88623f3..bf4df60 100755 --- a/lib/Stow.pm.in +++ b/lib/Stow.pm.in @@ -13,8 +13,8 @@ Stow - manage the installation of multiple software packages $stow->plan_unstow(@pkgs_to_unstow); $stow->plan_stow (@pkgs_to_stow); - my @conflicts = $stow->get_conflicts; - $stow->process_tasks() unless @conflicts; + my %conflicts = $stow->get_conflicts; + $stow->process_tasks() unless %conflicts; =head1 DESCRIPTION @@ -109,6 +109,8 @@ sub new { my $new = bless { }, $class; + $new->{action_count} = 0; + for my $required_arg (qw(dir target)) { croak "$class->new() called without '$required_arg' parameter\n" unless exists $opts{$required_arg}; @@ -125,8 +127,6 @@ sub new { join(", ", keys %opts), "\n"; } - $opts{simulate} = 1 if $opts{conflicts}; - set_debug_level($new->get_verbosity()); set_test_mode($new->{test_mode}); $new->set_stow_dir(); @@ -182,7 +182,8 @@ sub init_state { my $self = shift; # Store conflicts during pre-processing - $self->{conflicts} = []; + $self->{conflicts} = {}; + $self->{conflict_count} = 0; # Store command line packages to stow (-S and -R) $self->{pkgs_to_stow} = []; @@ -236,7 +237,7 @@ sub plan_unstow { $self->within_target_do(sub { for my $package (@packages) { if (not -d join_paths($self->{stow_path}, $package)) { - error("The given package name ($package) is not in your stow path $self->{stow_path}"); + error("The stow directory $self->{dir} does not contain package $package"); } debug(2, "Planning unstow of package $package..."); if ($self->{compat}) { @@ -254,6 +255,7 @@ sub plan_unstow { ); } debug(2, "Planning unstow of package $package... done"); + $self->{action_count}++; } }); } @@ -273,7 +275,7 @@ sub plan_stow { $self->within_target_do(sub { for my $package (@packages) { if (not -d join_paths($self->{stow_path}, $package)) { - error("The given package name ($package) is not in your stow path $self->{stow_path}"); + error("The stow directory $self->{dir} does not contain package $package"); } debug(2, "Planning stow of package $package..."); $self->stow_contents( @@ -283,6 +285,7 @@ sub plan_stow { join_paths($self->{stow_path}, $package), # source from target ); debug(2, "Planning stow of package $package... done"); + $self->{action_count}++; } }); } @@ -387,14 +390,18 @@ sub stow_node { my $path = join_paths($stow_path, $package, $target); - debug(2, "Stowing from $path"); + debug(2, "Stowing $path"); debug(3, "--- $target => $source"); # Don't try to stow absolute symlinks (they can't be unstowed) if (-l $source) { my $second_source = $self->read_a_link($source); if ($second_source =~ m{\A/}) { - $self->conflict("source is an absolute symlink $source => $second_source"); + $self->conflict( + 'stow', + $package, + "source is an absolute symlink $source => $second_source" + ); debug(3, "absolute symlinks cannot be unstowed"); return; } @@ -413,7 +420,11 @@ sub stow_node { my ($existing_path, $existing_stow_path, $existing_package) = $self->find_stowed_path($target, $existing_source); if (not $existing_path) { - $self->conflict("existing target is not owned by stow: $target"); + $self->conflict( + 'stow', + $package, + "existing target is not owned by stow: $target" + ); return; # XXX # } @@ -455,9 +466,10 @@ sub stow_node { } else { $self->conflict( - q{existing target is stowed to a different package: %s => %s}, - $target, - $existing_source, + 'stow', + $package, + "existing target is stowed to a different package: " + . "$target => $existing_source" ); } } @@ -480,7 +492,9 @@ sub stow_node { } else { $self->conflict( - qq{existing target is neither a link nor a directory: $target} + 'stow', + $package, + "existing target is neither a link nor a directory: $target" ); } } @@ -643,7 +657,9 @@ sub unstow_node_orig { } elsif (-e $target) { $self->conflict( - qq{existing target is neither a link nor a directory: $target}, + 'unstow', + $package, + "existing target is neither a link nor a directory: $target", ); } else { @@ -744,7 +760,9 @@ sub unstow_node { $self->find_stowed_path($target, $existing_source); if (not $existing_path) { $self->conflict( - qq{existing target is not owned by stow: $target => $existing_source} + 'unstow', + $package, + "existing target is not owned by stow: $target => $existing_source" ); return; # XXX # } @@ -768,9 +786,10 @@ sub unstow_node { #} #else { # $self->conflict( - # q{existing target is stowed to a different package: %s => %s}, - # $target, - # $existing_source + # 'unstow', + # $package, + # "existing target is stowed to a different package: " + # . "$target => $existing_source" # ); #} } @@ -791,7 +810,9 @@ sub unstow_node { } else { $self->conflict( - qq{existing target is neither a link nor a directory: $target}, + 'unstow', + $package, + "existing target is neither a link nor a directory: $target", ); } } @@ -1042,32 +1063,56 @@ sub fold_tree { #===== METHOD =============================================================== # Name : conflict() # Purpose : handle conflicts in stow operations -# Parameters: $format => message printf format -# : @args => paths that conflict +# Parameters: $package => the package involved with the conflicting operation +# : $message => a description of the conflict # Returns : n/a -# Throws : fatal exception unless 'conflicts' option is set -# Comments : indicates what type of conflict it is +# Throws : none +# Comments : none #============================================================================ sub conflict { my $self = shift; - my ($format, @args) = @_; + my ($action, $package, $message) = @_; - my $message = sprintf($format, @args); + debug(2, "CONFLICT when ${action}ing $package: $message"); + $self->{conflicts}{$action}{$package} ||= []; + push @{ $self->{conflicts}{$action}{$package} }, $message; + $self->{conflict_count}++; - debug(1, "CONFLICT: $message"); - push @{ $self->{conflicts} }, "CONFLICT: $message\n"; return; } =head2 get_conflicts() -Returns a list of all potential conflicts discovered. +Returns a nested hash of all potential conflicts discovered: the keys +are actions ('stow' or 'unstow'), and the values are hashrefs whose +keys are stow package names and whose values are conflict +descriptions, e.g.: + + ( + stow => { + perl => [ + "existing target is not owned by stow: bin/a2p" + "existing target is neither a link nor a directory: bin/perl" + ] + } + ) =cut sub get_conflicts { my $self = shift; - return @{ $self->{conflicts} }; + return %{ $self->{conflicts} }; +} + +=head2 get_conflict_count() + +Returns the number of conflicts found. + +=cut + +sub get_conflict_count { + my $self = shift; + return $self->{conflict_count}; } =head2 get_tasks() @@ -1081,6 +1126,17 @@ sub get_tasks { return @{ $self->{tasks} }; } +=head2 get_action_count() + +Returns the number of actions planned for this Stow instance. + +=cut + +sub get_action_count { + my $self = shift; + return $self->{action_count}; +} + #===== METHOD ================================================================ # Name : ignore # Purpose : determine if the given path matches a regex in our ignore list diff --git a/t/stow_contents.t b/t/stow_contents.t index db0e9fc..4a5775a 100755 --- a/t/stow_contents.t +++ b/t/stow_contents.t @@ -18,7 +18,7 @@ init_test_dirs(); cd("$OUT_DIR/target"); my $stow; -my @conflicts; +my %conflicts; # Note that each of the following tests use a distinct set of files @@ -84,9 +84,10 @@ make_file('bin4'); # this is a file but named like a directory make_dir('../stow/pkg4/bin4'); make_file('../stow/pkg4/bin4/file4'); $stow->plan_stow('pkg4'); -@conflicts = $stow->get_conflicts(); +%conflicts = $stow->get_conflicts(); like( - $conflicts[-1], qr(CONFLICT:.*existing target is neither a link nor a directory) + $conflicts{stow}{pkg4}[-1], + qr(existing target is neither a link nor a directory) => 'link to new dir conflicts with existing non-directory' ); @@ -99,9 +100,10 @@ make_dir('bin5'); make_link('bin5/file5','../../empty'); make_dir('../stow/pkg5/bin5/file5'); $stow->plan_stow('pkg5'); -@conflicts = $stow->get_conflicts(); +%conflicts = $stow->get_conflicts(); like( - $conflicts[-1], qr(CONFLICT:.*not owned by stow) + $conflicts{stow}{pkg5}[-1], + qr(not owned by stow) => 'target already exists but is not owned by stow' ); @@ -134,9 +136,10 @@ make_link('bin7/node7','../../stow/pkg7a/bin7/node7'); make_dir('../stow/pkg7b/bin7/node7'); make_file('../stow/pkg7b/bin7/node7/file7'); $stow->plan_stow('pkg7b'); -@conflicts = $stow->get_conflicts(); +%conflicts = $stow->get_conflicts(); like( - $conflicts[-1], qr(CONFLICT:.*existing target is stowed to a different package) + $conflicts{stow}{pkg7b}[-1], + qr(existing target is stowed to a different package) => 'link to new dir conflicts with existing stowed non-directory' ); diff --git a/t/unstow_contents.t b/t/unstow_contents.t index 6929a03..d398065 100755 --- a/t/unstow_contents.t +++ b/t/unstow_contents.t @@ -20,7 +20,7 @@ cd("$OUT_DIR/target"); # Note that each of the following tests use a distinct set of files my $stow; -my @conflicts; +my %conflicts; # # unstow a simple tree minimally @@ -106,9 +106,10 @@ make_dir('../stow/pkg5/bin5'); make_link('bin5', '../not-stow'); $stow->plan_unstow('pkg5'); -@conflicts = $stow->get_conflicts; +%conflicts = $stow->get_conflicts; like( - $conflicts[-1], qr(CONFLICT:.*existing target is not owned by stow) + $conflicts{unstow}{pkg5}[-1], + qr(existing target is not owned by stow) => q(existing link not owned by stow) ); @@ -300,10 +301,11 @@ stderr_like( qr/There are no outstanding operations to perform/, 'no tasks to process when unstowing pkg12 for third time' ); -@conflicts = $stow->get_conflicts; +%conflicts = $stow->get_conflicts; ok( - @conflicts == 1 && - $conflicts[0] =~ m!existing target is neither a link nor a directory: man12/man1/file12\.1! + $stow->get_conflict_count == 1 && + $conflicts{unstow}{pkg12}[0] + =~ m!existing target is neither a link nor a directory: man12/man1/file12\.1! => 'unstow pkg12 for third time' ); @@ -320,7 +322,7 @@ make_link("$OUT_DIR/target/bin13", '../stow/pkg13/bin13'); $stow->plan_unstow('pkg13'); $stow->process_tasks(); ok( - scalar($stow->get_conflicts) == 0 && + $stow->get_conflict_count == 0 && -f "$OUT_DIR/stow/pkg13/bin13/file13" && ! -e "$OUT_DIR/target/bin13" => 'unstow a simple tree' ); diff --git a/t/unstow_contents_orig.t b/t/unstow_contents_orig.t index ec86dac..436668a 100755 --- a/t/unstow_contents_orig.t +++ b/t/unstow_contents_orig.t @@ -20,7 +20,7 @@ cd("$OUT_DIR/target"); # Note that each of the following tests use a distinct set of files my $stow; -my @conflicts; +my %conflicts; # # unstow a simple tree minimally @@ -111,7 +111,7 @@ $stow->plan_unstow('pkg5'); # cause any conflicts. # #like( -# $Conflicts[-1], qr(CONFLICT:.*can't unlink.*not owned by stow) +# $Conflicts[-1], qr(can't unlink.*not owned by stow) # => q(existing link not owned by stow) #); ok( @@ -307,10 +307,11 @@ stderr_like( qr/There are no outstanding operations to perform/, 'no tasks to process when unstowing pkg12 for third time' ); -@conflicts = $stow->get_conflicts; +%conflicts = $stow->get_conflicts; ok( - @conflicts == 1 && - $conflicts[0] =~ m!existing target is neither a link nor a directory: man12/man1/file12\.1! + $stow->get_conflict_count == 1 && + $conflicts{unstow}{pkg12}[0] + =~ m!existing target is neither a link nor a directory: man12/man1/file12\.1! => 'unstow pkg12 for third time' ); @@ -327,7 +328,7 @@ make_link("$OUT_DIR/target/bin13", '../stow/pkg13/bin13'); $stow->plan_unstow('pkg13'); $stow->process_tasks(); ok( - scalar($stow->get_conflicts) == 0 && + $stow->get_conflict_count == 0 && -f "$OUT_DIR/stow/pkg13/bin13/file13" && ! -e "$OUT_DIR/target/bin13" => 'unstow a simple tree' ); From bcac91d68ae19b578fcd9a5883c84996e5968186 Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Sat, 26 Nov 2011 16:32:25 +0000 Subject: [PATCH 084/482] Remove quote stripping code. I'm guessing it was added due to a misunderstanding of how shell quoting works. When you invoke stow --ignore=".#.*" ... the shell strips out the quotes before the Perl process ever sees them. I can't imagine any sensible scenario in which you would need to invoke stow --ignore='"foo"' but if the user has a filename containing quotes at the beginning and end, they can now choose to ignore it (prior to this patch, they couldn't). --- bin/stow.in | 27 +++------------------------ t/stow.t | 17 +++-------------- 2 files changed, 6 insertions(+), 38 deletions(-) diff --git a/bin/stow.in b/bin/stow.in index 0db7a07..ab495a6 100755 --- a/bin/stow.in +++ b/bin/stow.in @@ -465,20 +465,19 @@ sub process_options { # clean and pre-compile any regex's at parse time 'ignore=s' => sub { - # FIXME: do we really need strip_quotes here? - my $regex = strip_quotes($_[1]); + my $regex = $_[1]; push @{$options{ignore}}, qr($regex\z); }, 'override=s' => sub { - my $regex = strip_quotes($_[1]); + my $regex = $_[1]; push @{$options{override}}, qr(\A$regex); }, 'defer=s' => sub { - my $regex = strip_quotes($_[1]); + my $regex = $_[1]; push @{$options{defer}}, qr(\A$regex); }, @@ -629,26 +628,6 @@ sub version { exit 0; } -#===== METHOD ================================================================ -# Name : strip_quotes -# Purpose : remove matching outer quotes from the given string -# Parameters: none -# Returns : n/a -# Throws : no exceptions -# Comments : none -#============================================================================= -sub strip_quotes { - my ($string) = @_; - - if ($string =~ m{\A\s*'(.*)'\s*\z}) { - return $1; - } - elsif ($string =~ m{\A\s*"(.*)"\s*\z}) { - return $1 - } - return $string; -} - # Local variables: # mode: perl diff --git a/t/stow.t b/t/stow.t index c9a021d..eddcd83 100755 --- a/t/stow.t +++ b/t/stow.t @@ -7,7 +7,7 @@ use strict; use warnings; -use Test::More tests => 10; +use Test::More tests => 9; use testutil; @@ -71,23 +71,12 @@ local @ARGV = ( ($options, $pkgs_to_delete, $pkgs_to_stow) = process_options(); is_deeply($options->{override}, [qr(\Aman), qr(\Ainfo)] => 'override man and info'); -# -# Check stripping any matched quotes -# -local @ARGV = ( - "--override='man'", - '--override="info"', - 'dummy' -); -($options, $pkgs_to_delete, $pkgs_to_stow) = process_options(); -is_deeply($options->{override}, [qr(\Aman), qr(\Ainfo)] => 'strip shell quoting'); - # # Check setting ignored paths # local @ARGV = ( - '--ignore="~"', - '--ignore="\.#.*"', + '--ignore=~', + '--ignore=\.#.*', 'dummy' ); ($options, $pkgs_to_delete, $pkgs_to_stow) = process_options(); From a8a0e360ae3c099016aac62638735c93bb9d4646 Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Fri, 25 Nov 2011 14:45:28 +0000 Subject: [PATCH 085/482] Add comment to manual about test_examples_in_manual() in t/ignore.t. --- doc/stow.texi | 3 +++ 1 file changed, 3 insertions(+) diff --git a/doc/stow.texi b/doc/stow.texi index 257b685..d487a0a 100644 --- a/doc/stow.texi +++ b/doc/stow.texi @@ -516,6 +516,9 @@ contain a @samp{/}, and if so, ignores the file or directory. Otherwise, the file or directory is not ignored. @end enumerate +@c N.B. if you change the examples below, please also consider +@c updating test_examples_in_manual() in t/ignore.t. + For example, if a file @file{bazqux} is in the @file{foo/bar} subdirectory of the package directory, Stow would use @code{/foo/bar/bazqux} as the text for matching against regular From 6b815a9a90523395284558aeeee276d5a466a8db Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Fri, 25 Nov 2011 15:03:46 +0000 Subject: [PATCH 086/482] Add chkstow to NEWS --- NEWS | 2 ++ 1 file changed, 2 insertions(+) diff --git a/NEWS b/NEWS index c588a73..b8e041c 100644 --- a/NEWS +++ b/NEWS @@ -125,6 +125,8 @@ already been stowed. Doing that on a live system is somewhat crazy and hopefully rare. We provide an option '-p|--compat' to enable the old behaviour for those needing to patch up mistakes. +** New chkstow utility for checking the integrity of the target directory. + ** Implement a test suite and support code. This was built before implementing any of the extra features so I could From 1f41616b12eaefb6bfd948d9d74c36698a3b02fa Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Fri, 25 Nov 2011 15:14:07 +0000 Subject: [PATCH 087/482] Tidy up chkstow code and documentation. --- bin/chkstow.in | 21 ++++++++----- doc/stow.texi | 82 +++++++++++++++++++++++++++----------------------- 2 files changed, 57 insertions(+), 46 deletions(-) diff --git a/bin/chkstow.in b/bin/chkstow.in index caf50bb..07e18f1 100755 --- a/bin/chkstow.in +++ b/bin/chkstow.in @@ -8,10 +8,12 @@ require 5.6.1; use File::Find; use Getopt::Long; -our $Wanted = \&bad_links; -our %Package=(); +my $DEFAULT_TARGET = '/usr/local/'; + +our $Wanted = \&bad_links; +our %Package = (); our $Stow_dir = ''; -our $Target = q{/usr/local/}; +our $Target = $DEFAULT_TARGET; # put the main loop into a block so that tests can load this as a module if ( not caller() ) { @@ -38,11 +40,13 @@ sub usage { USAGE: chkstow [options] Options: - -b, --badlinks Report symlinks that point to non-existant files. - -a, --aliens Report non-symlinks in the target directory. - -l, --list List packages in the target directory. - -t DIR, --target=DIR Set the target directory to DIR (default - is /usr/local) + -t DIR, --target=DIR Set the target directory to DIR + (default is $DEFAULT_TARGET) + -b, --badlinks Report symlinks that point to non-existent files + -a, --aliens Report non-symlinks in the target directory + -l, --list List packages in the target directory + +--badlinks is the default mode. EOT exit(0); } @@ -104,5 +108,6 @@ sub list { # Local variables: # mode: perl +# cperl-indent-level: 4 # End: # vim: ft=perl diff --git a/doc/stow.texi b/doc/stow.texi index d487a0a..620f0a5 100644 --- a/doc/stow.texi +++ b/doc/stow.texi @@ -355,12 +355,14 @@ doing. Verbosity levels are 0, 1, 2, and 3; 0 is the default. Using @item -p @itemx --compat -Scan the whole target tree when unstowing. By default, only directories -specified in the @dfn{installation image} are scanned during an unstow -operation. Scanning the whole tree can be prohibitive if your target tree is -very large. This option restores the legacy behaviour; however, the -@samp{--badlinks} option may be a better way of ensuring that your -installation does not have any dangling symlinks. +Scan the whole target tree when unstowing. By default, only +directories specified in the @dfn{installation image} are scanned +during an unstow operation. Scanning the whole tree can be +prohibitive if your target tree is very large. This option restores +the legacy behaviour; however, the @samp{--badlinks} option to the +@command{chkstow} utility may be a better way of ensuring that your +installation does not have any dangling symlinks (@pxref{Target +Maintenance}). @item -V @itemx --version @@ -395,29 +397,6 @@ might like to use this feature. This option may be repeated any number of times. @end table -The following options are useful for cleaning up your target tree: - -@table @samp -@item -b -@itemx --badlinks -Checks target directory for bogus symbolic links. That is, links that point to -non-existent files. - -@item -a -@itemx --aliens -Checks for files in the target directory that are not symbolic links. The -target directory should be managed by stow alone, except for directories that -contain a @file{.stow} file. - -@item -l -@itemx --list -Will display the target package for every symbolic link in the stow target -directory. -The following options are deprecated: -@end table - -@xref{Resource Files}, for a way to set default values for any of these -options. @c =========================================================================== @node Ignore Lists, Installing Packages, Invoking Stow, Top @@ -779,19 +758,46 @@ symlink, and thus cannot remove it). @node Target Maintenance, Resource Files, Multiple Stow Directories, Top @chapter Target Maintenance -From time to time you will need to clean up your target tree. -Stow includes three operational modes that performs checks that -would generally be too expensive to performed during normal stow +From time to time you will need to clean up your target tree. Since +version 2, Stow provides a new utility @command{chkstow} to help with +this. It includes three operational modes which performs checks that +would generally be too expensive to be performed during normal stow execution. -I've added a -l option to chkstow -which will give you a listing of every package name that has already been stowed -should be able to diff this with your directory listing +The syntax of the @code{chkstow} command is: -bash -cd build/scripts -diff <(../bin/chkstow -l) <(ls -1) +@example +chkstow [@var{options}] +@end example +@noindent +The following options are supported: + +@table @samp + +@item -t @var{dir} +@itemx --target=@var{dir} +Set the target directory to @var{dir} instead of the parent of the stow +directory. Defaults to the parent of the stow directory, so it is typical to +execute @code{stow} from the directory @file{/usr/local/stow}. + +@item -b +@itemx --badlinks +Checks target directory for bogus symbolic links. That is, links that point to +non-existent files. + +@item -a +@itemx --aliens +Checks for files in the target directory that are not symbolic links. The +target directory should be managed by stow alone, except for directories that +contain a @file{.stow} file. + +@item -l +@itemx --list +Will display the target package for every symbolic link in the stow target +directory. + +@end table @c =========================================================================== @node Resource Files, Compile-time vs Install-time, Target Maintenance, Top From d5aa061abe4b81273ea02744d82330985a2fa70d Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Fri, 25 Nov 2011 15:23:08 +0000 Subject: [PATCH 088/482] Fix documentation regarding splitting of symlinks across multiple stow directories. --- doc/stow.texi | 16 +++++++--------- lib/Stow.pm.in | 6 +++--- 2 files changed, 10 insertions(+), 12 deletions(-) diff --git a/doc/stow.texi b/doc/stow.texi index 620f0a5..61ee4f9 100644 --- a/doc/stow.texi +++ b/doc/stow.texi @@ -739,20 +739,18 @@ software separately, or if there is any other reason to want two or more stow directories, it can be done by creating a file named @file{.stow} in each stow directory. The presence of @file{/usr/local/foo/.stow} informs Stow that, though @file{foo} is not the current stow -directory, and though it is a subdirectory of the target directory, +directory, even if it is a subdirectory of the target directory, nevertheless it is @emph{a} stow directory and as such Stow doesn't ``own'' anything in it (@pxref{Installing Packages}). This will protect the contents of @file{foo} from a @samp{stow -D}, for instance. -XXX is this still true? XXX - -When multiple stow directories share a target tree, the effectiveness -of Stow is reduced. If a tree-folding symlink is encountered and -needs to be split open during an installation, but the symlink points -into the wrong stow directory, Stow will report a conflict rather -than split open the tree (because it doesn't consider itself to own the -symlink, and thus cannot remove it). +@c There is a test for the following case in t/examples.t: +When multiple stow directories share a target tree, if a tree-folding +symlink is encountered and needs to be split open during an +installation, as long as the top-level stow directory into which the +existing symlink points contains @file{.stow}, Stow knows how to split +open the tree in the correct manner. @c =========================================================================== @node Target Maintenance, Resource Files, Multiple Stow Directories, Top diff --git a/lib/Stow.pm.in b/lib/Stow.pm.in index bf4df60..3d8fa89 100755 --- a/lib/Stow.pm.in +++ b/lib/Stow.pm.in @@ -416,7 +416,7 @@ sub stow_node { } debug(3, "--- Evaluate existing link: $target => $existing_source"); - # Does it point to a node under our stow directory? + # Does it point to a node under any stow directory? my ($existing_path, $existing_stow_path, $existing_package) = $self->find_stowed_path($target, $existing_source); if (not $existing_path) { @@ -620,7 +620,7 @@ sub unstow_node_orig { error("Could not read link: $target"); } - # Does it point to a node under our stow directory? + # Does it point to a node under any stow directory? my ($existing_path, $existing_stow_path, $existing_package) = $self->find_stowed_path($target, $existing_source); if (not $existing_path) { @@ -755,7 +755,7 @@ sub unstow_node { return; # XXX # } - # Does it point to a node under our stow directory? + # Does it point to a node under any stow directory? my ($existing_path, $existing_stow_path, $existing_package) = $self->find_stowed_path($target, $existing_source); if (not $existing_path) { From a70302f99dfe16abfde36019244646989907cb7c Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Thu, 24 Nov 2011 00:26:50 +0000 Subject: [PATCH 089/482] Bump version to 2.1.0 --- META.json | 4 ++-- META.yml | 4 ++-- configure.ac | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/META.json b/META.json index 637c9f1..5aa0aa4 100644 --- a/META.json +++ b/META.json @@ -37,7 +37,7 @@ "provides" : { "Stow" : { "file" : "lib/Stow.pm", - "version" : "v2.0.2" + "version" : "v2.1.0" }, "Stow::Util" : { "file" : "lib/Stow/Util.pm", @@ -54,5 +54,5 @@ "url" : "http://github.com/aspiers/stow" } }, - "version" : "v2.0.2" + "version" : "v2.1.0" } diff --git a/META.yml b/META.yml index f09bef9..e79b3a2 100644 --- a/META.yml +++ b/META.yml @@ -17,7 +17,7 @@ name: Stow provides: Stow: file: lib/Stow.pm - version: v2.0.2 + version: v2.1.0 Stow::Util: file: lib/Stow/Util.pm version: 0 @@ -30,4 +30,4 @@ resources: homepage: https://savannah.gnu.org/projects/stow license: http://www.gnu.org/licenses/gpl-2.0.html repository: http://github.com/aspiers/stow -version: v2.0.2 +version: v2.1.0 diff --git a/configure.ac b/configure.ac index 1f1c468..e95b801 100644 --- a/configure.ac +++ b/configure.ac @@ -1,6 +1,6 @@ dnl Process this file with Autoconf to produce configure dnl -AC_INIT([stow], [2.0.2], [bug-stow@gnu.org]) +AC_INIT([stow], [2.1.0], [bug-stow@gnu.org]) AC_PREREQ([2.61]) AC_CONFIG_AUX_DIR([automake]) # Unfortunately we have to disable warnings for overrides, because we From b03c6df978d264918859462826fef998fa3f6db3 Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Thu, 24 Nov 2011 01:27:41 +0000 Subject: [PATCH 090/482] Add NEWS entry for 2.1.0 --- NEWS | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/NEWS b/NEWS index b8e041c..7224ce4 100644 --- a/NEWS +++ b/NEWS @@ -1,5 +1,21 @@ News file for Stow. +* Changes in version 2.1.0 +** Major refactoring of code into separate Stow and Stow::Util Perl modules. +** Added support for ignore list files. +** Added support for CPAN-style installation and distribution via Module::Build. +** Introduced `make test' target and significantly tightened up test suite. +** Very large number of code and documentation fixes (over 80 commits since version 2.0.1). +** The '--conflicts' option has been removed. + +Stow will always show conflicts if they are found during the scanning +phase. + +** Improved debugging output. +** Converted man page to POD format. +** Fixed code style consistency issues. +** Running configure from outside the source tree now works. +** `make distcheck' now works. * Changes in version 2.0.1 ** Defer operations until all potential conflicts have been assessed. From 08e15e3d43407baeda3acf8e800bb12a2f7c7321 Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Sat, 26 Nov 2011 18:15:26 +0000 Subject: [PATCH 091/482] Add HOWTO-RELEASE --- doc/HOWTO-RELEASE | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 doc/HOWTO-RELEASE diff --git a/doc/HOWTO-RELEASE b/doc/HOWTO-RELEASE new file mode 100644 index 0000000..b5b1c5d --- /dev/null +++ b/doc/HOWTO-RELEASE @@ -0,0 +1,40 @@ +How to make a new release of GNU Stow +===================================== + + - Ensure NEWS contains the latest changes. + + - Ensure configure.ac contains the new version number. + + - Check CPAN distribution will work via Module::Build: + + - Run perl Build.PL. + - Run ./Build test + - Run ./Build install + - Run ./Build distcheck + - Run ./Build distmeta and check META.* have the new version number. + + - Ensure all changes are committed to git. + + - Run make distcheck and ensure that everything looks good. + It should generate the distribution files for you. + + - Tag the current git HEAD with the new version number: + + git tag v7.8.9 + + - Upload to ftp.gnu.org. This is easiest using gnupload: + + - git clone git://git.savannah.gnu.org/gnulib.git + - Copy gnulib/build-aux/gnupload to somewhere on your $PATH + - Run gnupload --to ftp.gnu.org:gnu/stow --symlink-regex stow-7.8.9.tar.* + + - Send release announcements to + + - info-gnu@gnu.org + - info-stow@gnu.org + - https://savannah.gnu.org/news/?group=stow + + See http://www.gnu.org/prep/maintain/html_node/Announcements.html for + more on making release announcements. + + - Upload to CPAN via https://pause.perl.org/ From 4933d9623d5c3e0fcb17b353dd2646c465cbba10 Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Sat, 26 Nov 2011 18:24:35 +0000 Subject: [PATCH 092/482] Add a TODO concerning .nonstow. --- TODO | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/TODO b/TODO index 01d6fda..2b9a1a8 100644 --- a/TODO +++ b/TODO @@ -1,3 +1,9 @@ +* Distinguish between .stow and (undocumented) .nonstow +** .stow is for marking stow directories - avoids altering them + but also allows --override to work +** .nonstow should be only for protecting non-stow directories against modification by stow + but currently allows modification via --override. +** Documentation needs to be clear on this. * Prevent folding of directories which contain ignored files * Honour .no-stow-folding and --no-folding * Add semi-automatic conflict resolution From d672e3e6cf28622120f30e9d51436c68faa4cc27 Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Sat, 26 Nov 2011 18:55:10 +0000 Subject: [PATCH 093/482] Improve debug levels. --- lib/Stow.pm.in | 77 ++++++++++++++++++++++++------------------------ lib/Stow/Util.pm | 9 ++++-- 2 files changed, 45 insertions(+), 41 deletions(-) diff --git a/lib/Stow.pm.in b/lib/Stow.pm.in index 3d8fa89..99805f6 100755 --- a/lib/Stow.pm.in +++ b/lib/Stow.pm.in @@ -339,11 +339,10 @@ sub stow_contents { return if $self->should_skip_target_which_is_stow_dir($target); my $cwd = getcwd(); - my $msg = "Stowing contents of $path in package $package " - . "(cwd=$cwd, stow dir=$self->{stow_path})"; - $msg =~ s!$ENV{HOME}/!~/!g; - debug(2, $msg); - debug(3, "--- $target => $source"); + my $msg = "Stowing contents of $path (cwd=$cwd)"; + $msg =~ s!$ENV{HOME}(/|$)!~$1!g; + debug(3, $msg); + debug(4, " => $source"); error("stow_contents() called with non-directory path: $path") unless -d $path; @@ -390,8 +389,8 @@ sub stow_node { my $path = join_paths($stow_path, $package, $target); - debug(2, "Stowing $path"); - debug(3, "--- $target => $source"); + debug(3, "Stowing $path"); + debug(4, " => $source"); # Don't try to stow absolute symlinks (they can't be unstowed) if (-l $source) { @@ -402,7 +401,7 @@ sub stow_node { $package, "source is an absolute symlink $source => $second_source" ); - debug(3, "absolute symlinks cannot be unstowed"); + debug(3, "Absolute symlinks cannot be unstowed"); return; } } @@ -414,7 +413,7 @@ sub stow_node { if (not $existing_source) { error("Could not read link: $target"); } - debug(3, "--- Evaluate existing link: $target => $existing_source"); + debug(4, " Evaluate existing link: $target => $existing_source"); # Does it point to a node under any stow directory? my ($existing_path, $existing_stow_path, $existing_package) = @@ -431,13 +430,13 @@ sub stow_node { # Does the existing $target actually point to anything? if ($self->is_a_node($existing_path)) { if ($existing_source eq $source) { - debug(3, "--- Skipping $target as it already points to $source"); + debug(2, "--- Skipping $target as it already points to $source"); } elsif ($self->defer($target)) { - debug(3, "--- deferring installation of: $target"); + debug(2, "--- Deferring installation of: $target"); } elsif ($self->override($target)) { - debug(3, "--- overriding installation of: $target"); + debug(2, "--- Overriding installation of: $target"); $self->do_unlink($target); $self->do_link($source, $target); } @@ -448,7 +447,7 @@ sub stow_node { # and the proposed new link points to a directory, # then we can unfold (split open) the tree at that point - debug(3, "--- Unfolding $target which was already owned by $existing_package"); + debug(2, "--- Unfolding $target which was already owned by $existing_package"); $self->do_unlink($target); $self->do_mkdir($target); $self->stow_contents( @@ -475,13 +474,13 @@ sub stow_node { } else { # The existing link is invalid, so replace it with a good link - debug(3, "--- replacing invalid link: $path"); + debug(2, "--- replacing invalid link: $path"); $self->do_unlink($target); $self->do_link($source, $target); } } elsif ($self->is_a_node($target)) { - debug(3, "--- Evaluate existing node: $target"); + debug(4, " Evaluate existing node: $target"); if ($self->is_a_dir($target)) { $self->stow_contents( $self->{stow_path}, @@ -566,9 +565,9 @@ sub unstow_contents_orig { my $cwd = getcwd(); my $msg = "Unstowing from $target (compat mode, cwd=$cwd, stow dir=$self->{stow_path})"; - $msg =~ s!$ENV{HOME}/!~/!g; - debug(2, $msg); - debug(3, "--- source path is $path"); + $msg =~ s!$ENV{HOME}(/|$)!~$1!g; + debug(3, $msg); + debug(4, " source path is $path"); # In compat mode we traverse the target tree not the source tree, # so we're unstowing the contents of /target/foo, there's no # guarantee that the corresponding /stow/mypkg/foo exists. @@ -607,12 +606,12 @@ sub unstow_node_orig { my $path = join_paths($stow_path, $package, $target); - debug(2, "Unstowing $target (compat mode)"); - debug(3, "--- source path is $path"); + debug(3, "Unstowing $target (compat mode)"); + debug(4, " source path is $path"); # Does the target exist? if ($self->is_a_link($target)) { - debug(3, "Evaluate existing link: $target"); + debug(4, " Evaluate existing link: $target"); # Where is the link pointing? my $existing_source = $self->read_a_link($target); @@ -637,13 +636,13 @@ sub unstow_node_orig { $self->do_unlink($target); } elsif ($self->override($target)) { - debug(3, "--- overriding installation of: $target"); + debug(2, "--- overriding installation of: $target"); $self->do_unlink($target); } # else leave it alone } else { - debug(3, "--- removing invalid link into a stow directory: $path"); + debug(2, "--- removing invalid link into a stow directory: $path"); $self->do_unlink($target); } } @@ -663,7 +662,7 @@ sub unstow_node_orig { ); } else { - debug(3, "$target did not exist to be unstowed"); + debug(2, "$target did not exist to be unstowed"); } return; } @@ -691,8 +690,8 @@ sub unstow_contents { my $cwd = getcwd(); my $msg = "Unstowing from $target (cwd=$cwd, stow dir=$self->{stow_path})"; $msg =~ s!$ENV{HOME}/!~/!g; - debug(2, $msg); - debug(3, "--- source path is $path"); + debug(3, $msg); + debug(4, " source path is $path"); # We traverse the source tree not the target tree, so $path must exist. error("unstow_contents() called with non-directory path: $path") unless -d $path; @@ -737,12 +736,12 @@ sub unstow_node { my $path = join_paths($stow_path, $package, $target); - debug(2, "Unstowing $path"); - debug(3, "--- target is $target"); + debug(3, "Unstowing $path"); + debug(4, " target is $target"); # Does the target exist? if ($self->is_a_link($target)) { - debug(3, "Evaluate existing link: $target"); + debug(4, " Evaluate existing link: $target"); # Where is the link pointing? my $existing_source = $self->read_a_link($target); @@ -778,10 +777,10 @@ sub unstow_node { # package. #elsif (defer($target)) { - # debug(3, "--- deferring to installation of: $target"); + # debug(2, "--- deferring to installation of: $target"); #} #elsif ($self->override($target)) { - # debug(3, "--- overriding installation of: $target"); + # debug(2, "--- overriding installation of: $target"); # $self->do_unlink($target); #} #else { @@ -794,12 +793,12 @@ sub unstow_node { #} } else { - debug(3, "--- removing invalid link into a stow directory: $path"); + debug(2, "--- removing invalid link into a stow directory: $path"); $self->do_unlink($target); } } elsif (-e $target) { - debug(3, "Evaluate existing node: $target"); + debug(4, " Evaluate existing node: $target"); if (-d $target) { $self->unstow_contents($stow_path, $package, $target); @@ -817,7 +816,7 @@ sub unstow_node { } } else { - debug(3, "$target did not exist to be unstowed"); + debug(2, "$target did not exist to be unstowed"); } return; } @@ -951,7 +950,7 @@ sub cleanup_invalid_links { not -e join_paths($dir, $source) and # bad link $self->path_owned_by_package($node_path, $source) # owned by stow ){ - debug(3, "--- removing stale link: $node_path => " . + debug(2, "--- removing stale link: $node_path => " . join_paths($dir, $source)); $self->do_unlink($node_path); } @@ -1165,9 +1164,9 @@ sub ignore { my $package_dir = join_paths($stow_path, $package); my ($path_regexp, $segment_regexp) = $self->get_ignore_regexps($package_dir); - debug(3, " Ignore list regexp for paths: " . + debug(5, " Ignore list regexp for paths: " . (defined $path_regexp ? "/$path_regexp/" : "none")); - debug(3, " Ignore list regexp for segments: " . + debug(5, " Ignore list regexp for segments: " . (defined $segment_regexp ? "/$segment_regexp/" : "none")); if (defined $path_regexp and "/$target" =~ $path_regexp) { @@ -1201,11 +1200,11 @@ sub get_ignore_regexps { for my $file ($local_stow_ignore, $global_stow_ignore) { if (-e $file) { - debug(3, " Using ignore file: $file"); + debug(5, " Using ignore file: $file"); return $self->get_ignore_regexps_from_file($file); } else { - debug(4, " $file didn't exist"); + debug(5, " $file didn't exist"); } } diff --git a/lib/Stow/Util.pm b/lib/Stow/Util.pm index 885269b..072f880 100644 --- a/lib/Stow/Util.pm +++ b/lib/Stow/Util.pm @@ -93,12 +93,17 @@ Verbosity rules: =item >= 1: print operations: LINK/UNLINK/MKDIR/RMDIR -=item >= 2: print trace: stow/unstow package/contents/node +=item >= 2: print operation exceptions -=item >= 3: print trace detail: "_this_ already points to _that_" +e.g. "_this_ already points to _that_", skipping, deferring, +overriding, fixing invalid links + +=item >= 3: print trace detail: trace: stow/unstow/package/contents/node =item >= 4: debug helper routines +=item >= 5: debug ignore lists + =back =cut From aad96a0a44118fa9f44d7cfe7946632fec9b35c5 Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Mon, 28 Nov 2011 23:17:50 +0000 Subject: [PATCH 094/482] Don't duplicate stow.texi to manual.texi. --- MANIFEST | 2 +- MANIFEST.SKIP | 2 +- Makefile.am | 24 +++++++++--------------- 3 files changed, 11 insertions(+), 17 deletions(-) diff --git a/MANIFEST b/MANIFEST index 6454cf4..3d928ea 100644 --- a/MANIFEST +++ b/MANIFEST @@ -11,9 +11,9 @@ COPYING default-ignore-list doc/ChangeLog.OLD doc/manual.html -doc/manual.pdf doc/stow.8 doc/stow.info +doc/stow.pdf doc/stow.texi doc/texinfo.tex doc/version.texi diff --git a/MANIFEST.SKIP b/MANIFEST.SKIP index fa9f287..4904a25 100644 --- a/MANIFEST.SKIP +++ b/MANIFEST.SKIP @@ -76,7 +76,7 @@ ^doc/\.dirstamp$ ^doc/stamp-vti$ ^doc/manual.texi -^doc/stow.pdf +^doc/manual.pdf$ # Avoid test files ^tmp-testing-trees diff --git a/Makefile.am b/Makefile.am index 9da7140..e69e659 100644 --- a/Makefile.am +++ b/Makefile.am @@ -5,8 +5,9 @@ info_TEXINFOS = doc/stow.texi dist_man_MANS = doc/stow.8 dist_doc_DATA = \ README \ - doc/manual.html doc/manual.pdf \ + doc/manual.html \ ChangeLog doc/ChangeLog.OLD +doc_DATA = doc/manual.pdf # Would be nice to include the split page HTML version of the manual # in the distribution, but automake doesn't support wildcards and I'm @@ -77,6 +78,7 @@ $(TESTS_OUT): CPAN_FILES = MANIFEST MANIFEST.SKIP Build.PL META.yml META.json EXTRA_DIST = \ bin/stow.in bin/chkstow.in lib/Stow.pm.in \ + doc/stow.pdf \ $(TESTS) t/testutil.pm \ $(TEXINFO_TEX) \ $(DEFAULT_IGNORE_LIST) \ @@ -87,7 +89,7 @@ CLEANFILES = $(bin_SCRIPTS) $(dist_pm_DATA) clean-local: -rm -rf $(TESTS_OUT) \ bin/stow bin/chkstow doc/stow.8 ChangeLog \ - doc/manual.* + doc/manual.html doc/manual.pdf # this is more explicit and reliable than the config file trick edit = sed -e 's|[@]PERL[@]|$(PERL)|g' \ @@ -115,22 +117,14 @@ lib/Stow.pm: lib/Stow.pm.in Makefile $(DEFAULT_IGNORE_LIST) # generate manual.html and manual.pdf (which ultimately go somewhere # like /usr/share/doc/stow/) rather than stow.html and stow.pdf, to # make it obvious that these files contain the manual. So we have to -# jump through a few extra hoops. We preserve timestamps to avoid any -# unnecessary rebuilds, since not everyone has texinfo installed. -doc/manual.texi: doc/stow.texi doc/version.texi +# jump through a few extra hoops. +doc/manual.pdf: doc/stow.pdf [ -d doc ] || mkdir doc # required in vpath mode - cp --preserve=timestamps $< $@ + cp $< $@ -doc/manual.pdf: doc/stow.pdf doc/version.texi - [ -d doc ] || mkdir doc # required in vpath mode - cp --preserve=timestamps $< $@ - -# It's easier to calculate the absolute path to $(srcdir) rather than -# the relative path to it from the doc/ build subdirectory. -doc/manual.html: doc/manual.texi +doc/manual.html: doc/stow.texi -rm -f $@ - srcdir=$$( cd $(srcdir); pwd ); \ - cd doc && texi2html -I $$srcdir -expandinfo -menu -monolithic -verbose manual.texi + texi2html --P=$(srcdir) --output=$@ -expandinfo -menu -monolithic -verbose $< doc/stow.8: bin/stow Makefile [ -d doc ] || mkdir doc # required in vpath mode From e915435f3262593695bf10367f58f19c62b44e34 Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Mon, 28 Nov 2011 23:18:36 +0000 Subject: [PATCH 095/482] Ignore split page version of HTML manual. --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index ced8a07..3befba9 100644 --- a/.gitignore +++ b/.gitignore @@ -20,6 +20,7 @@ configure /doc/manual.html /doc/manual.pdf /doc/manual.texi +/doc/stow.html /doc/stow.pdf /doc/stow.8 /lib/Stow.pm From d2473363b2e2756ac86ce2b7f79dcd3f7d41a4e7 Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Mon, 28 Nov 2011 23:18:58 +0000 Subject: [PATCH 096/482] Synchronise CPAN MANIFEST files with automake distribution list. --- MANIFEST | 5 +++++ MANIFEST.SKIP | 4 +++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/MANIFEST b/MANIFEST index 3d928ea..161ff24 100644 --- a/MANIFEST +++ b/MANIFEST @@ -1,4 +1,8 @@ AUTHORS +aclocal.m4 +automake/install-sh +automake/mdate-sh +automake/missing bin/chkstow bin/chkstow.in bin/stow @@ -24,6 +28,7 @@ lib/Stow/Util.pm Makefile.am Makefile.in MANIFEST This list of files +MANIFEST.SKIP NEWS README t/chkstow.t diff --git a/MANIFEST.SKIP b/MANIFEST.SKIP index 4904a25..0d4129d 100644 --- a/MANIFEST.SKIP +++ b/MANIFEST.SKIP @@ -75,8 +75,10 @@ ^config\.(log|status)$ ^doc/\.dirstamp$ ^doc/stamp-vti$ -^doc/manual.texi +^doc/manual.texi$ ^doc/manual.pdf$ +^doc/HOWTO-RELEASE$ +^doc/stow\.html/.+\.html$ # Avoid test files ^tmp-testing-trees From 4e831ae7bd7783d319b87d65a5a00db9502acf28 Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Mon, 28 Nov 2011 23:20:14 +0000 Subject: [PATCH 097/482] Add result of ./Build dist to .gitignore --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 3befba9..81322a9 100644 --- a/.gitignore +++ b/.gitignore @@ -27,3 +27,4 @@ configure stamp-vti stow-[0-9].[0-9].[0-9].tar.* stow-[0-9].[0-9].[0-9]/ +Stow-v[0-9].[0-9].[0-9].tar.* From 4d6c23600b2f92f2d4bb1eba8b952e511670be52 Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Thu, 1 Dec 2011 16:23:04 +0000 Subject: [PATCH 098/482] Fix corner case where only -d is specified as a single directory. --- bin/stow.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/stow.in b/bin/stow.in index ab495a6..27f628b 100755 --- a/bin/stow.in +++ b/bin/stow.in @@ -529,7 +529,7 @@ sub sanitize_path_options { $options->{target} =~ s/ +\z//; } else { - $options->{target} = parent($options->{dir}); + $options->{target} = parent($options->{dir}) || '.'; } } From e1e8175ea57dea4ff243a38efb02340e9f375870 Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Thu, 1 Dec 2011 17:25:24 +0000 Subject: [PATCH 099/482] Switch to renaming to manual via install hook as suggested by Stefano Lattarini http://article.gmane.org/gmane.comp.sysutils.automake.general/13191 --- MANIFEST | 2 +- MANIFEST.SKIP | 2 +- Makefile.am | 31 +++++++++++++++++-------------- 3 files changed, 19 insertions(+), 16 deletions(-) diff --git a/MANIFEST b/MANIFEST index 161ff24..a9623e7 100644 --- a/MANIFEST +++ b/MANIFEST @@ -14,7 +14,7 @@ configure.ac COPYING default-ignore-list doc/ChangeLog.OLD -doc/manual.html +doc/stow.html doc/stow.8 doc/stow.info doc/stow.pdf diff --git a/MANIFEST.SKIP b/MANIFEST.SKIP index 0d4129d..1caa51c 100644 --- a/MANIFEST.SKIP +++ b/MANIFEST.SKIP @@ -78,7 +78,7 @@ ^doc/manual.texi$ ^doc/manual.pdf$ ^doc/HOWTO-RELEASE$ -^doc/stow\.html/.+\.html$ +^doc/manual\.html\b # Avoid test files ^tmp-testing-trees diff --git a/Makefile.am b/Makefile.am index e69e659..484414b 100644 --- a/Makefile.am +++ b/Makefile.am @@ -5,14 +5,13 @@ info_TEXINFOS = doc/stow.texi dist_man_MANS = doc/stow.8 dist_doc_DATA = \ README \ - doc/manual.html \ + doc/stow.html doc/stow.pdf \ ChangeLog doc/ChangeLog.OLD -doc_DATA = doc/manual.pdf # Would be nice to include the split page HTML version of the manual # in the distribution, but automake doesn't support wildcards and I'm # loathe to explicitly list every single page here :-( -#nobase_dist_doc_DATA = doc/stow.html/*.html +#nobase_dist_doc_DATA = doc/manual-split/*.html pmdir = $(libdir)/perl5 dist_pm_DATA = lib/Stow.pm @@ -89,7 +88,7 @@ CLEANFILES = $(bin_SCRIPTS) $(dist_pm_DATA) clean-local: -rm -rf $(TESTS_OUT) \ bin/stow bin/chkstow doc/stow.8 ChangeLog \ - doc/manual.html doc/manual.pdf + doc/stow.html doc/stow.pdf # this is more explicit and reliable than the config file trick edit = sed -e 's|[@]PERL[@]|$(PERL)|g' \ @@ -110,19 +109,11 @@ lib/Stow.pm: lib/Stow.pm.in Makefile $(DEFAULT_IGNORE_LIST) ( $(edit) < $<; cat $(DEFAULT_IGNORE_LIST) ) > $@ ############################################################################## -# The below rules are only used by the developer. +# The below rules should only be needed by developers. ############################################################################## -# It's conventional to generate $project.info, but it's also nicer to -# generate manual.html and manual.pdf (which ultimately go somewhere -# like /usr/share/doc/stow/) rather than stow.html and stow.pdf, to -# make it obvious that these files contain the manual. So we have to -# jump through a few extra hoops. -doc/manual.pdf: doc/stow.pdf +doc/stow.html: doc/stow.texi [ -d doc ] || mkdir doc # required in vpath mode - cp $< $@ - -doc/manual.html: doc/stow.texi -rm -f $@ texi2html --P=$(srcdir) --output=$@ -expandinfo -menu -monolithic -verbose $< @@ -130,6 +121,18 @@ doc/stow.8: bin/stow Makefile [ -d doc ] || mkdir doc # required in vpath mode pod2man $< > $@ +# It's conventional to generate $project.info, but it's also nicer to +# generate manual.html and manual.pdf (which ultimately go somewhere +# like /usr/share/doc/stow/) rather than stow.html and stow.pdf, to +# make it obvious that these files contain the manual. So we have to +# jump through a few extra hoops. +install-data-hook: + cd $(DESTDIR)$(docdir) && \ + mv -f stow.html manual.html && \ + mv -f stow.pdf manual.pdf + +uninstall-hook: + rm -f $(DESTDIR)$(docdir)/manual.{html,pdf} ChangeLog: doc/ChangeLog.OLD Makefile @if [ -d .git ]; then \ From aeedec3a5772ee625a09712fb38118983770eefe Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Thu, 1 Dec 2011 18:03:16 +0000 Subject: [PATCH 100/482] Add doc/version.texi to distribution. --- Makefile.am | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile.am b/Makefile.am index 484414b..30d3359 100644 --- a/Makefile.am +++ b/Makefile.am @@ -5,7 +5,7 @@ info_TEXINFOS = doc/stow.texi dist_man_MANS = doc/stow.8 dist_doc_DATA = \ README \ - doc/stow.html doc/stow.pdf \ + doc/stow.html doc/stow.pdf doc/version.texi \ ChangeLog doc/ChangeLog.OLD # Would be nice to include the split page HTML version of the manual From d55c314d28d83a2b68a1732fc8e2e7d04099c7df Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Fri, 2 Dec 2011 14:55:44 +0000 Subject: [PATCH 101/482] Add TODOs for .rpm and .deb support. --- TODO | 2 ++ 1 file changed, 2 insertions(+) diff --git a/TODO b/TODO index 2b9a1a8..549ba5f 100644 --- a/TODO +++ b/TODO @@ -1,3 +1,5 @@ +* Import a debian/ tree from an older package and update it. +* Import a .spec file from somewhere and update it. * Distinguish between .stow and (undocumented) .nonstow ** .stow is for marking stow directories - avoids altering them but also allows --override to work From e3eeedc2c15e2e4fc2b081fa621a4e5a719b63c9 Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Sat, 3 Dec 2011 00:54:05 +0000 Subject: [PATCH 102/482] Module::Build generates archive files with 'v' for version --- MANIFEST.SKIP | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MANIFEST.SKIP b/MANIFEST.SKIP index 1caa51c..d85b741 100644 --- a/MANIFEST.SKIP +++ b/MANIFEST.SKIP @@ -66,7 +66,7 @@ ^MANIFEST\.SKIP # Avoid archives of this distribution -\b[sS]tow-[\d\.\_]+ +\b[sS]tow-v?[\d\.\_]+ # Avoid autotools stuff ^aclocal.m4$ From 6682aa9caffbed12df8173280b845bfebe18b141 Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Sat, 3 Dec 2011 01:30:08 +0000 Subject: [PATCH 103/482] Temporarily remove PDF from dist_doc_DATA due to automake issue. http://article.gmane.org/gmane.comp.sysutils.automake.general/13192 This means that it is still included in the distribution and installed, but is only automatically (re)built when making a new distribution - if stow.texi changes during development, it has to be rebuilt manually via 'make pdf'. --- MANIFEST | 1 - MANIFEST.SKIP | 1 + Makefile.am | 19 ++++++++++++++++--- 3 files changed, 17 insertions(+), 4 deletions(-) diff --git a/MANIFEST b/MANIFEST index a9623e7..d6ce9da 100644 --- a/MANIFEST +++ b/MANIFEST @@ -17,7 +17,6 @@ doc/ChangeLog.OLD doc/stow.html doc/stow.8 doc/stow.info -doc/stow.pdf doc/stow.texi doc/texinfo.tex doc/version.texi diff --git a/MANIFEST.SKIP b/MANIFEST.SKIP index d85b741..cfbcaad 100644 --- a/MANIFEST.SKIP +++ b/MANIFEST.SKIP @@ -77,6 +77,7 @@ ^doc/stamp-vti$ ^doc/manual.texi$ ^doc/manual.pdf$ +^doc/stow.pdf$ ^doc/HOWTO-RELEASE$ ^doc/manual\.html\b diff --git a/Makefile.am b/Makefile.am index 30d3359..51502f1 100644 --- a/Makefile.am +++ b/Makefile.am @@ -5,7 +5,7 @@ info_TEXINFOS = doc/stow.texi dist_man_MANS = doc/stow.8 dist_doc_DATA = \ README \ - doc/stow.html doc/stow.pdf doc/version.texi \ + doc/stow.html doc/version.texi \ ChangeLog doc/ChangeLog.OLD # Would be nice to include the split page HTML version of the manual @@ -128,8 +128,8 @@ doc/stow.8: bin/stow Makefile # jump through a few extra hoops. install-data-hook: cd $(DESTDIR)$(docdir) && \ - mv -f stow.html manual.html && \ - mv -f stow.pdf manual.pdf + mv -f stow.html manual.html + cp $(srcdir)/doc/stow.pdf $(DESTDIR)$(docdir)/manual.pdf uninstall-hook: rm -f $(DESTDIR)$(docdir)/manual.{html,pdf} @@ -147,3 +147,16 @@ ChangeLog: doc/ChangeLog.OLD Makefile else \ echo "Not in a git repository; can't update ChangeLog."; \ fi + +# For website only; cannot currently be included in dist_doc_DATA +# because of: +# +# http://article.gmane.org/gmane.comp.sysutils.automake.general/13192 +# +# This means that it is still included in the distribution and +# installed, but is only automatically (re)built when making a new +# distribution - if stow.texi changes during development, it has to be +# rebuilt manually via 'make pdf'. +dist-hook: pdf + +pdf: doc/stow.pdf From e046048a1c6dce9de279d0a425414916fd2cd7ba Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Sat, 3 Dec 2011 02:07:19 +0000 Subject: [PATCH 104/482] Update reference to maintainer. --- AUTHORS | 2 +- README | 4 ++-- doc/stow.texi | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/AUTHORS b/AUTHORS index 5694873..bde121e 100644 --- a/AUTHORS +++ b/AUTHORS @@ -37,4 +37,4 @@ Stow.pm and Stow/Util.pm modules providing an OO interface, tightened up the test suite, added support for ignore lists, `make test', and distribution via CPAN, and cleaned up numerous other minor issues. -Stow is currently maintained by Troy Mill. +Stow is currently co-maintained by Adam Spiers and Troy Mill. diff --git a/README b/README index 4801308..e220527 100644 --- a/README +++ b/README @@ -27,5 +27,5 @@ can be found in the file COPYING. See INSTALL for installation instructions. -Please mail comments, questions, and criticisms to the current maintainer -Troy Mill via help-stow@gnu.org or bug-stow@gnu.org. +Please mail comments, questions, and criticisms to the current maintainers +via help-stow@gnu.org or bug-stow@gnu.org. diff --git a/doc/stow.texi b/doc/stow.texi index 61ee4f9..f13bf40 100644 --- a/doc/stow.texi +++ b/doc/stow.texi @@ -1147,7 +1147,7 @@ perl/bin/perl stow/bin/stow -vv * @node Reporting Bugs, Known Bugs, Bootstrapping, Top @chapter Reporting Bugs -Please send bug reports to the current maintainer, Troy Will, by electronic +Please send bug reports to the current maintainers by electronic mail. The address to use is @samp{}. Please include: From a17537af3e72d75416a466ac3579e97c1a99e1e4 Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Sat, 3 Dec 2011 14:03:58 +0000 Subject: [PATCH 105/482] Give up on automake's built-in rules for generating PDF and HTML and use our own. Also include split version of the manual. --- .gitignore | 4 +- MANIFEST | 3 +- MANIFEST.SKIP | 5 +-- Makefile.am | 101 ++++++++++++++++++++++++++++++++------------------ NEWS | 1 + 5 files changed, 71 insertions(+), 43 deletions(-) diff --git a/.gitignore b/.gitignore index 81322a9..7d6996a 100644 --- a/.gitignore +++ b/.gitignore @@ -17,10 +17,10 @@ config.log config.status configure /doc/ChangeLog.OLD -/doc/manual.html /doc/manual.pdf +/doc/manual-single.html +/doc/manual-split/ /doc/manual.texi -/doc/stow.html /doc/stow.pdf /doc/stow.8 /lib/Stow.pm diff --git a/MANIFEST b/MANIFEST index d6ce9da..ae3d9b9 100644 --- a/MANIFEST +++ b/MANIFEST @@ -14,7 +14,8 @@ configure.ac COPYING default-ignore-list doc/ChangeLog.OLD -doc/stow.html +doc/manual-single.html +doc/manual.pdf doc/stow.8 doc/stow.info doc/stow.texi diff --git a/MANIFEST.SKIP b/MANIFEST.SKIP index cfbcaad..1a0d298 100644 --- a/MANIFEST.SKIP +++ b/MANIFEST.SKIP @@ -74,12 +74,9 @@ ^autom4te\.cache/.+$ ^config\.(log|status)$ ^doc/\.dirstamp$ +^doc/manual-split/ ^doc/stamp-vti$ -^doc/manual.texi$ -^doc/manual.pdf$ -^doc/stow.pdf$ ^doc/HOWTO-RELEASE$ -^doc/manual\.html\b # Avoid test files ^tmp-testing-trees diff --git a/Makefile.am b/Makefile.am index 51502f1..9f1cbd1 100644 --- a/Makefile.am +++ b/Makefile.am @@ -5,14 +5,9 @@ info_TEXINFOS = doc/stow.texi dist_man_MANS = doc/stow.8 dist_doc_DATA = \ README \ - doc/stow.html doc/version.texi \ + doc/manual.pdf doc/manual-single.html doc/version.texi \ ChangeLog doc/ChangeLog.OLD -# Would be nice to include the split page HTML version of the manual -# in the distribution, but automake doesn't support wildcards and I'm -# loathe to explicitly list every single page here :-( -#nobase_dist_doc_DATA = doc/manual-split/*.html - pmdir = $(libdir)/perl5 dist_pm_DATA = lib/Stow.pm pmstowdir = $(pmdir)/Stow @@ -32,6 +27,8 @@ AM_MAKEINFOFLAGS = -I $(srcdir) # to AM_INIT_AUTOMAKE which has to be silenced via -Wno-override. TEXI2DVI = texi2dvi $(AM_MAKEINFOFLAGS) +doc_deps = $(info_TEXINFOS) doc/version.texi + DEFAULT_IGNORE_LIST = $(srcdir)/default-ignore-list TESTS_DIR = $(srcdir)/t @@ -77,7 +74,7 @@ $(TESTS_OUT): CPAN_FILES = MANIFEST MANIFEST.SKIP Build.PL META.yml META.json EXTRA_DIST = \ bin/stow.in bin/chkstow.in lib/Stow.pm.in \ - doc/stow.pdf \ + doc/manual-split \ $(TESTS) t/testutil.pm \ $(TEXINFO_TEX) \ $(DEFAULT_IGNORE_LIST) \ @@ -88,7 +85,7 @@ CLEANFILES = $(bin_SCRIPTS) $(dist_pm_DATA) clean-local: -rm -rf $(TESTS_OUT) \ bin/stow bin/chkstow doc/stow.8 ChangeLog \ - doc/stow.html doc/stow.pdf + doc/manual-split doc/manual-single.html doc/manual.pdf # this is more explicit and reliable than the config file trick edit = sed -e 's|[@]PERL[@]|$(PERL)|g' \ @@ -112,27 +109,72 @@ lib/Stow.pm: lib/Stow.pm.in Makefile $(DEFAULT_IGNORE_LIST) # The below rules should only be needed by developers. ############################################################################## -doc/stow.html: doc/stow.texi - [ -d doc ] || mkdir doc # required in vpath mode - -rm -f $@ - texi2html --P=$(srcdir) --output=$@ -expandinfo -menu -monolithic -verbose $< - doc/stow.8: bin/stow Makefile [ -d doc ] || mkdir doc # required in vpath mode pod2man $< > $@ -# It's conventional to generate $project.info, but it's also nicer to -# generate manual.html and manual.pdf (which ultimately go somewhere -# like /usr/share/doc/stow/) rather than stow.html and stow.pdf, to -# make it obvious that these files contain the manual. So we have to -# jump through a few extra hoops. -install-data-hook: - cd $(DESTDIR)$(docdir) && \ - mv -f stow.html manual.html - cp $(srcdir)/doc/stow.pdf $(DESTDIR)$(docdir)/manual.pdf +# We use automake's built-in rule to generate stow.info. The built-in +# rules would also generate doc/stow.html and doc/stow.pdf, but after +# installation we want $(docdir) (typically /usr/share/doc/stow/) to +# contain manual-single.html, manual.pdf, and manual-split/*.html, to +# make it explicitly obvious that these files contain the user manual +# rather than some other Stow-related documentation. +# +# If it were not for a troublesome dependency on doc/$(am__dirstamp): +# +# http://article.gmane.org/gmane.comp.sysutils.automake.general/13192 +# +# we could have achieved this using the built-in rules combined with +# install-data-hook to rename from stow.pdf to manual.pdf etc. on +# install. Instead, by overriding the built-in rules with modified +# versions, we can kill both birds with one stone. + +doc/manual-single.html: $(doc_deps) + [ -d doc ] || mkdir doc # required in vpath mode + -rm -f $@ + texi2html --P=$(srcdir) --output=$@ -expandinfo -menu -monolithic -verbose $< + +doc/manual.pdf: $(doc_deps) + TEXINPUTS="$(am__TEXINFO_TEX_DIR)$(PATH_SEPARATOR)$$TEXINPUTS" \ + MAKEINFO='$(MAKEINFO) $(AM_MAKEINFOFLAGS) $(MAKEINFOFLAGS) -I doc -I $(srcdir)/doc' \ + $(TEXI2PDF) -o $@ `test -f 'doc/stow.texi' || echo '$(srcdir)/'`doc/stow.texi + +doc/manual-split: $(doc_deps) + rm -rf $@.new + if $(MAKEINFOHTML) $(AM_MAKEINFOHTMLFLAGS) $(MAKEINFOFLAGS) -I doc -I $(srcdir)/doc \ + -o $@.new `test -f 'doc/stow.texi' || echo '$(srcdir)/'`doc/stow.texi; \ + then \ + rm -rf $@; \ + mv $@.new $@; \ + else \ + rm -Rf $@.new $@; \ + exit 1; \ + fi + +# The split version of the manual is copied to $(docdir)/manual-split +# by install-data-hook. The whole subdirectory is included via +# EXTRA_DIST in order to avoid having to list each file explicitly in +# dist_doc_DATA, since automake doesn't support wildcards, and +# dist_doc_DATA cannot refer to directories while EXTRA_DIST can (go +# figure ...) + +install-data-hook: doc/manual-split + cp -r $(srcdir)/doc/manual-split $(DESTDIR)$(docdir) uninstall-hook: - rm -f $(DESTDIR)$(docdir)/manual.{html,pdf} + chmod u+w -R $(DESTDIR)$(docdir)/manual-split + rm -rf $(DESTDIR)$(docdir)/manual-split + +# Using install-data-hook has the slightly annoying disadvantage that +# by default the split version of the manual isn't automatically +# rebuilt during development by a simple `make'. A workaround hack +# for this is to piggy-back the dependency onto manual-single.html, +# which *is* automatically rebuilt by `make': +doc/manual-single.html: doc/manual-split + +# With the above hack, this probably isn't necessary but is safer to +# keep in anyway: +dist-hook: doc/manual-split ChangeLog: doc/ChangeLog.OLD Makefile @if [ -d .git ]; then \ @@ -147,16 +189,3 @@ ChangeLog: doc/ChangeLog.OLD Makefile else \ echo "Not in a git repository; can't update ChangeLog."; \ fi - -# For website only; cannot currently be included in dist_doc_DATA -# because of: -# -# http://article.gmane.org/gmane.comp.sysutils.automake.general/13192 -# -# This means that it is still included in the distribution and -# installed, but is only automatically (re)built when making a new -# distribution - if stow.texi changes during development, it has to be -# rebuilt manually via 'make pdf'. -dist-hook: pdf - -pdf: doc/stow.pdf diff --git a/NEWS b/NEWS index 7224ce4..1c98110 100644 --- a/NEWS +++ b/NEWS @@ -13,6 +13,7 @@ phase. ** Improved debugging output. ** Converted man page to POD format. +** Include PDF, and both split- and single-page HTML versions of manual in the distribution. ** Fixed code style consistency issues. ** Running configure from outside the source tree now works. ** `make distcheck' now works. From 519566f3f4e50b805595b266c73bca8c3133e2e4 Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Sat, 3 Dec 2011 16:40:20 +0000 Subject: [PATCH 106/482] Add a missing hyperlink to the Stow homepage. --- doc/stow.texi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/stow.texi b/doc/stow.texi index f13bf40..0c970be 100644 --- a/doc/stow.texi +++ b/doc/stow.texi @@ -186,7 +186,7 @@ directory (e.g., @file{/usr/local/stow/emacs}), so it's always possible to rebuild the target tree (e.g., @file{/usr/local}). For information about the latest version of Stow, you can refer to -http://www.gnu.org/software/stow/. +@uref{http://www.gnu.org/software/stow/}. @c =========================================================================== From 4b75cb5fa954bb97066f24daaa99526240b78b6e Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Sat, 3 Dec 2011 17:09:48 +0000 Subject: [PATCH 107/482] Add a missing space. --- AUTHORS | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/AUTHORS b/AUTHORS index bde121e..65b0ebc 100644 --- a/AUTHORS +++ b/AUTHORS @@ -15,7 +15,7 @@ the generation of wrong links if there are links in the stow directory. Stow was maintained by Guillaume Morin up to November 2007. Kahlil (Kal) Hodgson performed a major rewrite -inorder to implement: +in order to implement: 1. defered operations, 2. option parsing via Getopt::Long, From f649cd2766c139bb97afc68469b95526dab3724b Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Sat, 3 Dec 2011 17:51:44 +0000 Subject: [PATCH 108/482] Fix error in gnupload command-line. --- doc/HOWTO-RELEASE | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/HOWTO-RELEASE b/doc/HOWTO-RELEASE index b5b1c5d..6113da3 100644 --- a/doc/HOWTO-RELEASE +++ b/doc/HOWTO-RELEASE @@ -26,7 +26,7 @@ How to make a new release of GNU Stow - git clone git://git.savannah.gnu.org/gnulib.git - Copy gnulib/build-aux/gnupload to somewhere on your $PATH - - Run gnupload --to ftp.gnu.org:gnu/stow --symlink-regex stow-7.8.9.tar.* + - Run gnupload --to ftp.gnu.org:stow --symlink-regex stow-7.8.9.tar.* - Send release announcements to From f5d0bd178d7b91e664d89f1950898b9889610584 Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Sat, 3 Dec 2011 17:51:48 +0000 Subject: [PATCH 109/482] Release announcements should go to stow-devel too. --- doc/HOWTO-RELEASE | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/doc/HOWTO-RELEASE b/doc/HOWTO-RELEASE index 6113da3..6ca1532 100644 --- a/doc/HOWTO-RELEASE +++ b/doc/HOWTO-RELEASE @@ -30,8 +30,9 @@ How to make a new release of GNU Stow - Send release announcements to - - info-gnu@gnu.org - info-stow@gnu.org + - stow-devel@gnu.org + - info-gnu@gnu.org - https://savannah.gnu.org/news/?group=stow See http://www.gnu.org/prep/maintain/html_node/Announcements.html for From f032e30cc88fb0ba05d2d5cb3051bf9aec305809 Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Sat, 3 Dec 2011 18:13:09 +0000 Subject: [PATCH 110/482] Add git push and update of online documentation to HOWTO-RELEASE. --- doc/HOWTO-RELEASE | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/doc/HOWTO-RELEASE b/doc/HOWTO-RELEASE index 6ca1532..af61d0a 100644 --- a/doc/HOWTO-RELEASE +++ b/doc/HOWTO-RELEASE @@ -22,6 +22,38 @@ How to make a new release of GNU Stow git tag v7.8.9 + - Push HEAD and tag to savannah + + git push + git push --tags + + - Regenerate the documentation for the website: + + # First check out texinfo CVS repository via: + # cvs -z3 -d:pserver:anonymous@cvs.savannah.gnu.org:/sources/texinfo co texinfo + + # and stow-web CVS repository via the instructions here: + # https://savannah.gnu.org/cvs/?group=stow + + # Set paths: + stow_repo=/path/to/stow/git/repo + stow_web_repo=/path/to/stow-web/CVS/working/dir + texinfo_repo=/path/to/texinfo/git/repo + + cd $stow_repo + export GENDOCS_TEMPLATE_DIR=$texinfo_repo/util + $texinfo_repo/util/gendocs.sh \ + -s doc/stow.texi \ + -o $stow_web_repo/manual \ + --email bug-stow@gnu.org \ + stow "GNU Stow manual" + + cd $stow_web_repo + # Check that the changes look OK + cvs diff + # Then commit + cvs commit + - Upload to ftp.gnu.org. This is easiest using gnupload: - git clone git://git.savannah.gnu.org/gnulib.git From 419e31b4c6d0f07d9a9ff92cca2584def070aa31 Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Sun, 4 Dec 2011 14:57:34 +0000 Subject: [PATCH 111/482] Change @dircategory to `System administration' as suggested by Karl Berry. --- doc/stow.texi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/stow.texi b/doc/stow.texi index 0c970be..5eb5fcd 100644 --- a/doc/stow.texi +++ b/doc/stow.texi @@ -7,7 +7,7 @@ @c @setchapternewpage odd @c @footnotestyle separate @c %**end of header -@dircategory Administration +@dircategory System administration @direntry * Stow: (stow). GNU Stow. @end direntry From d879bde678ba02b50476711315ccc005a8f5785f Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Tue, 6 Dec 2011 10:33:34 +0000 Subject: [PATCH 112/482] Fixed bug where --with-pmdir was ineffectual. --- Makefile.am | 2 +- NEWS | 2 ++ configure.ac | 1 + 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/Makefile.am b/Makefile.am index 9f1cbd1..d8da3fa 100644 --- a/Makefile.am +++ b/Makefile.am @@ -8,7 +8,7 @@ dist_doc_DATA = \ doc/manual.pdf doc/manual-single.html doc/version.texi \ ChangeLog doc/ChangeLog.OLD -pmdir = $(libdir)/perl5 +pmdir = $(PMDIR) dist_pm_DATA = lib/Stow.pm pmstowdir = $(pmdir)/Stow dist_pmstow_DATA = lib/Stow/Util.pm diff --git a/NEWS b/NEWS index 1c98110..9a77e29 100644 --- a/NEWS +++ b/NEWS @@ -1,5 +1,7 @@ News file for Stow. +* Changes in version 2.1.1 +** Fixed bug where ./configure --with-pmdir=X was ineffectual. * Changes in version 2.1.0 ** Major refactoring of code into separate Stow and Stow::Util Perl modules. ** Added support for ignore list files. diff --git a/configure.ac b/configure.ac index e95b801..b7006fd 100644 --- a/configure.ac +++ b/configure.ac @@ -24,6 +24,7 @@ AC_ARG_WITH( [ --with-pmdir=DIR perl modules are in DIR [[LIBDIR/perl5]]], [PMDIR=${withval}], [PMDIR=${libdir}/perl5] ) +AC_SUBST([PMDIR]) AC_CONFIG_FILES([Makefile]) AC_OUTPUT From 1507d1a055317c2d30e249bc793afc2030f10704 Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Tue, 6 Dec 2011 15:57:20 +0000 Subject: [PATCH 113/482] Calculated the correct default value for pmdir based on the local Perl installation. --- NEWS | 1 + configure.ac | 8 +++++--- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/NEWS b/NEWS index 9a77e29..9e2bc34 100644 --- a/NEWS +++ b/NEWS @@ -2,6 +2,7 @@ News file for Stow. * Changes in version 2.1.1 ** Fixed bug where ./configure --with-pmdir=X was ineffectual. +** Calculated the correct default value for pmdir based on the local Perl installation. * Changes in version 2.1.0 ** Major refactoring of code into separate Stow and Stow::Util Perl modules. ** Added support for ignore list files. diff --git a/configure.ac b/configure.ac index b7006fd..6d63176 100644 --- a/configure.ac +++ b/configure.ac @@ -21,9 +21,11 @@ fi AC_ARG_WITH( pmdir, - [ --with-pmdir=DIR perl modules are in DIR [[LIBDIR/perl5]]], - [PMDIR=${withval}], [PMDIR=${libdir}/perl5] -) + [ --with-pmdir=DIR Perl modules are in DIR [[LIBDIR/perl5]]], + [PMDIR=${withval}], + [eval `$PERL -V:installsitelib -V:siteprefix` + PMDIR='${prefix}'/"${installsitelib#$siteprefix/}"]) +AC_CONFIG_COMMANDS_POST([eval echo "Perl modules will be installed to $PMDIR"]) AC_SUBST([PMDIR]) AC_CONFIG_FILES([Makefile]) From bc661ae77b7282c4785aded4ba715c86da59edfa Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Tue, 6 Dec 2011 15:41:33 +0000 Subject: [PATCH 114/482] Add bug-reporting email address and a couple of URLs to usage text to comply with GNU Coding Standards for --help option. --- bin/stow.in | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/bin/stow.in b/bin/stow.in index 27f628b..f06d6a9 100755 --- a/bin/stow.in +++ b/bin/stow.in @@ -619,6 +619,10 @@ OPTIONS: if the file is already stowed to another package -V, --version Show stow version number -h, --help Show this help + +Report bugs to: bug-stow\@gnu.org +Stow home page: +General help using GNU software: EOT exit defined $msg ? 1 : 0; } From a9469a0f6729b32f19b0288c6533e3514bacd7c4 Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Tue, 6 Dec 2011 15:56:43 +0000 Subject: [PATCH 115/482] Add licensing changes to TODO. --- TODO | 2 ++ 1 file changed, 2 insertions(+) diff --git a/TODO b/TODO index 549ba5f..9bd09a4 100644 --- a/TODO +++ b/TODO @@ -1,3 +1,5 @@ +* Next release should be under GPL v3 +* Get permission for next documentation release to be under FDL 1.3 * Import a debian/ tree from an older package and update it. * Import a .spec file from somewhere and update it. * Distinguish between .stow and (undocumented) .nonstow From 884a4b8556b2308a1be91621a2fd009eab6f6fe4 Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Tue, 6 Dec 2011 15:57:36 +0000 Subject: [PATCH 116/482] Ditch deprecated AM_MAINTAINER_MODE. --- aclocal.m4 | 76 ---------------------------------------------------- configure.ac | 2 -- 2 files changed, 78 deletions(-) diff --git a/aclocal.m4 b/aclocal.m4 index fced0e9..3052e91 100644 --- a/aclocal.m4 +++ b/aclocal.m4 @@ -108,42 +108,6 @@ AC_PREREQ([2.50])dnl am_aux_dir=`cd $ac_aux_dir && pwd` ]) -# AM_CONDITIONAL -*- Autoconf -*- - -# Copyright (C) 1997, 2000, 2001, 2003, 2004, 2005, 2006, 2008 -# Free Software Foundation, Inc. -# -# This file is free software; the Free Software Foundation -# gives unlimited permission to copy and/or distribute it, -# with or without modifications, as long as this notice is preserved. - -# serial 9 - -# AM_CONDITIONAL(NAME, SHELL-CONDITION) -# ------------------------------------- -# Define a conditional. -AC_DEFUN([AM_CONDITIONAL], -[AC_PREREQ(2.52)dnl - ifelse([$1], [TRUE], [AC_FATAL([$0: invalid condition: $1])], - [$1], [FALSE], [AC_FATAL([$0: invalid condition: $1])])dnl -AC_SUBST([$1_TRUE])dnl -AC_SUBST([$1_FALSE])dnl -_AM_SUBST_NOTMAKE([$1_TRUE])dnl -_AM_SUBST_NOTMAKE([$1_FALSE])dnl -m4_define([_AM_COND_VALUE_$1], [$2])dnl -if $2; then - $1_TRUE= - $1_FALSE='#' -else - $1_TRUE='#' - $1_FALSE= -fi -AC_CONFIG_COMMANDS_PRE( -[if test -z "${$1_TRUE}" && test -z "${$1_FALSE}"; then - AC_MSG_ERROR([[conditional "$1" was never defined. -Usually this means the macro was only invoked conditionally.]]) -fi])]) - # Do all the work for Automake. -*- Autoconf -*- # Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, @@ -325,46 +289,6 @@ fi rmdir .tst 2>/dev/null AC_SUBST([am__leading_dot])]) -# Add --enable-maintainer-mode option to configure. -*- Autoconf -*- -# From Jim Meyering - -# Copyright (C) 1996, 1998, 2000, 2001, 2002, 2003, 2004, 2005, 2008 -# Free Software Foundation, Inc. -# -# This file is free software; the Free Software Foundation -# gives unlimited permission to copy and/or distribute it, -# with or without modifications, as long as this notice is preserved. - -# serial 5 - -# AM_MAINTAINER_MODE([DEFAULT-MODE]) -# ---------------------------------- -# Control maintainer-specific portions of Makefiles. -# Default is to disable them, unless `enable' is passed literally. -# For symmetry, `disable' may be passed as well. Anyway, the user -# can override the default with the --enable/--disable switch. -AC_DEFUN([AM_MAINTAINER_MODE], -[m4_case(m4_default([$1], [disable]), - [enable], [m4_define([am_maintainer_other], [disable])], - [disable], [m4_define([am_maintainer_other], [enable])], - [m4_define([am_maintainer_other], [enable]) - m4_warn([syntax], [unexpected argument to AM@&t@_MAINTAINER_MODE: $1])]) -AC_MSG_CHECKING([whether to am_maintainer_other maintainer-specific portions of Makefiles]) - dnl maintainer-mode's default is 'disable' unless 'enable' is passed - AC_ARG_ENABLE([maintainer-mode], -[ --][am_maintainer_other][-maintainer-mode am_maintainer_other make rules and dependencies not useful - (and sometimes confusing) to the casual installer], - [USE_MAINTAINER_MODE=$enableval], - [USE_MAINTAINER_MODE=]m4_if(am_maintainer_other, [enable], [no], [yes])) - AC_MSG_RESULT([$USE_MAINTAINER_MODE]) - AM_CONDITIONAL([MAINTAINER_MODE], [test $USE_MAINTAINER_MODE = yes]) - MAINT=$MAINTAINER_MODE_TRUE - AC_SUBST([MAINT])dnl -] -) - -AU_DEFUN([jm_MAINTAINER_MODE], [AM_MAINTAINER_MODE]) - # Fake the existence of programs that GNU maintainers use. -*- Autoconf -*- # Copyright (C) 1997, 1999, 2000, 2001, 2003, 2004, 2005, 2008 diff --git a/configure.ac b/configure.ac index 6d63176..ad9fc38 100644 --- a/configure.ac +++ b/configure.ac @@ -9,8 +9,6 @@ AC_CONFIG_AUX_DIR([automake]) AM_INIT_AUTOMAKE([-Wall -Werror -Wno-override dist-bzip2]) AC_PROG_INSTALL -AM_MAINTAINER_MODE([enable]) - dnl Check for perl on our system dnl call to AC_SUBST(PERL) is implicit AC_PATH_PROGS([PERL], [perl] [perl5], [false]) From 813a016c1ad3051e899e68a71f18a04d00c48f5d Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Tue, 6 Dec 2011 16:39:57 +0000 Subject: [PATCH 117/482] Add *.orig to MANIFEST.SKIP. --- MANIFEST.SKIP | 1 + 1 file changed, 1 insertion(+) diff --git a/MANIFEST.SKIP b/MANIFEST.SKIP index 1a0d298..f0190cf 100644 --- a/MANIFEST.SKIP +++ b/MANIFEST.SKIP @@ -42,6 +42,7 @@ \.tmp$ \.# \.rej$ +\.orig$ # Avoid OS-specific files/dirs # Mac OSX metadata From d1073789d2ba65fc34e521d41aa8b0ddb761f4cf Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Tue, 6 Dec 2011 16:47:32 +0000 Subject: [PATCH 118/482] Add $(PDF) and $(HTML) variables. --- Makefile.am | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/Makefile.am b/Makefile.am index d8da3fa..b8af445 100644 --- a/Makefile.am +++ b/Makefile.am @@ -3,9 +3,11 @@ dist_bin_SCRIPTS = bin/stow bin/chkstow info_TEXINFOS = doc/stow.texi dist_man_MANS = doc/stow.8 +PDF = doc/manual.pdf +HTML = doc/manual-single.html dist_doc_DATA = \ README \ - doc/manual.pdf doc/manual-single.html doc/version.texi \ + $(PDF) $(HTML) doc/version.texi \ ChangeLog doc/ChangeLog.OLD pmdir = $(PMDIR) @@ -85,7 +87,7 @@ CLEANFILES = $(bin_SCRIPTS) $(dist_pm_DATA) clean-local: -rm -rf $(TESTS_OUT) \ bin/stow bin/chkstow doc/stow.8 ChangeLog \ - doc/manual-split doc/manual-single.html doc/manual.pdf + doc/manual-split $(HTML) $(PDF) # this is more explicit and reliable than the config file trick edit = sed -e 's|[@]PERL[@]|$(PERL)|g' \ @@ -129,12 +131,12 @@ doc/stow.8: bin/stow Makefile # install. Instead, by overriding the built-in rules with modified # versions, we can kill both birds with one stone. -doc/manual-single.html: $(doc_deps) +$(HTML): $(doc_deps) [ -d doc ] || mkdir doc # required in vpath mode -rm -f $@ texi2html --P=$(srcdir) --output=$@ -expandinfo -menu -monolithic -verbose $< -doc/manual.pdf: $(doc_deps) +$(PDF): $(doc_deps) TEXINPUTS="$(am__TEXINFO_TEX_DIR)$(PATH_SEPARATOR)$$TEXINPUTS" \ MAKEINFO='$(MAKEINFO) $(AM_MAKEINFOFLAGS) $(MAKEINFOFLAGS) -I doc -I $(srcdir)/doc' \ $(TEXI2PDF) -o $@ `test -f 'doc/stow.texi' || echo '$(srcdir)/'`doc/stow.texi @@ -170,7 +172,7 @@ uninstall-hook: # rebuilt during development by a simple `make'. A workaround hack # for this is to piggy-back the dependency onto manual-single.html, # which *is* automatically rebuilt by `make': -doc/manual-single.html: doc/manual-split +$(HTML): doc/manual-split # With the above hack, this probably isn't necessary but is safer to # keep in anyway: From bbaace4d5adb2adf30f7f80a57da3333c1b07017 Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Tue, 6 Dec 2011 16:20:52 +0000 Subject: [PATCH 119/482] Fix automake issues (thanks to Stefano Lattarini for spotting these!) --- Build.PL | 2 +- Makefile.am | 21 ++++++++++++--------- NEWS | 1 + THANKS | 1 + 4 files changed, 15 insertions(+), 10 deletions(-) diff --git a/Build.PL b/Build.PL index 255bc5e..c9aef1f 100644 --- a/Build.PL +++ b/Build.PL @@ -49,7 +49,7 @@ my $build = Module::Build->new( 'IO::File' => 0, }, script_files => [ 'bin/stow' ], - all_from => 'lib/Stow.pm', + all_from => 'lib/Stow.pm.in', configure_requires => { 'Module::Build' => 0, }, diff --git a/Makefile.am b/Makefile.am index b8af445..38509e5 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1,6 +1,6 @@ ## Process this file with Automake to produce Makefile.in -dist_bin_SCRIPTS = bin/stow bin/chkstow +bin_SCRIPTS = bin/stow bin/chkstow info_TEXINFOS = doc/stow.texi dist_man_MANS = doc/stow.8 PDF = doc/manual.pdf @@ -11,7 +11,7 @@ dist_doc_DATA = \ ChangeLog doc/ChangeLog.OLD pmdir = $(PMDIR) -dist_pm_DATA = lib/Stow.pm +pm_DATA = lib/Stow.pm pmstowdir = $(pmdir)/Stow dist_pmstow_DATA = lib/Stow/Util.pm @@ -35,7 +35,7 @@ DEFAULT_IGNORE_LIST = $(srcdir)/default-ignore-list TESTS_DIR = $(srcdir)/t TESTS_OUT = tmp-testing-trees -TESTS_ENVIRONMENT = $(PERL) -I$(srcdir)/bin -I$(srcdir)/lib -I$(TESTS_DIR) +TESTS_ENVIRONMENT = $(PERL) -Ibin -Ilib -I$(TESTS_DIR) # This is a kind of hack; TESTS needs to be set to ensure that the # `check-am' target makes check-TESTS, but we override check-TESTS @@ -81,13 +81,14 @@ EXTRA_DIST = \ $(TEXINFO_TEX) \ $(DEFAULT_IGNORE_LIST) \ $(CPAN_FILES) -CLEANFILES = $(bin_SCRIPTS) $(dist_pm_DATA) +CLEANFILES = $(bin_SCRIPTS) $(pm_DATA) $(dist_man_MANS) $(HTML) $(PDF) ChangeLog + # clean up auto-generated files clean-local: - -rm -rf $(TESTS_OUT) \ - bin/stow bin/chkstow doc/stow.8 ChangeLog \ - doc/manual-split $(HTML) $(PDF) + -rm -rf $(TESTS_OUT) +maintainer-clean: + -rm -rf doc/manual-split # this is more explicit and reliable than the config file trick edit = sed -e 's|[@]PERL[@]|$(PERL)|g' \ @@ -111,7 +112,7 @@ lib/Stow.pm: lib/Stow.pm.in Makefile $(DEFAULT_IGNORE_LIST) # The below rules should only be needed by developers. ############################################################################## -doc/stow.8: bin/stow Makefile +doc/stow.8: bin/stow.in [ -d doc ] || mkdir doc # required in vpath mode pod2man $< > $@ @@ -178,7 +179,9 @@ $(HTML): doc/manual-split # keep in anyway: dist-hook: doc/manual-split -ChangeLog: doc/ChangeLog.OLD Makefile +dist-hook: $(dist_man_MANS) ChangeLog + +ChangeLog: doc/ChangeLog.OLD @if [ -d .git ]; then \ ( \ git log \ diff --git a/NEWS b/NEWS index 9e2bc34..52c368c 100644 --- a/NEWS +++ b/NEWS @@ -3,6 +3,7 @@ News file for Stow. * Changes in version 2.1.1 ** Fixed bug where ./configure --with-pmdir=X was ineffectual. ** Calculated the correct default value for pmdir based on the local Perl installation. +** Fixed some automake issues (thanks to Stefano Lattarini for spotting these!) * Changes in version 2.1.0 ** Major refactoring of code into separate Stow and Stow::Util Perl modules. ** Added support for ignore list files. diff --git a/THANKS b/THANKS index f40e883..cc2f3d7 100644 --- a/THANKS +++ b/THANKS @@ -21,3 +21,4 @@ Emil Mikulic Austin Wood Christopher Hoobin Adam Spiers +Stefano Lattarini From 51b1bd39588dc835c3a4476b19a258f5c1939b57 Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Tue, 6 Dec 2011 17:04:37 +0000 Subject: [PATCH 120/482] File::Slurp is no longer used. --- Build.PL | 1 - META.json | 1 - META.yml | 1 - 3 files changed, 3 deletions(-) diff --git a/Build.PL b/Build.PL index c9aef1f..883a71c 100644 --- a/Build.PL +++ b/Build.PL @@ -45,7 +45,6 @@ my $build = Module::Build->new( requires => { 'perl' => '5.006', 'Carp' => 0, - 'File::Slurp' => 0, 'IO::File' => 0, }, script_files => [ 'bin/stow' ], diff --git a/META.json b/META.json index 5aa0aa4..d895aea 100644 --- a/META.json +++ b/META.json @@ -28,7 +28,6 @@ "runtime" : { "requires" : { "Carp" : 0, - "File::Slurp" : 0, "IO::File" : 0, "perl" : "5.006" } diff --git a/META.yml b/META.yml index e79b3a2..7313ed4 100644 --- a/META.yml +++ b/META.yml @@ -23,7 +23,6 @@ provides: version: 0 requires: Carp: 0 - File::Slurp: 0 IO::File: 0 perl: 5.006 resources: From d6d51a78837a52eeff5de49c7d7a4ca612e76103 Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Tue, 6 Dec 2011 17:04:50 +0000 Subject: [PATCH 121/482] chkstow was missing from Module::Build install. --- Build.PL | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Build.PL b/Build.PL index 883a71c..c605d41 100644 --- a/Build.PL +++ b/Build.PL @@ -47,7 +47,7 @@ my $build = Module::Build->new( 'Carp' => 0, 'IO::File' => 0, }, - script_files => [ 'bin/stow' ], + script_files => [ 'bin/stow', 'bin/chkstow' ], all_from => 'lib/Stow.pm.in', configure_requires => { 'Module::Build' => 0, From 82debd4e8fec9dfc6957b7a4e82b1e55933ebb29 Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Tue, 6 Dec 2011 17:06:59 +0000 Subject: [PATCH 122/482] Document prerequisites for installation. --- INSTALL | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/INSTALL b/INSTALL index 21358ba..7d7134a 100644 --- a/INSTALL +++ b/INSTALL @@ -1,3 +1,12 @@ +Prerequisites +============= + +Stow is a collection of Perl scripts and modules. You must have Perl +5.6.1 or later in order for it to run. The test suite also requires +the Test::More and Test::Output modules which can be obtained from +CPAN. They are also available as packages in some of the GNU/Linux +distributions. + Basic Installation ================== From 695131521805f6bcc652708d472cf3610105c4ec Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Tue, 6 Dec 2011 17:07:29 +0000 Subject: [PATCH 123/482] Document installation via Module::Build. --- INSTALL | 59 +++++++++++++++++++++++++++++++++++++++++++-------------- 1 file changed, 45 insertions(+), 14 deletions(-) diff --git a/INSTALL b/INSTALL index 7d7134a..79e3854 100644 --- a/INSTALL +++ b/INSTALL @@ -7,25 +7,56 @@ the Test::More and Test::Output modules which can be obtained from CPAN. They are also available as packages in some of the GNU/Linux distributions. -Basic Installation -================== +Installation methods +==================== -Stow is a Perl script. You must have Perl 5.005 or later in order for -it to run. +Stow can either be installed via the standard GNU Autotools procedure +(./configure, make install) or since 2.1.0, via CPAN-style via +Module::Build. -The steps in building stow are: +Advantages of the Autotools approach: -1. `cd' to the directory containing the source code (and this file) - and type `./configure' to configure stow for your system. This + - It's arguably more flexible. + + - It will install the documentation in Info, HTML, man, and PDF + formats. + +Advantages of the Module::Build approach: + + - It's more in keeping with the standard way to distribute CPAN + modules. + + - It performs dependency checking to ensure you have the necessary + Perl modules installed. + +Basic Installation via Module::Build +==================================== + +The steps in building Stow are: + +1. `cd' to the directory containing the source code (and this file). + +2. If you are building from an official GNU release tarball, type + `./configure && make' to configure stow for your system. If you + are building from a CPAN tarball, this step can be skipped. + +3. Type `perl Build.PL'. + +4. Type `./Build install' to install the various files. As noted + above, this installs fewer files than the Autotools installation. + +Basic Installation via Autotools +================================ + +The steps in building Stow are: + +1. `cd' to the directory containing the source code (and this file). + +2. Type `./configure' to configure stow for your system. This step will attempt to locate your copy of perl and set its location - `Makefile.in'. + in `Makefile.in'. -2. Type `make' to create `stow' and `'stow.info'. If perl could not - be found by `./configure', you'll have to edit line 1 of `stow' - from `#!false' to `#!/path/to/perl' (where /path/to/perl is wherever - perl will be found when stow runs). - -3. Type `make install' to install `stow' and `stow.info'. +3. Type `make install' to install the various files. 4. You can remove the generated files from the source code directory by typing `make clean'. To also remove the files that `configure' From 7d30557b4d1b248ac692ca1646984c8fe4c0dbd2 Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Tue, 6 Dec 2011 17:08:13 +0000 Subject: [PATCH 124/482] Don't duplicate information from INSTALL. --- README | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/README b/README index e220527..4534ad8 100644 --- a/README +++ b/README @@ -7,9 +7,7 @@ the database. Also, stow will never delete any files, directories, or links that appear in a stow directory, so it is always possible to rebuild the target tree. -Stow is a Perl script which should run correctly under Perl 5.6.1 or -newer. You must install Perl before running Stow. For more -information about Perl, see http://www.perl.com/perl/. +See INSTALL for installation instructions. You can get the latest information about Stow from http://www.gnu.org/software/stow/stow.html @@ -25,7 +23,5 @@ possible to rebuild the target tree (e.g., /usr/local). Stow is free software, licensed under the GNU General Public License, which can be found in the file COPYING. -See INSTALL for installation instructions. - Please mail comments, questions, and criticisms to the current maintainers via help-stow@gnu.org or bug-stow@gnu.org. From d6afb3d06223cc123b3c5ce51da1d9dd4e844f72 Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Tue, 6 Dec 2011 17:08:21 +0000 Subject: [PATCH 125/482] Refill paragraph in README. --- README | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/README b/README index 4534ad8..a2b934b 100644 --- a/README +++ b/README @@ -1,11 +1,11 @@ This is GNU Stow, a program for managing the installation of software packages, keeping them separate (/usr/local/stow/emacs vs. -/usr/local/stow/perl, for example) while making them appear to be installed in -the same place (/usr/local). Stow doesn't store an extra state between runs, -so there's no danger of mangling directories when file hierarchies don't match -the database. Also, stow will never delete any files, directories, or links -that appear in a stow directory, so it is always possible to rebuild the -target tree. +/usr/local/stow/perl, for example) while making them appear to be +installed in the same place (/usr/local). Stow doesn't store an extra +state between runs, so there's no danger of mangling directories when +file hierarchies don't match the database. Also, stow will never +delete any files, directories, or links that appear in a stow +directory, so it is always possible to rebuild the target tree. See INSTALL for installation instructions. From 9dbe5e4c921ab4d190596dcdb2e53e58a2b6244a Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Tue, 6 Dec 2011 17:22:21 +0000 Subject: [PATCH 126/482] Fix release instructions regarding CPAN distribution. --- doc/HOWTO-RELEASE | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/doc/HOWTO-RELEASE b/doc/HOWTO-RELEASE index af61d0a..cb88041 100644 --- a/doc/HOWTO-RELEASE +++ b/doc/HOWTO-RELEASE @@ -7,6 +7,9 @@ How to make a new release of GNU Stow - Check CPAN distribution will work via Module::Build: + - Run ./configure && make to generate stow, chkstow, and lib/Stow.pm + (N.B. the CPAN distribution will contain these files, whereas + the GNU distribution will not.) - Run perl Build.PL. - Run ./Build test - Run ./Build install @@ -54,6 +57,10 @@ How to make a new release of GNU Stow # Then commit cvs commit + - Run ./Build dist + + - Upload the resulting Stow-v7.8.9.tar.gz to CPAN via https://pause.perl.org/ + - Upload to ftp.gnu.org. This is easiest using gnupload: - git clone git://git.savannah.gnu.org/gnulib.git @@ -69,5 +76,3 @@ How to make a new release of GNU Stow See http://www.gnu.org/prep/maintain/html_node/Announcements.html for more on making release announcements. - - - Upload to CPAN via https://pause.perl.org/ From 8fea1a8dbbf6bdde51ad015cf15bc6d742b3c6f0 Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Tue, 6 Dec 2011 17:24:44 +0000 Subject: [PATCH 127/482] Show when ChangeLog is rebuilt. --- Makefile.am | 1 + 1 file changed, 1 insertion(+) diff --git a/Makefile.am b/Makefile.am index 38509e5..d8430da 100644 --- a/Makefile.am +++ b/Makefile.am @@ -191,6 +191,7 @@ ChangeLog: doc/ChangeLog.OLD | sed 's/^\([A-Z]\)\t/ \1 /'; \ cat $< \ ) > $@; \ + echo "Rebuilt $@ from git commit history."; \ else \ echo "Not in a git repository; can't update ChangeLog."; \ fi From 7b62cbf09a26162038a769fc28a073ad85b4dbe5 Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Tue, 6 Dec 2011 17:30:58 +0000 Subject: [PATCH 128/482] Add a workaround for not being able to ensure that git commit triggers ChangeLog update. --- doc/HOWTO-RELEASE | 2 ++ 1 file changed, 2 insertions(+) diff --git a/doc/HOWTO-RELEASE b/doc/HOWTO-RELEASE index cb88041..18cb2e5 100644 --- a/doc/HOWTO-RELEASE +++ b/doc/HOWTO-RELEASE @@ -18,6 +18,8 @@ How to make a new release of GNU Stow - Ensure all changes are committed to git. + - Run `rm ChangeLog' to ensure it will get rebuilt. + - Run make distcheck and ensure that everything looks good. It should generate the distribution files for you. From fb2f621b1c48d2e5d4c5c0ad4fc1c1c6e3927d7c Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Tue, 6 Dec 2011 17:33:41 +0000 Subject: [PATCH 129/482] Ignore .mrdownload files from my `download' plugin to Joey Hess' mr utility. --- MANIFEST.SKIP | 1 + 1 file changed, 1 insertion(+) diff --git a/MANIFEST.SKIP b/MANIFEST.SKIP index f0190cf..6fa2f49 100644 --- a/MANIFEST.SKIP +++ b/MANIFEST.SKIP @@ -10,6 +10,7 @@ \B\.gitignore\b \b_darcs\b \B\.cvsignore$ +^\.mrdownload$ # Avoid VMS specific MakeMaker generated files \bDescrip.MMS$ From d051936bf5f2da1b989c10f790c8866f3a26ee52 Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Tue, 6 Dec 2011 10:35:31 +0000 Subject: [PATCH 130/482] Bump version to 2.1.1 --- META.json | 4 ++-- META.yml | 4 ++-- NEWS | 1 + configure.ac | 2 +- 4 files changed, 6 insertions(+), 5 deletions(-) diff --git a/META.json b/META.json index d895aea..4a77079 100644 --- a/META.json +++ b/META.json @@ -36,7 +36,7 @@ "provides" : { "Stow" : { "file" : "lib/Stow.pm", - "version" : "v2.1.0" + "version" : "v2.1.1" }, "Stow::Util" : { "file" : "lib/Stow/Util.pm", @@ -53,5 +53,5 @@ "url" : "http://github.com/aspiers/stow" } }, - "version" : "v2.1.0" + "version" : "v2.1.1" } diff --git a/META.yml b/META.yml index 7313ed4..3ef1bf3 100644 --- a/META.yml +++ b/META.yml @@ -17,7 +17,7 @@ name: Stow provides: Stow: file: lib/Stow.pm - version: v2.1.0 + version: v2.1.1 Stow::Util: file: lib/Stow/Util.pm version: 0 @@ -29,4 +29,4 @@ resources: homepage: https://savannah.gnu.org/projects/stow license: http://www.gnu.org/licenses/gpl-2.0.html repository: http://github.com/aspiers/stow -version: v2.1.0 +version: v2.1.1 diff --git a/NEWS b/NEWS index 52c368c..0c38927 100644 --- a/NEWS +++ b/NEWS @@ -4,6 +4,7 @@ News file for Stow. ** Fixed bug where ./configure --with-pmdir=X was ineffectual. ** Calculated the correct default value for pmdir based on the local Perl installation. ** Fixed some automake issues (thanks to Stefano Lattarini for spotting these!) +** Improved various bits of documentation. * Changes in version 2.1.0 ** Major refactoring of code into separate Stow and Stow::Util Perl modules. ** Added support for ignore list files. diff --git a/configure.ac b/configure.ac index ad9fc38..cd851d9 100644 --- a/configure.ac +++ b/configure.ac @@ -1,6 +1,6 @@ dnl Process this file with Autoconf to produce configure dnl -AC_INIT([stow], [2.1.0], [bug-stow@gnu.org]) +AC_INIT([stow], [2.1.1], [bug-stow@gnu.org]) AC_PREREQ([2.61]) AC_CONFIG_AUX_DIR([automake]) # Unfortunately we have to disable warnings for overrides, because we From 15f44a3275721afe97dce22b37d1958891b2fadd Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Tue, 6 Dec 2011 18:20:03 +0000 Subject: [PATCH 131/482] `make clean' shouldn't remove files which the user may not be able to rebuild. --- Makefile.am | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Makefile.am b/Makefile.am index d8430da..af6af81 100644 --- a/Makefile.am +++ b/Makefile.am @@ -81,8 +81,8 @@ EXTRA_DIST = \ $(TEXINFO_TEX) \ $(DEFAULT_IGNORE_LIST) \ $(CPAN_FILES) -CLEANFILES = $(bin_SCRIPTS) $(pm_DATA) $(dist_man_MANS) $(HTML) $(PDF) ChangeLog - +CLEANFILES = $(bin_SCRIPTS) $(pm_DATA) +MAINTAINERCLEANFILES = $(dist_man_MANS) $(HTML) $(PDF) ChangeLog # clean up auto-generated files clean-local: From 5eef9830c1a69641dc8f8737cf62025c82edd8f8 Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Wed, 7 Dec 2011 00:38:16 +0000 Subject: [PATCH 132/482] Use maintainer-clean-local rule, not maintainer-clean. --- Makefile.am | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile.am b/Makefile.am index af6af81..e0589b9 100644 --- a/Makefile.am +++ b/Makefile.am @@ -87,7 +87,7 @@ MAINTAINERCLEANFILES = $(dist_man_MANS) $(HTML) $(PDF) ChangeLog # clean up auto-generated files clean-local: -rm -rf $(TESTS_OUT) -maintainer-clean: +maintainer-clean-local: -rm -rf doc/manual-split # this is more explicit and reliable than the config file trick From e7e0646db0869a8c4e45586c3f1904248a369c14 Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Wed, 7 Dec 2011 01:23:41 +0000 Subject: [PATCH 133/482] Ensure the ChangeLog is up-to-date when making a new distribution. Thanks to Stefano Lattarini for this suggestion. --- Makefile.am | 9 ++++++++- NEWS | 3 +++ doc/HOWTO-RELEASE | 2 -- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/Makefile.am b/Makefile.am index e0589b9..fb6cdcc 100644 --- a/Makefile.am +++ b/Makefile.am @@ -179,7 +179,14 @@ $(HTML): doc/manual-split # keep in anyway: dist-hook: doc/manual-split -dist-hook: $(dist_man_MANS) ChangeLog +dist-hook: $(dist_man_MANS) +## If we are creating a distribution from a git checkout, ensure +## the ChangeLog file is in sync the git repository. + if test -d $(top_srcdir)/.git; then \ + rm -f ChangeLog \ + && $(MAKE) $(AM_MAKEFLAGS) ChangeLog \ + && cp -f ChangeLog $(distdir)/ChangeLog; \ + fi ChangeLog: doc/ChangeLog.OLD @if [ -d .git ]; then \ diff --git a/NEWS b/NEWS index 0c38927..feda14b 100644 --- a/NEWS +++ b/NEWS @@ -1,5 +1,8 @@ News file for Stow. +* Changes in version 2.1.2 +** Ensured the ChangeLog is up-to-date when making a new distribution. + Thanks to Stefano Lattarini for this suggestion. * Changes in version 2.1.1 ** Fixed bug where ./configure --with-pmdir=X was ineffectual. ** Calculated the correct default value for pmdir based on the local Perl installation. diff --git a/doc/HOWTO-RELEASE b/doc/HOWTO-RELEASE index 18cb2e5..cb88041 100644 --- a/doc/HOWTO-RELEASE +++ b/doc/HOWTO-RELEASE @@ -18,8 +18,6 @@ How to make a new release of GNU Stow - Ensure all changes are committed to git. - - Run `rm ChangeLog' to ensure it will get rebuilt. - - Run make distcheck and ensure that everything looks good. It should generate the distribution files for you. From d88434f16eb204c888723c755f9ade555fc3feb2 Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Wed, 7 Dec 2011 20:31:18 +0000 Subject: [PATCH 134/482] Abort ./configure if we can't find Perl. --- NEWS | 1 + configure.ac | 6 +++--- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/NEWS b/NEWS index feda14b..814569b 100644 --- a/NEWS +++ b/NEWS @@ -1,6 +1,7 @@ News file for Stow. * Changes in version 2.1.2 +** ./configure now aborts if Perl isn't found. ** Ensured the ChangeLog is up-to-date when making a new distribution. Thanks to Stefano Lattarini for this suggestion. * Changes in version 2.1.1 diff --git a/configure.ac b/configure.ac index cd851d9..d88c826 100644 --- a/configure.ac +++ b/configure.ac @@ -9,12 +9,12 @@ AC_CONFIG_AUX_DIR([automake]) AM_INIT_AUTOMAKE([-Wall -Werror -Wno-override dist-bzip2]) AC_PROG_INSTALL -dnl Check for perl on our system -dnl call to AC_SUBST(PERL) is implicit +dnl Check for perl on our system. +dnl Call to AC_SUBST(PERL) is implicit AC_PATH_PROGS([PERL], [perl] [perl5], [false]) if test "x$PERL" = xfalse then - AC_MSG_WARN([WARNING: Perl not found; you must edit line 1 of 'stow']) + AC_MSG_ERROR([Perl not found; check your \$PATH.]) fi AC_ARG_WITH( From 88178150598e8b2296f2578f8471c856bfe67759 Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Wed, 7 Dec 2011 01:20:07 +0000 Subject: [PATCH 135/482] Make capitalisation consistent in usage text. --- bin/stow.in | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/bin/stow.in b/bin/stow.in index f06d6a9..f31b64a 100755 --- a/bin/stow.in +++ b/bin/stow.in @@ -610,12 +610,12 @@ OPTIONS: -S, --stow Stow the package names that follow this option -D, --delete Unstow the package names that follow this option -R, --restow Restow (like stow -D followed by stow -S) - -p, --compat use legacy algorithm for unstowing + -p, --compat Use legacy algorithm for unstowing - --ignore=REGEX ignore files ending in this perl regex - --defer=REGEX don't stow files beginning with this perl regex + --ignore=REGEX Ignore files ending in this Perl regex + --defer=REGEX Don't stow files beginning with this Perl regex if the file is already stowed to another package - --override=REGEX force stowing files beginning with this perl regex + --override=REGEX Force stowing files beginning with this Perl regex if the file is already stowed to another package -V, --version Show stow version number -h, --help Show this help From 195c80e9d736a2025e33fe443db6821852116ddb Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Wed, 7 Dec 2011 20:28:28 +0000 Subject: [PATCH 136/482] Significantly improve the handling of --with-pmdir. --- INSTALL | 32 ++++++++++++++++++++++++++++---- Makefile.am | 46 +++++++++++++++++++++++++++++++++++++++------- NEWS | 16 +++++++++++++++- bin/stow.in | 1 + configure.ac | 46 +++++++++++++++++++++++++++++++++++++++++----- doc/HOWTO-RELEASE | 30 ++++++++++++++++++++++++------ 6 files changed, 148 insertions(+), 23 deletions(-) diff --git a/INSTALL b/INSTALL index 79e3854..d00e279 100644 --- a/INSTALL +++ b/INSTALL @@ -40,6 +40,14 @@ The steps in building Stow are: `./configure && make' to configure stow for your system. If you are building from a CPAN tarball, this step can be skipped. + If `make' warns that the Perl module installation directory is + not in @INC, then you should run: + + eval `perl -V:siteprefix` + ./configure --prefix=$siteprefix && make + + to avoid a superfluous "use lib" line in your stow executable. + 3. Type `perl Build.PL'. 4. Type `./Build install' to install the various files. As noted @@ -52,11 +60,27 @@ The steps in building Stow are: 1. `cd' to the directory containing the source code (and this file). -2. Type `./configure' to configure stow for your system. This - step will attempt to locate your copy of perl and set its location - in `Makefile.in'. +2. Type `./configure' to configure stow for your system. This step + will attempt to locate your copy of perl and set its location in + `Makefile.in'. You can use the normal arguments to change the + default installation paths (see below); additionally you can use + the -3. Type `make install' to install the various files. + --with-pmdir=/path/to/perl/modules + + option to manually choose where the Perl modules get installed. + However, if you don't, the configure script will go to great + lengths to try to choose a sensible default. + +3. Type `make install' to install the various files. If the chosen + installation directory for Perl modules is not included in Perl's + built-in @INC search path, the Makefile rules will automatically + insert a + + use lib "..."; + + line into the generated stow script to ensure that it can always + locate the Perl modules without needing to manually set PERL5LIB. 4. You can remove the generated files from the source code directory by typing `make clean'. To also remove the files that `configure' diff --git a/Makefile.am b/Makefile.am index fb6cdcc..c686269 100644 --- a/Makefile.am +++ b/Makefile.am @@ -91,22 +91,54 @@ maintainer-clean-local: -rm -rf doc/manual-split # this is more explicit and reliable than the config file trick -edit = sed -e 's|[@]PERL[@]|$(PERL)|g' \ - -e 's|[@]VERSION[@]|$(VERSION)|g' +edit = sed -e 's|[@]PERL[@]|$(PERL)|g' \ + -e 's|[@]VERSION[@]|$(VERSION)|g' \ + -e "s|[@]USE_LIB_PMDIR[@]|$$use_lib_pmdir|g" + +pmdir_in_INC = \ + PERL5LIB= $(PERL) -V | \ + awk '/@INC/ {p=1; next} p==1 {print $$1}' | \ + grep -q "$(pmdir)" + +calc_use_lib_pmdir = \ + if $(pmdir_in_INC); then \ + use_lib_pmdir=""; \ + else \ + use_lib_pmdir="use lib \"$(pmdir)\";"; \ + fi + +check_pmdir = \ + echo; \ + echo "\# Perl modules will be installed to $(pmdir)"; \ + echo "\# "; \ + if $(pmdir_in_INC); then \ + echo "\# This is in $(PERL)'s built-in @INC, so everything"; \ + echo "\# should work fine with no extra effort."; \ + else \ + echo "\# This is not in $(PERL)'s built-in @INC, so the"; \ + echo "\# front-end scripts will have an appropriate \"use lib\""; \ + echo "\# line inserted to compensate."; \ + fi; \ + echo bin/stow: bin/stow.in Makefile [ -d bin ] || mkdir bin # required in vpath mode + @$(check_pmdir) + @$(calc_use_lib_pmdir); \ $(edit) < $< > $@ + @echo "Generated $@ from $<" chmod +x $@ bin/chkstow: bin/chkstow.in Makefile - [ -d bin ] || mkdir bin # required in vpath mode - $(edit) < $< > $@ + @[ -d bin ] || mkdir bin # required in vpath mode + @$(edit) < $< > $@ + @echo "Generated $@ from $<" chmod +x $@ -lib/Stow.pm: lib/Stow.pm.in Makefile $(DEFAULT_IGNORE_LIST) - [ -d lib ] || mkdir lib # required in vpath mode - ( $(edit) < $<; cat $(DEFAULT_IGNORE_LIST) ) > $@ +lib/Stow.pm: lib/Stow.pm.in $(DEFAULT_IGNORE_LIST) Makefile + @[ -d lib ] || mkdir lib # required in vpath mode + @( $(edit) < $<; cat $(DEFAULT_IGNORE_LIST) ) > $@ + @echo "Generated $@ from $< and $(DEFAULT_IGNORE_LIST)" ############################################################################## # The below rules should only be needed by developers. diff --git a/NEWS b/NEWS index 814569b..16227e4 100644 --- a/NEWS +++ b/NEWS @@ -1,9 +1,23 @@ News file for Stow. * Changes in version 2.1.2 + Many thanks to Stefano Lattarini for help with numerous autoconf and + automake issues which are addressed in this release. +** Significantly improve the handling of --with-pmdir. +*** Calculation of the default value for --with-pmdir is now done safely in Perl. + Previously non-POSIX-compliant shells could cause issues. +*** The output of ./configure and make are now much more helpful. +*** The Makefile will now check whether pmdir is in Perl's built-in @INC. + If not, it will insert a + + use lib "..."; + + line into the generated stow script to ensure that it can always + locate the Perl modules without needing to manually set PERL5LIB. +*** Updated INSTALL and HOWTO-RELEASE accordingly. ** ./configure now aborts if Perl isn't found. ** Ensured the ChangeLog is up-to-date when making a new distribution. - Thanks to Stefano Lattarini for this suggestion. +** Fixed bug with `make clean' removing files which the user may not be able to rebuild. * Changes in version 2.1.1 ** Fixed bug where ./configure --with-pmdir=X was ineffectual. ** Calculated the correct default value for pmdir based on the local Perl installation. diff --git a/bin/stow.in b/bin/stow.in index f31b64a..6198d9a 100755 --- a/bin/stow.in +++ b/bin/stow.in @@ -395,6 +395,7 @@ require 5.6.1; use POSIX qw(getcwd); use Getopt::Long; +@USE_LIB_PMDIR@ use Stow; use Stow::Util qw(parent); diff --git a/configure.ac b/configure.ac index d88c826..e8b1839 100644 --- a/configure.ac +++ b/configure.ac @@ -17,13 +17,49 @@ then AC_MSG_ERROR([Perl not found; check your \$PATH.]) fi +# N.B. ${var#pattern} will not work with some shells, such as +# Solaris 10's /bin/sh :-( +# +# http://www.gnu.org/software/autoconf/manual/autoconf.html#Portable-Shell +# +# eval `$PERL -V:siteprefix -V:installsitelib` +# pmdir_relative_path="${installsitelib#$siteprefix/}" +# +# This will work: +# +# pmdir_relative_path=`echo "${installsitelib}" | sed -e "s!^$siteprefix/!!"` +# +# but this is cleaner: +pmdir_relative_path=`\ + $PERL -MConfig \ + -wle '($_ = $Config{installsitelib}) + =~ s!^\Q$Config{siteprefix}/!!; \ + print'` + AC_ARG_WITH( - pmdir, - [ --with-pmdir=DIR Perl modules are in DIR [[LIBDIR/perl5]]], + [pmdir], + AS_HELP_STRING( + [--with-pmdir=DIR], + [Install Perl modules in DIR]), [PMDIR=${withval}], - [eval `$PERL -V:installsitelib -V:siteprefix` - PMDIR='${prefix}'/"${installsitelib#$siteprefix/}"]) -AC_CONFIG_COMMANDS_POST([eval echo "Perl modules will be installed to $PMDIR"]) + [PMDIR='${prefix}'/"$pmdir_relative_path"]) +AC_CONFIG_COMMANDS_POST([[ + eval pmdir="$PMDIR" + cat < Date: Tue, 6 Dec 2011 18:30:28 +0000 Subject: [PATCH 137/482] Bump version to 2.1.2. --- META.json | 4 ++-- META.yml | 4 ++-- configure.ac | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/META.json b/META.json index 4a77079..6e34c58 100644 --- a/META.json +++ b/META.json @@ -36,7 +36,7 @@ "provides" : { "Stow" : { "file" : "lib/Stow.pm", - "version" : "v2.1.1" + "version" : "v2.1.2" }, "Stow::Util" : { "file" : "lib/Stow/Util.pm", @@ -53,5 +53,5 @@ "url" : "http://github.com/aspiers/stow" } }, - "version" : "v2.1.1" + "version" : "v2.1.2" } diff --git a/META.yml b/META.yml index 3ef1bf3..f02e0f2 100644 --- a/META.yml +++ b/META.yml @@ -17,7 +17,7 @@ name: Stow provides: Stow: file: lib/Stow.pm - version: v2.1.1 + version: v2.1.2 Stow::Util: file: lib/Stow/Util.pm version: 0 @@ -29,4 +29,4 @@ resources: homepage: https://savannah.gnu.org/projects/stow license: http://www.gnu.org/licenses/gpl-2.0.html repository: http://github.com/aspiers/stow -version: v2.1.1 +version: v2.1.2 diff --git a/configure.ac b/configure.ac index e8b1839..7d4ac4a 100644 --- a/configure.ac +++ b/configure.ac @@ -1,6 +1,6 @@ dnl Process this file with Autoconf to produce configure dnl -AC_INIT([stow], [2.1.1], [bug-stow@gnu.org]) +AC_INIT([stow], [2.1.2], [bug-stow@gnu.org]) AC_PREREQ([2.61]) AC_CONFIG_AUX_DIR([automake]) # Unfortunately we have to disable warnings for overrides, because we From 1f35c6c94f198ea855d21f984ab77c8a3ddf83dd Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Sun, 11 Dec 2011 13:12:32 +0000 Subject: [PATCH 138/482] Automate check for 'use lib' line in bin/stow. --- Build.PL | 26 ++++++++++++++++++++++++++ doc/HOWTO-RELEASE | 9 --------- 2 files changed, 26 insertions(+), 9 deletions(-) diff --git a/Build.PL b/Build.PL index c605d41..0dd13bb 100644 --- a/Build.PL +++ b/Build.PL @@ -58,4 +58,30 @@ my $build = Module::Build->new( }, ); +if (system('grep', '-q', '^use lib ', 'bin/stow') >> 8 == 0) { + die <<'EOF'; + +ERROR: bin/stow contains 'use lib' line which could interfere +with CPAN-style installation via Module::Build. To avoid this, +you should run ./configure with parameters which result in +--with-pmdir's value being in Perl's built-in @INC, and then run +'make' (NOT 'make install') to regenerate bin/stow, e.g. + + eval `perl -V:siteprefix` + ./configure --prefix=$siteprefix && make + +or + + ./configure --with-pmdir=`PERL5LIB= perl -le 'print $INC[0]'` && make + +Then re-run this script. + +Note that these parameters are chosen purely to regenerate +bin/stow without a 'use lib' line, so don't run 'make install' +while Stow is configured in this way unless you really want an +installation using these parameters. + +EOF +} + $build->create_build_script(); diff --git a/doc/HOWTO-RELEASE b/doc/HOWTO-RELEASE index 990b8db..3c7954b 100644 --- a/doc/HOWTO-RELEASE +++ b/doc/HOWTO-RELEASE @@ -15,15 +15,6 @@ How to make a new release of GNU Stow (N.B. the CPAN distribution will contain these files, whereas the GNU distribution will not.) - - Make sure bin/stow does not contain a "use lib" line. This - should only happen if the installation directory for Perl - modules (--with-pmdir's default value) is not in Perl's - built-in @INC, which would be caused by ./configure's default - prefix (/usr/local) not matching your Perl's siteprefix, but - the above --prefix should prevent that, as would: - - ./configure --with-pmdir=`perl -le 'print $INC[0]'` - - Make sure all the following commands all run successfully: perl Build.PL From d3847e951a0adaa6dca5004882cff8ba2ac32ead Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Sun, 11 Dec 2011 13:23:37 +0000 Subject: [PATCH 139/482] Make stow script return true for t/stow.t According to http://matrix.cpantesters.org/?dist=Stow this only seems to be an issue with Perl <= 5.8.7. --- bin/stow.in | 1 + 1 file changed, 1 insertion(+) diff --git a/bin/stow.in b/bin/stow.in index 6198d9a..2659129 100755 --- a/bin/stow.in +++ b/bin/stow.in @@ -633,6 +633,7 @@ sub version { exit 0; } +1; # This file is required by t/stow.t # Local variables: # mode: perl From 215e0dac13b7b861d6db4a6d4d4d6dd891a80592 Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Tue, 13 Dec 2011 16:12:29 +0000 Subject: [PATCH 140/482] Make configure check for Perl modules required by test suite. --- NEWS | 2 ++ configure.ac | 29 +++++++++++++++++++++++++++++ 2 files changed, 31 insertions(+) diff --git a/NEWS b/NEWS index 16227e4..fd59eec 100644 --- a/NEWS +++ b/NEWS @@ -1,5 +1,7 @@ News file for Stow. +* Changes in version 2.1.3 +** ./configure now checks for Perl modules required by the test suite. * Changes in version 2.1.2 Many thanks to Stefano Lattarini for help with numerous autoconf and automake issues which are addressed in this release. diff --git a/configure.ac b/configure.ac index 7d4ac4a..7563a99 100644 --- a/configure.ac +++ b/configure.ac @@ -17,6 +17,18 @@ then AC_MSG_ERROR([Perl not found; check your \$PATH.]) fi +missing_test_deps= +for mod in Test::More Test::Output; do + AC_MSG_CHECKING([$mod]) + if $PERL -M$mod -e 1 2>/dev/null + then + AC_MSG_RESULT([yes]) + else + AC_MSG_RESULT([no]) + missing_test_deps="$missing_test_deps $mod" + fi +done + # N.B. ${var#pattern} will not work with some shells, such as # Solaris 10's /bin/sh :-( # @@ -59,6 +71,23 @@ EOF EOF echo fi + + if test -n "$missing_test_deps"; then + cat <&2 +!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! +! WARNING! $PERL was missing modules: +! +! $missing_test_deps +! +! The test suite will fail. 'make install' may still render +! a working installation, but this cannot be guaranteed. +! +! Please (re-)read INSTALL, then install the missing modules +! and try again. +!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +EOF + fi ]]) AC_SUBST([PMDIR]) From 6e5331814da7cd76415fe110cb37cc16c5e22078 Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Thu, 15 Dec 2011 21:14:07 +0000 Subject: [PATCH 141/482] Fix some incorrect CPAN meta-data about the project. --- Build.PL | 9 ++++----- META.json | 2 +- META.yml | 2 +- 3 files changed, 6 insertions(+), 7 deletions(-) diff --git a/Build.PL b/Build.PL index 0dd13bb..9a755f8 100644 --- a/Build.PL +++ b/Build.PL @@ -27,19 +27,18 @@ my $build = Module::Build->new( # https://rt.cpan.org/Ticket/Display.html?id=71502 # bugtracker => { # web => 'http://rt.cpan.org/Public/Dist/Display.html?Name=Stow', - # mailto => 'mysqldiff@adamspiers.org', + # mailto => 'stow-devel@gnu.org', # }, #bugtracker => 'http://rt.cpan.org/Public/Dist/Display.html?Name=Stow', # Module::Build forces us to use v1.4 of the CPAN Meta Spec: # https://rt.cpan.org/Ticket/Display.html?id=71502 # repository => { - # url => 'git:github.com/aspiers/stow.git', - # web => 'http://github.com/aspiers/stow', + # url => 'git://git.savannah.gnu.org/stow.git', + # web => 'https://savannah.gnu.org/git/?group=stow', # type => 'git', # }, - repository => 'http://github.com/aspiers/stow', - #repository => 'https://savannah.gnu.org/git/?group=stow', + repository => 'git://git.savannah.gnu.org/stow.git', }, }, requires => { diff --git a/META.json b/META.json index 6e34c58..e762735 100644 --- a/META.json +++ b/META.json @@ -50,7 +50,7 @@ "http://www.gnu.org/licenses/gpl-2.0.html" ], "repository" : { - "url" : "http://github.com/aspiers/stow" + "url" : "git://git.savannah.gnu.org/stow.git" } }, "version" : "v2.1.2" diff --git a/META.yml b/META.yml index f02e0f2..84e5fd1 100644 --- a/META.yml +++ b/META.yml @@ -28,5 +28,5 @@ requires: resources: homepage: https://savannah.gnu.org/projects/stow license: http://www.gnu.org/licenses/gpl-2.0.html - repository: http://github.com/aspiers/stow + repository: git://git.savannah.gnu.org/stow.git version: v2.1.2 From 7c900003934b07d0294ecfadb4b71f1996dd3c10 Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Wed, 21 Dec 2011 11:45:43 +0000 Subject: [PATCH 142/482] Add another ignore example to the manual and test suite. --- doc/stow.texi | 10 +++++----- t/ignore.t | 4 ++-- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/doc/stow.texi b/doc/stow.texi index 5eb5fcd..86d1cfc 100644 --- a/doc/stow.texi +++ b/doc/stow.texi @@ -505,11 +505,11 @@ expressions which contain @samp{/}, and @code{bazqux} as the text for matching against regular expressions which don't contain @samp{/}. Then regular expressions @code{bazqux}, @code{baz.*}, @code{.*qux}, @code{bar/.*x}, and @code{^/foo/.*qux} would all match (causing the -file to be ignored), whereas @code{bar}, @code{baz}, and @code{qux} -would not (although @code{bar} would cause its parent directory to be -ignored and prevent Stow from recursing into that anyway, in which -case the file @file{bazqux} would not even be considered for -stowing). +file to be ignored), whereas @code{bar}, @code{baz}, @code{qux}, and +@code{o/bar/b} would not (although @code{bar} would cause its parent +directory to be ignored and prevent Stow from recursing into that +anyway, in which case the file @file{bazqux} would not even be +considered for stowing). As a special exception to the above algorithm, any @file{.stow-local-ignore} present in the top-level package directory diff --git a/t/ignore.t b/t/ignore.t index 83966fc..d50c94c 100755 --- a/t/ignore.t +++ b/t/ignore.t @@ -8,7 +8,7 @@ use strict; use warnings; use File::Temp qw(tempdir); -use Test::More tests => 286; +use Test::More tests => 287; use testutil; use Stow::Util qw(join_paths); @@ -235,7 +235,7 @@ sub test_examples_in_manual { ); } - for my $re ('bar', 'baz', 'qux') { + for my $re ('bar', 'baz', 'qux', 'o/bar/b') { my $local_ignore = setup_package_local_list($stow_path, $package, "$re\n"); test_ignores( $stow_path, $package, $context, From 782836bad7ee69f37de291d7b38ca8ba036fea18 Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Wed, 21 Dec 2011 11:45:59 +0000 Subject: [PATCH 143/482] Improve the footnote which defines 'subpath'. --- doc/stow.texi | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/doc/stow.texi b/doc/stow.texi index 86d1cfc..7bbbe58 100644 --- a/doc/stow.texi +++ b/doc/stow.texi @@ -477,9 +477,9 @@ regular expression is anchored at the beginning and end, in contrast to unanchored regular expressions which will match a substring.} match a subpath@footnote{In this context, ``subpath'' means a contiguous subset of path segments; e.g for the relative path -@file{one/two/three/four}, the following are examples of valid -subpaths: @file{one}, @file{two}, @file{two/three}, -@file{two/three/four}.} of this relative path, then the file or +@file{one/two/three}, there are six valid subpaths: @file{one}, +@file{two}, @file{three}, @file{one/two}, @file{two/three}, +@file{one/two/three}.} of this relative path, then the file or directory will be ignored. @item From 1efb7861404bef930357e554c2b1797e20021601 Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Mon, 9 Jan 2012 16:25:27 +0000 Subject: [PATCH 144/482] Improve existing comments. --- lib/Stow.pm.in | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/lib/Stow.pm.in b/lib/Stow.pm.in index 99805f6..416c956 100755 --- a/lib/Stow.pm.in +++ b/lib/Stow.pm.in @@ -198,8 +198,8 @@ sub init_state { # $self->{tasks}: list of operations to be performed (in order) # each element is a hash ref of the form # { - # action => ... - # type => ... + # action => ... ('create' or 'remove') + # type => ... ('link' or 'dir') # path => ... (unique) # source => ... (only for links) # } @@ -823,7 +823,7 @@ sub unstow_node { #===== METHOD =============================================================== # Name : path_owned_by_package() -# Purpose : determine if the given link points to a member of a +# Purpose : determine whether the given link points to a member of a # : stowed package # Parameters: $target => path to a symbolic link under current directory # : $source => where that link points to @@ -842,7 +842,7 @@ sub path_owned_by_package { #===== METHOD =============================================================== # Name : find_stowed_path() -# Purpose : determine if the given link points to a member of a +# Purpose : determine whether the given link points to a member of a # : stowed package # Parameters: $target => path to a symbolic link under current directory # : $source => where that link points to (needed because link @@ -962,7 +962,7 @@ sub cleanup_invalid_links { #===== METHOD =============================================================== # Name : foldable() -# Purpose : determine if a tree can be folded +# Purpose : determine whether a tree can be folded # Parameters: $target => path to a directory # Returns : path to the parent dir iff the tree can be safely folded # Throws : n/a @@ -1496,7 +1496,7 @@ sub dir_task_action { #===== METHOD =============================================================== # Name : parent_link_scheduled_for_removal() -# Purpose : determines whether the given path or any parent thereof +# Purpose : determine whether the given path or any parent thereof # : is a link scheduled for removal # Parameters: $path # Returns : Boolean @@ -1524,7 +1524,7 @@ sub parent_link_scheduled_for_removal { #===== METHOD =============================================================== # Name : is_a_link() -# Purpose : is the given path a current or planned link +# Purpose : determine if the given path is a current or planned link # Parameters: $path # Returns : Boolean # Throws : none @@ -1558,7 +1558,7 @@ sub is_a_link { #===== METHOD =============================================================== # Name : is_a_dir() -# Purpose : is the given path a current or planned directory +# Purpose : determine if the given path is a current or planned directory # Parameters: $path # Returns : Boolean # Throws : none @@ -1593,7 +1593,7 @@ sub is_a_dir { #===== METHOD =============================================================== # Name : is_a_node() -# Purpose : is the given path a current or planned node +# Purpose : determine whether the given path is a current or planned node # Parameters: $path # Returns : Boolean # Throws : none From e466732bbf856983883b3968ae3c85f224a36737 Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Mon, 9 Jan 2012 16:42:40 +0000 Subject: [PATCH 145/482] Improve readability of NEWS file when viewed raw. --- NEWS | 199 ++++++++++++++++++++++++++++++++++++++--------------------- 1 file changed, 128 insertions(+), 71 deletions(-) diff --git a/NEWS b/NEWS index fd59eec..4979922 100644 --- a/NEWS +++ b/NEWS @@ -1,65 +1,97 @@ News file for Stow. * Changes in version 2.1.3 + ** ./configure now checks for Perl modules required by the test suite. + * Changes in version 2.1.2 + Many thanks to Stefano Lattarini for help with numerous autoconf and automake issues which are addressed in this release. + ** Significantly improve the handling of --with-pmdir. + *** Calculation of the default value for --with-pmdir is now done safely in Perl. + Previously non-POSIX-compliant shells could cause issues. + *** The output of ./configure and make are now much more helpful. + *** The Makefile will now check whether pmdir is in Perl's built-in @INC. + If not, it will insert a use lib "..."; line into the generated stow script to ensure that it can always locate the Perl modules without needing to manually set PERL5LIB. + *** Updated INSTALL and HOWTO-RELEASE accordingly. + ** ./configure now aborts if Perl isn't found. + ** Ensured the ChangeLog is up-to-date when making a new distribution. + ** Fixed bug with `make clean' removing files which the user may not be able to rebuild. + * Changes in version 2.1.1 + ** Fixed bug where ./configure --with-pmdir=X was ineffectual. + ** Calculated the correct default value for pmdir based on the local Perl installation. + ** Fixed some automake issues (thanks to Stefano Lattarini for spotting these!) + ** Improved various bits of documentation. + * Changes in version 2.1.0 + ** Major refactoring of code into separate Stow and Stow::Util Perl modules. + ** Added support for ignore list files. + ** Added support for CPAN-style installation and distribution via Module::Build. + ** Introduced `make test' target and significantly tightened up test suite. + ** Very large number of code and documentation fixes (over 80 commits since version 2.0.1). + ** The '--conflicts' option has been removed. -Stow will always show conflicts if they are found during the scanning -phase. + Stow will always show conflicts if they are found during the scanning + phase. ** Improved debugging output. + ** Converted man page to POD format. + ** Include PDF, and both split- and single-page HTML versions of manual in the distribution. + ** Fixed code style consistency issues. + ** Running configure from outside the source tree now works. + ** `make distcheck' now works. + * Changes in version 2.0.1 + ** Defer operations until all potential conflicts have been assessed. -We do this by traversing the installation image(s) and recording the -actions that need to be performed. Redundant actions are factored out, -e.g., we don't want to create a link that we will later remove in order to -create a directory. Benefits of this approach + We do this by traversing the installation image(s) and recording the + actions that need to be performed. Redundant actions are factored out, + e.g., we don't want to create a link that we will later remove in order to + create a directory. Benefits of this approach: - 1. Get to see _all_ the conflicts that are blocking an installation: - you don't have to deal with them one at a time. - 2. No operations are be performed if _any_ conflicts are detected: - a failed stow will not leave you with a partially installed - package. - 3. Minimises the set of operations that need to be performed. - 4. Operations are executed as a batch which is much faster - This can be an advantage when upgrading packages on a live system - where you want to minimise the amount of time when the package is - unavailable. + 1. Get to see _all_ the conflicts that are blocking an installation: + you don't have to deal with them one at a time. + 2. No operations are be performed if _any_ conflicts are detected: + a failed stow will not leave you with a partially installed + package. + 3. Minimises the set of operations that need to be performed. + 4. Operations are executed as a batch which is much faster + This can be an advantage when upgrading packages on a live system + where you want to minimise the amount of time when the package is + unavailable. ** The above fixes the false conflict problem mentioned in the info file. @@ -75,70 +107,72 @@ create a directory. Benefits of this approach ** Default command line arguments set via '.stowrc' and '~/.stowrc' files. -Contents of these files are parsed as though they occurred first on the -command line. + Contents of these files are parsed as though they occurred first on + the command line. ** Support multiple actions per invocation. -In order for this to work, we had to add a new (optional) command line arg -(-S) to specify packages to stow. For example, to update an installation -of emacs you can now do + In order for this to work, we had to add a new (optional) command line arg + (-S) to specify packages to stow. For example, to update an installation + of emacs you can now do - stow -D emacs-21.3 -S emacs-21.4a + stow -D emacs-21.3 -S emacs-21.4a -which will replace emacs-21.3 with emacs-21.4a. -You can mix and match any number of actions, e.g., + which will replace emacs-21.3 with emacs-21.4a. + You can mix and match any number of actions, e.g., - stow -S p1 p2 -D p3 p4 -S p5 -R p6 + stow -S p1 p2 -D p3 p4 -S p5 -R p6 -will unstow p3, p4 and p6, then stow p1, p2, p5 and p6. + will unstow p3, p4 and p6, then stow p1, p2, p5 and p6. ** New (repeatable) command line arg: --ignore='' -This suppresses operating on a file matching the regex (suffix), e.g., + This suppresses operating on a file matching the regex (suffix), + e.g. - --ignore='~' --ignore='\.#.*' + --ignore='~' --ignore='\.#.*' -will ignore emacs and CVS backup files (suitable for ~/.stowrc file). + will ignore emacs and CVS backup files (suitable for ~/.stowrc file). -(I opted for Perl regular expressions because they are more powerful and -easier to implement). + (I opted for Perl regular expressions because they are more + powerful and easier to implement). ** New (repeatable) command line arg: --defer='' -This defers stowing a file matching the regex (prefix) if that file is -already stowed to a different package, e.g., + This defers stowing a file matching the regex (prefix) if that file + is already stowed to a different package, e.g., - --defer='man' --defer='info' + --defer='man' --defer='info' -will cause stow to skip over pre-existing man and info pages. + will cause stow to skip over pre-existing man and info pages. -Equivalently, you could use --defer='man|info' since the argument is just -a Perl regex. + Equivalently, you could use --defer='man|info' since the argument + is just a Perl regex. ** New (repeatable) command line arg: --override='' -This forces a file matching the regex (prefix) to be stowed even if the -file is already stowed to a different package, e.g., + This forces a file matching the regex (prefix) to be stowed even if + the file is already stowed to a different package, e.g. - --override='man' --override='info' + --override='man' --override='info' -will unstow any pre-existing man and info pages that would conflict with -the file we are trying to stow. + will unstow any pre-existing man and info pages that would conflict + with the file we are trying to stow. -Equivalently, you could use --override='man|info' since the argument is -just a Perl regex. + Equivalently, you could use --override='man|info' since the + argument is just a Perl regex. ** The above gives the ability to manage packages with common content. -For example, man pages that are shared by a number of CPAN packages. -Using multiple stow directories and .stowrc files can also simplify -things. In our setup we use the standard /usr/local/stow directory for -packages to be installed in /usr/local. Since we install a large number -of extra Perl packages (currently about 300) we use an additional stow -directory: /usr/local/stow/perl-5.8.8-extras. Both stow directories -contain a '.stow' file so that they collaborate appropriately. I then use -the following .stowrc file in /usr/local/stow/perl-5.8.8-extras + For example, man pages that are shared by a number of CPAN + packages. Using multiple stow directories and .stowrc files can + also simplify things. In our setup we use the standard + /usr/local/stow directory for packages to be installed in + /usr/local. Since we install a large number of extra Perl packages + (currently about 300) we use an additional stow directory: + /usr/local/stow/perl-5.8.8-extras. Both stow directories contain a + '.stow' file so that they collaborate appropriately. I then use + the following .stowrc file in /usr/local/stow/perl-5.8.8-extras --dir=/usr/local/stow/perl-5.8.8-extras --target=/usr/local @@ -148,54 +182,77 @@ the following .stowrc file in /usr/local/stow/perl-5.8.8-extras --ignore='\.packlist' --ignore='\.bs' -When I stow packages from there, they automatically override any man pages -and binaries that may already have been stowed by another package or by -the core perl-5.8.8 installation. For example, if you want to upgrade the -Test-Simple package, you need to override all the man pages that would -have been installed by the core package. If you are upgrading CPAN, you -will also have to override the pre-existing cpan executable. + When I stow packages from there, they automatically override any + man pages and binaries that may already have been stowed by another + package or by the core perl-5.8.8 installation. For example, if + you want to upgrade the Test-Simple package, you need to override + all the man pages that would have been installed by the core + package. If you are upgrading CPAN, you will also have to override + the pre-existing cpan executable. ** By default, search less aggressively for invalid symlinks when unstowing. -That is, we only search for bad symlinks in the directories explicitly -mentioned in the installation image, and do not dig down into other -subdirs. Digging down into other directories can be very time consuming -if you have a really big tree (like with a couple of Oracle installations -lying around). In general the old behaviour is only necessary when you -have really stuffed up your installation by deleting a directory that has -already been stowed. Doing that on a live system is somewhat crazy and -hopefully rare. We provide an option '-p|--compat' to enable the old -behaviour for those needing to patch up mistakes. + That is, we only search for bad symlinks in the directories + explicitly mentioned in the installation image, and do not dig down + into other subdirs. Digging down into other directories can be + very time consuming if you have a really big tree (like with a + couple of Oracle installations lying around). In general the old + behaviour is only necessary when you have really stuffed up your + installation by deleting a directory that has already been stowed. + Doing that on a live system is somewhat crazy and hopefully rare. + We provide an option '-p|--compat' to enable the old behaviour for + those needing to patch up mistakes. ** New chkstow utility for checking the integrity of the target directory. ** Implement a test suite and support code. -This was built before implementing any of the extra features so I could -more easily check for equivalent functionality. The initial code base had -to be refactored substantially to allow for testing. The test suite is -not exhaustive, but it should provide enough to check for regressions. + This was built before implementing any of the extra features so I + could more easily check for equivalent functionality. The initial + code base had to be refactored substantially to allow for testing. + The test suite is not exhaustive, but it should provide enough to + check for regressions. * Changes in version 1.3.3 + ** Now requires Perl 5.005 or later + ** Initially empty directories are not removed anymore + ** Removed buggy fastcwd (we use POSIX::getcwd instead) + ** Fixed bug when the common Parent of Target dir and Stow dir was "/" + ** Fixed bug when handling directories named "0" + ** Stow now only warns the user if a directory is unreadable during unstowing. + * Changes in version 1.3: + ** Added --restow option. + ** Fixed handling of slashes in package names. + ** Expanded configure-time search for Perl binary. + * Changes in version 1.2: + ** Dependency on `pwd' removed. + ** Perl 4 compatibility fixes. + ** Manual expanded even more. + * Changes in version 1.1: + ** Long and short options now accepted. + ** Manual expanded. + ** `make clean' removes stow (which is generated from stow.in). + * Initial public release (v1.0) of Stow. + * emacs local variables Local Variables: mode: org From 1200420687a2d5e317fd3ddaa2b865317e3e5b0c Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Mon, 9 Jan 2012 17:52:11 +0000 Subject: [PATCH 146/482] Link to website to encourage users to report bugs. --- lib/Stow.pm.in | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/Stow.pm.in b/lib/Stow.pm.in index 416c956..cf81d9b 100755 --- a/lib/Stow.pm.in +++ b/lib/Stow.pm.in @@ -1963,8 +1963,12 @@ sub do_rmdir { #============================================================================ sub internal_error { my ($format, @args) = @_; - die "$ProgramName: INTERNAL ERROR: " . sprintf($format, @args) . "\n", - "This _is_ a bug. Please submit a bug report so we can fix it:-)\n"; + my $error = sprintf($format, @args); + die < Date: Mon, 9 Jan 2012 18:32:06 +0000 Subject: [PATCH 147/482] Use get_conflict_count() in tests since get_conflicts() no longer returns a flat structure. --- t/cleanup_invalid_links.t | 4 ++-- t/examples.t | 10 +++++----- t/stow_contents.t | 14 +++++++------- t/unstow_contents.t | 28 ++++++++++++++-------------- t/unstow_contents_orig.t | 28 ++++++++++++++-------------- 5 files changed, 42 insertions(+), 42 deletions(-) diff --git a/t/cleanup_invalid_links.t b/t/cleanup_invalid_links.t index e6edd9d..f0f164b 100755 --- a/t/cleanup_invalid_links.t +++ b/t/cleanup_invalid_links.t @@ -46,7 +46,7 @@ make_link('bin2/file2b', '../../stow/pkg2/bin2/file2b'); $stow = new_Stow(); $stow->cleanup_invalid_links('bin2'); -is(scalar($stow->get_conflicts), 0, 'no conflicts cleaning up bad link'); +is($stow->get_conflict_count, 0, 'no conflicts cleaning up bad link'); is(scalar($stow->get_tasks), 1, 'one task cleaning up bad link'); is($stow->link_task_action('bin2/file2b'), 'remove', 'removal task for bad link'); @@ -62,5 +62,5 @@ make_link('bin3/file3b', '../../empty'); $stow = new_Stow(); $stow->cleanup_invalid_links('bin3'); -is(scalar($stow->get_conflicts), 0, 'no conflicts cleaning up bad link not owned by stow'); +is($stow->get_conflict_count, 0, 'no conflicts cleaning up bad link not owned by stow'); is(scalar($stow->get_tasks), 0, 'no tasks cleaning up bad link not owned by stow'); diff --git a/t/examples.t b/t/examples.t index 42894ef..7320ed5 100755 --- a/t/examples.t +++ b/t/examples.t @@ -54,7 +54,7 @@ $stow = new_Stow(dir => 'stow'); $stow->plan_stow('perl'); $stow->process_tasks(); ok( - scalar($stow->get_conflicts) == 0 && + $stow->get_conflict_count == 0 && -l 'bin' && -l 'info' && -l 'lib' && -l 'man' && readlink('bin') eq 'stow/perl/bin' && readlink('info') eq 'stow/perl/info' && @@ -81,7 +81,7 @@ $stow = new_Stow(dir => 'stow'); $stow->plan_stow('perl'); $stow->process_tasks(); ok( - scalar($stow->get_conflicts) == 0 && + $stow->get_conflict_count == 0 && -d 'bin' && -d 'lib' && -d 'man' && -d 'man/man1' && -l 'info' && -l 'bin/perl' && -l 'bin/a2p' && -l 'lib/perl' && -l 'man/man1/perl.1' && @@ -107,7 +107,7 @@ remove_dir('man'); $stow = new_Stow(dir => 'stow'); $stow->plan_stow('perl', 'emacs'); $stow->process_tasks(); -is(scalar($stow->get_conflicts), 0, 'no conflicts'); +is($stow->get_conflict_count, 0, 'no conflicts'); ok( -d 'bin' && -l 'bin/perl' && @@ -157,7 +157,7 @@ $stow = new_Stow(dir => 'stow'); $stow->plan_stow('pkg1a', 'pkg1b'); $stow->plan_unstow('pkg1b'); $stow->process_tasks(); -is(scalar($stow->get_conflicts), 0, 'no conflicts stowing empty dirs'); +is($stow->get_conflict_count, 0, 'no conflicts stowing empty dirs'); ok(-d 'bin1' => 'bug 1: stowing empty dirs'); # @@ -177,7 +177,7 @@ $stow->set_stow_dir('stow2b'); $stow->plan_stow('pkg2b'); $stow->process_tasks(); -is(scalar($stow->get_conflicts), 0, 'no conflicts splitting tree-folding symlinks'); +is($stow->get_conflict_count, 0, 'no conflicts splitting tree-folding symlinks'); ok(-d 'bin2' => 'tree got split by packages from multiple stow directories'); ok(-f 'bin2/file2a' => 'file from 1st stow dir'); ok(-f 'bin2/file2b' => 'file from 2nd stow dir'); diff --git a/t/stow_contents.t b/t/stow_contents.t index 4a5775a..24e01dc 100755 --- a/t/stow_contents.t +++ b/t/stow_contents.t @@ -157,7 +157,7 @@ make_file('../stow/pkg8b/0/file8b'); $stow->plan_stow('pkg8b'); $stow->process_tasks(); ok( - scalar($stow->get_conflicts) == 0 && + $stow->get_conflict_count == 0 && -d '0' && readlink('0/file8a') eq '../../stow/pkg8a/0/file8a' && readlink('0/file8b') eq '../../stow/pkg8b/0/file8b' @@ -179,7 +179,7 @@ make_file('../stow/pkg9b/man9/man1/file9.1'); $stow->plan_stow('pkg9b'); $stow->process_tasks(); ok( - scalar($stow->get_conflicts) == 0 && + $stow->get_conflict_count == 0 && readlink('man9/man1/file9.1') eq '../../../stow/pkg9b/man9/man1/file9.1' => 'overriding existing documentation files' ); @@ -204,7 +204,7 @@ stderr_like( 'no tasks to process' ); ok( - scalar($stow->get_conflicts) == 0 && + $stow->get_conflict_count == 0 && readlink('man10/man1/file10.1') eq '../../../stow/pkg10a/man10/man1/file10.1' => 'defer to existing documentation files' ); @@ -223,7 +223,7 @@ make_dir('man11/man1'); $stow->plan_stow('pkg11'); $stow->process_tasks(); ok( - scalar($stow->get_conflicts) == 0 && + $stow->get_conflict_count == 0 && readlink('man11/man1/file11.1') eq '../../../stow/pkg11/man11/man1/file11.1' && !-e 'man11/man1/file11.1~' && !-e 'man11/man1/.#file11.1' @@ -243,7 +243,7 @@ make_dir('lib12/'); $stow->plan_stow('pkg12'); $stow->process_tasks(); ok( - scalar($stow->get_conflicts) == 0 && + $stow->get_conflict_count == 0 && readlink('lib12/lib.so.1') eq '../../stow/pkg12/lib12/lib.so.1' => 'stow links to libraries' ); @@ -265,7 +265,7 @@ make_link('../stow/pkg13b/lib13/libb.so.1', 'libb.so'); $stow->plan_stow('pkg13b'); $stow->process_tasks(); ok( - scalar($stow->get_conflicts) == 0 && + $stow->get_conflict_count == 0 && readlink('lib13/liba.so.1') eq '../../stow/pkg13a/lib13/liba.so.1' && readlink('lib13/libb.so.1') eq '../../stow/pkg13b/lib13/libb.so.1' => 'unfolding to stow links to libraries' @@ -287,7 +287,7 @@ stderr_like( 'no tasks to process' ); ok( - scalar($stow->get_conflicts) == 0 && + $stow->get_conflict_count == 0 && ! -l 'stow/pkg15' => "stowing to stow dir should fail" ); diff --git a/t/unstow_contents.t b/t/unstow_contents.t index d398065..08af8ca 100755 --- a/t/unstow_contents.t +++ b/t/unstow_contents.t @@ -34,7 +34,7 @@ make_link('bin1', '../stow/pkg1/bin1'); $stow->plan_unstow('pkg1'); $stow->process_tasks(); ok( - scalar($stow->get_conflicts) == 0 && + $stow->get_conflict_count == 0 && -f '../stow/pkg1/bin1/file1' && ! -e 'bin1' => 'unstow a simple tree' ); @@ -51,7 +51,7 @@ make_link('lib2/file2', '../../stow/pkg2/lib2/file2'); $stow->plan_unstow('pkg2'); $stow->process_tasks(); ok( - scalar($stow->get_conflicts) == 0 && + $stow->get_conflict_count == 0 && -f '../stow/pkg2/lib2/file2' && -d 'lib2' => 'unstow simple tree from a pre-existing directory' ); @@ -73,7 +73,7 @@ make_link('bin3/file3b' => '../../stow/pkg3b/bin3/file3b'); # emulate stow $stow->plan_unstow('pkg3b'); $stow->process_tasks(); ok( - scalar($stow->get_conflicts) == 0 && + $stow->get_conflict_count == 0 && -l 'bin3' && readlink('bin3') eq '../stow/pkg3a/bin3' => 'fold tree after unstowing' @@ -92,7 +92,7 @@ make_link('bin4/file4', '../../stow/pkg4/bin4/does-not-exist'); $stow->plan_unstow('pkg4'); $stow->process_tasks(); ok( - scalar($stow->get_conflicts) == 0 && + $stow->get_conflict_count == 0 && ! -e 'bin4/file4' => q(remove invalid link owned by stow) ); @@ -128,7 +128,7 @@ make_file('../stow/pkg6b/bin6/file6'); $stow->plan_unstow('pkg6b'); ok( - scalar($stow->get_conflicts) == 0 && + $stow->get_conflict_count == 0 && -l 'bin6/file6' && readlink('bin6/file6') eq '../../stow/pkg6a/bin6/file6' => q(ignore existing link that points to a different package) @@ -152,7 +152,7 @@ stderr_like( 'no tasks to process when unstowing pkg7b' ); ok( - scalar($stow->get_conflicts) == 0 && + $stow->get_conflict_count == 0 && -l 'stow/pkg7b' && readlink('stow/pkg7b') eq '../stow/pkg7a/stow/pkg7b' => q(don't unlink any nodes under the stow directory) @@ -178,7 +178,7 @@ stderr_like( 'no tasks to process when unstowing pkg8a' ); ok( - scalar($stow->get_conflicts) == 0 && + $stow->get_conflict_count == 0 && -l 'stow2/pkg8b' && readlink('stow2/pkg8b') eq '../stow/pkg8a/stow2/pkg8b' => q(don't unlink any nodes under another stow directory) @@ -200,7 +200,7 @@ make_file('../stow/pkg9b/man9/man1/file9.1'); $stow->plan_unstow('pkg9b'); $stow->process_tasks(); ok( - scalar($stow->get_conflicts) == 0 && + $stow->get_conflict_count == 0 && !-l 'man9/man1/file9.1' => 'overriding existing documentation files' ); @@ -230,7 +230,7 @@ stderr_like( 'no tasks to process when unstowing pkg10c' ); ok( - scalar($stow->get_conflicts) == 0 && + $stow->get_conflict_count == 0 && readlink('man10/man1/file10a.1') eq '../../../stow/pkg10a/man10/man1/file10a.1' => 'defer to existing documentation files' ); @@ -250,7 +250,7 @@ make_link('man12/man1/file12.1' => '../../../stow/pkg12/man12/man1/file12.1'); $stow->plan_unstow('pkg12'); $stow->process_tasks(); ok( - scalar($stow->get_conflicts) == 0 && + $stow->get_conflict_count == 0 && !-e 'man12/man1/file12.1' => 'ignore temp files' ); @@ -266,7 +266,7 @@ stderr_like( 'no tasks to process when unstowing pkg12' ); ok( - scalar($stow->get_conflicts) == 0 + $stow->get_conflict_count == 0 => 'unstow already unstowed package pkg12' ); @@ -285,7 +285,7 @@ stderr_like( 'no tasks to process when unstowing pkg12 which was never stowed' ); ok( - scalar($stow->get_conflicts) == 0 + $stow->get_conflict_count == 0 => 'unstow never stowed package pkg12' ); @@ -341,7 +341,7 @@ make_link("$OUT_DIR/target/bin14", '../stow/pkg14/bin14'); $stow->plan_unstow('pkg14'); $stow->process_tasks(); ok( - scalar($stow->get_conflicts) == 0 && + $stow->get_conflict_count == 0 && -f "$OUT_DIR/stow/pkg14/bin14/file14" && ! -e "$OUT_DIR/target/bin14" => 'unstow a simple tree with absolute stow dir' ); @@ -360,7 +360,7 @@ make_link("$OUT_DIR/target/bin15", '../stow/pkg15/bin15'); $stow->plan_unstow('pkg15'); $stow->process_tasks(); ok( - scalar($stow->get_conflicts) == 0 && + $stow->get_conflict_count == 0 && -f "$OUT_DIR/stow/pkg15/bin15/file15" && ! -e "$OUT_DIR/target/bin15" => 'unstow a simple tree with absolute stow and target dirs' ); diff --git a/t/unstow_contents_orig.t b/t/unstow_contents_orig.t index 436668a..4ce750e 100755 --- a/t/unstow_contents_orig.t +++ b/t/unstow_contents_orig.t @@ -35,7 +35,7 @@ make_link('bin1', '../stow/pkg1/bin1'); $stow->plan_unstow('pkg1'); $stow->process_tasks(); ok( - scalar($stow->get_conflicts) == 0 && + $stow->get_conflict_count == 0 && -f '../stow/pkg1/bin1/file1' && ! -e 'bin1' => 'unstow a simple tree' ); @@ -52,7 +52,7 @@ make_link('lib2/file2', '../../stow/pkg2/lib2/file2'); $stow->plan_unstow('pkg2'); $stow->process_tasks(); ok( - scalar($stow->get_conflicts) == 0 && + $stow->get_conflict_count == 0 && -f '../stow/pkg2/lib2/file2' && -d 'lib2' => 'unstow simple tree from a pre-existing directory' ); @@ -74,7 +74,7 @@ make_link('bin3/file3b' => '../../stow/pkg3b/bin3/file3b'); # emulate stow $stow->plan_unstow('pkg3b'); $stow->process_tasks(); ok( - scalar($stow->get_conflicts) == 0 && + $stow->get_conflict_count == 0 && -l 'bin3' && readlink('bin3') eq '../stow/pkg3a/bin3' => 'fold tree after unstowing' @@ -93,7 +93,7 @@ make_link('bin4/file4', '../../stow/pkg4/bin4/does-not-exist'); $stow->plan_unstow('pkg4'); $stow->process_tasks(); ok( - scalar($stow->get_conflicts) == 0 && + $stow->get_conflict_count == 0 && ! -e 'bin4/file4' => q(remove invalid link owned by stow) ); @@ -134,7 +134,7 @@ make_file('../stow/pkg6b/bin6/file6'); $stow->plan_unstow('pkg6b'); ok( - scalar($stow->get_conflicts) == 0 && + $stow->get_conflict_count == 0 && -l 'bin6/file6' && readlink('bin6/file6') eq '../../stow/pkg6a/bin6/file6' => q(ignore existing link that points to a different package) @@ -158,7 +158,7 @@ stderr_like( 'no tasks to process when unstowing pkg7b' ); ok( - scalar($stow->get_conflicts) == 0 && + $stow->get_conflict_count == 0 && -l 'stow/pkg7b' && readlink('stow/pkg7b') eq '../stow/pkg7a/stow/pkg7b' => q(don't unlink any nodes under the stow directory) @@ -184,7 +184,7 @@ stderr_like( 'no tasks to process when unstowing pkg8a' ); ok( - scalar($stow->get_conflicts) == 0 && + $stow->get_conflict_count == 0 && -l 'stow2/pkg8b' && readlink('stow2/pkg8b') eq '../stow/pkg8a/stow2/pkg8b' => q(don't unlink any nodes under another stow directory) @@ -206,7 +206,7 @@ make_file('../stow/pkg9b/man9/man1/file9.1'); $stow->plan_unstow('pkg9b'); $stow->process_tasks(); ok( - scalar($stow->get_conflicts) == 0 && + $stow->get_conflict_count == 0 && !-l 'man9/man1/file9.1' => 'overriding existing documentation files' ); @@ -236,7 +236,7 @@ stderr_like( 'no tasks to process when unstowing pkg10c' ); ok( - scalar($stow->get_conflicts) == 0 && + $stow->get_conflict_count == 0 && readlink('man10/man1/file10a.1') eq '../../../stow/pkg10a/man10/man1/file10a.1' => 'defer to existing documentation files' ); @@ -256,7 +256,7 @@ make_link('man12/man1/file12.1' => '../../../stow/pkg12/man12/man1/file12.1'); $stow->plan_unstow('pkg12'); $stow->process_tasks(); ok( - scalar($stow->get_conflicts) == 0 && + $stow->get_conflict_count == 0 && !-e 'man12/man1/file12.1' => 'ignore temp files' ); @@ -272,7 +272,7 @@ stderr_like( 'no tasks to process when unstowing pkg12' ); ok( - scalar($stow->get_conflicts) == 0 + $stow->get_conflict_count == 0 => 'unstow already unstowed package pkg12' ); @@ -291,7 +291,7 @@ stderr_like( 'no tasks to process when unstowing pkg12 which was never stowed' ); ok( - scalar($stow->get_conflicts) == 0 + $stow->get_conflict_count == 0 => 'unstow never stowed package pkg12' ); @@ -347,7 +347,7 @@ make_link("$OUT_DIR/target/bin14", '../stow/pkg14/bin14'); $stow->plan_unstow('pkg14'); $stow->process_tasks(); ok( - scalar($stow->get_conflicts) == 0 && + $stow->get_conflict_count == 0 && -f "$OUT_DIR/stow/pkg14/bin14/file14" && ! -e "$OUT_DIR/target/bin14" => 'unstow a simple tree with absolute stow dir' ); @@ -366,7 +366,7 @@ make_link("$OUT_DIR/target/bin15", '../stow/pkg15/bin15'); $stow->plan_unstow('pkg15'); $stow->process_tasks(); ok( - scalar($stow->get_conflicts) == 0 && + $stow->get_conflict_count == 0 && -f "$OUT_DIR/stow/pkg15/bin15/file15" && ! -e "$OUT_DIR/target/bin15" => 'unstow a simple tree with absolute stow and target dirs' ); From 5110ea8338b80b0968db022a549c9eed487a3378 Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Mon, 9 Jan 2012 21:11:58 +0000 Subject: [PATCH 148/482] Add stacktrace to internal error report to aid debugging. --- lib/Stow.pm.in | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/Stow.pm.in b/lib/Stow.pm.in index cf81d9b..2c393f1 100755 --- a/lib/Stow.pm.in +++ b/lib/Stow.pm.in @@ -35,7 +35,7 @@ rebuild the target tree. use strict; use warnings; -use Carp qw(carp cluck croak confess); +use Carp qw(carp cluck croak confess longmess); use File::Spec; use POSIX qw(getcwd); @@ -1964,8 +1964,11 @@ sub do_rmdir { sub internal_error { my ($format, @args) = @_; my $error = sprintf($format, @args); + my $stacktrace = Carp::longmess(); die < Date: Mon, 9 Jan 2012 21:25:35 +0000 Subject: [PATCH 149/482] Add --adopt / -a option. --- NEWS | 5 +++ bin/stow.in | 18 ++++++++ doc/stow.texi | 23 ++++++++++ lib/Stow.pm.in | 93 ++++++++++++++++++++++++++++++++------- lib/Stow/Util.pm | 2 +- t/stow_contents.t | 109 ++++++++++++++++++++++++++++++++++++++++++---- t/testutil.pm | 23 +++++++++- 7 files changed, 246 insertions(+), 27 deletions(-) diff --git a/NEWS b/NEWS index 4979922..17cbf15 100644 --- a/NEWS +++ b/NEWS @@ -2,6 +2,11 @@ News file for Stow. * Changes in version 2.1.3 +** New --adopt / -a option + + This allows plain files in the target to be "adopted" into the + package being stowed. See the manual has more details. + ** ./configure now checks for Perl modules required by the test suite. * Changes in version 2.1.2 diff --git a/bin/stow.in b/bin/stow.in index 2659129..f2093df 100755 --- a/bin/stow.in +++ b/bin/stow.in @@ -181,6 +181,23 @@ Restow packages (first unstow, then stow again). This is useful for pruning obsolete symlinks from the target tree after updating the software in a package. +=item -a + +=item --adopt + +B This behaviour is specifically intended to alter the +contents of your stow directory. If you do not want that, this option +is not for you. + +When stowing, if a target is encountered which already exists but is a +plain file (and hence not owned by any existing stow package), then +normally Stow will register this as a conflict and refuse to proceed. +This option changes that behaviour so that the file is moved to the +same relative place within the package's installation image within the +stow directory, and then stowing proceeds as before. So effectively, +the file becomes adopted by the stow package, without its contents +changing. + =item --ignore=REGEX Ignore files ending in this Perl regex. @@ -462,6 +479,7 @@ sub process_options { \%options, 'verbose|v:+', 'help|h', 'simulate|n|no', 'version|V', 'compat|p', 'dir|d=s', 'target|t=s', + 'adopt|a', # clean and pre-compile any regex's at parse time 'ignore=s' => diff --git a/doc/stow.texi b/doc/stow.texi index 7bbbe58..155a64a 100644 --- a/doc/stow.texi +++ b/doc/stow.texi @@ -340,6 +340,29 @@ pages that are owned by stow and would otherwise cause a conflict. The regular expression is anchored to the beginning of the path relative to the target directory, because this is what you will want to do most of the time. +@item -a +@itemx --adopt +@strong{Warning!} This behaviour is specifically intended to alter the +contents of your stow directory. If you do not want that, this option +is not for you. + +When stowing, if a target is encountered which already exists but is a +plain file (and hence not owned by any existing stow package), then +normally Stow will register this as a conflict and refuse to proceed. +This option changes that behaviour so that the file is moved to the +same relative place within the package's installation image within the +stow directory, and then stowing proceeds as before. So effectively, +the file becomes adopted by the stow package, without its contents +changing. + +This is particularly useful when the stow package is under the control +of a version control system, because it allows files in the target +tree, with potentially different contents to the equivalent versions +in the stow package's installation image, to be adopted into the +package, then compared by running something like @samp{git diff ...} +inside the stow package, and finally either kept (e.g. via @samp{git +commit ...}) or discarded (@samp{git checkout HEAD ...}). + @item -n @itemx --no @itemx --simulate diff --git a/lib/Stow.pm.in b/lib/Stow.pm.in index 2c393f1..47a863d 100755 --- a/lib/Stow.pm.in +++ b/lib/Stow.pm.in @@ -36,6 +36,7 @@ use strict; use warnings; use Carp qw(carp cluck croak confess longmess); +use File::Copy qw(move); use File::Spec; use POSIX qw(getcwd); @@ -59,6 +60,7 @@ our %DEFAULT_OPTIONS = ( paranoid => 0, compat => 0, test_mode => 0, + adopt => 0, ignore => [], override => [], defer => [], @@ -198,10 +200,11 @@ sub init_state { # $self->{tasks}: list of operations to be performed (in order) # each element is a hash ref of the form # { - # action => ... ('create' or 'remove') - # type => ... ('link' or 'dir') + # action => ... ('create' or 'remove' or 'move') + # type => ... ('link' or 'dir' or 'file') # path => ... (unique) # source => ... (only for links) + # dest => ... (only for moving files) # } $self->{tasks} = []; @@ -490,11 +493,17 @@ sub stow_node { ); } else { - $self->conflict( - 'stow', - $package, - "existing target is neither a link nor a directory: $target" - ); + if ($self->{adopt}) { + $self->do_mv($target, $path); + $self->do_link($source, $target); + } + else { + $self->conflict( + 'stow', + $package, + "existing target is neither a link nor a directory: $target" + ); + } } } else { @@ -1413,6 +1422,7 @@ sub process_task { if ($task->{type} eq 'dir') { mkdir($task->{path}, 0777) or error(qq(Could not create directory: $task->{path})); + return; } elsif ($task->{type} eq 'link') { symlink $task->{source}, $task->{path} @@ -1421,27 +1431,33 @@ sub process_task { $task->{path}, $task->{source} ); - } - else { - internal_error(qq(bad task type: $task->{type})); + return; } } elsif ($task->{action} eq 'remove') { if ($task->{type} eq 'dir') { rmdir $task->{path} or error(qq(Could not remove directory: $task->{path})); + return; } elsif ($task->{type} eq 'link') { unlink $task->{path} or error(qq(Could not remove link: $task->{path})); - } - else { - internal_error(qq(bad task type: $task->{type})); + return; } } - else { - internal_error(qq(bad task action: $task->{action})); + elsif ($task->{action} eq 'move') { + if ($task->{type} eq 'file') { + # rename() not good enough, since the stow directory + # might be on a different filesystem to the target. + move $task->{path}, $task->{dest} + or error(qq(Could not move $task->{path} -> $task->{dest})); + return; + } } + + # Should never happen. + internal_error(qq(bad task action: $task->{action})); } #===== METHOD =============================================================== @@ -1946,6 +1962,53 @@ sub do_rmdir { return; } +#===== METHOD =============================================================== +# Name : do_mv() +# Purpose : wrap 'move' operation for later processing +# Parameters: $src => the file to move +# : $dst => the path to move it to +# Returns : n/a +# Throws : error if this clashes with an existing planned operation +# Comments : alters contents of package installation image in stow dir +#============================================================================ +sub do_mv { + my $self = shift; + my ($src, $dst) = @_; + + if (exists $self->{link_task_for}{$src}) { + # I don't *think* this should ever happen, but I'm not + # 100% sure. + my $task_ref = $self->{link_task_for}{$src}; + internal_error( + "do_mv: pre-existing link task for $src; action: %s, source: %s", + $task_ref->{action}, $task_ref->{source} + ); + } + elsif (exists $self->{dir_task_for}{$src}) { + my $task_ref = $self->{dir_task_for}{$src}; + internal_error( + "do_mv: pre-existing dir task for %s?! action: %s", + $src, $task_ref->{action} + ); + } + + # Remove the link + debug(1, "MV: $src -> $dst"); + + my $task = { + action => 'move', + type => 'file', + path => $src, + dest => $dst, + }; + push @{ $self->{tasks} }, $task; + + # FIXME: do we need this for anything? + #$self->{mv_task_for}{$file} = $task; + + return; +} + ############################################################################# # diff --git a/lib/Stow/Util.pm b/lib/Stow/Util.pm index 072f880..173f1ec 100644 --- a/lib/Stow/Util.pm +++ b/lib/Stow/Util.pm @@ -91,7 +91,7 @@ Verbosity rules: =item 0: errors only -=item >= 1: print operations: LINK/UNLINK/MKDIR/RMDIR +=item >= 1: print operations: LINK/UNLINK/MKDIR/RMDIR/MV =item >= 2: print operation exceptions diff --git a/t/stow_contents.t b/t/stow_contents.t index 24e01dc..d4e66f0 100755 --- a/t/stow_contents.t +++ b/t/stow_contents.t @@ -7,7 +7,7 @@ use strict; use warnings; -use Test::More tests => 23; +use Test::More tests => 35; use Test::Output; use English qw(-no_match_vars); @@ -47,6 +47,7 @@ $stow = new_Stow(); make_dir('../stow/pkg2/lib2'); make_file('../stow/pkg2/lib2/file2'); make_dir('lib2'); + $stow->plan_stow('pkg2'); $stow->process_tasks(); is( @@ -66,6 +67,7 @@ make_link('bin3' => '../stow/pkg3a/bin3'); # emulate stow make_dir('../stow/pkg3b/bin3'); make_file('../stow/pkg3b/bin3/file3b'); + $stow->plan_stow('pkg3b'); $stow->process_tasks(); ok( @@ -76,21 +78,103 @@ ok( ); # -# Link to a new dir conflicts with existing non-dir (can't unfold) +# Link to a new dir 'bin4' conflicts with existing non-dir so can't +# unfold # $stow = new_Stow(); make_file('bin4'); # this is a file but named like a directory make_dir('../stow/pkg4/bin4'); make_file('../stow/pkg4/bin4/file4'); + $stow->plan_stow('pkg4'); %conflicts = $stow->get_conflicts(); -like( - $conflicts{stow}{pkg4}[-1], - qr(existing target is neither a link nor a directory) - => 'link to new dir conflicts with existing non-directory' +ok( + $stow->get_conflict_count == 1 && + $conflicts{stow}{pkg4}[0] =~ + qr/existing target is neither a link nor a directory/ + => 'link to new dir bin4 conflicts with existing non-directory' ); +# +# Link to a new dir 'bin4a' conflicts with existing non-dir so can't +# unfold even with --adopt +# +#$stow = new_Stow(adopt => 1); +$stow = new_Stow(); + +make_file('bin4a'); # this is a file but named like a directory +make_dir('../stow/pkg4a/bin4a'); +make_file('../stow/pkg4a/bin4a/file4a'); + +$stow->plan_stow('pkg4a'); +%conflicts = $stow->get_conflicts(); +ok( + $stow->get_conflict_count == 1 && + $conflicts{stow}{pkg4a}[0] =~ + qr/existing target is neither a link nor a directory/ + => 'link to new dir bin4a conflicts with existing non-directory' +); + +# +# Link to files 'file4b' and 'bin4b' conflict with existing files +# without --adopt +# +$stow = new_Stow(); + +# Populate target +make_file('file4b', 'file4b - version originally in target'); +make_dir ('bin4b'); +make_file('bin4b/file4b', 'bin4b/file4b - version originally in target'); + +# Populate +make_dir ('../stow/pkg4b/bin4b'); +make_file('../stow/pkg4b/file4b', 'file4b - version originally in stow package'); +make_file('../stow/pkg4b/bin4b/file4b', 'bin4b/file4b - version originally in stow package'); + +$stow->plan_stow('pkg4b'); +%conflicts = $stow->get_conflicts(); +is($stow->get_conflict_count, 2 => 'conflict per file'); +for my $i (0, 1) { + like( + $conflicts{stow}{pkg4b}[$i], + qr/existing target is neither a link nor a directory/ + => 'link to file4b conflicts with existing non-directory' + ); +} + +# +# Link to files 'file4b' and 'bin4b' do not conflict with existing +# files when --adopt is given +# +$stow = new_Stow(adopt => 1); + +# Populate target +make_file('file4c', "file4c - version originally in target\n"); +make_dir ('bin4c'); +make_file('bin4c/file4c', "bin4c/file4c - version originally in target\n"); + +# Populate +make_dir ('../stow/pkg4c/bin4c'); +make_file('../stow/pkg4c/file4c', "file4c - version originally in stow package\n"); +make_file('../stow/pkg4c/bin4c/file4c', "bin4c/file4c - version originally in stow package\n"); + +$stow->plan_stow('pkg4c'); +is($stow->get_conflict_count, 0 => 'no conflicts with --adopt'); +my @tasks = $stow->get_tasks; +is(@tasks, 4 => 'two tasks per file'); +$stow->process_tasks(); +for my $file ('file4c', 'bin4c/file4c') { + ok(-l $file, "$file turned into a symlink"); + is( + readlink $file, + (index($file, '/') == -1 ? '' : '../' ) + . "../stow/pkg4c/$file" => "$file points to right place" + ); + is(cat_file($file), "$file - version originally in target\n" => "$file has right contents"); +} + + # # Target already exists but is not owned by stow # @@ -99,11 +183,12 @@ $stow = new_Stow(); make_dir('bin5'); make_link('bin5/file5','../../empty'); make_dir('../stow/pkg5/bin5/file5'); + $stow->plan_stow('pkg5'); %conflicts = $stow->get_conflicts(); like( $conflicts{stow}{pkg5}[-1], - qr(not owned by stow) + qr/not owned by stow/ => 'target already exists but is not owned by stow' ); @@ -115,6 +200,7 @@ $stow = new_Stow(); make_link('file6','../stow/path-does-not-exist'); make_dir('../stow/pkg6'); make_file('../stow/pkg6/file6'); + $stow->plan_stow('pkg6'); $stow->process_tasks(); is( @@ -135,11 +221,12 @@ make_file('../stow/pkg7a/bin7/node7'); make_link('bin7/node7','../../stow/pkg7a/bin7/node7'); make_dir('../stow/pkg7b/bin7/node7'); make_file('../stow/pkg7b/bin7/node7/file7'); + $stow->plan_stow('pkg7b'); %conflicts = $stow->get_conflicts(); like( $conflicts{stow}{pkg7b}[-1], - qr(existing target is stowed to a different package) + qr/existing target is stowed to a different package/ => 'link to new dir conflicts with existing stowed non-directory' ); @@ -154,6 +241,7 @@ make_link('0' => '../stow/pkg8a/0'); # emulate stow make_dir('../stow/pkg8b/0'); make_file('../stow/pkg8b/0/file8b'); + $stow->plan_stow('pkg8b'); $stow->process_tasks(); ok( @@ -176,6 +264,7 @@ make_link('man9/man1/file9.1' => '../../../stow/pkg9a/man9/man1/file9.1'); # emu make_dir('../stow/pkg9b/man9/man1'); make_file('../stow/pkg9b/man9/man1/file9.1'); + $stow->plan_stow('pkg9b'); $stow->process_tasks(); ok( @@ -196,8 +285,8 @@ make_link('man10/man1/file10.1' => '../../../stow/pkg10a/man10/man1/file10.1'); make_dir('../stow/pkg10b/man10/man1'); make_file('../stow/pkg10b/man10/man1/file10.1'); -$stow->plan_stow('pkg10b'); +$stow->plan_stow('pkg10b'); stderr_like( sub { $stow->process_tasks(); }, qr/There are no outstanding operations to perform/, @@ -240,6 +329,7 @@ make_file('../stow/pkg12/lib12/lib.so'); make_link('../stow/pkg12/lib12/lib.so.1','lib.so'); make_dir('lib12/'); + $stow->plan_stow('pkg12'); $stow->process_tasks(); ok( @@ -347,3 +437,4 @@ is( '../stow/pkg18/bin18', => "minimal stow of a simple tree with absolute stow and target dirs" ); + diff --git a/t/testutil.pm b/t/testutil.pm index 67d4f45..97ac422 100755 --- a/t/testutil.pm +++ b/t/testutil.pm @@ -9,6 +9,8 @@ package testutil; use strict; use warnings; +use File::Path qw(remove_tree); + use Stow; use Stow::Util qw(parent canon_path); @@ -20,13 +22,14 @@ our @EXPORT = qw( new_Stow new_compat_Stow make_dir make_link make_file remove_dir remove_link + cat_file ); our $OUT_DIR = 'tmp-testing-trees'; sub init_test_dirs { for my $dir ("$OUT_DIR/target", "$OUT_DIR/stow") { - -d $dir and remove_dir($dir); + -d $dir and remove_tree($dir); make_dir($dir); } @@ -110,7 +113,7 @@ sub make_dir { # Comments : detects clash with an existing non-file #============================================================================ sub make_file { - my ($path, $contents) =@_; + my ($path, $contents) = @_; if (-e $path and ! -f $path) { die "a non-file already exists at $path\n"; @@ -210,6 +213,22 @@ sub cd { chdir $dir or die "Failed to chdir($dir): $!\n"; } +#===== SUBROUTINE =========================================================== +# Name : cat_file() +# Purpose : return file contents +# Parameters: $file => file to read +# Returns : n/a +# Throws : fatal error if the open fails +# Comments : none +#============================================================================ +sub cat_file { + my ($file) = @_; + open F, $file or die "Failed to open($file): $!\n"; + my $contents = join '', ; + close(F); + return $contents; +} + 1; # Local variables: From 92eee74bb341348b71b815f3f4ef608a39fd5e2a Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Mon, 9 Jan 2012 22:10:19 +0000 Subject: [PATCH 150/482] perl Build.PL needs a prefix during testing --- doc/HOWTO-RELEASE | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/HOWTO-RELEASE b/doc/HOWTO-RELEASE index 3c7954b..06eb4db 100644 --- a/doc/HOWTO-RELEASE +++ b/doc/HOWTO-RELEASE @@ -17,7 +17,7 @@ How to make a new release of GNU Stow - Make sure all the following commands all run successfully: - perl Build.PL + perl Build.PL --prefix=/tmp/stow-test ./Build test ./Build install ./Build distcheck From c3c866a00beb72fa7e5e66cd12b6eed4f15636ae Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Mon, 9 Jan 2012 21:31:46 +0000 Subject: [PATCH 151/482] Rename stow.t to be more consistent with its purpose. --- MANIFEST | 2 +- t/{stow.t => cli_options.t} | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) rename t/{stow.t => cli_options.t} (98%) diff --git a/MANIFEST b/MANIFEST index ae3d9b9..a5a978b 100644 --- a/MANIFEST +++ b/MANIFEST @@ -33,6 +33,7 @@ NEWS README t/chkstow.t t/cleanup_invalid_links.t +t/cli_options.t t/defer.t t/examples.t t/find_stowed_path.t @@ -40,7 +41,6 @@ t/foldable.t t/ignore.t t/join_paths.t t/parent.t -t/stow.t t/stow_contents.t t/testutil.pm t/unstow_contents.t diff --git a/t/stow.t b/t/cli_options.t similarity index 98% rename from t/stow.t rename to t/cli_options.t index eddcd83..809cf15 100755 --- a/t/stow.t +++ b/t/cli_options.t @@ -1,7 +1,7 @@ #!/usr/local/bin/perl # -# Testing core application +# Test processing of CLI options. # use strict; From 0c6d5639e3bf3148027026dc73a743846a249f52 Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Mon, 9 Jan 2012 21:32:31 +0000 Subject: [PATCH 152/482] Rename test files to reflect their purpose. --- MANIFEST | 6 +++--- t/{stow_contents.t => stow.t} | 2 +- t/{unstow_contents.t => unstow.t} | 2 +- t/{unstow_contents_orig.t => unstow_orig.t} | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) rename t/{stow_contents.t => stow.t} (99%) rename t/{unstow_contents.t => unstow.t} (99%) rename t/{unstow_contents_orig.t => unstow_orig.t} (99%) diff --git a/MANIFEST b/MANIFEST index a5a978b..2c9ed06 100644 --- a/MANIFEST +++ b/MANIFEST @@ -41,10 +41,10 @@ t/foldable.t t/ignore.t t/join_paths.t t/parent.t -t/stow_contents.t +t/stow.t t/testutil.pm -t/unstow_contents.t -t/unstow_contents_orig.t +t/unstow.t +t/unstow_orig.t THANKS TODO META.yml diff --git a/t/stow_contents.t b/t/stow.t similarity index 99% rename from t/stow_contents.t rename to t/stow.t index d4e66f0..395201f 100755 --- a/t/stow_contents.t +++ b/t/stow.t @@ -1,7 +1,7 @@ #!/usr/local/bin/perl # -# Testing stow_contents() +# Test stowing packages. # use strict; diff --git a/t/unstow_contents.t b/t/unstow.t similarity index 99% rename from t/unstow_contents.t rename to t/unstow.t index 08af8ca..a666662 100755 --- a/t/unstow_contents.t +++ b/t/unstow.t @@ -1,7 +1,7 @@ #!/usr/local/bin/perl # -# Testing unstow_contents() +# Test unstowing packages # use strict; diff --git a/t/unstow_contents_orig.t b/t/unstow_orig.t similarity index 99% rename from t/unstow_contents_orig.t rename to t/unstow_orig.t index 4ce750e..79465ee 100755 --- a/t/unstow_contents_orig.t +++ b/t/unstow_orig.t @@ -1,7 +1,7 @@ #!/usr/local/bin/perl # -# Testing unstow_contents_orig() +# Test unstowing packages in compat mode # use strict; From 9889d10b2e6338cdb99b638f9390fedea3cee1b0 Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Mon, 9 Jan 2012 21:39:35 +0000 Subject: [PATCH 153/482] Bump version to 2.1.3 --- META.json | 4 ++-- META.yml | 4 ++-- NEWS | 2 +- configure.ac | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/META.json b/META.json index e762735..5a1a247 100644 --- a/META.json +++ b/META.json @@ -36,7 +36,7 @@ "provides" : { "Stow" : { "file" : "lib/Stow.pm", - "version" : "v2.1.2" + "version" : "v2.1.3" }, "Stow::Util" : { "file" : "lib/Stow/Util.pm", @@ -53,5 +53,5 @@ "url" : "git://git.savannah.gnu.org/stow.git" } }, - "version" : "v2.1.2" + "version" : "v2.1.3" } diff --git a/META.yml b/META.yml index 84e5fd1..789e6c4 100644 --- a/META.yml +++ b/META.yml @@ -17,7 +17,7 @@ name: Stow provides: Stow: file: lib/Stow.pm - version: v2.1.2 + version: v2.1.3 Stow::Util: file: lib/Stow/Util.pm version: 0 @@ -29,4 +29,4 @@ resources: homepage: https://savannah.gnu.org/projects/stow license: http://www.gnu.org/licenses/gpl-2.0.html repository: git://git.savannah.gnu.org/stow.git -version: v2.1.2 +version: v2.1.3 diff --git a/NEWS b/NEWS index 17cbf15..ecd1d66 100644 --- a/NEWS +++ b/NEWS @@ -9,7 +9,7 @@ News file for Stow. ** ./configure now checks for Perl modules required by the test suite. -* Changes in version 2.1.2 +* Changes in version 2.1.3 Many thanks to Stefano Lattarini for help with numerous autoconf and automake issues which are addressed in this release. diff --git a/configure.ac b/configure.ac index 7563a99..2339480 100644 --- a/configure.ac +++ b/configure.ac @@ -1,6 +1,6 @@ dnl Process this file with Autoconf to produce configure dnl -AC_INIT([stow], [2.1.2], [bug-stow@gnu.org]) +AC_INIT([stow], [2.1.3], [bug-stow@gnu.org]) AC_PREREQ([2.61]) AC_CONFIG_AUX_DIR([automake]) # Unfortunately we have to disable warnings for overrides, because we From d51ff055c206ee3ed90fccab018d0130f45b9374 Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Tue, 10 Jan 2012 12:17:58 +0000 Subject: [PATCH 154/482] Fix wrong version number in NEWS. --- NEWS | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/NEWS b/NEWS index ecd1d66..17cbf15 100644 --- a/NEWS +++ b/NEWS @@ -9,7 +9,7 @@ News file for Stow. ** ./configure now checks for Perl modules required by the test suite. -* Changes in version 2.1.3 +* Changes in version 2.1.2 Many thanks to Stefano Lattarini for help with numerous autoconf and automake issues which are addressed in this release. From 8357dca6451729f05eb0d2018ff014c3fa63c883 Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Wed, 11 Jan 2012 14:01:40 +0000 Subject: [PATCH 155/482] Remove "There are no outstanding operations to perform" warning. This is more in keeping with the UNIX convention of no output on success, and is also the way Stow v1.x behaved. Thanks to Adam Sampson for the suggestion. --- NEWS | 4 ++++ THANKS | 1 + lib/Stow.pm.in | 1 - t/stow.t | 15 +++------------ t/unstow.t | 36 ++++++------------------------------ t/unstow_orig.t | 36 ++++++------------------------------ 6 files changed, 20 insertions(+), 73 deletions(-) diff --git a/NEWS b/NEWS index 17cbf15..0b8e2e6 100644 --- a/NEWS +++ b/NEWS @@ -1,5 +1,9 @@ News file for Stow. +* Changes in version 2.1.4 + +** Remove "There are no outstanding operations to perform" warning. + * Changes in version 2.1.3 ** New --adopt / -a option diff --git a/THANKS b/THANKS index cc2f3d7..191e0ba 100644 --- a/THANKS +++ b/THANKS @@ -22,3 +22,4 @@ Austin Wood Christopher Hoobin Adam Spiers Stefano Lattarini +Adam Sampson diff --git a/lib/Stow.pm.in b/lib/Stow.pm.in index 47a863d..3565e3f 100755 --- a/lib/Stow.pm.in +++ b/lib/Stow.pm.in @@ -1391,7 +1391,6 @@ sub process_tasks { $self->{tasks} = [ grep { $_->{action} ne 'skip' } @{ $self->{tasks} } ]; if (not @{ $self->{tasks} }) { - warn "There are no outstanding operations to perform.\n"; return; } diff --git a/t/stow.t b/t/stow.t index 395201f..ef32b78 100755 --- a/t/stow.t +++ b/t/stow.t @@ -161,8 +161,7 @@ make_file('../stow/pkg4c/bin4c/file4c', "bin4c/file4c - version originally in st $stow->plan_stow('pkg4c'); is($stow->get_conflict_count, 0 => 'no conflicts with --adopt'); -my @tasks = $stow->get_tasks; -is(@tasks, 4 => 'two tasks per file'); +is($stow->get_tasks, 4 => 'two tasks per file'); $stow->process_tasks(); for my $file ('file4c', 'bin4c/file4c') { ok(-l $file, "$file turned into a symlink"); @@ -287,11 +286,7 @@ make_dir('../stow/pkg10b/man10/man1'); make_file('../stow/pkg10b/man10/man1/file10.1'); $stow->plan_stow('pkg10b'); -stderr_like( - sub { $stow->process_tasks(); }, - qr/There are no outstanding operations to perform/, - 'no tasks to process' -); +is($stow->get_tasks, 0, 'no tasks to process'); ok( $stow->get_conflict_count == 0 && readlink('man10/man1/file10.1') eq '../../../stow/pkg10a/man10/man1/file10.1' @@ -371,11 +366,7 @@ make_dir('stow/pkg14/stow/pkg15'); make_file('stow/pkg14/stow/pkg15/node15'); $stow->plan_stow('pkg14'); -stderr_like( - sub { $stow->process_tasks(); }, - qr/There are no outstanding operations to perform/, - 'no tasks to process' -); +is($stow->get_tasks, 0, 'no tasks to process'); ok( $stow->get_conflict_count == 0 && ! -l 'stow/pkg15' diff --git a/t/unstow.t b/t/unstow.t index a666662..23f42e7 100755 --- a/t/unstow.t +++ b/t/unstow.t @@ -146,11 +146,7 @@ make_file('stow/pkg7a/stow/pkg7b/file7b'); make_link('stow/pkg7b', '../stow/pkg7a/stow/pkg7b'); $stow->plan_unstow('pkg7b'); -stderr_like( - sub { $stow->process_tasks(); }, - qr/There are no outstanding operations to perform/, - 'no tasks to process when unstowing pkg7b' -); +is($stow->get_tasks, 0, 'no tasks to process when unstowing pkg7b'); ok( $stow->get_conflict_count == 0 && -l 'stow/pkg7b' && @@ -172,11 +168,7 @@ make_file('stow/pkg8a/stow2/pkg8b/file8b'); make_link('stow2/pkg8b', '../stow/pkg8a/stow2/pkg8b'); $stow->plan_unstow('pkg8a'); -stderr_like( - sub { $stow->process_tasks(); }, - qr/There are no outstanding operations to perform/, - 'no tasks to process when unstowing pkg8a' -); +is($stow->get_tasks, 0, 'no tasks to process when unstowing pkg8a'); ok( $stow->get_conflict_count == 0 && -l 'stow2/pkg8b' && @@ -224,11 +216,7 @@ make_link('man10/man1/file10b.1' => '../../../stow/pkg10b/man10/man1/file10b.1' make_dir('../stow/pkg10c/man10/man1'); make_file('../stow/pkg10c/man10/man1/file10a.1'); $stow->plan_unstow('pkg10c'); -stderr_like( - sub { $stow->process_tasks(); }, - qr/There are no outstanding operations to perform/, - 'no tasks to process when unstowing pkg10c' -); +is($stow->get_tasks, 0, 'no tasks to process when unstowing pkg10c'); ok( $stow->get_conflict_count == 0 && readlink('man10/man1/file10a.1') eq '../../../stow/pkg10a/man10/man1/file10a.1' @@ -260,11 +248,7 @@ ok( # $stow = new_Stow(); $stow->plan_unstow('pkg12'); -stderr_like( - sub { $stow->process_tasks(); }, - qr/There are no outstanding operations to perform/, - 'no tasks to process when unstowing pkg12' -); +is($stow->get_tasks, 0, 'no tasks to process when unstowing pkg12'); ok( $stow->get_conflict_count == 0 => 'unstow already unstowed package pkg12' @@ -279,11 +263,7 @@ mkdir("$OUT_DIR/target"); $stow = new_Stow(); $stow->plan_unstow('pkg12'); -stderr_like( - sub { $stow->process_tasks(); }, - qr/There are no outstanding operations to perform/, - 'no tasks to process when unstowing pkg12 which was never stowed' -); +is($stow->get_tasks, 0, 'no tasks to process when unstowing pkg12 which was never stowed'); ok( $stow->get_conflict_count == 0 => 'unstow never stowed package pkg12' @@ -296,11 +276,7 @@ make_file('man12/man1/file12.1'); $stow = new_Stow(); $stow->plan_unstow('pkg12'); -stderr_like( - sub { $stow->process_tasks(); }, - qr/There are no outstanding operations to perform/, - 'no tasks to process when unstowing pkg12 for third time' -); +is($stow->get_tasks, 0, 'no tasks to process when unstowing pkg12 for third time'); %conflicts = $stow->get_conflicts; ok( $stow->get_conflict_count == 1 && diff --git a/t/unstow_orig.t b/t/unstow_orig.t index 79465ee..ef04459 100755 --- a/t/unstow_orig.t +++ b/t/unstow_orig.t @@ -152,11 +152,7 @@ make_file('stow/pkg7a/stow/pkg7b/file7b'); make_link('stow/pkg7b', '../stow/pkg7a/stow/pkg7b'); $stow->plan_unstow('pkg7b'); -stderr_like( - sub { $stow->process_tasks(); }, - qr/There are no outstanding operations to perform/, - 'no tasks to process when unstowing pkg7b' -); +is($stow->get_tasks, 0, 'no tasks to process when unstowing pkg7b'); ok( $stow->get_conflict_count == 0 && -l 'stow/pkg7b' && @@ -178,11 +174,7 @@ make_file('stow/pkg8a/stow2/pkg8b/file8b'); make_link('stow2/pkg8b', '../stow/pkg8a/stow2/pkg8b'); $stow->plan_unstow('pkg8a'); -stderr_like( - sub { $stow->process_tasks(); }, - qr/There are no outstanding operations to perform/, - 'no tasks to process when unstowing pkg8a' -); +is($stow->get_tasks, 0, 'no tasks to process when unstowing pkg8a'); ok( $stow->get_conflict_count == 0 && -l 'stow2/pkg8b' && @@ -230,11 +222,7 @@ make_link('man10/man1/file10b.1' => '../../../stow/pkg10b/man10/man1/file10b.1' make_dir('../stow/pkg10c/man10/man1'); make_file('../stow/pkg10c/man10/man1/file10a.1'); $stow->plan_unstow('pkg10c'); -stderr_like( - sub { $stow->process_tasks(); }, - qr/There are no outstanding operations to perform/, - 'no tasks to process when unstowing pkg10c' -); +is($stow->get_tasks, 0, 'no tasks to process when unstowing pkg10c'); ok( $stow->get_conflict_count == 0 && readlink('man10/man1/file10a.1') eq '../../../stow/pkg10a/man10/man1/file10a.1' @@ -266,11 +254,7 @@ ok( # $stow = new_compat_Stow(); $stow->plan_unstow('pkg12'); -stderr_like( - sub { $stow->process_tasks(); }, - qr/There are no outstanding operations to perform/, - 'no tasks to process when unstowing pkg12' -); +is($stow->get_tasks, 0, 'no tasks to process when unstowing pkg12'); ok( $stow->get_conflict_count == 0 => 'unstow already unstowed package pkg12' @@ -285,11 +269,7 @@ mkdir("$OUT_DIR/target"); $stow = new_compat_Stow(); $stow->plan_unstow('pkg12'); -stderr_like( - sub { $stow->process_tasks(); }, - qr/There are no outstanding operations to perform/, - 'no tasks to process when unstowing pkg12 which was never stowed' -); +is($stow->get_tasks, 0, 'no tasks to process when unstowing pkg12 which was never stowed'); ok( $stow->get_conflict_count == 0 => 'unstow never stowed package pkg12' @@ -302,11 +282,7 @@ make_file('man12/man1/file12.1'); $stow = new_compat_Stow(); $stow->plan_unstow('pkg12'); -stderr_like( - sub { $stow->process_tasks(); }, - qr/There are no outstanding operations to perform/, - 'no tasks to process when unstowing pkg12 for third time' -); +is($stow->get_tasks, 0, 'no tasks to process when unstowing pkg12 for third time'); %conflicts = $stow->get_conflicts; ok( $stow->get_conflict_count == 1 && From 25b9ce0f21a07af1a8a14f57d87bb560b59e8352 Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Thu, 12 Jan 2012 17:54:32 +0000 Subject: [PATCH 156/482] Remove reference to old FSF address (thank you rpmlint for catching this!) --- bin/stow.in | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/bin/stow.in b/bin/stow.in index f2093df..173c388 100755 --- a/bin/stow.in +++ b/bin/stow.in @@ -17,8 +17,7 @@ # General Public License for more details. # # You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +# along with this program; if not, see . =head1 NAME From fe18b6c442cf5b2f2d87d89feb54bde0a2c6fbb9 Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Fri, 13 Jan 2012 11:34:55 +0000 Subject: [PATCH 157/482] Avoid "Use of uninitialized value" warnings from test suite. Happened on some versions of Perl when TEST_VERBOSE not yet. Thanks Adam Sampson! --- lib/Stow.pm.in | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/Stow.pm.in b/lib/Stow.pm.in index 3565e3f..329df9a 100755 --- a/lib/Stow.pm.in +++ b/lib/Stow.pm.in @@ -142,6 +142,7 @@ sub get_verbosity { return $self->{verbose} unless $self->{test_mode}; + return 0 unless exists $ENV{TEST_VERBOSE}; return 0 unless length $ENV{TEST_VERBOSE}; # Convert TEST_VERBOSE=y into numeric value From 9c6faebb951f4b7cf57a9f03d7aeda1aec1bbe82 Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Sat, 18 Feb 2012 11:53:46 +0000 Subject: [PATCH 158/482] Include --simulate in usage text. --- bin/stow.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/stow.in b/bin/stow.in index 173c388..a601d9a 100755 --- a/bin/stow.in +++ b/bin/stow.in @@ -619,7 +619,7 @@ SYNOPSIS: OPTIONS: - -n, --no Do not actually make any filesystem changes + -n, --no, --simulate Do not actually make any filesystem changes -d DIR, --dir=DIR Set stow dir to DIR (default is current dir) -t DIR, --target=DIR Set target to DIR (default is parent of stow dir) -v, --verbose[=N] Increase verbosity (levels are 0,1,2,3; From 1847b36e18b91ab8f0240f05e6789be2beb23d02 Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Sat, 18 Feb 2012 12:28:00 +0000 Subject: [PATCH 159/482] Make shared library tests match real-world scenarios. Typically, libfoo.so.X.Y.Z is the file, and libfoo.so is the symlink which points to it. --- t/stow.t | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/t/stow.t b/t/stow.t index ef32b78..762286b 100755 --- a/t/stow.t +++ b/t/stow.t @@ -320,8 +320,8 @@ ok( $stow = new_Stow(); make_dir('../stow/pkg12/lib12/'); -make_file('../stow/pkg12/lib12/lib.so'); -make_link('../stow/pkg12/lib12/lib.so.1','lib.so'); +make_file('../stow/pkg12/lib12/lib.so.1'); +make_link('../stow/pkg12/lib12/lib.so', 'lib.so.1'); make_dir('lib12/'); @@ -329,7 +329,8 @@ $stow->plan_stow('pkg12'); $stow->process_tasks(); ok( $stow->get_conflict_count == 0 && - readlink('lib12/lib.so.1') eq '../../stow/pkg12/lib12/lib.so.1' + readlink('lib12/lib.so.1') eq '../../stow/pkg12/lib12/lib.so.1' && + readlink('lib12/lib.so' ) eq '../../stow/pkg12/lib12/lib.so' => 'stow links to libraries' ); @@ -339,20 +340,22 @@ ok( $stow = new_Stow(); make_dir('../stow/pkg13a/lib13/'); -make_file('../stow/pkg13a/lib13/liba.so'); -make_link('../stow/pkg13a/lib13/liba.so.1', 'liba.so'); +make_file('../stow/pkg13a/lib13/liba.so.1'); +make_link('../stow/pkg13a/lib13/liba.so', 'liba.so.1'); make_link('lib13','../stow/pkg13a/lib13'); make_dir('../stow/pkg13b/lib13/'); -make_file('../stow/pkg13b/lib13/libb.so'); -make_link('../stow/pkg13b/lib13/libb.so.1', 'libb.so'); +make_file('../stow/pkg13b/lib13/libb.so.1'); +make_link('../stow/pkg13b/lib13/libb.so', 'libb.so.1'); $stow->plan_stow('pkg13b'); $stow->process_tasks(); ok( $stow->get_conflict_count == 0 && readlink('lib13/liba.so.1') eq '../../stow/pkg13a/lib13/liba.so.1' && - readlink('lib13/libb.so.1') eq '../../stow/pkg13b/lib13/libb.so.1' + readlink('lib13/liba.so' ) eq '../../stow/pkg13a/lib13/liba.so' && + readlink('lib13/libb.so.1') eq '../../stow/pkg13b/lib13/libb.so.1' && + readlink('lib13/libb.so' ) eq '../../stow/pkg13b/lib13/libb.so' => 'unfolding to stow links to libraries' ); From 6c3c617fd21b96d1ee53215e9b01bdf507d41dd1 Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Sat, 18 Feb 2012 14:07:45 +0000 Subject: [PATCH 160/482] Ignore tmp-testing-trees anywhere. --- .gitignore | 2 +- MANIFEST.SKIP | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index 7d6996a..6e48e79 100644 --- a/.gitignore +++ b/.gitignore @@ -9,7 +9,7 @@ /bin/stow /doc/stow.info /doc/version.texi -/tmp-testing-trees/ +tmp-testing-trees/ _build/ autom4te.cache/ blib/ diff --git a/MANIFEST.SKIP b/MANIFEST.SKIP index 6fa2f49..df1f41f 100644 --- a/MANIFEST.SKIP +++ b/MANIFEST.SKIP @@ -81,4 +81,4 @@ ^doc/HOWTO-RELEASE$ # Avoid test files -^tmp-testing-trees +tmp-testing-trees From a5c2134f59d5346ec7bf62415794ea559c04e5d0 Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Sat, 18 Feb 2012 14:08:17 +0000 Subject: [PATCH 161/482] Add missing options to pod, and reference to front-end documentation. --- lib/Stow.pm.in | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/lib/Stow.pm.in b/lib/Stow.pm.in index 329df9a..4479b6a 100755 --- a/lib/Stow.pm.in +++ b/lib/Stow.pm.in @@ -82,6 +82,8 @@ our %DEFAULT_OPTIONS = ( =head3 Non-mandatory options +See the documentation for the F CLI front-end for information on these. + =over 4 =item * conflicts @@ -92,6 +94,12 @@ our %DEFAULT_OPTIONS = ( =item * paranoid +=item * compat + +=item * test_mode + +=item * adopt + =item * ignore =item * override From 7b36267dd2f696a252fc79e0d9ac67633e8d09f1 Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Sat, 18 Feb 2012 14:11:33 +0000 Subject: [PATCH 162/482] Improve ordering of options in usage text. --- bin/stow.in | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/bin/stow.in b/bin/stow.in index a601d9a..b2ede1d 100755 --- a/bin/stow.in +++ b/bin/stow.in @@ -619,22 +619,23 @@ SYNOPSIS: OPTIONS: - -n, --no, --simulate Do not actually make any filesystem changes -d DIR, --dir=DIR Set stow dir to DIR (default is current dir) -t DIR, --target=DIR Set target to DIR (default is parent of stow dir) - -v, --verbose[=N] Increase verbosity (levels are 0,1,2,3; - -v or --verbose adds 1; --verbose=N sets level) -S, --stow Stow the package names that follow this option -D, --delete Unstow the package names that follow this option -R, --restow Restow (like stow -D followed by stow -S) - -p, --compat Use legacy algorithm for unstowing --ignore=REGEX Ignore files ending in this Perl regex --defer=REGEX Don't stow files beginning with this Perl regex if the file is already stowed to another package --override=REGEX Force stowing files beginning with this Perl regex if the file is already stowed to another package + -p, --compat Use legacy algorithm for unstowing + + -n, --no, --simulate Do not actually make any filesystem changes + -v, --verbose[=N] Increase verbosity (levels are 0,1,2,3; + -v or --verbose adds 1; --verbose=N sets level) -V, --version Show stow version number -h, --help Show this help From 2c5950ed00d6e24bcdcc9e34e760e13dc5a70910 Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Sat, 18 Feb 2012 14:15:14 +0000 Subject: [PATCH 163/482] Add --adopt to usage text. --- bin/stow.in | 2 ++ 1 file changed, 2 insertions(+) diff --git a/bin/stow.in b/bin/stow.in index b2ede1d..ca91955 100755 --- a/bin/stow.in +++ b/bin/stow.in @@ -631,6 +631,8 @@ OPTIONS: if the file is already stowed to another package --override=REGEX Force stowing files beginning with this Perl regex if the file is already stowed to another package + -a, --adopt (Use with care!) Import existing files into stow package + from target. Please read docs before using. -p, --compat Use legacy algorithm for unstowing -n, --no, --simulate Do not actually make any filesystem changes From 2da2f44a20f3c42e2dd962376b2a04b04f93e79c Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Sat, 18 Feb 2012 15:03:52 +0000 Subject: [PATCH 164/482] Fix formatting of regexp values in the manual. --- doc/stow.texi | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/doc/stow.texi b/doc/stow.texi index 155a64a..683c1c5 100644 --- a/doc/stow.texi +++ b/doc/stow.texi @@ -279,7 +279,7 @@ Set the target directory to @var{dir} instead of the parent of the stow directory. Defaults to the parent of the stow directory, so it is typical to execute @code{stow} from the directory @file{/usr/local/stow}. -@item --ignore='' +@item --ignore=@var{regexp} This (repeatable) option lets you suppress acting on files that match the given perl regular expression. For example, using the options @@ -297,7 +297,7 @@ Also note that by default Stow automatically ignores a ``sensible'' built-in list of files and directories such as @file{CVS}, editor backup files, and so on. @xref{Ignore Lists}, for more details. -@item --defer='' +@item --defer=@var{regexp} This (repeatable) option avoids stowing a file matching the given regular expression, if that file is already stowed by another package. This is effectively the opposite of @code{--override}. @@ -324,7 +324,7 @@ Note that the regular expression is anchored to the beginning of the path relative to the target directory, because this is what you will want to do most of the time. -@item --override='' +@item --override=@var{regexp} This (repeatable) option forces any file matching the regular expression to be stowed, even if the file is already stowed to another package. For example, the following options From 149034de9fc4920553d7f1bf57099e275b20abaa Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Sat, 18 Feb 2012 15:17:21 +0000 Subject: [PATCH 165/482] Use @command / @samp / @env / @var in the manual where appropriate, rather than @code. --- doc/stow.texi | 68 +++++++++++++++++++++++++-------------------------- 1 file changed, 34 insertions(+), 34 deletions(-) diff --git a/doc/stow.texi b/doc/stow.texi index 683c1c5..4f99e66 100644 --- a/doc/stow.texi +++ b/doc/stow.texi @@ -251,7 +251,7 @@ creates relative symlinks. @node Invoking Stow, Ignore Lists, Terminology, Top @chapter Invoking Stow -The syntax of the @code{stow} command is: +The syntax of the @command{stow} command is: @example stow [@var{options}] [@var{action flag}] @var{package @dots{}} @@ -277,7 +277,7 @@ variable @env{STOW_DIR} if set, or the current directory otherwise. @itemx --target=@var{dir} Set the target directory to @var{dir} instead of the parent of the stow directory. Defaults to the parent of the stow directory, so it is typical to -execute @code{stow} from the directory @file{/usr/local/stow}. +execute @command{stow} from the directory @file{/usr/local/stow}. @item --ignore=@var{regexp} This (repeatable) option lets you suppress acting on files that match the @@ -300,9 +300,9 @@ backup files, and so on. @xref{Ignore Lists}, for more details. @item --defer=@var{regexp} This (repeatable) option avoids stowing a file matching the given regular expression, if that file is already stowed by another package. -This is effectively the opposite of @code{--override}. +This is effectively the opposite of @option{--override}. -(N.B. the name @code{--defer} was chosen in the sense that the package +(N.B. the name @option{--defer} was chosen in the sense that the package currently being stowed is treated with lower precedence than any already installed package, not in the sense that the operation is being postponed to be run at a later point in time; do not confuse @@ -317,7 +317,7 @@ For example, the following options @noindent will cause stow to skip over pre-existing man and info pages. -Equivalently, you could use @code{--defer='man|info'} since the +Equivalently, you could use @samp{--defer='man|info'} since the argument is just a Perl regex. Note that the regular expression is anchored to the beginning of the path @@ -367,13 +367,13 @@ commit ...}) or discarded (@samp{git checkout HEAD ...}). @itemx --no @itemx --simulate Do not perform any operations that modify the file system; in combination with -@samp{-v} can be used to merely show what would happen. +@option{-v} can be used to merely show what would happen. @item -v @itemx --verbose[=@var{n}] Send verbose output to standard error describing what Stow is doing. Verbosity levels are 0, 1, 2, and 3; 0 is the default. Using -@samp{-v} or @samp{--verbose} increases the verbosity by one; using +@option{-v} or @option{--verbose} increases the verbosity by one; using @samp{--verbose=@var{n}} sets it to @var{n}. @item -p @@ -382,7 +382,7 @@ Scan the whole target tree when unstowing. By default, only directories specified in the @dfn{installation image} are scanned during an unstow operation. Scanning the whole tree can be prohibitive if your target tree is very large. This option restores -the legacy behaviour; however, the @samp{--badlinks} option to the +the legacy behaviour; however, the @option{--badlinks} option to the @command{chkstow} utility may be a better way of ensuring that your installation does not have any dangling symlinks (@pxref{Target Maintenance}). @@ -414,7 +414,7 @@ number of times. @item -S @item --stow explictly stow the package name(s) that follow this option. May be -omitted if you are not using the @samp{-D} or @samp{-R} options in the +omitted if you are not using the @option{-D} or @option{-R} options in the same invocation. @xref{Mixing Operations}, for details of when you might like to use this feature. This option may be repeated any number of times. @@ -447,9 +447,9 @@ may be files or directories relating to the build of the package which are not needed at run-time. In these cases, it can be rather cumbersome to specify a -@samp{--ignore} parameter for each file or directory to be ignored. +@option{--ignore} parameter for each file or directory to be ignored. This could be worked around by ensuring the existence of -@file{~/.stowrc} containing multiple @samp{--ignore} lines, or if a +@file{~/.stowrc} containing multiple @option{--ignore} lines, or if a different set of files/directories should be ignored depending on which stow package is involved, a @file{.stowrc} file for each stow package, but this would require the user to ensure that they were in @@ -460,7 +460,7 @@ table with excessively long parameter lists, or even worse, exceed the operating system's limit for process arguments. @cindex ignore lists -Therefore in addition to @samp{--ignore} parameters, Stow provides a +Therefore in addition to @option{--ignore} parameters, Stow provides a way to specify lists of files and directories to ignore. @c =========================================================================== @@ -523,13 +523,13 @@ Otherwise, the file or directory is not ignored. For example, if a file @file{bazqux} is in the @file{foo/bar} subdirectory of the package directory, Stow would use -@code{/foo/bar/bazqux} as the text for matching against regular -expressions which contain @samp{/}, and @code{bazqux} as the text for +@samp{/foo/bar/bazqux} as the text for matching against regular +expressions which contain @samp{/}, and @samp{bazqux} as the text for matching against regular expressions which don't contain @samp{/}. -Then regular expressions @code{bazqux}, @code{baz.*}, @code{.*qux}, -@code{bar/.*x}, and @code{^/foo/.*qux} would all match (causing the -file to be ignored), whereas @code{bar}, @code{baz}, @code{qux}, and -@code{o/bar/b} would not (although @code{bar} would cause its parent +Then regular expressions @samp{bazqux}, @samp{baz.*}, @samp{.*qux}, +@samp{bar/.*x}, and @samp{^/foo/.*qux} would all match (causing the +file to be ignored), whereas @samp{bar}, @samp{baz}, @samp{qux}, and +@samp{o/bar/b} would not (although @samp{bar} would cause its parent directory to be ignored and prevent Stow from recursing into that anyway, in which case the file @file{bazqux} would not even be considered for stowing). @@ -544,10 +544,10 @@ list, because this file serves no purpose outside the stow directory. @section Justification For Yet Another Set Of Ignore Files The reader may note that this format is very similar to existing -ignore list file formats, such as those for @code{CVS}, @code{git}, -@code{rsync} etc., and wonder if another set of ignore lists is +ignore list file formats, such as those for @command{cvs}, @command{git}, +@command{rsync} etc., and wonder if another set of ignore lists is justified. However there are good reasons why Stow does not simply -check for the presence of say, @code{.cvsignore}, and use that if it +check for the presence of say, @file{.cvsignore}, and use that if it exists. Firstly, there is no guarantee that a stow package would contain any version control meta-data, or permit introducing this if it didn't already exist. @@ -660,7 +660,7 @@ by Stow, then a @dfn{conflict} has arisen. @xref{Conflicts}. @chapter Deleting Packages @cindex deletion -When the @samp{-D} option is given, the action of Stow is to +When the @option{-D} option is given, the action of Stow is to delete a package from the target tree. Note that Stow will not delete anything it doesn't ``own''. Deleting a package does @emph{not} mean removing it from the stow directory or discarding the package @@ -673,8 +673,8 @@ target tree was scanned and stow directories were explicitly omitted. This became problematic when dealing with very large installations. The only situation where this is useful is if you accidentally delete a directory in the package tree, leaving you with a whole bunch of dangling links. Note that -you can enable the old approach with the @samp{-p} option. Alternatively, you can -use the @samp{--badlinks} option get stow to search for dangling links in your target tree and remove the offenders manually.} +you can enable the old approach with the @option{-p} option. Alternatively, you can +use the @option{--badlinks} option get stow to search for dangling links in your target tree and remove the offenders manually.} For example, if the target directory is @file{/usr/local} and the installation image for the package being deleted has only a @file{bin} directory and a @file{man} directory at the top level, then we only scan @@ -785,7 +785,7 @@ this. It includes three operational modes which performs checks that would generally be too expensive to be performed during normal stow execution. -The syntax of the @code{chkstow} command is: +The syntax of the @command{chkstow} command is: @example chkstow [@var{options}] @@ -800,7 +800,7 @@ The following options are supported: @itemx --target=@var{dir} Set the target directory to @var{dir} instead of the parent of the stow directory. Defaults to the parent of the stow directory, so it is typical to -execute @code{stow} from the directory @file{/usr/local/stow}. +execute @command{stow} from the directory @file{/usr/local/stow}. @item -b @itemx --badlinks @@ -910,21 +910,21 @@ shell script in place of @samp{make install}. Be sure to execute the script using the same shell that @samp{make install} would have used. (If you use GNU Make and a shell [such as GNU bash] that understands -@code{pushd} and @code{popd}, you can do the following: +@command{pushd} and @command{popd}, you can do the following: @enumerate @item Replace all lines matching @samp{make[@var{n}]: Entering directory -`@var{dir}'} with @code{pushd @var{dir}}. +`@var{dir}'} with @samp{pushd @var{dir}}. @item Replace all lines matching @samp{make[@var{n}]: Leaving directory -`@var{dir}'} with @code{popd}. +`@var{dir}'} with @samp{popd}. @item Delete all lines matching @samp{make[@var{n}]: Nothing to be done for @var{rule}}. @end enumerate -Then find other lines in the output containing @code{cd} or @code{make} +Then find other lines in the output containing @command{cd} or @command{make} commands and rewrite or delete them. In particular, you should be able to delete sections of the script that resemble this: @@ -963,9 +963,9 @@ make install prefix=/usr/local/stow/@var{package} @end example @noindent -If you try this with Emacs, then the new value for @code{prefix} in the +If you try this with Emacs, then the new value for @var{prefix} in the @samp{make install} step will cause some files to get recompiled with -the new value of @code{prefix} wired into them. In Emacs 19.23 and +the new value of @var{prefix} wired into them. In Emacs 19.23 and later,@footnote{As I write this, the current version of Emacs is 19.31.} the way to work around this problem is: @@ -1149,7 +1149,7 @@ stow -vv * @end example @noindent -but @code{stow} is not yet in your @code{PATH}. Nor can you do this: +but @command{stow} is not yet in your @env{PATH}. Nor can you do this: @example cd /usr/local/stow @@ -1157,7 +1157,7 @@ stow/bin/stow -vv * @end example @noindent -because the @samp{#!} line at the beginning of @code{stow} tries to +because the @samp{#!} line at the beginning of @command{stow} tries to locate Perl (usually in @file{/usr/local/bin/perl}), and that won't be found. The solution you must use is: From c6a45b7c8126f8f6f3568130dfb32a9137fe7121 Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Sat, 18 Feb 2012 15:45:16 +0000 Subject: [PATCH 166/482] Add some @sections to the manual to break larger nodes up. --- doc/stow.texi | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/doc/stow.texi b/doc/stow.texi index 4f99e66..eb2f9ae 100644 --- a/doc/stow.texi +++ b/doc/stow.texi @@ -127,7 +127,7 @@ Ignore Lists * Types And Syntax Of Ignore Lists:: * Justification For Yet Another Set Of Ignore Files:: -Compile-time vs Install-time +Advice on changing compilation and installation parameters * GNU Emacs:: * Other FSF Software:: @@ -580,6 +580,8 @@ Stow can create a single symlink that points to an entire subtree within the package tree, it will choose to do that rather than create a directory in the target tree and populate it with symlinks. +@anchor{tree folding} +@section Tree folding @cindex tree folding @cindex directory folding @cindex folding trees @@ -616,6 +618,8 @@ tree-folding symlink @file{perl} pointing to descends as far as necessary into the target tree when it can create a tree-folding symlink. +@anchor{Tree unfolding} +@section Tree unfolding @cindex splitting open folded trees @cindex unfolding trees The time often comes when a tree-folding symlink has to be undone @@ -638,6 +642,7 @@ directory @file{/usr/local/bin} is created; links are made from @file{/usr/local/bin} to @file{../stow/perl/bin/perl} and @file{../stow/perl/bin/a2p}. +@section Ownership @cindex ownership When splitting open a folded tree, Stow makes sure that the symlink it is about to remove points inside a valid package in the @@ -649,6 +654,7 @@ the stow directory, or directories that only contain symlinks that stow ``owns''. Note that by this definition, Stow doesn't ``own'' anything @emph{in} the stow directory or in any of the packages. +@section Conflicts during installation @cindex conflict If Stow needs to create a directory or a symlink in the target tree and it cannot because that name is already in use and is not owned @@ -889,6 +895,7 @@ This means that when you compile a package, you must tell it the location of the run-time, or target tree; but when you install it, you must place it in the stow tree. +@section Advice on changing compilation and installation parameters Some software packages allow you to specify, at compile-time, separate locations for installation and for run-time. Perl is one such package; see @ref{Perl and Perl 5 Modules}. Others allow you to compile the From 2ae90481cbc29362e2eb563633f2e4a52b8dd4b3 Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Sat, 18 Feb 2012 15:45:49 +0000 Subject: [PATCH 167/482] Add some more index entries to the manual. --- doc/stow.texi | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/doc/stow.texi b/doc/stow.texi index eb2f9ae..c560e74 100644 --- a/doc/stow.texi +++ b/doc/stow.texi @@ -340,6 +340,7 @@ pages that are owned by stow and would otherwise cause a conflict. The regular expression is anchored to the beginning of the path relative to the target directory, because this is what you will want to do most of the time. +@cindex adopting existing files @item -a @itemx --adopt @strong{Warning!} This behaviour is specifically intended to alter the @@ -363,12 +364,15 @@ package, then compared by running something like @samp{git diff ...} inside the stow package, and finally either kept (e.g. via @samp{git commit ...}) or discarded (@samp{git checkout HEAD ...}). +@cindex dry run +@cindex simulated run @item -n @itemx --no @itemx --simulate Do not perform any operations that modify the file system; in combination with @option{-v} can be used to merely show what would happen. +@cindex verbosity levels @item -v @itemx --verbose[=@var{n}] Send verbose output to standard error describing what Stow is @@ -622,6 +626,8 @@ tree-folding symlink. @section Tree unfolding @cindex splitting open folded trees @cindex unfolding trees +@cindex tree unfolding +@cindex tree unsplitting The time often comes when a tree-folding symlink has to be undone because another package uses one or more of the folded subdirectories in its installation image. This operation is called @dfn{splitting open} or @@ -655,7 +661,8 @@ the stow directory, or directories that only contain symlinks that stow @emph{in} the stow directory or in any of the packages. @section Conflicts during installation -@cindex conflict +@cindex conflicts +@cindex installation conflicts If Stow needs to create a directory or a symlink in the target tree and it cannot because that name is already in use and is not owned by Stow, then a @dfn{conflict} has arisen. @xref{Conflicts}. From 934ff5e273d910cf35e24ff44827eacbd4e66e91 Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Sat, 18 Feb 2012 15:46:14 +0000 Subject: [PATCH 168/482] Fix various formatting issues in the manual. --- doc/stow.texi | 37 +++++++++++++++++++------------------ 1 file changed, 19 insertions(+), 18 deletions(-) diff --git a/doc/stow.texi b/doc/stow.texi index c560e74..f595212 100644 --- a/doc/stow.texi +++ b/doc/stow.texi @@ -311,7 +311,7 @@ this nomenclature with the wording used in @ref{Deferred Operation}.) For example, the following options @example ---defer='man' --defer='info' +--defer=man --defer=info @end example @noindent @@ -330,7 +330,7 @@ stowed, even if the file is already stowed to another package. For example, the following options @example ---override='man' --override='info' +--override=man --override=info @end example @noindent @@ -837,15 +837,15 @@ directory. @node Resource Files, Compile-time vs Install-time, Target Maintenance, Top @chapter Resource Files -Default command line options may be set in `.stowrc' (current directory) or -`~/.stowrc' (home directory). These are parsed in that order, and effectively +Default command line options may be set in @file{.stowrc} (current directory) or +@file{~/.stowrc} (home directory). These are parsed in that order, and effectively prepended to you command line. This feature can be used for some interesting effects. For example, suppose your site uses more than one stow directory, perhaps in order to share around responsibilities with a number of systems administrators. One of the administrators might have the following in there -`~/.stowrc' file: +@file{~/.stowrc} file: @example --dir=/usr/local/stow2 @@ -854,13 +854,13 @@ administrators. One of the administrators might have the following in there --ignore='^CVS' @end example -so that the `stow' command will default to operating on the @file{/usr/local/stow2} -directory, with @file{/usr/local} as the target, and ignoring vi backup files -and CVS directories. +so that the @command{stow} command will default to operating on the +@file{/usr/local/stow2} directory, with @file{/usr/local} as the +target, and ignoring vi backup files and CVS directories. -If you had a stow directory `/usr/local/stow/perl-extras' that was only used -for Perl modules, then you might place the following in -`/usr/local/stow/perl-extras/.stowrc': +If you had a stow directory @file{/usr/local/stow/perl-extras} that +was only used for Perl modules, then you might place the following in +@file{/usr/local/stow/perl-extras/.stowrc}: @example --dir=/usr/local/stow/perl-extras @@ -872,11 +872,12 @@ for Perl modules, then you might place the following in --ignore='\.bs' @end example -so that the when your are in the @file{/usr/local/stow/perl-extras} directory, -`stow' will regard any subdirectories as stow packages, with @file{/usr/local} -as the target (rather than the immediate parent directoy -@file{/usr/local/stow}), overriding any pre-existing links to bin files or man -pages, and ignoring some cruft that gets installed by default. +so that the when your are in the @file{/usr/local/stow/perl-extras} +directory, @command{stow} will regard any subdirectories as stow +packages, with @file{/usr/local} as the target (rather than the +immediate parent directory @file{/usr/local/stow}), overriding any +pre-existing links to bin files or man pages, and ignoring some cruft +that gets installed by default. @c =========================================================================== @@ -929,10 +930,10 @@ script using the same shell that @samp{make install} would have used. @enumerate @item Replace all lines matching @samp{make[@var{n}]: Entering directory -`@var{dir}'} with @samp{pushd @var{dir}}. +@var{dir}} with @samp{pushd @var{dir}}. @item Replace all lines matching @samp{make[@var{n}]: Leaving directory -`@var{dir}'} with @samp{popd}. +@var{dir}} with @samp{popd}. @item Delete all lines matching @samp{make[@var{n}]: Nothing to be done for @var{rule}}. From 52d7e2f384be0730847ccae21a7607c7149a63d9 Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Sat, 18 Feb 2012 15:47:19 +0000 Subject: [PATCH 169/482] Update structure of manual to match recommended texinfo structure. TOC now appears after title page. Copying information is no longer duplicated. --- doc/stow.texi | 64 ++++++++++++++++++++------------------------------- 1 file changed, 25 insertions(+), 39 deletions(-) diff --git a/doc/stow.texi b/doc/stow.texi index f595212..291bd59 100644 --- a/doc/stow.texi +++ b/doc/stow.texi @@ -7,16 +7,16 @@ @c @setchapternewpage odd @c @footnotestyle separate @c %**end of header -@dircategory System administration -@direntry -* Stow: (stow). GNU Stow. -@end direntry @include version.texi @ifinfo -This file describes GNU Stow version @value{VERSION}, a program for -managing the installation of software packages. +@end ifinfo + +@copying +This manual describes GNU Stow version @value{VERSION} +(@value{UPDATED}), a program for managing the installation of software +packages. Software and documentation is copyrighted by the following: @@ -28,6 +28,7 @@ Software and documentation is copyrighted by the following: @* @copyright{} 2011 Adam Spiers +@quotation Permission is granted to make and distribute verbatim copies of this manual provided the copyright notice and this permission notice are preserved on all copies. @@ -50,8 +51,15 @@ Permission is granted to copy and distribute translations of this manual into another language, under the above conditions for modified versions, except that this permission notice may be stated in a translation approved by the Free Software Foundation. -@end ifinfo +@end quotation +@end copying +@dircategory System administration +@direntry +* Stow: (stow). GNU Stow. +@end direntry + +@c =========================================================================== @titlepage @title Stow @value{VERSION} @subtitle Managing the installation of software packages @@ -59,45 +67,24 @@ approved by the Free Software Foundation. @author Kahlil Hodgson, RMIT Univerity, Australia. @page @vskip 0pt plus 1filll -This manual describes GNU Stow version @value{VERSION}, a program for -managing the installation of software packages. - -Software and documentation is copyrighted by the following: - -@copyright{} 1993, 1994, 1995, 1996 Bob Glickstein -@* -@copyright{} 2000, 2001 Guillaume Morin -@* -@copyright{} 2007 Kahlil (Kal) Hodgson -@* -@copyright{} 2011 Adam Spiers - -Permission is granted to make and distribute verbatim copies of this -manual provided the copyright notice and this permission notice are -preserved on all copies. - -Permission is granted to copy and distribute modified versions of this -manual under the conditions for verbatim copying, provided also that the -section entitled ``GNU General Public License'' is included with the -modified manual, and provided that the entire resulting derived work is -distributed under the terms of a permission notice identical to this -one. - -Permission is granted to copy and distribute translations of this manual -into another language, under the above conditions for modified versions, -except that this permission notice may be stated in a translation -approved by the Free Software Foundation. +@insertcopying @end titlepage +@c FIXME: How to include the TOC in the TOC? +@c @node Table of Contents, Top, (dir), (dir) +@c @unnumbered Table of Contents +@contents @c ========================================================================== -@node Top, Introduction, (dir), (dir) +@ifnottex +@node Top @top @ifinfo -This manual describes GNU Stow @value{VERSION}, a program for managing -the installation of software packages. +This manual describes GNU Stow @value{VERSION} (@value{UPDATED}), a +program for managing the installation of software packages. @end ifinfo +@end ifnottex @menu * Introduction:: Description of Stow. @@ -1638,5 +1625,4 @@ General Public License instead of this License. @printindex cp -@contents @bye From 1af824908da719e4045847d105a7ec92909cb337 Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Sat, 18 Feb 2012 20:32:40 +0000 Subject: [PATCH 170/482] Last known bug was fixed a long time ago :-) --- doc/stow.texi | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/doc/stow.texi b/doc/stow.texi index 291bd59..3576f1a 100644 --- a/doc/stow.texi +++ b/doc/stow.texi @@ -1199,7 +1199,8 @@ adding @samp{--verbose=3} to the Stow command line). @end itemize If you are really keen, consider developing a minimal test case and -creating a new test. See the @file{t/} for lots of examples. +creating a new test. See the @file{t/} directory in the source for +lots of examples. Before reporting a bug, please read the manual carefully, especially @ref{Known Bugs}, to see whether you're encountering @@ -1210,17 +1211,13 @@ something that doesn't need reporting. @node Known Bugs, GNU General Public License, Reporting Bugs, Top @chapter Known Bugs -@itemize @bullet -@item -When using multiple stow directories (@pxref{Multiple Stow -Directories}), Stow fails to ``split open'' tree-folding symlinks -(@pxref{Installing Packages}) that point into a stow directory which is -not the one in use by the current Stow command. Before failing, it -should search the target of the link to see whether any element of the -path contains a @file{.stow} file. If it finds one, it can ``learn'' -about the cooperating stow directory to short-circuit the @file{.stow} -search the next time it encounters a tree-folding symlink. -@end itemize +There are no known bugs in Stow version @value{VERSION}! +If you think you have found one, please @pxref{Reporting Bugs}. + +@c @itemize @bullet +@c @item +@c Put known bugs here +@c @end itemize @c =========================================================================== @node GNU General Public License, Index, Known Bugs, Top From 30a70aa3ef45d2f4873b433eb8311cf1088eba67 Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Sat, 18 Feb 2012 17:07:15 +0000 Subject: [PATCH 171/482] Update TODO --- TODO | 38 ++++++++++++++++++++------------------ 1 file changed, 20 insertions(+), 18 deletions(-) diff --git a/TODO b/TODO index 9bd09a4..ecc84a1 100644 --- a/TODO +++ b/TODO @@ -1,34 +1,36 @@ * Next release should be under GPL v3 + * Get permission for next documentation release to be under FDL 1.3 + * Import a debian/ tree from an older package and update it. + * Import a .spec file from somewhere and update it. -* Distinguish between .stow and (undocumented) .nonstow + +* Distinguish between .stow and (undocumented) .nonstow / .notstowed + ** .stow is for marking stow directories - avoids altering them + but also allows --override to work + ** .nonstow should be only for protecting non-stow directories against modification by stow - but currently allows modification via --override. + + but currently allows modification via --override + +** .notstowed is only honoured by chkstow + ** Documentation needs to be clear on this. + * Prevent folding of directories which contain ignored files + * Honour .no-stow-folding and --no-folding + * Add semi-automatic conflict resolution + + (This idea is possibly obsoleted via --override and --adopt.) + *** STOW_RESOLVE_CONFLICTS="non_stow_symlinks=t stow_symlinks=r" + *** Add documentation about conflict resolution -* get account on fencepost.gnu.org (email accounts@gnu.org) - set up copyright papers? - 'assign.future' and 'request-assign.future.manual' - -* Figure out what needs the files '.nonstow' and '.notstowed'. Can they be removed? - -* Update http://directory.fsf.org/project/stow/ - -* Update savannah CVS - -* Check that all email addresses are working: need an account on fenchpost for - this bug-stow@gnu.org, help-stow@gnu.org - -* Get some pre-testers: need to find appropriate mailing list? - -* Announce release on info-gnu@gnu.org. * Autodetect "foreign" stow directories From af4557c5434a2993a164f95251754fc8b4241657 Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Sat, 18 Feb 2012 15:47:36 +0000 Subject: [PATCH 172/482] Add documentation improvements to NEWS. --- NEWS | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/NEWS b/NEWS index 0b8e2e6..24e28ea 100644 --- a/NEWS +++ b/NEWS @@ -2,6 +2,10 @@ News file for Stow. * Changes in version 2.1.4 +** Documentation improvements + + Various fixes and cosmetic improvements have been made in the manual. + ** Remove "There are no outstanding operations to perform" warning. * Changes in version 2.1.3 From 91c816e32d64780215f3f0f9f5a7cdcf70a058fa Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Sat, 18 Feb 2012 20:19:05 +0000 Subject: [PATCH 173/482] Use make_invalid_link() to reliably setup symlink fixtures. --- NEWS | 4 ++++ t/chkstow.t | 2 +- t/cleanup_invalid_links.t | 4 ++-- t/stow.t | 4 ++-- t/testutil.pm | 41 +++++++++++++++++++++++++++++++-------- t/unstow.t | 4 ++-- t/unstow_orig.t | 4 ++-- 7 files changed, 46 insertions(+), 17 deletions(-) diff --git a/NEWS b/NEWS index 24e28ea..4ccd179 100644 --- a/NEWS +++ b/NEWS @@ -2,6 +2,10 @@ News file for Stow. * Changes in version 2.1.4 +** Test suite improvements + + The test suite has been tightened up slightly. + ** Documentation improvements Various fixes and cosmetic improvements have been made in the manual. diff --git a/t/chkstow.t b/t/chkstow.t index bb611d8..e18a476 100755 --- a/t/chkstow.t +++ b/t/chkstow.t @@ -98,7 +98,7 @@ stdout_like( qr{Unstowed\ file:\ ./bin/alien}xms, "Aliens exist"); -make_link('bin/link', 'ireallyhopethisfiledoesn/t.exist'); +make_invalid_link('bin/link', 'ireallyhopethisfiledoesn/t.exist'); @ARGV = ('-t', '.', '-b'); stdout_like( \&run_chkstow, diff --git a/t/cleanup_invalid_links.t b/t/cleanup_invalid_links.t index f0f164b..b9c62af 100755 --- a/t/cleanup_invalid_links.t +++ b/t/cleanup_invalid_links.t @@ -42,7 +42,7 @@ make_dir('bin2'); make_dir('../stow/pkg2/bin2'); make_file('../stow/pkg2/bin2/file2a'); make_link('bin2/file2a', '../../stow/pkg2/bin2/file2a'); -make_link('bin2/file2b', '../../stow/pkg2/bin2/file2b'); +make_invalid_link('bin2/file2b', '../../stow/pkg2/bin2/file2b'); $stow = new_Stow(); $stow->cleanup_invalid_links('bin2'); @@ -58,7 +58,7 @@ make_dir('bin3'); make_dir('../stow/pkg3/bin3'); make_file('../stow/pkg3/bin3/file3a'); make_link('bin3/file3a', '../../stow/pkg3/bin3/file3a'); -make_link('bin3/file3b', '../../empty'); +make_invalid_link('bin3/file3b', '../../empty'); $stow = new_Stow(); $stow->cleanup_invalid_links('bin3'); diff --git a/t/stow.t b/t/stow.t index 762286b..0786d18 100755 --- a/t/stow.t +++ b/t/stow.t @@ -180,7 +180,7 @@ for my $file ('file4c', 'bin4c/file4c') { $stow = new_Stow(); make_dir('bin5'); -make_link('bin5/file5','../../empty'); +make_invalid_link('bin5/file5','../../empty'); make_dir('../stow/pkg5/bin5/file5'); $stow->plan_stow('pkg5'); @@ -196,7 +196,7 @@ like( # $stow = new_Stow(); -make_link('file6','../stow/path-does-not-exist'); +make_invalid_link('file6','../stow/path-does-not-exist'); make_dir('../stow/pkg6'); make_file('../stow/pkg6/file6'); diff --git a/t/testutil.pm b/t/testutil.pm index 97ac422..9e4573b 100755 --- a/t/testutil.pm +++ b/t/testutil.pm @@ -9,7 +9,10 @@ package testutil; use strict; use warnings; +use Carp qw(croak); +use File::Basename; use File::Path qw(remove_tree); +use File::Spec; use Stow; use Stow::Util qw(parent canon_path); @@ -20,7 +23,7 @@ our @EXPORT = qw( init_test_dirs cd new_Stow new_compat_Stow - make_dir make_link make_file + make_dir make_link make_invalid_link make_file remove_dir remove_link cat_file ); @@ -56,28 +59,50 @@ sub new_compat_Stow { # Purpose : safely create a link # Parameters: $target => path to the link # : $source => where the new link should point +# : $invalid => true iff $source refers to non-existent file # Returns : n/a # Throws : fatal error if the link can not be safely created # Comments : checks for existing nodes #============================================================================ sub make_link { - my ($target, $source) = @_; + my ($target, $source, $invalid) = @_; if (-l $target) { my $old_source = readlink join('/', parent($target), $source) - or die "could not read link $target/$source"; + or die "$target is already a link but could not read link $target/$source"; if ($old_source ne $source) { die "$target already exists but points elsewhere\n"; } } - elsif (-e $target) { - die "$target already exists and is not a link\n"; + die "$target already exists and is not a link\n" if -e $target; + my $abs_target = File::Spec->rel2abs($target); + my $target_container = dirname($abs_target); + my $abs_source = File::Spec->rel2abs($source, $target_container); + #warn "t $target c $target_container as $abs_source"; + if (-e $abs_source) { + croak "Won't make invalid link pointing to existing $abs_target" + if $invalid; } else { - symlink $source, $target - or die "could not create link $target => $source ($!)\n"; + croak "Won't make link pointing to non-existent $abs_target" + unless $invalid; } - return; + symlink $source, $target + or die "could not create link $target => $source ($!)\n"; +} + +#===== SUBROUTINE =========================================================== +# Name : make_invalid_link() +# Purpose : safely create an invalid link +# Parameters: $target => path to the link +# : $source => the non-existent source where the new link should point +# Returns : n/a +# Throws : fatal error if the link can not be safely created +# Comments : checks for existing nodes +#============================================================================ +sub make_invalid_link { + my ($target, $source, $allow_invalid) = @_; + make_link($target, $source, 1); } #===== SUBROUTINE =========================================================== diff --git a/t/unstow.t b/t/unstow.t index 23f42e7..bf46bfa 100755 --- a/t/unstow.t +++ b/t/unstow.t @@ -87,7 +87,7 @@ $stow = new_Stow(); make_dir('bin4'); make_dir('../stow/pkg4/bin4'); make_file('../stow/pkg4/bin4/file4'); -make_link('bin4/file4', '../../stow/pkg4/bin4/does-not-exist'); +make_invalid_link('bin4/file4', '../../stow/pkg4/bin4/does-not-exist'); $stow->plan_unstow('pkg4'); $stow->process_tasks(); @@ -103,7 +103,7 @@ ok( $stow = new_Stow(); make_dir('../stow/pkg5/bin5'); -make_link('bin5', '../not-stow'); +make_invalid_link('bin5', '../not-stow'); $stow->plan_unstow('pkg5'); %conflicts = $stow->get_conflicts; diff --git a/t/unstow_orig.t b/t/unstow_orig.t index ef04459..d91b775 100755 --- a/t/unstow_orig.t +++ b/t/unstow_orig.t @@ -88,7 +88,7 @@ $stow = new_compat_Stow(); make_dir('bin4'); make_dir('../stow/pkg4/bin4'); make_file('../stow/pkg4/bin4/file4'); -make_link('bin4/file4', '../../stow/pkg4/bin4/does-not-exist'); +make_invalid_link('bin4/file4', '../../stow/pkg4/bin4/does-not-exist'); $stow->plan_unstow('pkg4'); $stow->process_tasks(); @@ -104,7 +104,7 @@ ok( $stow = new_compat_Stow(); make_dir('../stow/pkg5/bin5'); -make_link('bin5', '../not-stow'); +make_invalid_link('bin5', '../not-stow'); $stow->plan_unstow('pkg5'); # Unlike the corresponding stow_contents.t test, this doesn't From a127d22457f11e67aab623b22fa19add83da598f Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Sat, 18 Feb 2012 20:12:14 +0000 Subject: [PATCH 174/482] Improve error message when package is not found. --- NEWS | 6 ++++++ lib/Stow.pm.in | 12 +++++++----- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/NEWS b/NEWS index 4ccd179..2f4f87e 100644 --- a/NEWS +++ b/NEWS @@ -2,6 +2,12 @@ News file for Stow. * Changes in version 2.1.4 +** Improve error message when stow package is not found. + + The error message displayed a path to the missing stow package + which was relative to the target directory rather than the cwd, + which was confusing for the user. + ** Test suite improvements The test suite has been tightened up slightly. diff --git a/lib/Stow.pm.in b/lib/Stow.pm.in index 4479b6a..7ef1828 100755 --- a/lib/Stow.pm.in +++ b/lib/Stow.pm.in @@ -248,8 +248,9 @@ sub plan_unstow { $self->within_target_do(sub { for my $package (@packages) { - if (not -d join_paths($self->{stow_path}, $package)) { - error("The stow directory $self->{dir} does not contain package $package"); + my $path = join_paths($self->{stow_path}, $package); + if (not -d $path) { + error("The stow directory $self->{stow_path} does not contain package $package"); } debug(2, "Planning unstow of package $package..."); if ($self->{compat}) { @@ -286,15 +287,16 @@ sub plan_stow { $self->within_target_do(sub { for my $package (@packages) { - if (not -d join_paths($self->{stow_path}, $package)) { - error("The stow directory $self->{dir} does not contain package $package"); + my $path = join_paths($self->{stow_path}, $package); + if (not -d $path) { + error("The stow directory $self->{stow_path} does not contain package $package"); } debug(2, "Planning stow of package $package..."); $self->stow_contents( $self->{stow_path}, $package, '.', - join_paths($self->{stow_path}, $package), # source from target + $path, # source from target ); debug(2, "Planning stow of package $package... done"); $self->{action_count}++; From 17d3586e842f0fae5ce9c3783eaf0959cfa005fc Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Sat, 18 Feb 2012 14:20:07 +0000 Subject: [PATCH 175/482] Remove -a option for safety reasons (but keep --adopt). --- NEWS | 9 +++++++++ bin/stow.in | 6 ++---- doc/stow.texi | 3 +-- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/NEWS b/NEWS index 2f4f87e..8cfd33a 100644 --- a/NEWS +++ b/NEWS @@ -2,6 +2,15 @@ News file for Stow. * Changes in version 2.1.4 +** Remove -a option (--adopt still available) + + As --adopt is the only option which allows stow to modify files, it + is considered potentially dangerous (especially for stow package + directories which are not managed by a version control system). + Therefore it seems prudent to require a bit more effort from the + user to enable this option, minimising the change of enabling it + via a typo. + ** Improve error message when stow package is not found. The error message displayed a path to the missing stow package diff --git a/bin/stow.in b/bin/stow.in index ca91955..45bc0f0 100755 --- a/bin/stow.in +++ b/bin/stow.in @@ -180,8 +180,6 @@ Restow packages (first unstow, then stow again). This is useful for pruning obsolete symlinks from the target tree after updating the software in a package. -=item -a - =item --adopt B This behaviour is specifically intended to alter the @@ -478,7 +476,7 @@ sub process_options { \%options, 'verbose|v:+', 'help|h', 'simulate|n|no', 'version|V', 'compat|p', 'dir|d=s', 'target|t=s', - 'adopt|a', + 'adopt', # clean and pre-compile any regex's at parse time 'ignore=s' => @@ -631,7 +629,7 @@ OPTIONS: if the file is already stowed to another package --override=REGEX Force stowing files beginning with this Perl regex if the file is already stowed to another package - -a, --adopt (Use with care!) Import existing files into stow package + --adopt (Use with care!) Import existing files into stow package from target. Please read docs before using. -p, --compat Use legacy algorithm for unstowing diff --git a/doc/stow.texi b/doc/stow.texi index 3576f1a..2d042c3 100644 --- a/doc/stow.texi +++ b/doc/stow.texi @@ -328,8 +328,7 @@ The regular expression is anchored to the beginning of the path relative to the target directory, because this is what you will want to do most of the time. @cindex adopting existing files -@item -a -@itemx --adopt +@item --adopt @strong{Warning!} This behaviour is specifically intended to alter the contents of your stow directory. If you do not want that, this option is not for you. From ed12c787df985896c8ba1c188af45b9fb637b017 Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Sat, 18 Feb 2012 20:13:32 +0000 Subject: [PATCH 176/482] Add --no-folding option. --- NEWS | 5 +++ bin/stow.in | 7 +++- doc/stow.texi | 32 +++++++++++---- lib/Stow.pm.in | 36 ++++++++++++----- t/stow.t | 108 ++++++++++++++++++++++++++++++++++++++++++++++--- t/testutil.pm | 37 +++++++++++++++++ t/unstow.t | 85 +++++++++++++++++++++++++++++++++++++- 7 files changed, 285 insertions(+), 25 deletions(-) diff --git a/NEWS b/NEWS index 8cfd33a..81be11e 100644 --- a/NEWS +++ b/NEWS @@ -2,6 +2,11 @@ News file for Stow. * Changes in version 2.1.4 +** New --no-folding option + + Disables folding of newly stowed directories when stowing, and + refolding of newly foldable directories when unstowing. + ** Remove -a option (--adopt still available) As --adopt is the only option which allows stow to modify files, it diff --git a/bin/stow.in b/bin/stow.in index 45bc0f0..8d70f76 100755 --- a/bin/stow.in +++ b/bin/stow.in @@ -195,6 +195,11 @@ stow directory, and then stowing proceeds as before. So effectively, the file becomes adopted by the stow package, without its contents changing. +=item --no-folding + +Disable folding of newly stowed directories when stowing, and +refolding of newly foldable directories when unstowing. + =item --ignore=REGEX Ignore files ending in this Perl regex. @@ -476,7 +481,7 @@ sub process_options { \%options, 'verbose|v:+', 'help|h', 'simulate|n|no', 'version|V', 'compat|p', 'dir|d=s', 'target|t=s', - 'adopt', + 'adopt', 'no-folding', # clean and pre-compile any regex's at parse time 'ignore=s' => diff --git a/doc/stow.texi b/doc/stow.texi index 2d042c3..d3b4423 100644 --- a/doc/stow.texi +++ b/doc/stow.texi @@ -327,6 +327,16 @@ pages that are owned by stow and would otherwise cause a conflict. The regular expression is anchored to the beginning of the path relative to the target directory, because this is what you will want to do most of the time. +@item --no-folding + +This disables any further @ref{tree folding} or @ref{tree refolding}. +If a new subdirectory is encountered whilst stowing a new package, the +subdirectory is created within the target, and its contents are +symlinked, rather than just creating a symlink for the directory. If +removal of symlinks whilst unstowing a package causes a subtree to be +foldable (i.e. only containing symlinks to a single package), that +subtree will not be removed and replaced with a symlink. + @cindex adopting existing files @item --adopt @strong{Warning!} This behaviour is specifically intended to alter the @@ -606,7 +616,8 @@ and it will descend into @file{/usr/local/lib} and create the tree-folding symlink @file{perl} pointing to @file{../stow/perl/lib/perl}, and so on. As a rule, Stow only descends as far as necessary into the target tree when it can create a -tree-folding symlink. +tree-folding symlink. However, this behaviour can be changed via +the @option{--no-folding} option; @pxref{Invoking Stow}. @anchor{Tree unfolding} @section Tree unfolding @@ -681,13 +692,20 @@ directory and a @file{man} directory at the top level, then we only scan @file{/usr/local/lib} or @file{/usr/local/share}, or for that matter @file{/usr/local/stow}. Any symlink it finds that points into the package being deleted is removed. Any directory that contained only symlinks to the -package being deleted is removed. Any directory that, after removing symlinks -and empty subdirectories, contains only symlinks to a single other package, is -considered to be a previously ``folded'' tree that was ``split open.'' Stow -will re-fold the tree by removing the symlinks to the surviving package, -removing the directory, then linking the directory back to the surviving -package. +package being deleted is removed. +@anchor{tree refolding} +@section Refolding ``foldable'' trees. +@cindex refolding trees +@cindex tree refolding + +After removing symlinks and empty subdirectories, any directory that +contains only symlinks to a single other package is considered to be a +previously ``folded'' tree that was ``split open.'' Stow will refold +the tree by removing the symlinks to the surviving package, removing +the directory, then linking the directory back to the surviving +package. However, this behaviour can be prevented via the +@option{--no-folding} option; @pxref{Invoking Stow}. @c =========================================================================== @node Conflicts, Mixing Operations, Deleting Packages, Top diff --git a/lib/Stow.pm.in b/lib/Stow.pm.in index 7ef1828..101a422 100755 --- a/lib/Stow.pm.in +++ b/lib/Stow.pm.in @@ -54,16 +54,17 @@ our @default_global_ignore_regexps = # These are the default options for each Stow instance. our %DEFAULT_OPTIONS = ( - conflicts => 0, - simulate => 0, - verbose => 0, - paranoid => 0, - compat => 0, - test_mode => 0, - adopt => 0, - ignore => [], - override => [], - defer => [], + conflicts => 0, + simulate => 0, + verbose => 0, + paranoid => 0, + compat => 0, + test_mode => 0, + adopt => 0, + 'no-folding' => 0, + ignore => [], + override => [], + defer => [], ); =head1 CONSTRUCTORS @@ -100,6 +101,8 @@ See the documentation for the F CLI front-end for information on these. =item * adopt +=item * no-folding + =item * ignore =item * override @@ -517,6 +520,15 @@ sub stow_node { } } } + elsif ($self->{'no-folding'} && -d $path) { + $self->do_mkdir($target); + $self->stow_contents( + $self->{stow_path}, + $package, + $target, + join_paths('..', $source), + ); + } else { $self->do_link($source, $target); } @@ -994,6 +1006,10 @@ sub foldable { my ($target) = @_; debug(3, "--- Is $target foldable?"); + if ($self->{'no-folding'}) { + debug(3, "--- no because --no-folding enabled"); + return ''; + } opendir my $DIR, $target or error(qq{Cannot read directory "$target" ($!)\n}); diff --git a/t/stow.t b/t/stow.t index 0786d18..ccad54d 100755 --- a/t/stow.t +++ b/t/stow.t @@ -7,7 +7,7 @@ use strict; use warnings; -use Test::More tests => 35; +use Test::More tests => 111; use Test::Output; use English qw(-no_match_vars); @@ -32,7 +32,7 @@ make_file('../stow/pkg1/bin1/file1'); $stow->plan_stow('pkg1'); $stow->process_tasks(); -is($stow->get_conflicts(), 0, 'no conflicts with minimal stow'); +is_deeply([ $stow->get_conflicts ], [], 'no conflicts with minimal stow'); is( readlink('bin1'), '../stow/pkg1/bin1', @@ -387,7 +387,7 @@ make_file("$OUT_DIR/stow/pkg16/bin16/file16"); $stow->plan_stow('pkg16'); $stow->process_tasks(); -is($stow->get_conflicts(), 0, 'no conflicts with minimal stow'); +is_deeply([ $stow->get_conflicts ], [], 'no conflicts with minimal stow'); is( readlink("$OUT_DIR/target/bin16"), '../stow/pkg16/bin16', @@ -406,7 +406,7 @@ make_file("$OUT_DIR/stow/pkg17/bin17/file17"); $stow->plan_stow('pkg17'); $stow->process_tasks(); -is($stow->get_conflicts(), 0, 'no conflicts with minimal stow'); +is_deeply([ $stow->get_conflicts ], [], 'no conflicts with minimal stow'); is( readlink("$OUT_DIR/target/bin17"), '../stow/pkg17/bin17', @@ -425,10 +425,108 @@ make_file("$OUT_DIR/stow/pkg18/bin18/file18"); $stow->plan_stow('pkg18'); $stow->process_tasks(); -is($stow->get_conflicts(), 0, 'no conflicts with minimal stow'); +is_deeply([ $stow->get_conflicts ], [], 'no conflicts with minimal stow'); is( readlink("$OUT_DIR/target/bin18"), '../stow/pkg18/bin18', => "minimal stow of a simple tree with absolute stow and target dirs" ); +# +# stow a tree with no-folding enabled - +# no new folded directories should be created, and existing +# folded directories should be split open (unfolded) where +# (and only where) necessary +# +cd("$OUT_DIR/target"); + +sub create_pkg { + my ($id, $pkg) = @_; + + my $stow_pkg = "../stow/$id-$pkg"; + make_dir ($stow_pkg); + make_file("$stow_pkg/$id-file-$pkg"); + + # create a shallow hierarchy specific to this package which isn't + # yet stowed + make_dir ("$stow_pkg/$id-$pkg-only-new"); + make_file("$stow_pkg/$id-$pkg-only-new/$id-file-$pkg"); + + # create a deeper hierarchy specific to this package which isn't + # yet stowed + make_dir ("$stow_pkg/$id-$pkg-only-new2/subdir"); + make_file("$stow_pkg/$id-$pkg-only-new2/subdir/$id-file-$pkg"); + + # create a hierarchy specific to this package which is already + # stowed via a folded tree + make_dir ("$stow_pkg/$id-$pkg-only-old"); + make_link("$id-$pkg-only-old", "$stow_pkg/$id-$pkg-only-old"); + make_file("$stow_pkg/$id-$pkg-only-old/$id-file-$pkg"); + + # create a shared hierarchy which this package uses + make_dir ("$stow_pkg/$id-shared"); + make_file("$stow_pkg/$id-shared/$id-file-$pkg"); + + # create a partially shared hierarchy which this package uses + make_dir ("$stow_pkg/$id-shared2/subdir-$pkg"); + make_file("$stow_pkg/$id-shared2/$id-file-$pkg"); + make_file("$stow_pkg/$id-shared2/subdir-$pkg/$id-file-$pkg"); +} + +foreach my $pkg (qw{a b}) { + create_pkg('no-folding', $pkg); +} + +$stow = new_Stow('no-folding' => 1); +$stow->plan_stow('no-folding-a'); +is_deeply([ $stow->get_conflicts ], [] => 'no conflicts with --no-folding'); +my @tasks = $stow->get_tasks; +use Data::Dumper; +is(scalar(@tasks), 12 => "6 dirs, 6 links") || warn Dumper(\@tasks); +$stow->process_tasks(); + +sub check_no_folding { + my ($pkg) = @_; + my $stow_pkg = "../stow/no-folding-$pkg"; + is_link("no-folding-file-$pkg", "$stow_pkg/no-folding-file-$pkg"); + + # check existing folded tree is untouched + is_link("no-folding-$pkg-only-old", "$stow_pkg/no-folding-$pkg-only-old"); + + # check newly stowed shallow tree is not folded + is_dir_not_symlink("no-folding-$pkg-only-new"); + is_link("no-folding-$pkg-only-new/no-folding-file-$pkg", + "../$stow_pkg/no-folding-$pkg-only-new/no-folding-file-$pkg"); + + # check newly stowed deeper tree is not folded + is_dir_not_symlink("no-folding-$pkg-only-new2"); + is_dir_not_symlink("no-folding-$pkg-only-new2/subdir"); + is_link("no-folding-$pkg-only-new2/subdir/no-folding-file-$pkg", + "../../$stow_pkg/no-folding-$pkg-only-new2/subdir/no-folding-file-$pkg"); + + # check shared tree is not folded. first time round this will be + # newly stowed. + is_dir_not_symlink('no-folding-shared'); + is_link("no-folding-shared/no-folding-file-$pkg", + "../$stow_pkg/no-folding-shared/no-folding-file-$pkg"); + + # check partially shared tree is not folded. first time round this + # will be newly stowed. + is_dir_not_symlink('no-folding-shared2'); + is_link("no-folding-shared2/no-folding-file-$pkg", + "../$stow_pkg/no-folding-shared2/no-folding-file-$pkg"); + is_link("no-folding-shared2/no-folding-file-$pkg", + "../$stow_pkg/no-folding-shared2/no-folding-file-$pkg"); +} + +check_no_folding('a'); + +$stow = new_Stow('no-folding' => 1); +$stow->plan_stow('no-folding-b'); +is_deeply([ $stow->get_conflicts ], [] => 'no conflicts with --no-folding'); +@tasks = $stow->get_tasks; +is(scalar(@tasks), 10 => '4 dirs, 6 links') || warn Dumper(\@tasks); +$stow->process_tasks(); + +check_no_folding('a'); +check_no_folding('b'); diff --git a/t/testutil.pm b/t/testutil.pm index 9e4573b..b9359be 100755 --- a/t/testutil.pm +++ b/t/testutil.pm @@ -13,6 +13,7 @@ use Carp qw(croak); use File::Basename; use File::Path qw(remove_tree); use File::Spec; +use Test::More; use Stow; use Stow::Util qw(parent canon_path); @@ -26,6 +27,7 @@ our @EXPORT = qw( make_dir make_link make_invalid_link make_file remove_dir remove_link cat_file + is_link is_dir_not_symlink is_nonexistent_path ); our $OUT_DIR = 'tmp-testing-trees'; @@ -254,6 +256,41 @@ sub cat_file { return $contents; } +#===== SUBROUTINE =========================================================== +# Name : is_link() +# Purpose : assert path is a symlink +# Parameters: $path => path to check +# : $dest => target symlink should point to +#============================================================================ +sub is_link { + my ($path, $dest) = @_; + ok(-l $path => "$path should be symlink"); + is(readlink $path, $dest => "$path symlinks to $dest"); +} + +#===== SUBROUTINE =========================================================== +# Name : is_dir_not_symlink() +# Purpose : assert path is a directory not a symlink +# Parameters: $path => path to check +#============================================================================ +sub is_dir_not_symlink { + my ($path) = @_; + ok(! -l $path => "$path should not be symlink"); + ok(-d _ => "$path should be a directory"); +} + +#===== SUBROUTINE =========================================================== +# Name : is_nonexistent_path() +# Purpose : assert path does not exist +# Parameters: $path => path to check +#============================================================================ +sub is_nonexistent_path { + my ($path) = @_; + ok(! -l $path => "$path should not be symlink"); + ok(! -e _ => "$path should not exist"); +} + + 1; # Local variables: diff --git a/t/unstow.t b/t/unstow.t index bf46bfa..d166107 100755 --- a/t/unstow.t +++ b/t/unstow.t @@ -7,7 +7,7 @@ use strict; use warnings; -use Test::More tests => 23; +use Test::More tests => 38; use Test::Output; use English qw(-no_match_vars); @@ -341,8 +341,89 @@ ok( => 'unstow a simple tree with absolute stow and target dirs' ); +# +# unstow a tree with no-folding enabled - +# no refolding should take place +# +cd("$OUT_DIR/target"); + +sub create_and_stow_pkg { + my ($id, $pkg) = @_; + + my $stow_pkg = "../stow/$id-$pkg"; + make_dir ($stow_pkg); + make_file("$stow_pkg/$id-file-$pkg"); + + # create a shallow hierarchy specific to this package and stow + # via folding + make_dir ("$stow_pkg/$id-$pkg-only-folded"); + make_file("$stow_pkg/$id-$pkg-only-folded/file-$pkg"); + make_link("$id-$pkg-only-folded", "$stow_pkg/$id-$pkg-only-folded"); + + # create a deeper hierarchy specific to this package and stow + # via folding + make_dir ("$stow_pkg/$id-$pkg-only-folded2/subdir"); + make_file("$stow_pkg/$id-$pkg-only-folded2/subdir/file-$pkg"); + make_link("$id-$pkg-only-folded2", + "$stow_pkg/$id-$pkg-only-folded2"); + + # create a shallow hierarchy specific to this package and stow + # without folding + make_dir ("$stow_pkg/$id-$pkg-only-unfolded"); + make_file("$stow_pkg/$id-$pkg-only-unfolded/file-$pkg"); + make_dir ("$id-$pkg-only-unfolded"); + make_link("$id-$pkg-only-unfolded/file-$pkg", + "../$stow_pkg/$id-$pkg-only-unfolded/file-$pkg"); + + # create a deeper hierarchy specific to this package and stow + # without folding + make_dir ("$stow_pkg/$id-$pkg-only-unfolded2/subdir"); + make_file("$stow_pkg/$id-$pkg-only-unfolded2/subdir/file-$pkg"); + make_dir ("$id-$pkg-only-unfolded2/subdir"); + make_link("$id-$pkg-only-unfolded2/subdir/file-$pkg", + "../../$stow_pkg/$id-$pkg-only-unfolded2/subdir/file-$pkg"); + + # create a shallow shared hierarchy which this package uses, and stow + # its contents without folding + make_dir ("$stow_pkg/$id-shared"); + make_file("$stow_pkg/$id-shared/file-$pkg"); + make_dir ("$id-shared"); + make_link("$id-shared/file-$pkg", + "../$stow_pkg/$id-shared/file-$pkg"); + + # create a deeper shared hierarchy which this package uses, and stow + # its contents without folding + make_dir ("$stow_pkg/$id-shared2/subdir"); + make_file("$stow_pkg/$id-shared2/file-$pkg"); + make_file("$stow_pkg/$id-shared2/subdir/file-$pkg"); + make_dir ("$id-shared2/subdir"); + make_link("$id-shared2/file-$pkg", + "../$stow_pkg/$id-shared2/file-$pkg"); + make_link("$id-shared2/subdir/file-$pkg", + "../../$stow_pkg/$id-shared2/subdir/file-$pkg"); +} + +foreach my $pkg (qw{a b}) { + create_and_stow_pkg('no-folding', $pkg); +} + +$stow = new_Stow('no-folding' => 1); +$stow->plan_unstow('no-folding-b'); +is_deeply([ $stow->get_conflicts ], [] => 'no conflicts with --no-folding'); +use Data::Dumper; +#warn Dumper($stow->get_tasks); + +$stow->process_tasks(); + +is_nonexistent_path('no-folding-b-only-folded'); +is_nonexistent_path('no-folding-b-only-folded2'); +is_nonexistent_path('no-folding-b-only-unfolded/file-b'); +is_nonexistent_path('no-folding-b-only-unfolded2/subdir/file-b'); +is_dir_not_symlink('no-folding-shared'); +is_dir_not_symlink('no-folding-shared2'); +is_dir_not_symlink('no-folding-shared2/subdir'); + # Todo # # Test cleaning up subdirs with --paranoid option - From 4cd91ed54c0e016e215acf496120df6897743a7b Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Sat, 18 Feb 2012 17:08:19 +0000 Subject: [PATCH 177/482] Bump version to 2.2.0 --- META.json | 4 ++-- META.yml | 4 ++-- NEWS | 2 +- configure.ac | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/META.json b/META.json index 5a1a247..227736e 100644 --- a/META.json +++ b/META.json @@ -36,7 +36,7 @@ "provides" : { "Stow" : { "file" : "lib/Stow.pm", - "version" : "v2.1.3" + "version" : "v2.2.0" }, "Stow::Util" : { "file" : "lib/Stow/Util.pm", @@ -53,5 +53,5 @@ "url" : "git://git.savannah.gnu.org/stow.git" } }, - "version" : "v2.1.3" + "version" : "v2.2.0" } diff --git a/META.yml b/META.yml index 789e6c4..c8f1285 100644 --- a/META.yml +++ b/META.yml @@ -17,7 +17,7 @@ name: Stow provides: Stow: file: lib/Stow.pm - version: v2.1.3 + version: v2.2.0 Stow::Util: file: lib/Stow/Util.pm version: 0 @@ -29,4 +29,4 @@ resources: homepage: https://savannah.gnu.org/projects/stow license: http://www.gnu.org/licenses/gpl-2.0.html repository: git://git.savannah.gnu.org/stow.git -version: v2.1.3 +version: v2.2.0 diff --git a/NEWS b/NEWS index 81be11e..92c83a6 100644 --- a/NEWS +++ b/NEWS @@ -1,6 +1,6 @@ News file for Stow. -* Changes in version 2.1.4 +* Changes in version 2.2.0 ** New --no-folding option diff --git a/configure.ac b/configure.ac index 2339480..2d55081 100644 --- a/configure.ac +++ b/configure.ac @@ -1,6 +1,6 @@ dnl Process this file with Autoconf to produce configure dnl -AC_INIT([stow], [2.1.3], [bug-stow@gnu.org]) +AC_INIT([stow], [2.2.0], [bug-stow@gnu.org]) AC_PREREQ([2.61]) AC_CONFIG_AUX_DIR([automake]) # Unfortunately we have to disable warnings for overrides, because we From 50d28a43061f8895deebbc84addd1630d4d0b039 Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Sat, 18 Feb 2012 20:43:20 +0000 Subject: [PATCH 178/482] Add boilerplate commit message for web docs update. --- doc/HOWTO-RELEASE | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/HOWTO-RELEASE b/doc/HOWTO-RELEASE index 06eb4db..1837f0a 100644 --- a/doc/HOWTO-RELEASE +++ b/doc/HOWTO-RELEASE @@ -64,7 +64,7 @@ How to make a new release of GNU Stow # Check that the changes look OK cvs diff # Then commit - cvs commit + cvs commit -m 'Update manual to v7.8.9' - Run ./Build dist From 037ce9ee8a69b30fd22b73b5e68071a369171b38 Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Sun, 19 Feb 2012 01:42:04 +0000 Subject: [PATCH 179/482] Add a few more items to index. --- doc/stow.texi | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/doc/stow.texi b/doc/stow.texi index d3b4423..c2d4f07 100644 --- a/doc/stow.texi +++ b/doc/stow.texi @@ -711,6 +711,7 @@ package. However, this behaviour can be prevented via the @node Conflicts, Mixing Operations, Deleting Packages, Top @chapter Conflicts +@cindex conflicts If, during installation, a file or symlink exists in the target tree and has the same name as something Stow needs to create, and if the existing name is not a folded tree that can be split open, then a @@ -728,6 +729,7 @@ take into account all of these operations. @anchor{Deferred Operation} @section Deferred Operation +@cindex deferred operation Since version 2.0, Stow now adopts a two-phase algorithm, first scanning for any potential conflicts before any stowing or unstowing @@ -743,6 +745,7 @@ inconsistent state. @c =========================================================================== @node Mixing Operations, Multiple Stow Directories, Conflicts, Top @chapter Mixing Operations +@cindex mixing operations Since version 2.0, multiple distinct actions can be specified in a single invocation of GNU Stow. For example, to update an installation of Emacs from @@ -755,6 +758,7 @@ stow -D emacs-21.3 -S emacs-21.4a @noindent which will replace emacs-21.3 with emacs-21.4a using a single invocation. +@cindex deferred operation This is much faster and cleaner than performing two separate invocations of stow, because redundant folding/unfolding operations can be factored out. In addition, all the operations are calculated @@ -796,6 +800,7 @@ open the tree in the correct manner. @node Target Maintenance, Resource Files, Multiple Stow Directories, Top @chapter Target Maintenance +@cindex maintenance From time to time you will need to clean up your target tree. Since version 2, Stow provides a new utility @command{chkstow} to help with this. It includes three operational modes which performs checks that From db784f0a5f34efaa20d1aa21c281f18ffb0bb682 Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Sun, 19 Feb 2012 01:42:10 +0000 Subject: [PATCH 180/482] Fix typo in manual. --- doc/stow.texi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/stow.texi b/doc/stow.texi index c2d4f07..52b1821 100644 --- a/doc/stow.texi +++ b/doc/stow.texi @@ -881,7 +881,7 @@ was only used for Perl modules, then you might place the following in --ignore='\.bs' @end example -so that the when your are in the @file{/usr/local/stow/perl-extras} +so that when you are in the @file{/usr/local/stow/perl-extras} directory, @command{stow} will regard any subdirectories as stow packages, with @file{/usr/local} as the target (rather than the immediate parent directory @file{/usr/local/stow}), overriding any From 1517384e53d97adc8950ec18a7e04ff0d07f3bf3 Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Sun, 19 Feb 2012 11:54:53 +0000 Subject: [PATCH 181/482] Improve docs for path_owned_by_package() --- lib/Stow.pm.in | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/Stow.pm.in b/lib/Stow.pm.in index 101a422..fc24f4f 100755 --- a/lib/Stow.pm.in +++ b/lib/Stow.pm.in @@ -881,7 +881,9 @@ sub path_owned_by_package { # : might not exist yet due to two-phase approach, # : so we can't just call readlink()) # Returns : ($path, $stow_path, $package) where $path and $stow_path are -# : relative from the current (i.e. target) directory +# : relative from the current (i.e. target) directory. $path +# : is the full relative path, $stow_path is the relative path +# : to the stow directory, and $package is the name of the package. # : or ('', '', '') if link is not owned by stow # Throws : n/a # Comments : Needs From af36a44bcbc214d4aa85d2df819e1ae569230aa4 Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Sun, 19 Feb 2012 19:15:48 +0000 Subject: [PATCH 182/482] Remove accidentally duplicated code. --- t/examples.t | 7 ------- 1 file changed, 7 deletions(-) diff --git a/t/examples.t b/t/examples.t index 7320ed5..b784592 100755 --- a/t/examples.t +++ b/t/examples.t @@ -42,13 +42,6 @@ make_file('stow/emacs/man/man1/emacs.1'); # # stow perl into an empty target # -make_dir('stow/perl/bin'); -make_file('stow/perl/bin/perl'); -make_file('stow/perl/bin/a2p'); -make_dir('stow/perl/info'); -make_dir('stow/perl/lib/perl'); -make_dir('stow/perl/man/man1'); -make_file('stow/perl/man/man1/perl.1'); $stow = new_Stow(dir => 'stow'); $stow->plan_stow('perl'); From b6f9ef2b2fb4ce11a28ec389dd620ede52ed948d Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Thu, 1 Mar 2012 11:40:34 +0000 Subject: [PATCH 183/482] Revamp README. --- README | 68 ++++++++++++++++++++++++++++++++++++++++------------------ 1 file changed, 47 insertions(+), 21 deletions(-) diff --git a/README b/README index a2b934b..d8df705 100644 --- a/README +++ b/README @@ -1,27 +1,53 @@ -This is GNU Stow, a program for managing the installation of software -packages, keeping them separate (/usr/local/stow/emacs vs. -/usr/local/stow/perl, for example) while making them appear to be -installed in the same place (/usr/local). Stow doesn't store an extra -state between runs, so there's no danger of mangling directories when -file hierarchies don't match the database. Also, stow will never -delete any files, directories, or links that appear in a stow -directory, so it is always possible to rebuild the target tree. +README for GNU Stow +=================== + +This is GNU Stow, a symlink farm manager program which takes distinct +packages of software and/or data located in separate directories on +the filesystem, and makes them appear to be installed in the same +place. For example, /usr/local/bin could contain symlinks to files +within /usr/local/stow/emacs/bin, /usr/local/stow/perl/bin etc., and +likewise recursively for any other subdirectories such as .../share, +.../man, and so on. + +This is particularly useful for keeping track of system-wide and +per-user installations of software built from source, but can also +facilitate a more controlled approach to management of configuration +files in the user's home directory, especially when coupled with +version control systems. + +Stow is implemented as a combination of a Perl script providing a CLI +interface, and a backend Perl module which does most of the work. + +You can get the latest information about Stow from the home page: + + http://www.gnu.org/software/stow/ + +License +------- + +Stow is free software, licensed under the GNU General Public License, +which can be found in the file COPYING. + +Installation +------------ See INSTALL for installation instructions. -You can get the latest information about Stow from -http://www.gnu.org/software/stow/stow.html +Feedback +-------- -Stow was inspired by Carnegie Mellon's "Depot" program, but is substantially -simpler. Whereas Depot requires database files to keep things in sync, Stow -stores no extra state between runs, so there's no danger (as there is in -Depot) of mangling directories when file hierarchies don't match the database. -Also unlike Depot, Stow will never delete any files, directories, or links -that appear in a Stow directory (e.g., /usr/local/stow/emacs), so it's always -possible to rebuild the target tree (e.g., /usr/local). +Please do send comments, questions, and constructive criticism. The +mailing lists and any other communication channels are detailed on the +above home page. -Stow is free software, licensed under the GNU General Public License, which -can be found in the file COPYING. +Brief history +------------- -Please mail comments, questions, and criticisms to the current maintainers -via help-stow@gnu.org or bug-stow@gnu.org. +Stow was inspired by Carnegie Mellon's "Depot" program, but is +substantially simpler. Whereas Depot requires database files to keep +things in sync, Stow stores no extra state between runs, so there's no +danger (as there is in Depot) of mangling directories when file +hierarchies don't match the database. Also unlike Depot, Stow will +never delete any files, directories, or links that appear in a Stow +directory (e.g., /usr/local/stow/emacs), so it's always possible to +rebuild the target tree (e.g., /usr/local). From db7819dbf217c351527348c578ddf5be05333484 Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Wed, 16 May 2012 11:00:38 +0100 Subject: [PATCH 184/482] Bug #36478 - fix Perl warnings from 'require 5.6.1;' https://savannah.gnu.org/bugs/?36478 --- bin/chkstow.in | 2 +- bin/stow.in | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/bin/chkstow.in b/bin/chkstow.in index 07e18f1..c35ba26 100755 --- a/bin/chkstow.in +++ b/bin/chkstow.in @@ -3,7 +3,7 @@ use strict; use warnings; -require 5.6.1; +require 5.006_001; use File::Find; use Getopt::Long; diff --git a/bin/stow.in b/bin/stow.in index 8d70f76..e8fa64b 100755 --- a/bin/stow.in +++ b/bin/stow.in @@ -409,7 +409,7 @@ translation approved by the Free Software Foundation. use strict; use warnings; -require 5.6.1; +require 5.006_001; use POSIX qw(getcwd); use Getopt::Long; From 67936bd7de13713a38d11880f685f6187c408dc4 Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Mon, 9 Jul 2012 01:05:27 +0100 Subject: [PATCH 185/482] Fix RT ticket #75349 https://rt.cpan.org/Ticket/Display.html?id=75349 --- bin/stow.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/stow.in b/bin/stow.in index e8fa64b..5263fe8 100755 --- a/bin/stow.in +++ b/bin/stow.in @@ -416,7 +416,7 @@ use Getopt::Long; @USE_LIB_PMDIR@ use Stow; -use Stow::Util qw(parent); +use Stow::Util qw(parent error); my $ProgramName = $0; $ProgramName =~ s{.*/}{}; From 8ccef0760156b1f394294e726462e683f1015904 Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Mon, 9 Jul 2012 01:06:13 +0100 Subject: [PATCH 186/482] Only include $! in error messages for failed syscalls. --- lib/Stow.pm.in | 26 +++++++++++++------------- lib/Stow/Util.pm | 2 +- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/lib/Stow.pm.in b/lib/Stow.pm.in index fc24f4f..931740f 100755 --- a/lib/Stow.pm.in +++ b/lib/Stow.pm.in @@ -323,7 +323,7 @@ sub within_target_do { my $cwd = getcwd(); chdir($self->{target}) - or error("Cannot chdir to target tree: $self->{target}"); + or error("Cannot chdir to target tree: $self->{target} ($!)"); debug(3, "cwd now $self->{target}"); $self->$code(); @@ -367,7 +367,7 @@ sub stow_contents { unless $self->is_a_node($target); opendir my $DIR, $path - or error("cannot read directory: $path"); + or error("cannot read directory: $path ($!)"); my @listing = readdir $DIR; closedir $DIR; @@ -607,7 +607,7 @@ sub unstow_contents_orig { unless -d $target; opendir my $DIR, $target - or error("cannot read directory: $target"); + or error("cannot read directory: $target ($!)"); my @listing = readdir $DIR; closedir $DIR; @@ -734,7 +734,7 @@ sub unstow_contents { unless $self->is_a_node($target); opendir my $DIR, $path - or error("cannot read directory: $path"); + or error("cannot read directory: $path ($!)"); my @listing = readdir $DIR; closedir $DIR; @@ -960,7 +960,7 @@ sub cleanup_invalid_links { } opendir my $DIR, $dir - or error("cannot read directory: $dir"); + or error("cannot read directory: $dir ($!)"); my @listing = readdir $DIR; closedir $DIR; @@ -1449,13 +1449,13 @@ sub process_task { if ($task->{action} eq 'create') { if ($task->{type} eq 'dir') { mkdir($task->{path}, 0777) - or error(qq(Could not create directory: $task->{path})); + or error("Could not create directory: $task->{path} ($!)"); return; } elsif ($task->{type} eq 'link') { symlink $task->{source}, $task->{path} or error( - q(Could not create symlink: %s => %s), + "Could not create symlink: %s => %s ($!)", $task->{path}, $task->{source} ); @@ -1465,12 +1465,12 @@ sub process_task { elsif ($task->{action} eq 'remove') { if ($task->{type} eq 'dir') { rmdir $task->{path} - or error(qq(Could not remove directory: $task->{path})); + or error("Could not remove directory: $task->{path} ($!)"); return; } elsif ($task->{type} eq 'link') { unlink $task->{path} - or error(qq(Could not remove link: $task->{path})); + or error("Could not remove link: $task->{path} ($!)"); return; } } @@ -1479,13 +1479,13 @@ sub process_task { # rename() not good enough, since the stow directory # might be on a different filesystem to the target. move $task->{path}, $task->{dest} - or error(qq(Could not move $task->{path} -> $task->{dest})); + or error("Could not move $task->{path} -> $task->{dest} ($!)"); return; } } # Should never happen. - internal_error(qq(bad task action: $task->{action})); + internal_error("bad task action: $task->{action}"); } #===== METHOD =============================================================== @@ -1735,7 +1735,7 @@ sub read_a_link { elsif (-l $path) { debug(4, " read_a_link($path): real link"); return readlink $path - or error("Could not read link: $path"); + or error("Could not read link: $path ($!)"); } internal_error("read_a_link() passed a non link path: $path\n"); } @@ -1859,7 +1859,7 @@ sub do_unlink { # Remove the link debug(1, "UNLINK: $file"); - my $source = readlink $file or error("could not readlink $file"); + my $source = readlink $file or error("could not readlink $file ($!)"); my $task = { action => 'remove', diff --git a/lib/Stow/Util.pm b/lib/Stow/Util.pm index 173f1ec..2b5bbdb 100644 --- a/lib/Stow/Util.pm +++ b/lib/Stow/Util.pm @@ -43,7 +43,7 @@ Outputs an error message in a consistent form and then dies. sub error { my ($format, @args) = @_; - die "$ProgramName: ERROR: " . sprintf($format, @args) . " ($!)\n"; + die "$ProgramName: ERROR: " . sprintf($format, @args) . "\n"; } =head2 set_debug_level($level) From fe5b65880327ec823ce425f3ed3313733193b665 Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Thu, 17 Jan 2013 12:25:43 +0000 Subject: [PATCH 187/482] default-ignore-list: ignore top-level README.*, LICENSE.*, and COPYING These files are by definition specific to a given package, so if they exist in the top-level directory, they should not be stowed. --- default-ignore-list | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/default-ignore-list b/default-ignore-list index 351480f..17bf13d 100644 --- a/default-ignore-list +++ b/default-ignore-list @@ -16,3 +16,7 @@ _darcs .+~ # emacs backup files \#.*\# # emacs autosave files + +^/README.* +^/LICENSE.* +^/COPYING From c500216f20b081fae0799253d1d86536d48ff6ba Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Fri, 12 Apr 2013 17:47:29 +0100 Subject: [PATCH 188/482] correctly handle the stow/target directories as non-canonical paths Fix the case discovered by Hiroyuki Iwatsuki where stowing fails if the stow / target directories are non-canonical paths. For example, on FreeBSD /home is a symlink pointing to 'usr/home', so running with the stow directory as /home/user/local/stow and the target directory as /home/user/local previously resulted in the stow directory path being calculated as ../../../usr/home/user/local/stow relative to the target. http://article.gmane.org/gmane.comp.gnu.stow.bugs/8820 --- lib/Stow.pm.in | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/Stow.pm.in b/lib/Stow.pm.in index 931740f..98ecf35 100755 --- a/lib/Stow.pm.in +++ b/lib/Stow.pm.in @@ -185,11 +185,11 @@ sub set_stow_dir { } my $stow_dir = canon_path($self->{dir}); - - $self->{stow_path} = File::Spec->abs2rel($stow_dir, $self->{target}); + my $target = canon_path($self->{target}); + $self->{stow_path} = File::Spec->abs2rel($stow_dir, $target); debug(2, "stow dir is $stow_dir"); - debug(2, "stow dir path relative to target $self->{target} is $self->{stow_path}"); + debug(2, "stow dir path relative to target $target is $self->{stow_path}"); } sub init_state { From 20d3759ac12db66dab2187f0ba7898c35a64ad1d Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Wed, 24 Apr 2013 08:44:32 +0100 Subject: [PATCH 189/482] add TODO for install-hooks --- TODO | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/TODO b/TODO index ecc84a1..e0ba300 100644 --- a/TODO +++ b/TODO @@ -1,3 +1,11 @@ +* Add support for pre/post-(un)install hooks + + This would allow correct handling of the Info dir file via + install-info, amongst other things: + +*** http://unix.stackexchange.com/questions/73426/dealing-with-gnu-stow-conflicts +*** http://article.gmane.org/gmane.comp.gnu.stow.general/6661 + * Next release should be under GPL v3 * Get permission for next documentation release to be under FDL 1.3 From d788ce0c1c59b3158270143659f7a4363da73056 Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Mon, 16 Jun 2014 10:22:55 +0100 Subject: [PATCH 190/482] avoid precedence warning With Perl 5.20, installing a package with stow gives a warning like this: Possible precedence issue with control flow operator at /gar/packages/stow-2.2.0/lib/perl5/site_perl/5.20.0/Stow.pm line 1736. http://lists.gnu.org/archive/html/bug-stow/2014-06/msg00000.html Suggested-by: Adam Sampson --- lib/Stow.pm.in | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/Stow.pm.in b/lib/Stow.pm.in index 98ecf35..948c7a6 100755 --- a/lib/Stow.pm.in +++ b/lib/Stow.pm.in @@ -1734,8 +1734,8 @@ sub read_a_link { } elsif (-l $path) { debug(4, " read_a_link($path): real link"); - return readlink $path - or error("Could not read link: $path ($!)"); + my $target = readlink $path or error("Could not read link: $path ($!)"); + return $target; } internal_error("read_a_link() passed a non link path: $path\n"); } From dda7c5a359206d8e7ae71cf59d2d5c9f9cb72333 Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Mon, 22 Sep 2014 00:14:56 +0100 Subject: [PATCH 191/482] update aclocal --- aclocal.m4 | 478 +++++++++++++++++++++++++++++++---------------------- 1 file changed, 284 insertions(+), 194 deletions(-) diff --git a/aclocal.m4 b/aclocal.m4 index 3052e91..7ea634c 100644 --- a/aclocal.m4 +++ b/aclocal.m4 @@ -1,7 +1,7 @@ -# generated automatically by aclocal 1.11.1 -*- Autoconf -*- +# generated automatically by aclocal 1.13.4 -*- Autoconf -*- + +# Copyright (C) 1996-2013 Free Software Foundation, Inc. -# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, -# 2005, 2006, 2007, 2008, 2009 Free Software Foundation, Inc. # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. @@ -11,15 +11,16 @@ # even the implied warranty of MERCHANTABILITY or FITNESS FOR A # PARTICULAR PURPOSE. +m4_ifndef([AC_CONFIG_MACRO_DIRS], [m4_defun([_AM_CONFIG_MACRO_DIRS], [])m4_defun([AC_CONFIG_MACRO_DIRS], [_AM_CONFIG_MACRO_DIRS($@)])]) m4_ifndef([AC_AUTOCONF_VERSION], [m4_copy([m4_PACKAGE_VERSION], [AC_AUTOCONF_VERSION])])dnl -m4_if(m4_defn([AC_AUTOCONF_VERSION]), [2.68],, -[m4_warning([this file was generated for autoconf 2.68. +m4_if(m4_defn([AC_AUTOCONF_VERSION]), [2.69],, +[m4_warning([this file was generated for autoconf 2.69. You have another version of autoconf. It may work, but is not guaranteed to. If you have problems, you may need to regenerate the build system entirely. -To do so, use the procedure documented by the package, typically `autoreconf'.])]) +To do so, use the procedure documented by the package, typically 'autoreconf'.])]) -# Copyright (C) 2002, 2003, 2005, 2006, 2007, 2008 Free Software Foundation, Inc. +# Copyright (C) 2002-2013 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -31,10 +32,10 @@ To do so, use the procedure documented by the package, typically `autoreconf'.]) # generated from the m4 files accompanying Automake X.Y. # (This private macro should not be called outside this file.) AC_DEFUN([AM_AUTOMAKE_VERSION], -[am__api_version='1.11' +[am__api_version='1.13' dnl Some users find AM_AUTOMAKE_VERSION and mistake it for a way to dnl require some minimum version. Point them to the right macro. -m4_if([$1], [1.11.1], [], +m4_if([$1], [1.13.4], [], [AC_FATAL([Do not call $0, use AM_INIT_AUTOMAKE([$1]).])])dnl ]) @@ -50,22 +51,22 @@ m4_define([_AM_AUTOCONF_VERSION], []) # Call AM_AUTOMAKE_VERSION and AM_AUTOMAKE_VERSION so they can be traced. # This function is AC_REQUIREd by AM_INIT_AUTOMAKE. AC_DEFUN([AM_SET_CURRENT_AUTOMAKE_VERSION], -[AM_AUTOMAKE_VERSION([1.11.1])dnl +[AM_AUTOMAKE_VERSION([1.13.4])dnl m4_ifndef([AC_AUTOCONF_VERSION], [m4_copy([m4_PACKAGE_VERSION], [AC_AUTOCONF_VERSION])])dnl _AM_AUTOCONF_VERSION(m4_defn([AC_AUTOCONF_VERSION]))]) # AM_AUX_DIR_EXPAND -*- Autoconf -*- -# Copyright (C) 2001, 2003, 2005 Free Software Foundation, Inc. +# Copyright (C) 2001-2013 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # For projects using AC_CONFIG_AUX_DIR([foo]), Autoconf sets -# $ac_aux_dir to `$srcdir/foo'. In other projects, it is set to -# `$srcdir', `$srcdir/..', or `$srcdir/../..'. +# $ac_aux_dir to '$srcdir/foo'. In other projects, it is set to +# '$srcdir', '$srcdir/..', or '$srcdir/../..'. # # Of course, Automake must honor this variable whenever it calls a # tool from the auxiliary directory. The problem is that $srcdir (and @@ -84,7 +85,7 @@ _AM_AUTOCONF_VERSION(m4_defn([AC_AUTOCONF_VERSION]))]) # # The reason of the latter failure is that $top_srcdir and $ac_aux_dir # are both prefixed by $srcdir. In an in-source build this is usually -# harmless because $srcdir is `.', but things will broke when you +# harmless because $srcdir is '.', but things will broke when you # start a VPATH build or use an absolute $srcdir. # # So we could use something similar to $top_srcdir/$ac_aux_dir/missing, @@ -110,15 +111,12 @@ am_aux_dir=`cd $ac_aux_dir && pwd` # Do all the work for Automake. -*- Autoconf -*- -# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, -# 2005, 2006, 2008, 2009 Free Software Foundation, Inc. +# Copyright (C) 1996-2013 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. -# serial 16 - # This macro actually does too much. Some checks are only needed if # your package does certain things. But this isn't really a big deal. @@ -134,7 +132,7 @@ am_aux_dir=`cd $ac_aux_dir && pwd` # arguments mandatory, and then we can depend on a new Autoconf # release and drop the old call support. AC_DEFUN([AM_INIT_AUTOMAKE], -[AC_PREREQ([2.62])dnl +[AC_PREREQ([2.65])dnl dnl Autoconf wants to disallow AM_ names. We explicitly allow dnl the ones we care about. m4_pattern_allow([^AM_[A-Z]+FLAGS$])dnl @@ -163,31 +161,40 @@ AC_SUBST([CYGPATH_W]) # Define the identity of the package. dnl Distinguish between old-style and new-style calls. m4_ifval([$2], -[m4_ifval([$3], [_AM_SET_OPTION([no-define])])dnl +[AC_DIAGNOSE([obsolete], + [$0: two- and three-arguments forms are deprecated.]) +m4_ifval([$3], [_AM_SET_OPTION([no-define])])dnl AC_SUBST([PACKAGE], [$1])dnl AC_SUBST([VERSION], [$2])], [_AM_SET_OPTIONS([$1])dnl dnl Diagnose old-style AC_INIT with new-style AM_AUTOMAKE_INIT. -m4_if(m4_ifdef([AC_PACKAGE_NAME], 1)m4_ifdef([AC_PACKAGE_VERSION], 1), 11,, +m4_if( + m4_ifdef([AC_PACKAGE_NAME], [ok]):m4_ifdef([AC_PACKAGE_VERSION], [ok]), + [ok:ok],, [m4_fatal([AC_INIT should be called with package and version arguments])])dnl AC_SUBST([PACKAGE], ['AC_PACKAGE_TARNAME'])dnl AC_SUBST([VERSION], ['AC_PACKAGE_VERSION'])])dnl _AM_IF_OPTION([no-define],, -[AC_DEFINE_UNQUOTED(PACKAGE, "$PACKAGE", [Name of package]) - AC_DEFINE_UNQUOTED(VERSION, "$VERSION", [Version number of package])])dnl +[AC_DEFINE_UNQUOTED([PACKAGE], ["$PACKAGE"], [Name of package]) + AC_DEFINE_UNQUOTED([VERSION], ["$VERSION"], [Version number of package])])dnl # Some tools Automake needs. AC_REQUIRE([AM_SANITY_CHECK])dnl AC_REQUIRE([AC_ARG_PROGRAM])dnl -AM_MISSING_PROG(ACLOCAL, aclocal-${am__api_version}) -AM_MISSING_PROG(AUTOCONF, autoconf) -AM_MISSING_PROG(AUTOMAKE, automake-${am__api_version}) -AM_MISSING_PROG(AUTOHEADER, autoheader) -AM_MISSING_PROG(MAKEINFO, makeinfo) +AM_MISSING_PROG([ACLOCAL], [aclocal-${am__api_version}]) +AM_MISSING_PROG([AUTOCONF], [autoconf]) +AM_MISSING_PROG([AUTOMAKE], [automake-${am__api_version}]) +AM_MISSING_PROG([AUTOHEADER], [autoheader]) +AM_MISSING_PROG([MAKEINFO], [makeinfo]) AC_REQUIRE([AM_PROG_INSTALL_SH])dnl AC_REQUIRE([AM_PROG_INSTALL_STRIP])dnl -AC_REQUIRE([AM_PROG_MKDIR_P])dnl +AC_REQUIRE([AC_PROG_MKDIR_P])dnl +# For better backward compatibility. To be removed once Automake 1.9.x +# dies out for good. For more background, see: +# +# +AC_SUBST([mkdir_p], ['$(MKDIR_P)']) # We need awk for the "check" target. The system "awk" is bad on # some platforms. AC_REQUIRE([AC_PROG_AWK])dnl @@ -198,28 +205,32 @@ _AM_IF_OPTION([tar-ustar], [_AM_PROG_TAR([ustar])], [_AM_PROG_TAR([v7])])]) _AM_IF_OPTION([no-dependencies],, [AC_PROVIDE_IFELSE([AC_PROG_CC], - [_AM_DEPENDENCIES(CC)], - [define([AC_PROG_CC], - defn([AC_PROG_CC])[_AM_DEPENDENCIES(CC)])])dnl + [_AM_DEPENDENCIES([CC])], + [m4_define([AC_PROG_CC], + m4_defn([AC_PROG_CC])[_AM_DEPENDENCIES([CC])])])dnl AC_PROVIDE_IFELSE([AC_PROG_CXX], - [_AM_DEPENDENCIES(CXX)], - [define([AC_PROG_CXX], - defn([AC_PROG_CXX])[_AM_DEPENDENCIES(CXX)])])dnl + [_AM_DEPENDENCIES([CXX])], + [m4_define([AC_PROG_CXX], + m4_defn([AC_PROG_CXX])[_AM_DEPENDENCIES([CXX])])])dnl AC_PROVIDE_IFELSE([AC_PROG_OBJC], - [_AM_DEPENDENCIES(OBJC)], - [define([AC_PROG_OBJC], - defn([AC_PROG_OBJC])[_AM_DEPENDENCIES(OBJC)])])dnl + [_AM_DEPENDENCIES([OBJC])], + [m4_define([AC_PROG_OBJC], + m4_defn([AC_PROG_OBJC])[_AM_DEPENDENCIES([OBJC])])])dnl +AC_PROVIDE_IFELSE([AC_PROG_OBJCXX], + [_AM_DEPENDENCIES([OBJCXX])], + [m4_define([AC_PROG_OBJCXX], + m4_defn([AC_PROG_OBJCXX])[_AM_DEPENDENCIES([OBJCXX])])])dnl ]) -_AM_IF_OPTION([silent-rules], [AC_REQUIRE([AM_SILENT_RULES])])dnl -dnl The `parallel-tests' driver may need to know about EXEEXT, so add the -dnl `am__EXEEXT' conditional if _AM_COMPILER_EXEEXT was seen. This macro -dnl is hooked onto _AC_COMPILER_EXEEXT early, see below. +AC_REQUIRE([AM_SILENT_RULES])dnl +dnl The testsuite driver may need to know about EXEEXT, so add the +dnl 'am__EXEEXT' conditional if _AM_COMPILER_EXEEXT was seen. This +dnl macro is hooked onto _AC_COMPILER_EXEEXT early, see below. AC_CONFIG_COMMANDS_PRE(dnl [m4_provide_if([_AM_COMPILER_EXEEXT], [AM_CONDITIONAL([am__EXEEXT], [test -n "$EXEEXT"])])])dnl ]) -dnl Hook into `_AC_COMPILER_EXEEXT' early to learn its expansion. Do not +dnl Hook into '_AC_COMPILER_EXEEXT' early to learn its expansion. Do not dnl add the conditional right here, as _AC_COMPILER_EXEEXT may be further dnl mangled by Autoconf and run in a shell conditional statement. m4_define([_AC_COMPILER_EXEEXT], @@ -247,7 +258,7 @@ for _am_header in $config_headers :; do done echo "timestamp for $_am_arg" >`AS_DIRNAME(["$_am_arg"])`/stamp-h[]$_am_stamp_count]) -# Copyright (C) 2001, 2003, 2005, 2008 Free Software Foundation, Inc. +# Copyright (C) 2001-2013 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -266,16 +277,14 @@ if test x"${install_sh}" != xset; then install_sh="\${SHELL} $am_aux_dir/install-sh" esac fi -AC_SUBST(install_sh)]) +AC_SUBST([install_sh])]) -# Copyright (C) 2003, 2005 Free Software Foundation, Inc. +# Copyright (C) 2003-2013 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. -# serial 2 - # Check whether the underlying file-system supports filenames # with a leading dot. For instance MS-DOS doesn't. AC_DEFUN([AM_SET_LEADING_DOT], @@ -291,15 +300,12 @@ AC_SUBST([am__leading_dot])]) # Fake the existence of programs that GNU maintainers use. -*- Autoconf -*- -# Copyright (C) 1997, 1999, 2000, 2001, 2003, 2004, 2005, 2008 -# Free Software Foundation, Inc. +# Copyright (C) 1997-2013 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. -# serial 6 - # AM_MISSING_PROG(NAME, PROGRAM) # ------------------------------ AC_DEFUN([AM_MISSING_PROG], @@ -307,11 +313,10 @@ AC_DEFUN([AM_MISSING_PROG], $1=${$1-"${am_missing_run}$2"} AC_SUBST($1)]) - # AM_MISSING_HAS_RUN # ------------------ -# Define MISSING if not defined so far and test if it supports --run. -# If it does, set am_missing_run to use it, otherwise, to nothing. +# Define MISSING if not defined so far and test if it is modern enough. +# If it is, set am_missing_run to use it, otherwise, to nothing. AC_DEFUN([AM_MISSING_HAS_RUN], [AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl AC_REQUIRE_AUX_FILE([missing])dnl @@ -324,63 +329,35 @@ if test x"${MISSING+set}" != xset; then esac fi # Use eval to expand $SHELL -if eval "$MISSING --run true"; then - am_missing_run="$MISSING --run " +if eval "$MISSING --is-lightweight"; then + am_missing_run="$MISSING " else am_missing_run= - AC_MSG_WARN([`missing' script is too old or missing]) + AC_MSG_WARN(['missing' script is too old or missing]) fi ]) -# Copyright (C) 2003, 2004, 2005, 2006 Free Software Foundation, Inc. -# -# This file is free software; the Free Software Foundation -# gives unlimited permission to copy and/or distribute it, -# with or without modifications, as long as this notice is preserved. - -# AM_PROG_MKDIR_P -# --------------- -# Check for `mkdir -p'. -AC_DEFUN([AM_PROG_MKDIR_P], -[AC_PREREQ([2.60])dnl -AC_REQUIRE([AC_PROG_MKDIR_P])dnl -dnl Automake 1.8 to 1.9.6 used to define mkdir_p. We now use MKDIR_P, -dnl while keeping a definition of mkdir_p for backward compatibility. -dnl @MKDIR_P@ is magic: AC_OUTPUT adjusts its value for each Makefile. -dnl However we cannot define mkdir_p as $(MKDIR_P) for the sake of -dnl Makefile.ins that do not define MKDIR_P, so we do our own -dnl adjustment using top_builddir (which is defined more often than -dnl MKDIR_P). -AC_SUBST([mkdir_p], ["$MKDIR_P"])dnl -case $mkdir_p in - [[\\/$]]* | ?:[[\\/]]*) ;; - */*) mkdir_p="\$(top_builddir)/$mkdir_p" ;; -esac -]) - # Helper functions for option handling. -*- Autoconf -*- -# Copyright (C) 2001, 2002, 2003, 2005, 2008 Free Software Foundation, Inc. +# Copyright (C) 2001-2013 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. -# serial 4 - # _AM_MANGLE_OPTION(NAME) # ----------------------- AC_DEFUN([_AM_MANGLE_OPTION], [[_AM_OPTION_]m4_bpatsubst($1, [[^a-zA-Z0-9_]], [_])]) # _AM_SET_OPTION(NAME) -# ------------------------------ +# -------------------- # Set option NAME. Presently that only means defining a flag for this option. AC_DEFUN([_AM_SET_OPTION], -[m4_define(_AM_MANGLE_OPTION([$1]), 1)]) +[m4_define(_AM_MANGLE_OPTION([$1]), [1])]) # _AM_SET_OPTIONS(OPTIONS) -# ---------------------------------- +# ------------------------ # OPTIONS is a space-separated list of Automake options. AC_DEFUN([_AM_SET_OPTIONS], [m4_foreach_w([_AM_Option], [$1], [_AM_SET_OPTION(_AM_Option)])]) @@ -393,22 +370,16 @@ AC_DEFUN([_AM_IF_OPTION], # Check to make sure that the build environment is sane. -*- Autoconf -*- -# Copyright (C) 1996, 1997, 2000, 2001, 2003, 2005, 2008 -# Free Software Foundation, Inc. +# Copyright (C) 1996-2013 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. -# serial 5 - # AM_SANITY_CHECK # --------------- AC_DEFUN([AM_SANITY_CHECK], [AC_MSG_CHECKING([whether build environment is sane]) -# Just in case -sleep 1 -echo timestamp > conftest.file # Reject unsafe characters in $srcdir or the absolute working directory # name. Accept space and tab only in the latter. am_lf=' @@ -419,32 +390,40 @@ case `pwd` in esac case $srcdir in *[[\\\"\#\$\&\'\`$am_lf\ \ ]]*) - AC_MSG_ERROR([unsafe srcdir value: `$srcdir']);; + AC_MSG_ERROR([unsafe srcdir value: '$srcdir']);; esac -# Do `set' in a subshell so we don't clobber the current shell's +# Do 'set' in a subshell so we don't clobber the current shell's # arguments. Must try -L first in case configure is actually a # symlink; some systems play weird games with the mod time of symlinks # (eg FreeBSD returns the mod time of the symlink's containing # directory). if ( - set X `ls -Lt "$srcdir/configure" conftest.file 2> /dev/null` - if test "$[*]" = "X"; then - # -L didn't work. - set X `ls -t "$srcdir/configure" conftest.file` - fi - rm -f conftest.file - if test "$[*]" != "X $srcdir/configure conftest.file" \ - && test "$[*]" != "X conftest.file $srcdir/configure"; then - - # If neither matched, then we have a broken ls. This can happen - # if, for instance, CONFIG_SHELL is bash and it inherits a - # broken ls alias from the environment. This has actually - # happened. Such a system could not be considered "sane". - AC_MSG_ERROR([ls -t appears to fail. Make sure there is not a broken -alias in your environment]) - fi + am_has_slept=no + for am_try in 1 2; do + echo "timestamp, slept: $am_has_slept" > conftest.file + set X `ls -Lt "$srcdir/configure" conftest.file 2> /dev/null` + if test "$[*]" = "X"; then + # -L didn't work. + set X `ls -t "$srcdir/configure" conftest.file` + fi + if test "$[*]" != "X $srcdir/configure conftest.file" \ + && test "$[*]" != "X conftest.file $srcdir/configure"; then + # If neither matched, then we have a broken ls. This can happen + # if, for instance, CONFIG_SHELL is bash and it inherits a + # broken ls alias from the environment. This has actually + # happened. Such a system could not be considered "sane". + AC_MSG_ERROR([ls -t appears to fail. Make sure there is not a broken + alias in your environment]) + fi + if test "$[2]" = conftest.file || test $am_try -eq 2; then + break + fi + # Just in case. + sleep 1 + am_has_slept=yes + done test "$[2]" = conftest.file ) then @@ -454,9 +433,85 @@ else AC_MSG_ERROR([newly created file is older than distributed files! Check your system clock]) fi -AC_MSG_RESULT(yes)]) +AC_MSG_RESULT([yes]) +# If we didn't sleep, we still need to ensure time stamps of config.status and +# generated files are strictly newer. +am_sleep_pid= +if grep 'slept: no' conftest.file >/dev/null 2>&1; then + ( sleep 1 ) & + am_sleep_pid=$! +fi +AC_CONFIG_COMMANDS_PRE( + [AC_MSG_CHECKING([that generated files are newer than configure]) + if test -n "$am_sleep_pid"; then + # Hide warnings about reused PIDs. + wait $am_sleep_pid 2>/dev/null + fi + AC_MSG_RESULT([done])]) +rm -f conftest.file +]) -# Copyright (C) 2001, 2003, 2005 Free Software Foundation, Inc. +# Copyright (C) 2009-2013 Free Software Foundation, Inc. +# +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# AM_SILENT_RULES([DEFAULT]) +# -------------------------- +# Enable less verbose build rules; with the default set to DEFAULT +# ("yes" being less verbose, "no" or empty being verbose). +AC_DEFUN([AM_SILENT_RULES], +[AC_ARG_ENABLE([silent-rules], [dnl +AS_HELP_STRING( + [--enable-silent-rules], + [less verbose build output (undo: "make V=1")]) +AS_HELP_STRING( + [--disable-silent-rules], + [verbose build output (undo: "make V=0")])dnl +]) +case $enable_silent_rules in @%:@ ((( + yes) AM_DEFAULT_VERBOSITY=0;; + no) AM_DEFAULT_VERBOSITY=1;; + *) AM_DEFAULT_VERBOSITY=m4_if([$1], [yes], [0], [1]);; +esac +dnl +dnl A few 'make' implementations (e.g., NonStop OS and NextStep) +dnl do not support nested variable expansions. +dnl See automake bug#9928 and bug#10237. +am_make=${MAKE-make} +AC_CACHE_CHECK([whether $am_make supports nested variables], + [am_cv_make_support_nested_variables], + [if AS_ECHO([['TRUE=$(BAR$(V)) +BAR0=false +BAR1=true +V=1 +am__doit: + @$(TRUE) +.PHONY: am__doit']]) | $am_make -f - >/dev/null 2>&1; then + am_cv_make_support_nested_variables=yes +else + am_cv_make_support_nested_variables=no +fi]) +if test $am_cv_make_support_nested_variables = yes; then + dnl Using '$V' instead of '$(V)' breaks IRIX make. + AM_V='$(V)' + AM_DEFAULT_V='$(AM_DEFAULT_VERBOSITY)' +else + AM_V=$AM_DEFAULT_VERBOSITY + AM_DEFAULT_V=$AM_DEFAULT_VERBOSITY +fi +AC_SUBST([AM_V])dnl +AM_SUBST_NOTMAKE([AM_V])dnl +AC_SUBST([AM_DEFAULT_V])dnl +AM_SUBST_NOTMAKE([AM_DEFAULT_V])dnl +AC_SUBST([AM_DEFAULT_VERBOSITY])dnl +AM_BACKSLASH='\' +AC_SUBST([AM_BACKSLASH])dnl +_AM_SUBST_NOTMAKE([AM_BACKSLASH])dnl +]) + +# Copyright (C) 2001-2013 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -464,34 +519,32 @@ AC_MSG_RESULT(yes)]) # AM_PROG_INSTALL_STRIP # --------------------- -# One issue with vendor `install' (even GNU) is that you can't +# One issue with vendor 'install' (even GNU) is that you can't # specify the program used to strip binaries. This is especially # annoying in cross-compiling environments, where the build's strip # is unlikely to handle the host's binaries. # Fortunately install-sh will honor a STRIPPROG variable, so we -# always use install-sh in `make install-strip', and initialize +# always use install-sh in "make install-strip", and initialize # STRIPPROG with the value of the STRIP variable (set by the user). AC_DEFUN([AM_PROG_INSTALL_STRIP], [AC_REQUIRE([AM_PROG_INSTALL_SH])dnl -# Installed binaries are usually stripped using `strip' when the user -# run `make install-strip'. However `strip' might not be the right +# Installed binaries are usually stripped using 'strip' when the user +# run "make install-strip". However 'strip' might not be the right # tool to use in cross-compilation environments, therefore Automake -# will honor the `STRIP' environment variable to overrule this program. -dnl Don't test for $cross_compiling = yes, because it might be `maybe'. +# will honor the 'STRIP' environment variable to overrule this program. +dnl Don't test for $cross_compiling = yes, because it might be 'maybe'. if test "$cross_compiling" != no; then AC_CHECK_TOOL([STRIP], [strip], :) fi INSTALL_STRIP_PROGRAM="\$(install_sh) -c -s" AC_SUBST([INSTALL_STRIP_PROGRAM])]) -# Copyright (C) 2006, 2008 Free Software Foundation, Inc. +# Copyright (C) 2006-2013 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. -# serial 2 - # _AM_SUBST_NOTMAKE(VARIABLE) # --------------------------- # Prevent Automake from outputting VARIABLE = @VARIABLE@ in Makefile.in. @@ -499,24 +552,22 @@ AC_SUBST([INSTALL_STRIP_PROGRAM])]) AC_DEFUN([_AM_SUBST_NOTMAKE]) # AM_SUBST_NOTMAKE(VARIABLE) -# --------------------------- +# -------------------------- # Public sister of _AM_SUBST_NOTMAKE. AC_DEFUN([AM_SUBST_NOTMAKE], [_AM_SUBST_NOTMAKE($@)]) # Check how to create a tarball. -*- Autoconf -*- -# Copyright (C) 2004, 2005 Free Software Foundation, Inc. +# Copyright (C) 2004-2013 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. -# serial 2 - # _AM_PROG_TAR(FORMAT) # -------------------- # Check how to create a tarball in format FORMAT. -# FORMAT should be one of `v7', `ustar', or `pax'. +# FORMAT should be one of 'v7', 'ustar', or 'pax'. # # Substitute a variable $(am__tar) that is a command # writing to stdout a FORMAT-tarball containing the directory @@ -526,75 +577,114 @@ AC_DEFUN([AM_SUBST_NOTMAKE], [_AM_SUBST_NOTMAKE($@)]) # Substitute a variable $(am__untar) that extract such # a tarball read from stdin. # $(am__untar) < result.tar +# AC_DEFUN([_AM_PROG_TAR], -[# Always define AMTAR for backward compatibility. -AM_MISSING_PROG([AMTAR], [tar]) -m4_if([$1], [v7], - [am__tar='${AMTAR} chof - "$$tardir"'; am__untar='${AMTAR} xf -'], - [m4_case([$1], [ustar],, [pax],, - [m4_fatal([Unknown tar format])]) -AC_MSG_CHECKING([how to create a $1 tar archive]) -# Loop over all known methods to create a tar archive until one works. +[# Always define AMTAR for backward compatibility. Yes, it's still used +# in the wild :-( We should find a proper way to deprecate it ... +AC_SUBST([AMTAR], ['$${TAR-tar}']) + +# We'll loop over all known methods to create a tar archive until one works. _am_tools='gnutar m4_if([$1], [ustar], [plaintar]) pax cpio none' -_am_tools=${am_cv_prog_tar_$1-$_am_tools} -# Do not fold the above two line into one, because Tru64 sh and -# Solaris sh will not grok spaces in the rhs of `-'. -for _am_tool in $_am_tools -do - case $_am_tool in - gnutar) - for _am_tar in tar gnutar gtar; - do - AM_RUN_LOG([$_am_tar --version]) && break - done - am__tar="$_am_tar --format=m4_if([$1], [pax], [posix], [$1]) -chf - "'"$$tardir"' - am__tar_="$_am_tar --format=m4_if([$1], [pax], [posix], [$1]) -chf - "'"$tardir"' - am__untar="$_am_tar -xf -" - ;; - plaintar) - # Must skip GNU tar: if it does not support --format= it doesn't create - # ustar tarball either. - (tar --version) >/dev/null 2>&1 && continue - am__tar='tar chf - "$$tardir"' - am__tar_='tar chf - "$tardir"' - am__untar='tar xf -' - ;; - pax) - am__tar='pax -L -x $1 -w "$$tardir"' - am__tar_='pax -L -x $1 -w "$tardir"' - am__untar='pax -r' - ;; - cpio) - am__tar='find "$$tardir" -print | cpio -o -H $1 -L' - am__tar_='find "$tardir" -print | cpio -o -H $1 -L' - am__untar='cpio -i -H $1 -d' - ;; - none) - am__tar=false - am__tar_=false - am__untar=false - ;; - esac - # If the value was cached, stop now. We just wanted to have am__tar - # and am__untar set. - test -n "${am_cv_prog_tar_$1}" && break +m4_if([$1], [v7], + [am__tar='$${TAR-tar} chof - "$$tardir"' am__untar='$${TAR-tar} xf -'], - # tar/untar a dummy directory, and stop if the command works + [m4_case([$1], + [ustar], + [# The POSIX 1988 'ustar' format is defined with fixed-size fields. + # There is notably a 21 bits limit for the UID and the GID. In fact, + # the 'pax' utility can hang on bigger UID/GID (see automake bug#8343 + # and bug#13588). + am_max_uid=2097151 # 2^21 - 1 + am_max_gid=$am_max_uid + # The $UID and $GID variables are not portable, so we need to resort + # to the POSIX-mandated id(1) utility. Errors in the 'id' calls + # below are definitely unexpected, so allow the users to see them + # (that is, avoid stderr redirection). + am_uid=`id -u || echo unknown` + am_gid=`id -g || echo unknown` + AC_MSG_CHECKING([whether UID '$am_uid' is supported by ustar format]) + if test $am_uid -le $am_max_uid; then + AC_MSG_RESULT([yes]) + else + AC_MSG_RESULT([no]) + _am_tools=none + fi + AC_MSG_CHECKING([whether GID '$am_gid' is supported by ustar format]) + if test $am_gid -le $am_max_gid; then + AC_MSG_RESULT([yes]) + else + AC_MSG_RESULT([no]) + _am_tools=none + fi], + + [pax], + [], + + [m4_fatal([Unknown tar format])]) + + AC_MSG_CHECKING([how to create a $1 tar archive]) + + # Go ahead even if we have the value already cached. We do so because we + # need to set the values for the 'am__tar' and 'am__untar' variables. + _am_tools=${am_cv_prog_tar_$1-$_am_tools} + + for _am_tool in $_am_tools; do + case $_am_tool in + gnutar) + for _am_tar in tar gnutar gtar; do + AM_RUN_LOG([$_am_tar --version]) && break + done + am__tar="$_am_tar --format=m4_if([$1], [pax], [posix], [$1]) -chf - "'"$$tardir"' + am__tar_="$_am_tar --format=m4_if([$1], [pax], [posix], [$1]) -chf - "'"$tardir"' + am__untar="$_am_tar -xf -" + ;; + plaintar) + # Must skip GNU tar: if it does not support --format= it doesn't create + # ustar tarball either. + (tar --version) >/dev/null 2>&1 && continue + am__tar='tar chf - "$$tardir"' + am__tar_='tar chf - "$tardir"' + am__untar='tar xf -' + ;; + pax) + am__tar='pax -L -x $1 -w "$$tardir"' + am__tar_='pax -L -x $1 -w "$tardir"' + am__untar='pax -r' + ;; + cpio) + am__tar='find "$$tardir" -print | cpio -o -H $1 -L' + am__tar_='find "$tardir" -print | cpio -o -H $1 -L' + am__untar='cpio -i -H $1 -d' + ;; + none) + am__tar=false + am__tar_=false + am__untar=false + ;; + esac + + # If the value was cached, stop now. We just wanted to have am__tar + # and am__untar set. + test -n "${am_cv_prog_tar_$1}" && break + + # tar/untar a dummy directory, and stop if the command works. + rm -rf conftest.dir + mkdir conftest.dir + echo GrepMe > conftest.dir/file + AM_RUN_LOG([tardir=conftest.dir && eval $am__tar_ >conftest.tar]) + rm -rf conftest.dir + if test -s conftest.tar; then + AM_RUN_LOG([$am__untar /dev/null 2>&1 && break + fi + done rm -rf conftest.dir - mkdir conftest.dir - echo GrepMe > conftest.dir/file - AM_RUN_LOG([tardir=conftest.dir && eval $am__tar_ >conftest.tar]) - rm -rf conftest.dir - if test -s conftest.tar; then - AM_RUN_LOG([$am__untar /dev/null 2>&1 && break - fi -done -rm -rf conftest.dir -AC_CACHE_VAL([am_cv_prog_tar_$1], [am_cv_prog_tar_$1=$_am_tool]) -AC_MSG_RESULT([$am_cv_prog_tar_$1])]) + AC_CACHE_VAL([am_cv_prog_tar_$1], [am_cv_prog_tar_$1=$_am_tool]) + AC_MSG_RESULT([$am_cv_prog_tar_$1])]) + AC_SUBST([am__tar]) AC_SUBST([am__untar]) ]) # _AM_PROG_TAR From 497a0676217135113cdb97f905159a95fd97459e Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Mon, 22 Sep 2014 00:40:25 +0100 Subject: [PATCH 192/482] trim trailing whitespace --- t/stow.t | 78 ++++++++++++++++++++++++++++---------------------------- 1 file changed, 39 insertions(+), 39 deletions(-) diff --git a/t/stow.t b/t/stow.t index ccad54d..15f48c4 100755 --- a/t/stow.t +++ b/t/stow.t @@ -24,7 +24,7 @@ my %conflicts; # # stow a simple tree minimally -# +# $stow = new_Stow(dir => '../stow'); make_dir('../stow/pkg1/bin1'); @@ -33,10 +33,10 @@ make_file('../stow/pkg1/bin1/file1'); $stow->plan_stow('pkg1'); $stow->process_tasks(); is_deeply([ $stow->get_conflicts ], [], 'no conflicts with minimal stow'); -is( - readlink('bin1'), - '../stow/pkg1/bin1', - => 'minimal stow of a simple tree' +is( + readlink('bin1'), + '../stow/pkg1/bin1', + => 'minimal stow of a simple tree' ); # @@ -50,14 +50,14 @@ make_dir('lib2'); $stow->plan_stow('pkg2'); $stow->process_tasks(); -is( +is( readlink('lib2/file2'), - '../../stow/pkg2/lib2/file2', - => 'stow simple tree to existing directory' + '../../stow/pkg2/lib2/file2', + => 'stow simple tree to existing directory' ); # -# unfold existing tree +# unfold existing tree # $stow = new_Stow(); @@ -70,10 +70,10 @@ make_file('../stow/pkg3b/bin3/file3b'); $stow->plan_stow('pkg3b'); $stow->process_tasks(); -ok( +ok( -d 'bin3' && readlink('bin3/file3a') eq '../../stow/pkg3a/bin3/file3a' && - readlink('bin3/file3b') eq '../../stow/pkg3b/bin3/file3b' + readlink('bin3/file3b') eq '../../stow/pkg3b/bin3/file3b' => 'target already has 1 stowed package' ); @@ -84,8 +84,8 @@ ok( $stow = new_Stow(); make_file('bin4'); # this is a file but named like a directory -make_dir('../stow/pkg4/bin4'); -make_file('../stow/pkg4/bin4/file4'); +make_dir('../stow/pkg4/bin4'); +make_file('../stow/pkg4/bin4/file4'); $stow->plan_stow('pkg4'); %conflicts = $stow->get_conflicts(); @@ -104,14 +104,14 @@ ok( $stow = new_Stow(); make_file('bin4a'); # this is a file but named like a directory -make_dir('../stow/pkg4a/bin4a'); -make_file('../stow/pkg4a/bin4a/file4a'); +make_dir('../stow/pkg4a/bin4a'); +make_file('../stow/pkg4a/bin4a/file4a'); $stow->plan_stow('pkg4a'); %conflicts = $stow->get_conflicts(); ok( $stow->get_conflict_count == 1 && - $conflicts{stow}{pkg4a}[0] =~ + $conflicts{stow}{pkg4a}[0] =~ qr/existing target is neither a link nor a directory/ => 'link to new dir bin4a conflicts with existing non-directory' ); @@ -124,11 +124,11 @@ $stow = new_Stow(); # Populate target make_file('file4b', 'file4b - version originally in target'); -make_dir ('bin4b'); +make_dir ('bin4b'); make_file('bin4b/file4b', 'bin4b/file4b - version originally in target'); # Populate -make_dir ('../stow/pkg4b/bin4b'); +make_dir ('../stow/pkg4b/bin4b'); make_file('../stow/pkg4b/file4b', 'file4b - version originally in stow package'); make_file('../stow/pkg4b/bin4b/file4b', 'bin4b/file4b - version originally in stow package'); @@ -151,11 +151,11 @@ $stow = new_Stow(adopt => 1); # Populate target make_file('file4c', "file4c - version originally in target\n"); -make_dir ('bin4c'); +make_dir ('bin4c'); make_file('bin4c/file4c', "bin4c/file4c - version originally in target\n"); # Populate -make_dir ('../stow/pkg4c/bin4c'); +make_dir ('../stow/pkg4c/bin4c'); make_file('../stow/pkg4c/file4c', "file4c - version originally in stow package\n"); make_file('../stow/pkg4c/bin4c/file4c', "bin4c/file4c - version originally in stow package\n"); @@ -173,26 +173,26 @@ for my $file ('file4c', 'bin4c/file4c') { is(cat_file($file), "$file - version originally in target\n" => "$file has right contents"); } - + # # Target already exists but is not owned by stow # $stow = new_Stow(); -make_dir('bin5'); +make_dir('bin5'); make_invalid_link('bin5/file5','../../empty'); -make_dir('../stow/pkg5/bin5/file5'); +make_dir('../stow/pkg5/bin5/file5'); $stow->plan_stow('pkg5'); %conflicts = $stow->get_conflicts(); -like( +like( $conflicts{stow}{pkg5}[-1], qr/not owned by stow/ => 'target already exists but is not owned by stow' ); # -# Replace existing but invalid target +# Replace existing but invalid target # $stow = new_Stow(); @@ -202,9 +202,9 @@ make_file('../stow/pkg6/file6'); $stow->plan_stow('pkg6'); $stow->process_tasks(); -is( +is( readlink('file6'), - '../stow/pkg6/file6' + '../stow/pkg6/file6' => 'replace existing but invalid target' ); @@ -243,11 +243,11 @@ make_file('../stow/pkg8b/0/file8b'); $stow->plan_stow('pkg8b'); $stow->process_tasks(); -ok( +ok( $stow->get_conflict_count == 0 && -d '0' && readlink('0/file8a') eq '../../stow/pkg8a/0/file8a' && - readlink('0/file8b') eq '../../stow/pkg8b/0/file8b' + readlink('0/file8b') eq '../../stow/pkg8b/0/file8b' => 'stowing directories named 0' ); @@ -266,9 +266,9 @@ make_file('../stow/pkg9b/man9/man1/file9.1'); $stow->plan_stow('pkg9b'); $stow->process_tasks(); -ok( +ok( $stow->get_conflict_count == 0 && - readlink('man9/man1/file9.1') eq '../../../stow/pkg9b/man9/man1/file9.1' + readlink('man9/man1/file9.1') eq '../../../stow/pkg9b/man9/man1/file9.1' => 'overriding existing documentation files' ); @@ -287,9 +287,9 @@ make_file('../stow/pkg10b/man10/man1/file10.1'); $stow->plan_stow('pkg10b'); is($stow->get_tasks, 0, 'no tasks to process'); -ok( +ok( $stow->get_conflict_count == 0 && - readlink('man10/man1/file10.1') eq '../../../stow/pkg10a/man10/man1/file10.1' + readlink('man10/man1/file10.1') eq '../../../stow/pkg10a/man10/man1/file10.1' => 'defer to existing documentation files' ); @@ -306,10 +306,10 @@ make_dir('man11/man1'); $stow->plan_stow('pkg11'); $stow->process_tasks(); -ok( +ok( $stow->get_conflict_count == 0 && readlink('man11/man1/file11.1') eq '../../../stow/pkg11/man11/man1/file11.1' && - !-e 'man11/man1/file11.1~' && + !-e 'man11/man1/file11.1~' && !-e 'man11/man1/.#file11.1' => 'ignore temp files' ); @@ -327,7 +327,7 @@ make_dir('lib12/'); $stow->plan_stow('pkg12'); $stow->process_tasks(); -ok( +ok( $stow->get_conflict_count == 0 && readlink('lib12/lib.so.1') eq '../../stow/pkg12/lib12/lib.so.1' && readlink('lib12/lib.so' ) eq '../../stow/pkg12/lib12/lib.so' @@ -350,12 +350,12 @@ make_link('../stow/pkg13b/lib13/libb.so', 'libb.so.1'); $stow->plan_stow('pkg13b'); $stow->process_tasks(); -ok( +ok( $stow->get_conflict_count == 0 && readlink('lib13/liba.so.1') eq '../../stow/pkg13a/lib13/liba.so.1' && readlink('lib13/liba.so' ) eq '../../stow/pkg13a/lib13/liba.so' && - readlink('lib13/libb.so.1') eq '../../stow/pkg13b/lib13/libb.so.1' && - readlink('lib13/libb.so' ) eq '../../stow/pkg13b/lib13/libb.so' + readlink('lib13/libb.so.1') eq '../../stow/pkg13b/lib13/libb.so.1' && + readlink('lib13/libb.so' ) eq '../../stow/pkg13b/lib13/libb.so' => 'unfolding to stow links to libraries' ); From 07a84541f189bf07c5861a975403df613a1e4bc1 Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Mon, 22 Sep 2014 00:36:25 +0100 Subject: [PATCH 193/482] make it more obvious when target (sub)directory is skipped This should avoid the sort of confusion seen in: https://github.com/aspiers/shell-env/issues/1 --- lib/Stow.pm.in | 4 ++-- t/stow.t | 7 ++++++- t/testutil.pm | 16 ++++++++++++++++ t/unstow.t | 8 +++++++- t/unstow_orig.t | 35 ++++++++++++++++++++++++++++++++++- 5 files changed, 65 insertions(+), 5 deletions(-) diff --git a/lib/Stow.pm.in b/lib/Stow.pm.in index 948c7a6..c7ee267 100755 --- a/lib/Stow.pm.in +++ b/lib/Stow.pm.in @@ -550,12 +550,12 @@ sub should_skip_target_which_is_stow_dir { # Don't try to remove anything under a stow directory if ($target eq $self->{stow_path}) { - debug(2, "Skipping target which was current stow directory $target"); + warn "WARNING: skipping target which was current stow directory $target\n"; return 1; } if ($self->marked_stow_dir($target)) { - debug(2, "Skipping protected directory $target"); + warn "WARNING: skipping protected directory $target\n"; return 1; } diff --git a/t/stow.t b/t/stow.t index 15f48c4..793e14e 100755 --- a/t/stow.t +++ b/t/stow.t @@ -7,7 +7,7 @@ use strict; use warnings; -use Test::More tests => 111; +use Test::More tests => 112; use Test::Output; use English qw(-no_match_vars); @@ -368,6 +368,7 @@ $stow = new_Stow(dir => 'stow'); make_dir('stow/pkg14/stow/pkg15'); make_file('stow/pkg14/stow/pkg15/node15'); +capture_stderr(); $stow->plan_stow('pkg14'); is($stow->get_tasks, 0, 'no tasks to process'); ok( @@ -375,6 +376,10 @@ ok( ! -l 'stow/pkg15' => "stowing to stow dir should fail" ); +like($stderr, + qr/WARNING: skipping target which was current stow directory stow/ + => "stowing to stow dir should give warning"); +uncapture_stderr(); # # stow a simple tree minimally when cwd isn't target diff --git a/t/testutil.pm b/t/testutil.pm index b9359be..32fc2f1 100755 --- a/t/testutil.pm +++ b/t/testutil.pm @@ -13,6 +13,7 @@ use Carp qw(croak); use File::Basename; use File::Path qw(remove_tree); use File::Spec; +use IO::Scalar; use Test::More; use Stow; @@ -21,6 +22,7 @@ use Stow::Util qw(parent canon_path); use base qw(Exporter); our @EXPORT = qw( $OUT_DIR + $stderr init_test_dirs cd new_Stow new_compat_Stow @@ -28,10 +30,24 @@ our @EXPORT = qw( remove_dir remove_link cat_file is_link is_dir_not_symlink is_nonexistent_path + capture_stderr uncapture_stderr ); our $OUT_DIR = 'tmp-testing-trees'; +our $stderr; +my $tied_err; + +sub capture_stderr { + undef $stderr; + $tied_err = tie *STDERR, 'IO::Scalar', \$stderr; +} + +sub uncapture_stderr { + undef $tied_err; + untie *STDERR; +} + sub init_test_dirs { for my $dir ("$OUT_DIR/target", "$OUT_DIR/stow") { -d $dir and remove_tree($dir); diff --git a/t/unstow.t b/t/unstow.t index d166107..7de78c9 100755 --- a/t/unstow.t +++ b/t/unstow.t @@ -7,7 +7,7 @@ use strict; use warnings; -use Test::More tests => 38; +use Test::More tests => 39; use Test::Output; use English qw(-no_match_vars); @@ -154,6 +154,7 @@ ok( => q(don't unlink any nodes under the stow directory) ); + # # Don't unlink any nodes under another stow directory # @@ -167,6 +168,7 @@ make_dir('stow/pkg8a/stow2/pkg8b'); make_file('stow/pkg8a/stow2/pkg8b/file8b'); make_link('stow2/pkg8b', '../stow/pkg8a/stow2/pkg8b'); +capture_stderr(); $stow->plan_unstow('pkg8a'); is($stow->get_tasks, 0, 'no tasks to process when unstowing pkg8a'); ok( @@ -175,6 +177,10 @@ ok( readlink('stow2/pkg8b') eq '../stow/pkg8a/stow2/pkg8b' => q(don't unlink any nodes under another stow directory) ); +like($stderr, + qr/WARNING: skipping protected directory stow2/ + => "unstowing from ourself should skip stow"); +uncapture_stderr(); # # overriding already stowed documentation diff --git a/t/unstow_orig.t b/t/unstow_orig.t index d91b775..8be5094 100755 --- a/t/unstow_orig.t +++ b/t/unstow_orig.t @@ -7,7 +7,7 @@ use strict; use warnings; -use Test::More tests => 23; +use Test::More tests => 37; use Test::Output; use English qw(-no_match_vars); @@ -151,6 +151,7 @@ make_dir('stow/pkg7a/stow/pkg7b'); make_file('stow/pkg7a/stow/pkg7b/file7b'); make_link('stow/pkg7b', '../stow/pkg7a/stow/pkg7b'); +capture_stderr(); $stow->plan_unstow('pkg7b'); is($stow->get_tasks, 0, 'no tasks to process when unstowing pkg7b'); ok( @@ -159,6 +160,10 @@ ok( readlink('stow/pkg7b') eq '../stow/pkg7a/stow/pkg7b' => q(don't unlink any nodes under the stow directory) ); +like($stderr, + qr/WARNING: skipping target which was current stow directory stow/ + => "warn when unstowing from ourself"); +uncapture_stderr(); # # Don't unlink any nodes under another stow directory @@ -173,6 +178,7 @@ make_dir('stow/pkg8a/stow2/pkg8b'); make_file('stow/pkg8a/stow2/pkg8b/file8b'); make_link('stow2/pkg8b', '../stow/pkg8a/stow2/pkg8b'); +capture_stderr(); $stow->plan_unstow('pkg8a'); is($stow->get_tasks, 0, 'no tasks to process when unstowing pkg8a'); ok( @@ -181,10 +187,25 @@ ok( readlink('stow2/pkg8b') eq '../stow/pkg8a/stow2/pkg8b' => q(don't unlink any nodes under another stow directory) ); +like($stderr, + qr/WARNING: skipping target which was current stow directory stow/ + => "warn when skipping unstowing"); +uncapture_stderr(); # # overriding already stowed documentation # + +# This will be used by this and subsequent tests +sub check_protected_dirs_skipped { + for my $dir (qw{stow stow2}) { + like($stderr, + qr/WARNING: skipping protected directory $dir/ + => "warn when skipping protected directory $dir"); + } + uncapture_stderr(); +} + $stow = new_compat_Stow(override => ['man9', 'info9']); make_file('stow/.stow'); @@ -195,6 +216,7 @@ make_link('man9/man1/file9.1' => '../../../stow/pkg9a/man9/man1/file9.1'); # emu make_dir('../stow/pkg9b/man9/man1'); make_file('../stow/pkg9b/man9/man1/file9.1'); +capture_stderr(); $stow->plan_unstow('pkg9b'); $stow->process_tasks(); ok( @@ -202,6 +224,7 @@ ok( !-l 'man9/man1/file9.1' => 'overriding existing documentation files' ); +check_protected_dirs_skipped(); # # deferring to already stowed documentation @@ -221,6 +244,7 @@ make_link('man10/man1/file10b.1' => '../../../stow/pkg10b/man10/man1/file10b.1' make_dir('../stow/pkg10c/man10/man1'); make_file('../stow/pkg10c/man10/man1/file10a.1'); +capture_stderr(); $stow->plan_unstow('pkg10c'); is($stow->get_tasks, 0, 'no tasks to process when unstowing pkg10c'); ok( @@ -228,6 +252,7 @@ ok( readlink('man10/man1/file10a.1') eq '../../../stow/pkg10a/man10/man1/file10a.1' => 'defer to existing documentation files' ); +check_protected_dirs_skipped(); # # Ignore temp files @@ -241,6 +266,7 @@ make_file('../stow/pkg12/man12/man1/.#file12.1'); make_dir('man12/man1'); make_link('man12/man1/file12.1' => '../../../stow/pkg12/man12/man1/file12.1'); +capture_stderr(); $stow->plan_unstow('pkg12'); $stow->process_tasks(); ok( @@ -248,17 +274,20 @@ ok( !-e 'man12/man1/file12.1' => 'ignore temp files' ); +check_protected_dirs_skipped(); # # Unstow an already unstowed package # $stow = new_compat_Stow(); +capture_stderr(); $stow->plan_unstow('pkg12'); is($stow->get_tasks, 0, 'no tasks to process when unstowing pkg12'); ok( $stow->get_conflict_count == 0 => 'unstow already unstowed package pkg12' ); +check_protected_dirs_skipped(); # # Unstow a never stowed package @@ -268,12 +297,14 @@ eval { remove_dir("$OUT_DIR/target"); }; mkdir("$OUT_DIR/target"); $stow = new_compat_Stow(); +capture_stderr(); $stow->plan_unstow('pkg12'); is($stow->get_tasks, 0, 'no tasks to process when unstowing pkg12 which was never stowed'); ok( $stow->get_conflict_count == 0 => 'unstow never stowed package pkg12' ); +check_protected_dirs_skipped(); # # Unstowing when target contains a real file shouldn't be an issue. @@ -281,6 +312,7 @@ ok( make_file('man12/man1/file12.1'); $stow = new_compat_Stow(); +capture_stderr(); $stow->plan_unstow('pkg12'); is($stow->get_tasks, 0, 'no tasks to process when unstowing pkg12 for third time'); %conflicts = $stow->get_conflicts; @@ -290,6 +322,7 @@ ok( =~ m!existing target is neither a link nor a directory: man12/man1/file12\.1! => 'unstow pkg12 for third time' ); +check_protected_dirs_skipped(); # # unstow a simple tree minimally when cwd isn't target From 5be496a795eae8a139105d57fa98a9fcb172a122 Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Thu, 1 Jan 2015 19:02:26 +0000 Subject: [PATCH 194/482] improve debug --- lib/Stow.pm.in | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/Stow.pm.in b/lib/Stow.pm.in index c7ee267..2e0b71e 100755 --- a/lib/Stow.pm.in +++ b/lib/Stow.pm.in @@ -406,7 +406,7 @@ sub stow_node { my $path = join_paths($stow_path, $package, $target); - debug(3, "Stowing $path"); + debug(3, "Stowing $stow_path / $package / $target"); debug(4, " => $source"); # Don't try to stow absolute symlinks (they can't be unstowed) @@ -1582,9 +1582,11 @@ sub is_a_link { if (my $action = $self->link_task_action($path)) { if ($action eq 'remove') { + debug(4, " is_a_link($path): returning 0 (remove action found)"); return 0; } elsif ($action eq 'create') { + debug(4, " is_a_link($path): returning 1 (create action found)"); return 1; } } @@ -1596,7 +1598,7 @@ sub is_a_link { return $self->parent_link_scheduled_for_removal($path) ? 0 : 1; } - debug(4, " is_a_link($path): returning false"); + debug(4, " is_a_link($path): returning 0"); return 0; } From 7b43622dd9ff7b8793d1c08727f84ac5069d3fb4 Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Thu, 1 Jan 2015 19:02:46 +0000 Subject: [PATCH 195/482] fix stowing of relative links when --no-folding is used With a tree like this: . |-- stow | `-- pkg | `-- lib | |-- itk-current -> itk4.0.0 | `-- itk4.0.0 | `-- libitk4.0.0.so `-- target `-- lib |-- itk4.0.0 -> ../../stow/pkg/lib/itk4.0.0 `-- libfoo-1.2.3.so stowing pkg with the --no-folding option resulted in itk-current being "unpacked": . `-- target `-- lib |-- itk-current | `-- libitk4.0.0.so -> ../../../stow/pkg/lib/itk-current/libitk4.0.0.so |-- itk4.0.0 | `-- libitk4.0.0.so -> ../../../stow/pkg/lib/itk4.0.0/libitk4.0.0.so `-- libfoo-1.2.3.so This commit fixes it so that it gets stowed as a symlink: . `-- target `-- lib ... |-- itk-current -> ../../stow/pkg/lib/itk-current ... Thanks to Gabriele Balducci for reporting this problem: http://thread.gmane.org/gmane.comp.gnu.stow.general/6676 --- lib/Stow.pm.in | 2 +- t/stow.t | 9 ++++++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/lib/Stow.pm.in b/lib/Stow.pm.in index 2e0b71e..851bb86 100755 --- a/lib/Stow.pm.in +++ b/lib/Stow.pm.in @@ -520,7 +520,7 @@ sub stow_node { } } } - elsif ($self->{'no-folding'} && -d $path) { + elsif ($self->{'no-folding'} && -d $path && ! -l $path) { $self->do_mkdir($target); $self->stow_contents( $self->{stow_path}, diff --git a/t/stow.t b/t/stow.t index 793e14e..92141fc 100755 --- a/t/stow.t +++ b/t/stow.t @@ -7,7 +7,7 @@ use strict; use warnings; -use Test::More tests => 112; +use Test::More tests => 118; use Test::Output; use English qw(-no_match_vars); @@ -461,6 +461,7 @@ sub create_pkg { # yet stowed make_dir ("$stow_pkg/$id-$pkg-only-new2/subdir"); make_file("$stow_pkg/$id-$pkg-only-new2/subdir/$id-file-$pkg"); + make_link("$stow_pkg/$id-$pkg-only-new2/current", "subdir"); # create a hierarchy specific to this package which is already # stowed via a folded tree @@ -487,7 +488,7 @@ $stow->plan_stow('no-folding-a'); is_deeply([ $stow->get_conflicts ], [] => 'no conflicts with --no-folding'); my @tasks = $stow->get_tasks; use Data::Dumper; -is(scalar(@tasks), 12 => "6 dirs, 6 links") || warn Dumper(\@tasks); +is(scalar(@tasks), 13 => "6 dirs, 7 links") || warn Dumper(\@tasks); $stow->process_tasks(); sub check_no_folding { @@ -508,6 +509,8 @@ sub check_no_folding { is_dir_not_symlink("no-folding-$pkg-only-new2/subdir"); is_link("no-folding-$pkg-only-new2/subdir/no-folding-file-$pkg", "../../$stow_pkg/no-folding-$pkg-only-new2/subdir/no-folding-file-$pkg"); + is_link("no-folding-$pkg-only-new2/current", + "../$stow_pkg/no-folding-$pkg-only-new2/current"); # check shared tree is not folded. first time round this will be # newly stowed. @@ -530,7 +533,7 @@ $stow = new_Stow('no-folding' => 1); $stow->plan_stow('no-folding-b'); is_deeply([ $stow->get_conflicts ], [] => 'no conflicts with --no-folding'); @tasks = $stow->get_tasks; -is(scalar(@tasks), 10 => '4 dirs, 6 links') || warn Dumper(\@tasks); +is(scalar(@tasks), 11 => '4 dirs, 7 links') || warn Dumper(\@tasks); $stow->process_tasks(); check_no_folding('a'); From 3a7cf35165a391c6503d3f71221ff369bda39d47 Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Sat, 7 Feb 2015 19:24:22 +0000 Subject: [PATCH 196/482] remove automake files These should be generated at development / install-time, rather than distributing versions via git which will inevitably age over time. --- automake/.gitignore | 4 + automake/install-sh | 507 -------------------------------------------- automake/mdate-sh | 201 ------------------ automake/missing | 367 -------------------------------- 4 files changed, 4 insertions(+), 1075 deletions(-) create mode 100644 automake/.gitignore delete mode 100755 automake/install-sh delete mode 100755 automake/mdate-sh delete mode 100755 automake/missing diff --git a/automake/.gitignore b/automake/.gitignore new file mode 100644 index 0000000..f23d52a --- /dev/null +++ b/automake/.gitignore @@ -0,0 +1,4 @@ +install-sh +missing +mdate-sh +test-driver diff --git a/automake/install-sh b/automake/install-sh deleted file mode 100755 index 4fbbae7..0000000 --- a/automake/install-sh +++ /dev/null @@ -1,507 +0,0 @@ -#!/bin/sh -# install - install a program, script, or datafile - -scriptversion=2006-10-14.15 - -# This originates from X11R5 (mit/util/scripts/install.sh), which was -# later released in X11R6 (xc/config/util/install.sh) with the -# following copyright and license. -# -# Copyright (C) 1994 X Consortium -# -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documentation files (the "Software"), to -# deal in the Software without restriction, including without limitation the -# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or -# sell copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in -# all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN -# AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNEC- -# TION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -# -# Except as contained in this notice, the name of the X Consortium shall not -# be used in advertising or otherwise to promote the sale, use or other deal- -# ings in this Software without prior written authorization from the X Consor- -# tium. -# -# -# FSF changes to this file are in the public domain. -# -# Calling this script install-sh is preferred over install.sh, to prevent -# `make' implicit rules from creating a file called install from it -# when there is no Makefile. -# -# This script is compatible with the BSD install script, but was written -# from scratch. - -nl=' -' -IFS=" "" $nl" - -# set DOITPROG to echo to test this script - -# Don't use :- since 4.3BSD and earlier shells don't like it. -doit="${DOITPROG-}" -if test -z "$doit"; then - doit_exec=exec -else - doit_exec=$doit -fi - -# Put in absolute file names if you don't have them in your path; -# or use environment vars. - -mvprog="${MVPROG-mv}" -cpprog="${CPPROG-cp}" -chmodprog="${CHMODPROG-chmod}" -chownprog="${CHOWNPROG-chown}" -chgrpprog="${CHGRPPROG-chgrp}" -stripprog="${STRIPPROG-strip}" -rmprog="${RMPROG-rm}" -mkdirprog="${MKDIRPROG-mkdir}" - -posix_glob= -posix_mkdir= - -# Desired mode of installed file. -mode=0755 - -chmodcmd=$chmodprog -chowncmd= -chgrpcmd= -stripcmd= -rmcmd="$rmprog -f" -mvcmd="$mvprog" -src= -dst= -dir_arg= -dstarg= -no_target_directory= - -usage="Usage: $0 [OPTION]... [-T] SRCFILE DSTFILE - or: $0 [OPTION]... SRCFILES... DIRECTORY - or: $0 [OPTION]... -t DIRECTORY SRCFILES... - or: $0 [OPTION]... -d DIRECTORIES... - -In the 1st form, copy SRCFILE to DSTFILE. -In the 2nd and 3rd, copy all SRCFILES to DIRECTORY. -In the 4th, create DIRECTORIES. - -Options: --c (ignored) --d create directories instead of installing files. --g GROUP $chgrpprog installed files to GROUP. --m MODE $chmodprog installed files to MODE. --o USER $chownprog installed files to USER. --s $stripprog installed files. --t DIRECTORY install into DIRECTORY. --T report an error if DSTFILE is a directory. ---help display this help and exit. ---version display version info and exit. - -Environment variables override the default commands: - CHGRPPROG CHMODPROG CHOWNPROG CPPROG MKDIRPROG MVPROG RMPROG STRIPPROG -" - -while test $# -ne 0; do - case $1 in - -c) shift - continue;; - - -d) dir_arg=true - shift - continue;; - - -g) chgrpcmd="$chgrpprog $2" - shift - shift - continue;; - - --help) echo "$usage"; exit $?;; - - -m) mode=$2 - shift - shift - case $mode in - *' '* | *' '* | *' -'* | *'*'* | *'?'* | *'['*) - echo "$0: invalid mode: $mode" >&2 - exit 1;; - esac - continue;; - - -o) chowncmd="$chownprog $2" - shift - shift - continue;; - - -s) stripcmd=$stripprog - shift - continue;; - - -t) dstarg=$2 - shift - shift - continue;; - - -T) no_target_directory=true - shift - continue;; - - --version) echo "$0 $scriptversion"; exit $?;; - - --) shift - break;; - - -*) echo "$0: invalid option: $1" >&2 - exit 1;; - - *) break;; - esac -done - -if test $# -ne 0 && test -z "$dir_arg$dstarg"; then - # When -d is used, all remaining arguments are directories to create. - # When -t is used, the destination is already specified. - # Otherwise, the last argument is the destination. Remove it from $@. - for arg - do - if test -n "$dstarg"; then - # $@ is not empty: it contains at least $arg. - set fnord "$@" "$dstarg" - shift # fnord - fi - shift # arg - dstarg=$arg - done -fi - -if test $# -eq 0; then - if test -z "$dir_arg"; then - echo "$0: no input file specified." >&2 - exit 1 - fi - # It's OK to call `install-sh -d' without argument. - # This can happen when creating conditional directories. - exit 0 -fi - -if test -z "$dir_arg"; then - trap '(exit $?); exit' 1 2 13 15 - - # Set umask so as not to create temps with too-generous modes. - # However, 'strip' requires both read and write access to temps. - case $mode in - # Optimize common cases. - *644) cp_umask=133;; - *755) cp_umask=22;; - - *[0-7]) - if test -z "$stripcmd"; then - u_plus_rw= - else - u_plus_rw='% 200' - fi - cp_umask=`expr '(' 777 - $mode % 1000 ')' $u_plus_rw`;; - *) - if test -z "$stripcmd"; then - u_plus_rw= - else - u_plus_rw=,u+rw - fi - cp_umask=$mode$u_plus_rw;; - esac -fi - -for src -do - # Protect names starting with `-'. - case $src in - -*) src=./$src ;; - esac - - if test -n "$dir_arg"; then - dst=$src - dstdir=$dst - test -d "$dstdir" - dstdir_status=$? - else - - # Waiting for this to be detected by the "$cpprog $src $dsttmp" command - # might cause directories to be created, which would be especially bad - # if $src (and thus $dsttmp) contains '*'. - if test ! -f "$src" && test ! -d "$src"; then - echo "$0: $src does not exist." >&2 - exit 1 - fi - - if test -z "$dstarg"; then - echo "$0: no destination specified." >&2 - exit 1 - fi - - dst=$dstarg - # Protect names starting with `-'. - case $dst in - -*) dst=./$dst ;; - esac - - # If destination is a directory, append the input filename; won't work - # if double slashes aren't ignored. - if test -d "$dst"; then - if test -n "$no_target_directory"; then - echo "$0: $dstarg: Is a directory" >&2 - exit 1 - fi - dstdir=$dst - dst=$dstdir/`basename "$src"` - dstdir_status=0 - else - # Prefer dirname, but fall back on a substitute if dirname fails. - dstdir=` - (dirname "$dst") 2>/dev/null || - expr X"$dst" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ - X"$dst" : 'X\(//\)[^/]' \| \ - X"$dst" : 'X\(//\)$' \| \ - X"$dst" : 'X\(/\)' \| . 2>/dev/null || - echo X"$dst" | - sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ - s//\1/ - q - } - /^X\(\/\/\)[^/].*/{ - s//\1/ - q - } - /^X\(\/\/\)$/{ - s//\1/ - q - } - /^X\(\/\).*/{ - s//\1/ - q - } - s/.*/./; q' - ` - - test -d "$dstdir" - dstdir_status=$? - fi - fi - - obsolete_mkdir_used=false - - if test $dstdir_status != 0; then - case $posix_mkdir in - '') - # Create intermediate dirs using mode 755 as modified by the umask. - # This is like FreeBSD 'install' as of 1997-10-28. - umask=`umask` - case $stripcmd.$umask in - # Optimize common cases. - *[2367][2367]) mkdir_umask=$umask;; - .*0[02][02] | .[02][02] | .[02]) mkdir_umask=22;; - - *[0-7]) - mkdir_umask=`expr $umask + 22 \ - - $umask % 100 % 40 + $umask % 20 \ - - $umask % 10 % 4 + $umask % 2 - `;; - *) mkdir_umask=$umask,go-w;; - esac - - # With -d, create the new directory with the user-specified mode. - # Otherwise, rely on $mkdir_umask. - if test -n "$dir_arg"; then - mkdir_mode=-m$mode - else - mkdir_mode= - fi - - posix_mkdir=false - case $umask in - *[123567][0-7][0-7]) - # POSIX mkdir -p sets u+wx bits regardless of umask, which - # is incompatible with FreeBSD 'install' when (umask & 300) != 0. - ;; - *) - tmpdir=${TMPDIR-/tmp}/ins$RANDOM-$$ - trap 'ret=$?; rmdir "$tmpdir/d" "$tmpdir" 2>/dev/null; exit $ret' 0 - - if (umask $mkdir_umask && - exec $mkdirprog $mkdir_mode -p -- "$tmpdir/d") >/dev/null 2>&1 - then - if test -z "$dir_arg" || { - # Check for POSIX incompatibilities with -m. - # HP-UX 11.23 and IRIX 6.5 mkdir -m -p sets group- or - # other-writeable bit of parent directory when it shouldn't. - # FreeBSD 6.1 mkdir -m -p sets mode of existing directory. - ls_ld_tmpdir=`ls -ld "$tmpdir"` - case $ls_ld_tmpdir in - d????-?r-*) different_mode=700;; - d????-?--*) different_mode=755;; - *) false;; - esac && - $mkdirprog -m$different_mode -p -- "$tmpdir" && { - ls_ld_tmpdir_1=`ls -ld "$tmpdir"` - test "$ls_ld_tmpdir" = "$ls_ld_tmpdir_1" - } - } - then posix_mkdir=: - fi - rmdir "$tmpdir/d" "$tmpdir" - else - # Remove any dirs left behind by ancient mkdir implementations. - rmdir ./$mkdir_mode ./-p ./-- 2>/dev/null - fi - trap '' 0;; - esac;; - esac - - if - $posix_mkdir && ( - umask $mkdir_umask && - $doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir" - ) - then : - else - - # The umask is ridiculous, or mkdir does not conform to POSIX, - # or it failed possibly due to a race condition. Create the - # directory the slow way, step by step, checking for races as we go. - - case $dstdir in - /*) prefix=/ ;; - -*) prefix=./ ;; - *) prefix= ;; - esac - - case $posix_glob in - '') - if (set -f) 2>/dev/null; then - posix_glob=true - else - posix_glob=false - fi ;; - esac - - oIFS=$IFS - IFS=/ - $posix_glob && set -f - set fnord $dstdir - shift - $posix_glob && set +f - IFS=$oIFS - - prefixes= - - for d - do - test -z "$d" && continue - - prefix=$prefix$d - if test -d "$prefix"; then - prefixes= - else - if $posix_mkdir; then - (umask=$mkdir_umask && - $doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir") && break - # Don't fail if two instances are running concurrently. - test -d "$prefix" || exit 1 - else - case $prefix in - *\'*) qprefix=`echo "$prefix" | sed "s/'/'\\\\\\\\''/g"`;; - *) qprefix=$prefix;; - esac - prefixes="$prefixes '$qprefix'" - fi - fi - prefix=$prefix/ - done - - if test -n "$prefixes"; then - # Don't fail if two instances are running concurrently. - (umask $mkdir_umask && - eval "\$doit_exec \$mkdirprog $prefixes") || - test -d "$dstdir" || exit 1 - obsolete_mkdir_used=true - fi - fi - fi - - if test -n "$dir_arg"; then - { test -z "$chowncmd" || $doit $chowncmd "$dst"; } && - { test -z "$chgrpcmd" || $doit $chgrpcmd "$dst"; } && - { test "$obsolete_mkdir_used$chowncmd$chgrpcmd" = false || - test -z "$chmodcmd" || $doit $chmodcmd $mode "$dst"; } || exit 1 - else - - # Make a couple of temp file names in the proper directory. - dsttmp=$dstdir/_inst.$$_ - rmtmp=$dstdir/_rm.$$_ - - # Trap to clean up those temp files at exit. - trap 'ret=$?; rm -f "$dsttmp" "$rmtmp" && exit $ret' 0 - - # Copy the file name to the temp name. - (umask $cp_umask && $doit_exec $cpprog "$src" "$dsttmp") && - - # and set any options; do chmod last to preserve setuid bits. - # - # If any of these fail, we abort the whole thing. If we want to - # ignore errors from any of these, just make sure not to ignore - # errors from the above "$doit $cpprog $src $dsttmp" command. - # - { test -z "$chowncmd" || $doit $chowncmd "$dsttmp"; } \ - && { test -z "$chgrpcmd" || $doit $chgrpcmd "$dsttmp"; } \ - && { test -z "$stripcmd" || $doit $stripcmd "$dsttmp"; } \ - && { test -z "$chmodcmd" || $doit $chmodcmd $mode "$dsttmp"; } && - - # Now rename the file to the real destination. - { $doit $mvcmd -f "$dsttmp" "$dst" 2>/dev/null \ - || { - # The rename failed, perhaps because mv can't rename something else - # to itself, or perhaps because mv is so ancient that it does not - # support -f. - - # Now remove or move aside any old file at destination location. - # We try this two ways since rm can't unlink itself on some - # systems and the destination file might be busy for other - # reasons. In this case, the final cleanup might fail but the new - # file should still install successfully. - { - if test -f "$dst"; then - $doit $rmcmd -f "$dst" 2>/dev/null \ - || { $doit $mvcmd -f "$dst" "$rmtmp" 2>/dev/null \ - && { $doit $rmcmd -f "$rmtmp" 2>/dev/null; :; }; }\ - || { - echo "$0: cannot unlink or rename $dst" >&2 - (exit 1); exit 1 - } - else - : - fi - } && - - # Now rename the file to the real destination. - $doit $mvcmd "$dsttmp" "$dst" - } - } || exit 1 - - trap '' 0 - fi -done - -# Local variables: -# eval: (add-hook 'write-file-hooks 'time-stamp) -# time-stamp-start: "scriptversion=" -# time-stamp-format: "%:y-%02m-%02d.%02H" -# time-stamp-end: "$" -# End: diff --git a/automake/mdate-sh b/automake/mdate-sh deleted file mode 100755 index cd916c0..0000000 --- a/automake/mdate-sh +++ /dev/null @@ -1,201 +0,0 @@ -#!/bin/sh -# Get modification time of a file or directory and pretty-print it. - -scriptversion=2005-06-29.22 - -# Copyright (C) 1995, 1996, 1997, 2003, 2004, 2005 Free Software -# Foundation, Inc. -# written by Ulrich Drepper , June 1995 -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2, or (at your option) -# any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software Foundation, -# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - -# As a special exception to the GNU General Public License, if you -# distribute this file as part of a program that contains a -# configuration script generated by Autoconf, you may include it under -# the same distribution terms that you use for the rest of that program. - -# This file is maintained in Automake, please report -# bugs to or send patches to -# . - -case $1 in - '') - echo "$0: No file. Try \`$0 --help' for more information." 1>&2 - exit 1; - ;; - -h | --h*) - cat <<\EOF -Usage: mdate-sh [--help] [--version] FILE - -Pretty-print the modification time of FILE. - -Report bugs to . -EOF - exit $? - ;; - -v | --v*) - echo "mdate-sh $scriptversion" - exit $? - ;; -esac - -# Prevent date giving response in another language. -LANG=C -export LANG -LC_ALL=C -export LC_ALL -LC_TIME=C -export LC_TIME - -# GNU ls changes its time format in response to the TIME_STYLE -# variable. Since we cannot assume `unset' works, revert this -# variable to its documented default. -if test "${TIME_STYLE+set}" = set; then - TIME_STYLE=posix-long-iso - export TIME_STYLE -fi - -save_arg1=$1 - -# Find out how to get the extended ls output of a file or directory. -if ls -L /dev/null 1>/dev/null 2>&1; then - ls_command='ls -L -l -d' -else - ls_command='ls -l -d' -fi - -# A `ls -l' line looks as follows on OS/2. -# drwxrwx--- 0 Aug 11 2001 foo -# This differs from Unix, which adds ownership information. -# drwxrwx--- 2 root root 4096 Aug 11 2001 foo -# -# To find the date, we split the line on spaces and iterate on words -# until we find a month. This cannot work with files whose owner is a -# user named `Jan', or `Feb', etc. However, it's unlikely that `/' -# will be owned by a user whose name is a month. So we first look at -# the extended ls output of the root directory to decide how many -# words should be skipped to get the date. - -# On HPUX /bin/sh, "set" interprets "-rw-r--r--" as options, so the "x" below. -set x`ls -l -d /` - -# Find which argument is the month. -month= -command= -until test $month -do - shift - # Add another shift to the command. - command="$command shift;" - case $1 in - Jan) month=January; nummonth=1;; - Feb) month=February; nummonth=2;; - Mar) month=March; nummonth=3;; - Apr) month=April; nummonth=4;; - May) month=May; nummonth=5;; - Jun) month=June; nummonth=6;; - Jul) month=July; nummonth=7;; - Aug) month=August; nummonth=8;; - Sep) month=September; nummonth=9;; - Oct) month=October; nummonth=10;; - Nov) month=November; nummonth=11;; - Dec) month=December; nummonth=12;; - esac -done - -# Get the extended ls output of the file or directory. -set dummy x`eval "$ls_command \"\$save_arg1\""` - -# Remove all preceding arguments -eval $command - -# Because of the dummy argument above, month is in $2. -# -# On a POSIX system, we should have -# -# $# = 5 -# $1 = file size -# $2 = month -# $3 = day -# $4 = year or time -# $5 = filename -# -# On Darwin 7.7.0 and 7.6.0, we have -# -# $# = 4 -# $1 = day -# $2 = month -# $3 = year or time -# $4 = filename - -# Get the month. -case $2 in - Jan) month=January; nummonth=1;; - Feb) month=February; nummonth=2;; - Mar) month=March; nummonth=3;; - Apr) month=April; nummonth=4;; - May) month=May; nummonth=5;; - Jun) month=June; nummonth=6;; - Jul) month=July; nummonth=7;; - Aug) month=August; nummonth=8;; - Sep) month=September; nummonth=9;; - Oct) month=October; nummonth=10;; - Nov) month=November; nummonth=11;; - Dec) month=December; nummonth=12;; -esac - -case $3 in - ???*) day=$1;; - *) day=$3; shift;; -esac - -# Here we have to deal with the problem that the ls output gives either -# the time of day or the year. -case $3 in - *:*) set `date`; eval year=\$$# - case $2 in - Jan) nummonthtod=1;; - Feb) nummonthtod=2;; - Mar) nummonthtod=3;; - Apr) nummonthtod=4;; - May) nummonthtod=5;; - Jun) nummonthtod=6;; - Jul) nummonthtod=7;; - Aug) nummonthtod=8;; - Sep) nummonthtod=9;; - Oct) nummonthtod=10;; - Nov) nummonthtod=11;; - Dec) nummonthtod=12;; - esac - # For the first six month of the year the time notation can also - # be used for files modified in the last year. - if (expr $nummonth \> $nummonthtod) > /dev/null; - then - year=`expr $year - 1` - fi;; - *) year=$3;; -esac - -# The result. -echo $day $month $year - -# Local Variables: -# mode: shell-script -# sh-indentation: 2 -# eval: (add-hook 'write-file-hooks 'time-stamp) -# time-stamp-start: "scriptversion=" -# time-stamp-format: "%:y-%02m-%02d.%02H" -# time-stamp-end: "$" -# End: diff --git a/automake/missing b/automake/missing deleted file mode 100755 index 1c8ff70..0000000 --- a/automake/missing +++ /dev/null @@ -1,367 +0,0 @@ -#! /bin/sh -# Common stub for a few missing GNU programs while installing. - -scriptversion=2006-05-10.23 - -# Copyright (C) 1996, 1997, 1999, 2000, 2002, 2003, 2004, 2005, 2006 -# Free Software Foundation, Inc. -# Originally by Fran,cois Pinard , 1996. - -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2, or (at your option) -# any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA -# 02110-1301, USA. - -# As a special exception to the GNU General Public License, if you -# distribute this file as part of a program that contains a -# configuration script generated by Autoconf, you may include it under -# the same distribution terms that you use for the rest of that program. - -if test $# -eq 0; then - echo 1>&2 "Try \`$0 --help' for more information" - exit 1 -fi - -run=: -sed_output='s/.* --output[ =]\([^ ]*\).*/\1/p' -sed_minuso='s/.* -o \([^ ]*\).*/\1/p' - -# In the cases where this matters, `missing' is being run in the -# srcdir already. -if test -f configure.ac; then - configure_ac=configure.ac -else - configure_ac=configure.in -fi - -msg="missing on your system" - -case $1 in ---run) - # Try to run requested program, and just exit if it succeeds. - run= - shift - "$@" && exit 0 - # Exit code 63 means version mismatch. This often happens - # when the user try to use an ancient version of a tool on - # a file that requires a minimum version. In this case we - # we should proceed has if the program had been absent, or - # if --run hadn't been passed. - if test $? = 63; then - run=: - msg="probably too old" - fi - ;; - - -h|--h|--he|--hel|--help) - echo "\ -$0 [OPTION]... PROGRAM [ARGUMENT]... - -Handle \`PROGRAM [ARGUMENT]...' for when PROGRAM is missing, or return an -error status if there is no known handling for PROGRAM. - -Options: - -h, --help display this help and exit - -v, --version output version information and exit - --run try to run the given command, and emulate it if it fails - -Supported PROGRAM values: - aclocal touch file \`aclocal.m4' - autoconf touch file \`configure' - autoheader touch file \`config.h.in' - autom4te touch the output file, or create a stub one - automake touch all \`Makefile.in' files - bison create \`y.tab.[ch]', if possible, from existing .[ch] - flex create \`lex.yy.c', if possible, from existing .c - help2man touch the output file - lex create \`lex.yy.c', if possible, from existing .c - makeinfo touch the output file - tar try tar, gnutar, gtar, then tar without non-portable flags - yacc create \`y.tab.[ch]', if possible, from existing .[ch] - -Send bug reports to ." - exit $? - ;; - - -v|--v|--ve|--ver|--vers|--versi|--versio|--version) - echo "missing $scriptversion (GNU Automake)" - exit $? - ;; - - -*) - echo 1>&2 "$0: Unknown \`$1' option" - echo 1>&2 "Try \`$0 --help' for more information" - exit 1 - ;; - -esac - -# Now exit if we have it, but it failed. Also exit now if we -# don't have it and --version was passed (most likely to detect -# the program). -case $1 in - lex|yacc) - # Not GNU programs, they don't have --version. - ;; - - tar) - if test -n "$run"; then - echo 1>&2 "ERROR: \`tar' requires --run" - exit 1 - elif test "x$2" = "x--version" || test "x$2" = "x--help"; then - exit 1 - fi - ;; - - *) - if test -z "$run" && ($1 --version) > /dev/null 2>&1; then - # We have it, but it failed. - exit 1 - elif test "x$2" = "x--version" || test "x$2" = "x--help"; then - # Could not run --version or --help. This is probably someone - # running `$TOOL --version' or `$TOOL --help' to check whether - # $TOOL exists and not knowing $TOOL uses missing. - exit 1 - fi - ;; -esac - -# If it does not exist, or fails to run (possibly an outdated version), -# try to emulate it. -case $1 in - aclocal*) - echo 1>&2 "\ -WARNING: \`$1' is $msg. You should only need it if - you modified \`acinclude.m4' or \`${configure_ac}'. You might want - to install the \`Automake' and \`Perl' packages. Grab them from - any GNU archive site." - touch aclocal.m4 - ;; - - autoconf) - echo 1>&2 "\ -WARNING: \`$1' is $msg. You should only need it if - you modified \`${configure_ac}'. You might want to install the - \`Autoconf' and \`GNU m4' packages. Grab them from any GNU - archive site." - touch configure - ;; - - autoheader) - echo 1>&2 "\ -WARNING: \`$1' is $msg. You should only need it if - you modified \`acconfig.h' or \`${configure_ac}'. You might want - to install the \`Autoconf' and \`GNU m4' packages. Grab them - from any GNU archive site." - files=`sed -n 's/^[ ]*A[CM]_CONFIG_HEADER(\([^)]*\)).*/\1/p' ${configure_ac}` - test -z "$files" && files="config.h" - touch_files= - for f in $files; do - case $f in - *:*) touch_files="$touch_files "`echo "$f" | - sed -e 's/^[^:]*://' -e 's/:.*//'`;; - *) touch_files="$touch_files $f.in";; - esac - done - touch $touch_files - ;; - - automake*) - echo 1>&2 "\ -WARNING: \`$1' is $msg. You should only need it if - you modified \`Makefile.am', \`acinclude.m4' or \`${configure_ac}'. - You might want to install the \`Automake' and \`Perl' packages. - Grab them from any GNU archive site." - find . -type f -name Makefile.am -print | - sed 's/\.am$/.in/' | - while read f; do touch "$f"; done - ;; - - autom4te) - echo 1>&2 "\ -WARNING: \`$1' is needed, but is $msg. - You might have modified some files without having the - proper tools for further handling them. - You can get \`$1' as part of \`Autoconf' from any GNU - archive site." - - file=`echo "$*" | sed -n "$sed_output"` - test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"` - if test -f "$file"; then - touch $file - else - test -z "$file" || exec >$file - echo "#! /bin/sh" - echo "# Created by GNU Automake missing as a replacement of" - echo "# $ $@" - echo "exit 0" - chmod +x $file - exit 1 - fi - ;; - - bison|yacc) - echo 1>&2 "\ -WARNING: \`$1' $msg. You should only need it if - you modified a \`.y' file. You may need the \`Bison' package - in order for those modifications to take effect. You can get - \`Bison' from any GNU archive site." - rm -f y.tab.c y.tab.h - if test $# -ne 1; then - eval LASTARG="\${$#}" - case $LASTARG in - *.y) - SRCFILE=`echo "$LASTARG" | sed 's/y$/c/'` - if test -f "$SRCFILE"; then - cp "$SRCFILE" y.tab.c - fi - SRCFILE=`echo "$LASTARG" | sed 's/y$/h/'` - if test -f "$SRCFILE"; then - cp "$SRCFILE" y.tab.h - fi - ;; - esac - fi - if test ! -f y.tab.h; then - echo >y.tab.h - fi - if test ! -f y.tab.c; then - echo 'main() { return 0; }' >y.tab.c - fi - ;; - - lex|flex) - echo 1>&2 "\ -WARNING: \`$1' is $msg. You should only need it if - you modified a \`.l' file. You may need the \`Flex' package - in order for those modifications to take effect. You can get - \`Flex' from any GNU archive site." - rm -f lex.yy.c - if test $# -ne 1; then - eval LASTARG="\${$#}" - case $LASTARG in - *.l) - SRCFILE=`echo "$LASTARG" | sed 's/l$/c/'` - if test -f "$SRCFILE"; then - cp "$SRCFILE" lex.yy.c - fi - ;; - esac - fi - if test ! -f lex.yy.c; then - echo 'main() { return 0; }' >lex.yy.c - fi - ;; - - help2man) - echo 1>&2 "\ -WARNING: \`$1' is $msg. You should only need it if - you modified a dependency of a manual page. You may need the - \`Help2man' package in order for those modifications to take - effect. You can get \`Help2man' from any GNU archive site." - - file=`echo "$*" | sed -n "$sed_output"` - test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"` - if test -f "$file"; then - touch $file - else - test -z "$file" || exec >$file - echo ".ab help2man is required to generate this page" - exit 1 - fi - ;; - - makeinfo) - echo 1>&2 "\ -WARNING: \`$1' is $msg. You should only need it if - you modified a \`.texi' or \`.texinfo' file, or any other file - indirectly affecting the aspect of the manual. The spurious - call might also be the consequence of using a buggy \`make' (AIX, - DU, IRIX). You might want to install the \`Texinfo' package or - the \`GNU make' package. Grab either from any GNU archive site." - # The file to touch is that specified with -o ... - file=`echo "$*" | sed -n "$sed_output"` - test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"` - if test -z "$file"; then - # ... or it is the one specified with @setfilename ... - infile=`echo "$*" | sed 's/.* \([^ ]*\) *$/\1/'` - file=`sed -n ' - /^@setfilename/{ - s/.* \([^ ]*\) *$/\1/ - p - q - }' $infile` - # ... or it is derived from the source name (dir/f.texi becomes f.info) - test -z "$file" && file=`echo "$infile" | sed 's,.*/,,;s,.[^.]*$,,'`.info - fi - # If the file does not exist, the user really needs makeinfo; - # let's fail without touching anything. - test -f $file || exit 1 - touch $file - ;; - - tar) - shift - - # We have already tried tar in the generic part. - # Look for gnutar/gtar before invocation to avoid ugly error - # messages. - if (gnutar --version > /dev/null 2>&1); then - gnutar "$@" && exit 0 - fi - if (gtar --version > /dev/null 2>&1); then - gtar "$@" && exit 0 - fi - firstarg="$1" - if shift; then - case $firstarg in - *o*) - firstarg=`echo "$firstarg" | sed s/o//` - tar "$firstarg" "$@" && exit 0 - ;; - esac - case $firstarg in - *h*) - firstarg=`echo "$firstarg" | sed s/h//` - tar "$firstarg" "$@" && exit 0 - ;; - esac - fi - - echo 1>&2 "\ -WARNING: I can't seem to be able to run \`tar' with the given arguments. - You may want to install GNU tar or Free paxutils, or check the - command line arguments." - exit 1 - ;; - - *) - echo 1>&2 "\ -WARNING: \`$1' is needed, and is $msg. - You might have modified some files without having the - proper tools for further handling them. Check the \`README' file, - it often tells you about the needed prerequisites for installing - this package. You may also peek at any GNU archive site, in case - some other package would contain this missing \`$1' program." - exit 1 - ;; -esac - -exit 0 - -# Local variables: -# eval: (add-hook 'write-file-hooks 'time-stamp) -# time-stamp-start: "scriptversion=" -# time-stamp-format: "%:y-%02m-%02d.%02H" -# time-stamp-end: "$" -# End: From 99b669968db1197463dd86394eaf628e8fe9a7c9 Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Sat, 7 Feb 2015 19:29:43 +0000 Subject: [PATCH 197/482] substitute @VERSION@ in stow.8 man page Thanks to Yue Du for spotting this issue and providing the fix. --- Makefile.am | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Makefile.am b/Makefile.am index c686269..f406bf0 100644 --- a/Makefile.am +++ b/Makefile.am @@ -144,9 +144,9 @@ lib/Stow.pm: lib/Stow.pm.in $(DEFAULT_IGNORE_LIST) Makefile # The below rules should only be needed by developers. ############################################################################## -doc/stow.8: bin/stow.in +doc/stow.8: bin/stow.in Makefile [ -d doc ] || mkdir doc # required in vpath mode - pod2man $< > $@ + $(edit) < $< | pod2man > $@ # We use automake's built-in rule to generate stow.info. The built-in # rules would also generate doc/stow.html and doc/stow.pdf, but after From e255b279762c1e1acba672e78e382c28b801888a Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Mon, 17 Sep 2012 16:55:03 +0100 Subject: [PATCH 198/482] Fix a typo in the docs. --- doc/stow.texi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/stow.texi b/doc/stow.texi index 52b1821..eca8247 100644 --- a/doc/stow.texi +++ b/doc/stow.texi @@ -853,7 +853,7 @@ effects. For example, suppose your site uses more than one stow directory, perhaps in order to share around responsibilities with a number of systems -administrators. One of the administrators might have the following in there +administrators. One of the administrators might have the following in their @file{~/.stowrc} file: @example From 29a8b5d4e51bd35553eb090076dde6e3d2105230 Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Mon, 17 Sep 2012 16:55:17 +0100 Subject: [PATCH 199/482] Add more index entries to the manual. --- doc/stow.texi | 2 ++ 1 file changed, 2 insertions(+) diff --git a/doc/stow.texi b/doc/stow.texi index eca8247..6690e45 100644 --- a/doc/stow.texi +++ b/doc/stow.texi @@ -845,6 +845,8 @@ directory. @c =========================================================================== @node Resource Files, Compile-time vs Install-time, Target Maintenance, Top @chapter Resource Files +@cindex resource files +@cindex configuration files Default command line options may be set in @file{.stowrc} (current directory) or @file{~/.stowrc} (home directory). These are parsed in that order, and effectively From 3d0e3cb48e87de0d1a12c36f44f5e8d1e06760ea Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Mon, 9 Nov 2015 09:15:51 +0000 Subject: [PATCH 200/482] Remove trailing whitespace from NEWS file --- NEWS | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/NEWS b/NEWS index 92c83a6..27aa8d0 100644 --- a/NEWS +++ b/NEWS @@ -119,10 +119,10 @@ News file for Stow. e.g., we don't want to create a link that we will later remove in order to create a directory. Benefits of this approach: - 1. Get to see _all_ the conflicts that are blocking an installation: + 1. Get to see _all_ the conflicts that are blocking an installation: you don't have to deal with them one at a time. 2. No operations are be performed if _any_ conflicts are detected: - a failed stow will not leave you with a partially installed + a failed stow will not leave you with a partially installed package. 3. Minimises the set of operations that need to be performed. 4. Operations are executed as a batch which is much faster @@ -130,13 +130,13 @@ News file for Stow. where you want to minimise the amount of time when the package is unavailable. -** The above fixes the false conflict problem mentioned in the info file. +** The above fixes the false conflict problem mentioned in the info file. ** It also fixes the two bugs mentioned in the man page. ** Multiple stow directories will now cooperate in folding/unfolding. -** Conflict messages are more uniform and informative. +** Conflict messages are more uniform and informative. ** Verbosity and tracing is more extensive and uniform. @@ -210,7 +210,7 @@ News file for Stow. /usr/local/stow/perl-5.8.8-extras. Both stow directories contain a '.stow' file so that they collaborate appropriately. I then use the following .stowrc file in /usr/local/stow/perl-5.8.8-extras - + --dir=/usr/local/stow/perl-5.8.8-extras --target=/usr/local --override=bin @@ -242,7 +242,7 @@ News file for Stow. ** New chkstow utility for checking the integrity of the target directory. -** Implement a test suite and support code. +** Implement a test suite and support code. This was built before implementing any of the extra features so I could more easily check for equivalent functionality. The initial From c77e85c5e952ca861ada7d9d762bbf9dab83c53d Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Mon, 9 Nov 2015 09:16:32 +0000 Subject: [PATCH 201/482] Prepare NEWS file for 2.2.1 release --- NEWS | 98 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 98 insertions(+) diff --git a/NEWS b/NEWS index 27aa8d0..ae9a790 100644 --- a/NEWS +++ b/NEWS @@ -1,5 +1,103 @@ News file for Stow. +* Changes in version 2.2.1 + +** Small improvements to documentation + +*** The README has been revamped. + +*** Some index points have been added to the manual. + +*** Some typos were fixed. + +*** @VERSION@ substitution was fixed in the stow(8) man page. + +** Fix Perl warnings + + Stow no longer emits "v-string in use/require non-portable" and + "Possible precedence issue with control flow operator" warnings + with newer Perl versions. See https://savannah.gnu.org/bugs/?36478 + and http://lists.gnu.org/archive/html/bug-stow/2014-06/msg00000.html + for full details. + +** Fix "Undefined subroutine &main::error" error + + See https://rt.cpan.org/Public/Bug/Display.html?id=75349 for details. + +** Failed system calls now include error description + + This should make errors easier to understand. + +** Default ignore list now ignores top-level README.*, LICENSE.*, and COPYING + + These files are by definition specific to a given package, so if + they exist in the top-level directory, they should not be stowed. + +** Correctly handle the stow/target directories as non-canonical paths + + Fix the case discovered by Hiroyuki Iwatsuki where stowing fails if + the stow / target directories are non-canonical paths. For + example, on FreeBSD /home is a symlink pointing to 'usr/home', so + running with the stow directory as /home/user/local/stow and the + target directory as /home/user/local previously resulted in the + stow directory path being calculated as + ../../../usr/home/user/local/stow relative to the target. + + See http://article.gmane.org/gmane.comp.gnu.stow.bugs/8820 for details. + +** Fix stowing of relative links when --no-folding is used. + + With a tree like this: + + . + |-- stow + | `-- pkg + | `-- lib + | |-- itk-current -> itk4.0.0 + | `-- itk4.0.0 + | `-- libitk4.0.0.so + `-- target + `-- lib + |-- itk4.0.0 -> ../../stow/pkg/lib/itk4.0.0 + `-- libfoo-1.2.3.so + + stowing pkg with the --no-folding option resulted in itk-current + being "unpacked": + + . + `-- target + `-- lib + |-- itk-current + | `-- libitk4.0.0.so -> ../../../stow/pkg/lib/itk-current/libitk4.0.0.so + |-- itk4.0.0 + | `-- libitk4.0.0.so -> ../../../stow/pkg/lib/itk4.0.0/libitk4.0.0.so + `-- libfoo-1.2.3.so + + This commit fixes it so that it gets stowed as a symlink: + + . + `-- target + `-- lib + ... + |-- itk-current -> ../../stow/pkg/lib/itk-current + ... + + Thanks to Gabriele Balducci for reporting this problem: + + http://thread.gmane.org/gmane.comp.gnu.stow.general/6676 + +** Internal code cleanups + +*** aclocal was updated. + +*** automake files were removed. + +*** Trailing whitespace was removed. + +*** Comments were added. + +*** Debug messages were improved. + * Changes in version 2.2.0 ** New --no-folding option From 99e4b7049a0603ee12d807785154dd153dbb1fb3 Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Mon, 9 Nov 2015 09:17:34 +0000 Subject: [PATCH 202/482] Bump version to 2.2.1 --- configure.ac | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index 2d55081..aeb521a 100644 --- a/configure.ac +++ b/configure.ac @@ -1,6 +1,6 @@ dnl Process this file with Autoconf to produce configure dnl -AC_INIT([stow], [2.2.0], [bug-stow@gnu.org]) +AC_INIT([stow], [2.2.1], [bug-stow@gnu.org]) AC_PREREQ([2.61]) AC_CONFIG_AUX_DIR([automake]) # Unfortunately we have to disable warnings for overrides, because we From c749cc4f26936bd34fc153fbfea116842cdc5992 Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Mon, 9 Nov 2015 09:27:49 +0000 Subject: [PATCH 203/482] Update META.{yml,json} Rebuilt with newer Module::Build. --- META.json | 23 ++++++++++++----------- META.yml | 24 ++++++++++++------------ 2 files changed, 24 insertions(+), 23 deletions(-) diff --git a/META.json b/META.json index 227736e..e794404 100644 --- a/META.json +++ b/META.json @@ -4,9 +4,9 @@ "unknown" ], "dynamic_config" : 1, - "generated_by" : "Module::Build version 0.38, CPAN::Meta::Converter version 2.112621", + "generated_by" : "Module::Build version 0.4212", "license" : [ - "open_source" + "gpl_1" ], "meta-spec" : { "url" : "http://search.cpan.org/perldoc?CPAN::Meta::Spec", @@ -16,19 +16,19 @@ "prereqs" : { "build" : { "requires" : { - "Test::More" : 0, - "Test::Output" : 0 + "Test::More" : "0", + "Test::Output" : "0" } }, "configure" : { "requires" : { - "Module::Build" : 0 + "Module::Build" : "0" } }, "runtime" : { "requires" : { - "Carp" : 0, - "IO::File" : 0, + "Carp" : "0", + "IO::File" : "0", "perl" : "5.006" } } @@ -36,11 +36,10 @@ "provides" : { "Stow" : { "file" : "lib/Stow.pm", - "version" : "v2.2.0" + "version" : "v2.2.1" }, "Stow::Util" : { - "file" : "lib/Stow/Util.pm", - "version" : 0 + "file" : "lib/Stow/Util.pm" } }, "release_status" : "stable", @@ -50,8 +49,10 @@ "http://www.gnu.org/licenses/gpl-2.0.html" ], "repository" : { + "type" : "git", "url" : "git://git.savannah.gnu.org/stow.git" } }, - "version" : "v2.2.0" + "version" : "v2.2.1", + "x_serialization_backend" : "JSON::PP version 2.27203" } diff --git a/META.yml b/META.yml index c8f1285..da051c4 100644 --- a/META.yml +++ b/META.yml @@ -3,30 +3,30 @@ abstract: 'manage the installation of multiple software packages' author: - unknown build_requires: - Test::More: 0 - Test::Output: 0 + Test::More: '0' + Test::Output: '0' configure_requires: - Module::Build: 0 + Module::Build: '0' dynamic_config: 1 -generated_by: 'Module::Build version 0.38, CPAN::Meta::Converter version 2.112621' -license: open_source +generated_by: 'Module::Build version 0.4212, CPAN::Meta::Converter version 2.150005' +license: gpl meta-spec: url: http://module-build.sourceforge.net/META-spec-v1.4.html - version: 1.4 + version: '1.4' name: Stow provides: Stow: file: lib/Stow.pm - version: v2.2.0 + version: v2.2.1 Stow::Util: file: lib/Stow/Util.pm - version: 0 requires: - Carp: 0 - IO::File: 0 - perl: 5.006 + Carp: '0' + IO::File: '0' + perl: '5.006' resources: homepage: https://savannah.gnu.org/projects/stow license: http://www.gnu.org/licenses/gpl-2.0.html repository: git://git.savannah.gnu.org/stow.git -version: v2.2.0 +version: v2.2.1 +x_serialization_backend: 'CPAN::Meta::YAML version 0.012' From f1b67d2432436fef638bf068da47c801aacdf2a7 Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Mon, 9 Nov 2015 09:28:11 +0000 Subject: [PATCH 204/482] HOWTO-RELEASE: include automake --add-missing This is necessary since automake files were removed from the repository recently. --- doc/HOWTO-RELEASE | 1 + 1 file changed, 1 insertion(+) diff --git a/doc/HOWTO-RELEASE b/doc/HOWTO-RELEASE index 1837f0a..6f8abeb 100644 --- a/doc/HOWTO-RELEASE +++ b/doc/HOWTO-RELEASE @@ -10,6 +10,7 @@ How to make a new release of GNU Stow - Generate stow, chkstow, and lib/Stow.pm via: eval `perl -V:siteprefix` + automake --add-missing ./configure --prefix=$siteprefix && make (N.B. the CPAN distribution will contain these files, whereas From dc6a141da4d684e4a7b1e32899ad86624bfd3c4a Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Mon, 9 Nov 2015 10:08:31 +0000 Subject: [PATCH 205/482] fix make distcheck The dependency of the distributed file stow.8 on the non-distributed file Makefile was causing this error: ERROR: files left in build directory after distclean: ./doc/stow.8 The automake FAQ explains why this happens: https://www.gnu.org/software/automake/manual/html_node/Errors-with-distclean.html so change stow.8 to depend on Makefile.am which is distributed. --- Makefile.am | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile.am b/Makefile.am index f406bf0..2cea9a6 100644 --- a/Makefile.am +++ b/Makefile.am @@ -144,7 +144,7 @@ lib/Stow.pm: lib/Stow.pm.in $(DEFAULT_IGNORE_LIST) Makefile # The below rules should only be needed by developers. ############################################################################## -doc/stow.8: bin/stow.in Makefile +doc/stow.8: bin/stow.in Makefile.am [ -d doc ] || mkdir doc # required in vpath mode $(edit) < $< | pod2man > $@ From 7faa1d86dcf3928a58fa214ce7d07fd9d688dda4 Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Mon, 9 Nov 2015 10:10:36 +0000 Subject: [PATCH 206/482] HOWTO-RELEASE: use gnulib for gendocs instead of texinfo These days it seems that gendocs can be done entirely from the templates in gnulib, rather than requiring the texinfo repository. --- doc/HOWTO-RELEASE | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/doc/HOWTO-RELEASE b/doc/HOWTO-RELEASE index 6f8abeb..0f9f49b 100644 --- a/doc/HOWTO-RELEASE +++ b/doc/HOWTO-RELEASE @@ -42,8 +42,8 @@ How to make a new release of GNU Stow - Regenerate the documentation for the website: - # First check out texinfo CVS repository via: - # cvs -z3 -d:pserver:anonymous@cvs.savannah.gnu.org:/sources/texinfo co texinfo + # First check out gnulib repository via: + # git clone git://git.savannah.gnu.org/gnulib.git # and stow-web CVS repository via the instructions here: # https://savannah.gnu.org/cvs/?group=stow @@ -51,11 +51,11 @@ How to make a new release of GNU Stow # Set paths: stow_repo=/path/to/stow/git/repo stow_web_repo=/path/to/stow-web/CVS/working/dir - texinfo_repo=/path/to/texinfo/git/repo + gnulib_repo=/path/to/gnulib/git/repo cd $stow_repo - export GENDOCS_TEMPLATE_DIR=$texinfo_repo/util - $texinfo_repo/util/gendocs.sh \ + export GENDOCS_TEMPLATE_DIR=$gnulib_repo/doc + $gnulib_repo/util/gendocs.sh \ -s doc/stow.texi \ -o $stow_web_repo/manual \ --email bug-stow@gnu.org \ From 0a54a6bbab5ac55dd7948fc85614bc47e400ce5b Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Mon, 9 Nov 2015 10:11:59 +0000 Subject: [PATCH 207/482] HOWTO-RELEASE: encourage GPG-signing of release tags --- doc/HOWTO-RELEASE | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/HOWTO-RELEASE b/doc/HOWTO-RELEASE index 0f9f49b..2bc3de3 100644 --- a/doc/HOWTO-RELEASE +++ b/doc/HOWTO-RELEASE @@ -33,7 +33,7 @@ How to make a new release of GNU Stow - Tag the current git HEAD with the new version number: - git tag v7.8.9 + git tag -s v7.8.9 - Push HEAD and tag to savannah From 2119e75d2bc59ed20aead3e8c0cfdce0b361bdb2 Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Mon, 9 Nov 2015 10:13:34 +0000 Subject: [PATCH 208/482] HOWTO-RELEASE: encourage use of SemVer --- doc/HOWTO-RELEASE | 3 +++ 1 file changed, 3 insertions(+) diff --git a/doc/HOWTO-RELEASE b/doc/HOWTO-RELEASE index 2bc3de3..d4988e3 100644 --- a/doc/HOWTO-RELEASE +++ b/doc/HOWTO-RELEASE @@ -4,6 +4,9 @@ How to make a new release of GNU Stow - Ensure NEWS contains the latest changes. - Ensure configure.ac contains the new version number. + This should follow Semantic Versioning as described at: + + http://semver.org/ - Check CPAN distribution will work via Module::Build: From ee118fb61603b9792232925c63dea6d5705a6dc4 Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Mon, 9 Nov 2015 11:04:21 +0000 Subject: [PATCH 209/482] HOWTO-RELEASE: add link to official GNU maintainers guide --- doc/HOWTO-RELEASE | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/doc/HOWTO-RELEASE b/doc/HOWTO-RELEASE index d4988e3..c8d9059 100644 --- a/doc/HOWTO-RELEASE +++ b/doc/HOWTO-RELEASE @@ -1,6 +1,16 @@ How to make a new release of GNU Stow ===================================== +Prerequisite reading +-------------------- + +First read the official information for maintainers of GNU software: + + https://www.gnu.org/prep/maintain/ + +Release procedure +----------------- + - Ensure NEWS contains the latest changes. - Ensure configure.ac contains the new version number. From d82b6aa1a8677fb7140a9a6daa934f250859b947 Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Mon, 9 Nov 2015 11:05:00 +0000 Subject: [PATCH 210/482] HOWTO-RELEASE: remove body indent --- doc/HOWTO-RELEASE | 122 +++++++++++++++++++++++----------------------- 1 file changed, 61 insertions(+), 61 deletions(-) diff --git a/doc/HOWTO-RELEASE b/doc/HOWTO-RELEASE index c8d9059..65f5afd 100644 --- a/doc/HOWTO-RELEASE +++ b/doc/HOWTO-RELEASE @@ -6,96 +6,96 @@ Prerequisite reading First read the official information for maintainers of GNU software: - https://www.gnu.org/prep/maintain/ + https://www.gnu.org/prep/maintain/ Release procedure ----------------- - - Ensure NEWS contains the latest changes. +- Ensure NEWS contains the latest changes. - - Ensure configure.ac contains the new version number. - This should follow Semantic Versioning as described at: +- Ensure configure.ac contains the new version number. + This should follow Semantic Versioning as described at: - http://semver.org/ + http://semver.org/ - - Check CPAN distribution will work via Module::Build: +- Check CPAN distribution will work via Module::Build: - - Generate stow, chkstow, and lib/Stow.pm via: + - Generate stow, chkstow, and lib/Stow.pm via: - eval `perl -V:siteprefix` - automake --add-missing - ./configure --prefix=$siteprefix && make + eval `perl -V:siteprefix` + automake --add-missing + ./configure --prefix=$siteprefix && make - (N.B. the CPAN distribution will contain these files, whereas - the GNU distribution will not.) + (N.B. the CPAN distribution will contain these files, whereas + the GNU distribution will not.) - - Make sure all the following commands all run successfully: + - Make sure all the following commands all run successfully: - perl Build.PL --prefix=/tmp/stow-test - ./Build test - ./Build install - ./Build distcheck - ./Build distmeta + perl Build.PL --prefix=/tmp/stow-test + ./Build test + ./Build install + ./Build distcheck + ./Build distmeta - - Check META.yaml and META.json have the new version number. + - Check META.yaml and META.json have the new version number. - - Ensure all changes are committed to git. +- Ensure all changes are committed to git. - - Run make distcheck and ensure that everything looks good. - It should generate the distribution files for you. +- Run make distcheck and ensure that everything looks good. + It should generate the distribution files for you. - - Tag the current git HEAD with the new version number: +- Tag the current git HEAD with the new version number: - git tag -s v7.8.9 + git tag -s v7.8.9 - - Push HEAD and tag to savannah +- Push HEAD and tag to savannah - git push - git push --tags + git push + git push --tags - - Regenerate the documentation for the website: +- Regenerate the documentation for the website: - # First check out gnulib repository via: - # git clone git://git.savannah.gnu.org/gnulib.git + # First check out gnulib repository via: + # git clone git://git.savannah.gnu.org/gnulib.git - # and stow-web CVS repository via the instructions here: - # https://savannah.gnu.org/cvs/?group=stow + # and stow-web CVS repository via the instructions here: + # https://savannah.gnu.org/cvs/?group=stow - # Set paths: - stow_repo=/path/to/stow/git/repo - stow_web_repo=/path/to/stow-web/CVS/working/dir - gnulib_repo=/path/to/gnulib/git/repo + # Set paths: + stow_repo=/path/to/stow/git/repo + stow_web_repo=/path/to/stow-web/CVS/working/dir + gnulib_repo=/path/to/gnulib/git/repo - cd $stow_repo - export GENDOCS_TEMPLATE_DIR=$gnulib_repo/doc - $gnulib_repo/util/gendocs.sh \ - -s doc/stow.texi \ - -o $stow_web_repo/manual \ - --email bug-stow@gnu.org \ - stow "GNU Stow manual" + cd $stow_repo + export GENDOCS_TEMPLATE_DIR=$gnulib_repo/doc + $gnulib_repo/util/gendocs.sh \ + -s doc/stow.texi \ + -o $stow_web_repo/manual \ + --email bug-stow@gnu.org \ + stow "GNU Stow manual" - cd $stow_web_repo - # Check that the changes look OK - cvs diff - # Then commit - cvs commit -m 'Update manual to v7.8.9' + cd $stow_web_repo + # Check that the changes look OK + cvs diff + # Then commit + cvs commit -m 'Update manual to v7.8.9' - - Run ./Build dist +- Run ./Build dist - - Upload the resulting Stow-v7.8.9.tar.gz to CPAN via https://pause.perl.org/ +- Upload the resulting Stow-v7.8.9.tar.gz to CPAN via https://pause.perl.org/ - - Upload to ftp.gnu.org. This is easiest using gnupload: +- Upload to ftp.gnu.org. This is easiest using gnupload: - - git clone git://git.savannah.gnu.org/gnulib.git - - Copy gnulib/build-aux/gnupload to somewhere on your $PATH - - Run gnupload --to ftp.gnu.org:stow --symlink-regex stow-7.8.9.tar.* + - git clone git://git.savannah.gnu.org/gnulib.git + - Copy gnulib/build-aux/gnupload to somewhere on your $PATH + - Run gnupload --to ftp.gnu.org:stow --symlink-regex stow-7.8.9.tar.* - - Send release announcements to +- Send release announcements to - - info-stow@gnu.org - - stow-devel@gnu.org - - info-gnu@gnu.org - - https://savannah.gnu.org/news/?group=stow + - info-stow@gnu.org + - stow-devel@gnu.org + - info-gnu@gnu.org + - https://savannah.gnu.org/news/?group=stow - See http://www.gnu.org/prep/maintain/html_node/Announcements.html for - more on making release announcements. + See http://www.gnu.org/prep/maintain/html_node/Announcements.html for + more on making release announcements. From 43333b8ecafffdcd6345710b034fb26ea6898e05 Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Mon, 9 Nov 2015 11:36:11 +0000 Subject: [PATCH 211/482] add Stow/Util.pm.in with @VERSION@ substitution This is now necessary in order to prevent pause.perl.org from complaining: Status: Decreasing version number ================================= module : Stow::Util version: undef in file: lib/Stow/Util.pm status : Not indexed because lib/Stow/Util.pm in A/AS/ASPIERS/Stow-v2.2.0.tar.gz has a higher version number (0) --- .gitignore | 1 + MANIFEST | 1 + META.json | 3 ++- META.yml | 1 + Makefile.am | 7 ++++++- NEWS | 4 ++++ lib/Stow/{Util.pm => Util.pm.in} | 1 + 7 files changed, 16 insertions(+), 2 deletions(-) rename lib/Stow/{Util.pm => Util.pm.in} (99%) diff --git a/.gitignore b/.gitignore index 6e48e79..eb004eb 100644 --- a/.gitignore +++ b/.gitignore @@ -24,6 +24,7 @@ configure /doc/stow.pdf /doc/stow.8 /lib/Stow.pm +/lib/Stow/Util.pm stamp-vti stow-[0-9].[0-9].[0-9].tar.* stow-[0-9].[0-9].[0-9]/ diff --git a/MANIFEST b/MANIFEST index 2c9ed06..93becf6 100644 --- a/MANIFEST +++ b/MANIFEST @@ -25,6 +25,7 @@ INSTALL lib/Stow.pm lib/Stow.pm.in lib/Stow/Util.pm +lib/Stow/Util.pm.in Makefile.am Makefile.in MANIFEST This list of files diff --git a/META.json b/META.json index e794404..19b928a 100644 --- a/META.json +++ b/META.json @@ -39,7 +39,8 @@ "version" : "v2.2.1" }, "Stow::Util" : { - "file" : "lib/Stow/Util.pm" + "file" : "lib/Stow/Util.pm", + "version" : "v2.2.1" } }, "release_status" : "stable", diff --git a/META.yml b/META.yml index da051c4..721ff1c 100644 --- a/META.yml +++ b/META.yml @@ -20,6 +20,7 @@ provides: version: v2.2.1 Stow::Util: file: lib/Stow/Util.pm + version: v2.2.1 requires: Carp: '0' IO::File: '0' diff --git a/Makefile.am b/Makefile.am index 2cea9a6..3303a6a 100644 --- a/Makefile.am +++ b/Makefile.am @@ -75,7 +75,7 @@ $(TESTS_OUT): CPAN_FILES = MANIFEST MANIFEST.SKIP Build.PL META.yml META.json EXTRA_DIST = \ - bin/stow.in bin/chkstow.in lib/Stow.pm.in \ + bin/stow.in bin/chkstow.in lib/Stow.pm.in lib/Stow/Util.pm.in \ doc/manual-split \ $(TESTS) t/testutil.pm \ $(TEXINFO_TEX) \ @@ -140,6 +140,11 @@ lib/Stow.pm: lib/Stow.pm.in $(DEFAULT_IGNORE_LIST) Makefile @( $(edit) < $<; cat $(DEFAULT_IGNORE_LIST) ) > $@ @echo "Generated $@ from $< and $(DEFAULT_IGNORE_LIST)" +lib/Stow/Util.pm: lib/Stow/Util.pm.in Makefile.am + @[ -d lib/Stow ] || mkdir -p lib/Stow # required in vpath mode + @$(edit) < $< > $@ + @echo "Generated $@ from $<" + ############################################################################## # The below rules should only be needed by developers. ############################################################################## diff --git a/NEWS b/NEWS index ae9a790..32ec5f8 100644 --- a/NEWS +++ b/NEWS @@ -1,5 +1,9 @@ News file for Stow. +* Changes in version 2.2.2 + +** @VERSION@ substitution was set up for the Stow::Util module. + * Changes in version 2.2.1 ** Small improvements to documentation diff --git a/lib/Stow/Util.pm b/lib/Stow/Util.pm.in similarity index 99% rename from lib/Stow/Util.pm rename to lib/Stow/Util.pm.in index 2b5bbdb..b709e7e 100644 --- a/lib/Stow/Util.pm +++ b/lib/Stow/Util.pm.in @@ -26,6 +26,7 @@ our @EXPORT_OK = qw( ); our $ProgramName = 'stow'; +our $VERSION = '@VERSION@'; ############################################################################# # From ab9d03535d39caf743b1dbccdc423f80fd1f06d3 Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Mon, 9 Nov 2015 11:46:50 +0000 Subject: [PATCH 212/482] Bump version to 2.2.2 --- META.json | 6 +++--- META.yml | 6 +++--- configure.ac | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/META.json b/META.json index 19b928a..5d93975 100644 --- a/META.json +++ b/META.json @@ -36,11 +36,11 @@ "provides" : { "Stow" : { "file" : "lib/Stow.pm", - "version" : "v2.2.1" + "version" : "v2.2.2" }, "Stow::Util" : { "file" : "lib/Stow/Util.pm", - "version" : "v2.2.1" + "version" : "v2.2.2" } }, "release_status" : "stable", @@ -54,6 +54,6 @@ "url" : "git://git.savannah.gnu.org/stow.git" } }, - "version" : "v2.2.1", + "version" : "v2.2.2", "x_serialization_backend" : "JSON::PP version 2.27203" } diff --git a/META.yml b/META.yml index 721ff1c..d496750 100644 --- a/META.yml +++ b/META.yml @@ -17,10 +17,10 @@ name: Stow provides: Stow: file: lib/Stow.pm - version: v2.2.1 + version: v2.2.2 Stow::Util: file: lib/Stow/Util.pm - version: v2.2.1 + version: v2.2.2 requires: Carp: '0' IO::File: '0' @@ -29,5 +29,5 @@ resources: homepage: https://savannah.gnu.org/projects/stow license: http://www.gnu.org/licenses/gpl-2.0.html repository: git://git.savannah.gnu.org/stow.git -version: v2.2.1 +version: v2.2.2 x_serialization_backend: 'CPAN::Meta::YAML version 0.012' diff --git a/configure.ac b/configure.ac index aeb521a..4b3bd49 100644 --- a/configure.ac +++ b/configure.ac @@ -1,6 +1,6 @@ dnl Process this file with Autoconf to produce configure dnl -AC_INIT([stow], [2.2.1], [bug-stow@gnu.org]) +AC_INIT([stow], [2.2.2], [bug-stow@gnu.org]) AC_PREREQ([2.61]) AC_CONFIG_AUX_DIR([automake]) # Unfortunately we have to disable warnings for overrides, because we From c482b0291dffa9cd5c43c5d8d840d9e5cb182c18 Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Mon, 9 Nov 2015 11:48:55 +0000 Subject: [PATCH 213/482] NEWS: Explain why 2.2.1 was not released --- NEWS | 3 +++ 1 file changed, 3 insertions(+) diff --git a/NEWS b/NEWS index 32ec5f8..cbcd10c 100644 --- a/NEWS +++ b/NEWS @@ -6,6 +6,9 @@ News file for Stow. * Changes in version 2.2.1 +Version 2.2.1 was not released since it was rejected by pause.perl.org +due to Stow::Util missing $VERSION. + ** Small improvements to documentation *** The README has been revamped. From b5dbc3b7b4f71a38c927a83cfe598e05190929bd Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Mon, 9 Nov 2015 12:37:09 +0000 Subject: [PATCH 214/482] More fixes to "make distcheck" As with dc6a141d, the dependency of distributed files on non-distributed files was causing this error: ERROR: files left in build directory after distclean: The automake FAQ explains why this happens: https://www.gnu.org/software/automake/manual/html_node/Errors-with-distclean.html so change the dependency to Makefile.am which is distributed. --- Makefile.am | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Makefile.am b/Makefile.am index 3303a6a..7a1a808 100644 --- a/Makefile.am +++ b/Makefile.am @@ -121,7 +121,7 @@ check_pmdir = \ fi; \ echo -bin/stow: bin/stow.in Makefile +bin/stow: bin/stow.in Makefile.am [ -d bin ] || mkdir bin # required in vpath mode @$(check_pmdir) @$(calc_use_lib_pmdir); \ @@ -129,13 +129,13 @@ bin/stow: bin/stow.in Makefile @echo "Generated $@ from $<" chmod +x $@ -bin/chkstow: bin/chkstow.in Makefile +bin/chkstow: bin/chkstow.in Makefile.am @[ -d bin ] || mkdir bin # required in vpath mode @$(edit) < $< > $@ @echo "Generated $@ from $<" chmod +x $@ -lib/Stow.pm: lib/Stow.pm.in $(DEFAULT_IGNORE_LIST) Makefile +lib/Stow.pm: lib/Stow.pm.in $(DEFAULT_IGNORE_LIST) Makefile.am @[ -d lib ] || mkdir lib # required in vpath mode @( $(edit) < $<; cat $(DEFAULT_IGNORE_LIST) ) > $@ @echo "Generated $@ from $< and $(DEFAULT_IGNORE_LIST)" From d0f3e5458fd9f93bff68cb2047ad531c7e0e9375 Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Wed, 11 Nov 2015 11:22:05 +0000 Subject: [PATCH 215/482] Correctly handle empty STOW_DIR (#5, #6) In shell, a variable is often considered unset even if it is set to the empty string. In other words, STOW_DIR= stow [args] is an idiomatic alternative to writing: unset STOW_DIR stow [args] and it also has the advantage of temporarily "unsetting" STOW_DIR for a single command. Therefore we should treat STOW_DIR being set to the empty string as equivalent to it not being set at all. Thanks to Cuong Manh Le for highlighting this issue! Fixes #6 - https://github.com/aspiers/stow/issues/6 Closes #5 - https://github.com/aspiers/stow/pull/5 --- THANKS | 1 + bin/stow.in | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/THANKS b/THANKS index 191e0ba..bd3b5a9 100644 --- a/THANKS +++ b/THANKS @@ -23,3 +23,4 @@ Christopher Hoobin Adam Spiers Stefano Lattarini Adam Sampson +Cuong Manh Le diff --git a/bin/stow.in b/bin/stow.in index 5263fe8..c437f29 100755 --- a/bin/stow.in +++ b/bin/stow.in @@ -542,7 +542,7 @@ sub sanitize_path_options { $options->{dir} =~ s/ +\z//; } else { - $options->{dir} = exists $ENV{STOW_DIR} ? $ENV{STOW_DIR} : getcwd(); + $options->{dir} = $ENV{STOW_DIR} ? $ENV{STOW_DIR} : getcwd(); } if (exists $options->{target}) { From a111eeb8aebdfd27f8dca53b97ad3d090450c818 Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Wed, 11 Nov 2015 12:25:19 +0000 Subject: [PATCH 216/482] Do more validation on --dir / --target directories (#7) Previously STOW_DIR=0 would cause the cwd to be used as the STOW_DIR. Make that instead raise an error. Do similar validation on the target directory. Closes #7 - https://github.com/aspiers/stow/pull/7 --- bin/stow.in | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/bin/stow.in b/bin/stow.in index c437f29..1ebc695 100755 --- a/bin/stow.in +++ b/bin/stow.in @@ -542,12 +542,17 @@ sub sanitize_path_options { $options->{dir} =~ s/ +\z//; } else { - $options->{dir} = $ENV{STOW_DIR} ? $ENV{STOW_DIR} : getcwd(); + $options->{dir} = length $ENV{STOW_DIR} ? $ENV{STOW_DIR} : getcwd(); } + usage("--dir value '$options->{dir}' is not a valid directory") + unless -d $options->{dir}; + if (exists $options->{target}) { $options->{target} =~ s/\A +//; $options->{target} =~ s/ +\z//; + usage("--target value '$options->{target}' is not a valid directory") + unless -d $options->{target}; } else { $options->{target} = parent($options->{dir}) || '.'; From f24de47b82834d77319ff29ebbdbd3959adf5064 Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Fri, 13 Nov 2015 12:04:52 +0000 Subject: [PATCH 217/482] add IO::Scalar to build_requires --- Build.PL | 1 + META.json | 1 + META.yml | 1 + 3 files changed, 3 insertions(+) diff --git a/Build.PL b/Build.PL index 9a755f8..a14b93b 100644 --- a/Build.PL +++ b/Build.PL @@ -54,6 +54,7 @@ my $build = Module::Build->new( build_requires => { 'Test::More' => 0, 'Test::Output' => 0, + 'IO::Scalar' => 0, }, ); diff --git a/META.json b/META.json index 5d93975..443f81c 100644 --- a/META.json +++ b/META.json @@ -16,6 +16,7 @@ "prereqs" : { "build" : { "requires" : { + "IO::Scalar" : "0", "Test::More" : "0", "Test::Output" : "0" } diff --git a/META.yml b/META.yml index d496750..d72d950 100644 --- a/META.yml +++ b/META.yml @@ -3,6 +3,7 @@ abstract: 'manage the installation of multiple software packages' author: - unknown build_requires: + IO::Scalar: '0' Test::More: '0' Test::Output: '0' configure_requires: From dc1ded469b4d0e790e2ba67cd8ea76caab9e91af Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Fri, 13 Nov 2015 11:13:06 +0000 Subject: [PATCH 218/482] set up Travis CI --- .travis.yml | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 .travis.yml diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..025b98d --- /dev/null +++ b/.travis.yml @@ -0,0 +1,22 @@ +language: perl +perl: + - "5.20" + - "5.18" + - "5.16" + - "5.14" +# Can't use containers until this is accepted: +# https://github.com/travis-ci/apt-package-whitelist/issues/1759 +#sudo: false +addons: + apt: + packages: + - texinfo + - texlive + - texi2html +before_install: + - sudo apt-get update -qq + - sudo apt-get install -qq texi2html + - autoreconf --install + - eval `perl -V:siteprefix` + - ./configure --prefix=$siteprefix && make +after_failure: find /home/travis/.cpanm/ -name build.log | xargs grep . From 8544b2f0f55a18a55cbc6db098ec70bc19f07246 Mon Sep 17 00:00:00 2001 From: LE Manh Cuong Date: Fri, 13 Nov 2015 11:57:21 +0700 Subject: [PATCH 219/482] Allow directory with trailing and leading spaces - The `sanitize_path_options` functions remove all trailing and leading spaces. So any valid directory like ` 123`, `123 ` can not be used - Also if there are two directories ` 123` and `123`, and if user pick the ` 123` as option to `-d` or `-t`, then stow pick directory `123` as the argument instead of ` 123` as user want. ``` STOW_DIR=. stow -n -v3 -t \ 123 456 stow dir is /tmp/test stow dir path relative to target 123 is .. cwd now 123 cwd restored to /tmp/test cwd now 123 Planning stow of package 456... Stowing contents of ../456 (cwd=/tmp/test/123) Planning stow of package 456... done cwd restored to /tmp/test WARNING: in simulation mode so not modifying filesystem. ``` - This commit remove the check in `sanitize_path_options` function, and now stow can work with those directories. There have been a check for valid directory, so we are safe. --- bin/stow.in | 8 +------- t/cli_options.t | 4 ++-- 2 files changed, 3 insertions(+), 9 deletions(-) diff --git a/bin/stow.in b/bin/stow.in index 1ebc695..ec83f59 100755 --- a/bin/stow.in +++ b/bin/stow.in @@ -537,11 +537,7 @@ sub process_options { sub sanitize_path_options { my ($options) = @_; - if (exists $options->{dir}) { - $options->{dir} =~ s/\A +//; - $options->{dir} =~ s/ +\z//; - } - else { + unless (exists $options->{dir}) { $options->{dir} = length $ENV{STOW_DIR} ? $ENV{STOW_DIR} : getcwd(); } @@ -549,8 +545,6 @@ sub sanitize_path_options { unless -d $options->{dir}; if (exists $options->{target}) { - $options->{target} =~ s/\A +//; - $options->{target} =~ s/ +\z//; usage("--target value '$options->{target}' is not a valid directory") unless -d $options->{target}; } diff --git a/t/cli_options.t b/t/cli_options.t index 809cf15..fafb6d8 100755 --- a/t/cli_options.t +++ b/t/cli_options.t @@ -17,8 +17,8 @@ init_test_dirs(); local @ARGV = ( '-v', - "-d $OUT_DIR/stow", - "-t $OUT_DIR/target", + '-d', "$OUT_DIR/stow", + '-t', "$OUT_DIR/target", 'dummy' ); From 7ca44238eab2e07e2519a079481493c6782cc381 Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Mon, 16 Nov 2015 21:56:45 +0000 Subject: [PATCH 220/482] switch to Travis CI containers --- .travis.yml | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/.travis.yml b/.travis.yml index 025b98d..a7ac3d3 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,9 +4,7 @@ perl: - "5.18" - "5.16" - "5.14" -# Can't use containers until this is accepted: -# https://github.com/travis-ci/apt-package-whitelist/issues/1759 -#sudo: false +sudo: false addons: apt: packages: @@ -14,8 +12,6 @@ addons: - texlive - texi2html before_install: - - sudo apt-get update -qq - - sudo apt-get install -qq texi2html - autoreconf --install - eval `perl -V:siteprefix` - ./configure --prefix=$siteprefix && make From 589da2713899ee14ced13aedc1f67ac6f248de53 Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Mon, 16 Nov 2015 22:12:02 +0000 Subject: [PATCH 221/482] convert README to Markdown --- README => README.md | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) rename README => README.md (76%) diff --git a/README b/README.md similarity index 76% rename from README rename to README.md index d8df705..9d0a5f1 100644 --- a/README +++ b/README.md @@ -4,10 +4,10 @@ README for GNU Stow This is GNU Stow, a symlink farm manager program which takes distinct packages of software and/or data located in separate directories on the filesystem, and makes them appear to be installed in the same -place. For example, /usr/local/bin could contain symlinks to files -within /usr/local/stow/emacs/bin, /usr/local/stow/perl/bin etc., and -likewise recursively for any other subdirectories such as .../share, -.../man, and so on. +place. For example, `/usr/local/bin` could contain symlinks to files +within `/usr/local/stow/emacs/bin`, `/usr/local/stow/perl/bin` etc., and +likewise recursively for any other subdirectories such as `.../share`, +`.../man`, and so on. This is particularly useful for keeping track of system-wide and per-user installations of software built from source, but can also @@ -26,12 +26,12 @@ License ------- Stow is free software, licensed under the GNU General Public License, -which can be found in the file COPYING. +which can be found in the file [`COPYING`](COPYING). Installation ------------ -See INSTALL for installation instructions. +See [`INSTALL`](INSTALL) for installation instructions. Feedback -------- @@ -49,5 +49,5 @@ things in sync, Stow stores no extra state between runs, so there's no danger (as there is in Depot) of mangling directories when file hierarchies don't match the database. Also unlike Depot, Stow will never delete any files, directories, or links that appear in a Stow -directory (e.g., /usr/local/stow/emacs), so it's always possible to -rebuild the target tree (e.g., /usr/local). +directory (e.g., `/usr/local/stow/emacs`), so it's always possible to +rebuild the target tree (e.g., `/usr/local`). From 4feff09211081c9423d933944620808b3d98b43b Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Mon, 16 Nov 2015 22:21:44 +0000 Subject: [PATCH 222/482] convert INSTALL to Markdown --- INSTALL | 172 ---------------------------------------------------- INSTALL.md | 175 +++++++++++++++++++++++++++++++++++++++++++++++++++++ README.md | 2 +- 3 files changed, 176 insertions(+), 173 deletions(-) delete mode 100644 INSTALL create mode 100644 INSTALL.md diff --git a/INSTALL b/INSTALL deleted file mode 100644 index d00e279..0000000 --- a/INSTALL +++ /dev/null @@ -1,172 +0,0 @@ -Prerequisites -============= - -Stow is a collection of Perl scripts and modules. You must have Perl -5.6.1 or later in order for it to run. The test suite also requires -the Test::More and Test::Output modules which can be obtained from -CPAN. They are also available as packages in some of the GNU/Linux -distributions. - -Installation methods -==================== - -Stow can either be installed via the standard GNU Autotools procedure -(./configure, make install) or since 2.1.0, via CPAN-style via -Module::Build. - -Advantages of the Autotools approach: - - - It's arguably more flexible. - - - It will install the documentation in Info, HTML, man, and PDF - formats. - -Advantages of the Module::Build approach: - - - It's more in keeping with the standard way to distribute CPAN - modules. - - - It performs dependency checking to ensure you have the necessary - Perl modules installed. - -Basic Installation via Module::Build -==================================== - -The steps in building Stow are: - -1. `cd' to the directory containing the source code (and this file). - -2. If you are building from an official GNU release tarball, type - `./configure && make' to configure stow for your system. If you - are building from a CPAN tarball, this step can be skipped. - - If `make' warns that the Perl module installation directory is - not in @INC, then you should run: - - eval `perl -V:siteprefix` - ./configure --prefix=$siteprefix && make - - to avoid a superfluous "use lib" line in your stow executable. - -3. Type `perl Build.PL'. - -4. Type `./Build install' to install the various files. As noted - above, this installs fewer files than the Autotools installation. - -Basic Installation via Autotools -================================ - -The steps in building Stow are: - -1. `cd' to the directory containing the source code (and this file). - -2. Type `./configure' to configure stow for your system. This step - will attempt to locate your copy of perl and set its location in - `Makefile.in'. You can use the normal arguments to change the - default installation paths (see below); additionally you can use - the - - --with-pmdir=/path/to/perl/modules - - option to manually choose where the Perl modules get installed. - However, if you don't, the configure script will go to great - lengths to try to choose a sensible default. - -3. Type `make install' to install the various files. If the chosen - installation directory for Perl modules is not included in Perl's - built-in @INC search path, the Makefile rules will automatically - insert a - - use lib "..."; - - line into the generated stow script to ensure that it can always - locate the Perl modules without needing to manually set PERL5LIB. - -4. You can remove the generated files from the source code directory - by typing `make clean'. To also remove the files that `configure' - created (so you can compile the package for a different computer), - type `make distclean'. There is also a `make maintainer-clean' - target, but that is intended mainly for stow's developers. If you - use it, you may have to get all sorts of other programs in order - to regenerate files that came with the distribution. - -Installation Names -================== - -By default, `make install' will install the package's files in -`/usr/local/bin' and `/usr/local/info'. You can specify an -installation prefix other than `/usr/local' by giving `configure' the -option `--prefix=PATH'. - -If the package supports it, you can cause programs to be installed -with an extra prefix or suffix on their names by giving `configure' -the option `--program-prefix=PREFIX' or `--program-suffix=SUFFIX'. - -Since `stow' is concerned with separating a package's installation -tree from its run-time tree, you might want to install `stow' into a -directory such as `/usr/local/stow/stow' but have it run out of -`/usr/local'. Do this by giving the run-time prefix (e.g., -/usr/local) to configure as described above; then run `make'; then run -`make install prefix=/usr/local/stow/stow'. For more information on -this technique, see the Stow manual. - -The configuration system -======================== - -The `configure' shell script attempts to guess correct values for -various system-dependent variables used during compilation. It uses -those values to create a `Makefile' and to create the `stow' script -itself, using Makefile.in and stow.in as templates. Finally, it -creates a shell script `config.status' that you can run in the future -to recreate the current configuration, a file `config.cache' that -saves the results of its tests to speed up reconfiguring, and a file -`config.log' containing other output. - -The file `configure.ac' is used to create `configure' by a program -called `autoconf'. You only need `configure.ac' if you want to change -it or regenerate `configure' using a newer version of `autoconf'. - -The file `Makefile.am' is used to create `Makefile.in' by a program -called `automake'. You only need `Makefile.am' if you want to change -it or regenerate `Makefile.in' using a newer version of `automake'. - -Sharing Defaults -================ - -If you want to set default values for `configure' scripts to share, -you can create a site shell script called `config.site' that gives -default values for variables like `CC', `cache_file', and `prefix'. -`configure' looks for `PREFIX/share/config.site' if it exists, then -`PREFIX/etc/config.site' if it exists. Or, you can set the -`CONFIG_SITE' environment variable to the location of the site script. -A warning: not all `configure' scripts look for a site script. - -Operation Controls -================== - - `configure' recognizes the following options to control how it -operates. - -`--cache-file=FILE' - Use and save the results of the tests in FILE instead of - `./config.cache'. Set FILE to `/dev/null' to disable caching, for - debugging `configure'. - -`--help' - Print a summary of the options to `configure', and exit. - -`--quiet' -`--silent' -`-q' - Do not print messages saying which checks are being made. - -`--srcdir=DIR' - Look for the package's source code in directory DIR. Usually - `configure' can determine that directory automatically. - -`--version' - Print the version of Autoconf used to generate the `configure' - script, and exit. - -`configure' also accepts some other, not widely useful, options. - diff --git a/INSTALL.md b/INSTALL.md new file mode 100644 index 0000000..f962755 --- /dev/null +++ b/INSTALL.md @@ -0,0 +1,175 @@ +How to install GNU Stow +======================= + +Prerequisites +------------- + +Stow is a collection of Perl scripts and modules. You must have Perl +5.6.1 or later in order for it to run. The test suite also requires +the `Test::More` and `Test::Output` modules which can be obtained from +CPAN. They are also available as packages in some of the GNU/Linux +distributions. + +Installation methods +-------------------- + +Stow can either be installed via the standard GNU Autotools procedure +(`./configure && make install`) or since 2.1.0, via CPAN-style via +Module::Build. + +Advantages of the Autotools approach: + + - It's arguably more flexible. + + - It will install the documentation in Info, HTML, man, and PDF + formats. + +Advantages of the `Module::Build` approach: + + - It's more in keeping with the standard way to distribute CPAN + modules. + + - It performs dependency checking to ensure you have the necessary + Perl modules installed. + +Basic Installation via `Module::Build` +-------------------------------------- + +The steps in building Stow are: + +1. `cd` to the directory containing the source code (and this file). + +2. If you are building from an official GNU release tarball, type + `./configure && make` to configure stow for your system. If you + are building from a CPAN tarball, this step can be skipped. + + If `make` warns that the Perl module installation directory is + not in `@INC`, then you should run: + + eval `perl -V:siteprefix` + ./configure --prefix=$siteprefix && make + + to avoid a superfluous `use lib` line in your stow executable. + +3. Type `perl Build.PL`. + +4. Type `./Build install` to install the various files. As noted + above, this installs fewer files than the Autotools installation. + +Basic Installation via Autotools +-------------------------------- + +The steps in building Stow are: + +1. `cd` to the directory containing the source code (and this file). + +2. Type `./configure` to configure stow for your system. This step + will attempt to locate your copy of perl and set its location in + `Makefile.in`. You can use the normal arguments to change the + default installation paths (see below); additionally you can use + the + + --with-pmdir=/path/to/perl/modules + + option to manually choose where the Perl modules get installed. + However, if you don't, the `configure` script will go to great + lengths to try to choose a sensible default. + +3. Type `make install` to install the various files. If the chosen + installation directory for Perl modules is not included in Perl's + built-in `@INC` search path, the Makefile rules will automatically + insert a + + use lib "..."; + + line into the generated stow script to ensure that it can always + locate the Perl modules without needing to manually set `PERL5LIB`. + +4. You can remove the generated files from the source code directory + by typing `make clean`. To also remove the files that `configure` + created (so you can compile the package for a different computer), + type `make distclean`. There is also a `make maintainer-clean` + target, but that is intended mainly for stow's developers. If you + use it, you may have to get all sorts of other programs in order + to regenerate files that came with the distribution. + +Installation Names +------------------ + +By default, `make install` will install the package's files in +`/usr/local/bin` and `/usr/local/info`. You can specify an +installation prefix other than `/usr/local` by giving `configure` the +option `--prefix=PATH`. + +If the package supports it, you can cause programs to be installed +with an extra prefix or suffix on their names by giving `configure` +the option `--program-prefix=PREFIX` or `--program-suffix=SUFFIX`. + +Since `stow` is concerned with separating a package's installation +tree from its run-time tree, you might want to install `stow` into a +directory such as `/usr/local/stow/stow` but have it run out of +`/usr/local`. Do this by giving the run-time prefix (e.g., +/usr/local) to configure as described above; then run `make`; then run +`make install prefix=/usr/local/stow/stow`. For more information on +this technique, see the Stow manual. + +The configuration system +------------------------ + +The `configure` shell script attempts to guess correct values for +various system-dependent variables used during compilation. It uses +those values to create a `Makefile` and to create the `stow` script +itself, using Makefile.in and stow.in as templates. Finally, it +creates a shell script `config.status` that you can run in the future +to recreate the current configuration, a file `config.cache` that +saves the results of its tests to speed up reconfiguring, and a file +`config.log` containing other output. + +The file `configure.ac` is used to create `configure` by a program +called `autoconf`. You only need `configure.ac` if you want to change +it or regenerate `configure` using a newer version of `autoconf`. + +The file `Makefile.am` is used to create `Makefile.in` by a program +called `automake`. You only need `Makefile.am` if you want to change +it or regenerate `Makefile.in` using a newer version of `automake`. + +Sharing Defaults +---------------- + +If you want to set default values for `configure` scripts to share, +you can create a site shell script called `config.site` that gives +default values for variables like `CC`, `cache_file`, and `prefix`. +`configure` looks for `PREFIX/share/config.site` if it exists, then +`PREFIX/etc/config.site` if it exists. Or, you can set the +`CONFIG_SITE` environment variable to the location of the site script. +A warning: not all `configure` scripts look for a site script. + +Operation Controls +------------------ + +`configure` recognizes the following options to control how it +operates. + +`--cache-file=FILE` + Use and save the results of the tests in FILE instead of + `./config.cache`. Set FILE to `/dev/null` to disable caching, for + debugging `configure`. + +`--help` + Print a summary of the options to `configure`, and exit. + +`--quiet` +`--silent` +`-q` + Do not print messages saying which checks are being made. + +`--srcdir=DIR` + Look for the package's source code in directory DIR. Usually + `configure` can determine that directory automatically. + +`--version` + Print the version of Autoconf used to generate the `configure` + script, and exit. + +`configure` also accepts some other, not widely useful, options. + diff --git a/README.md b/README.md index 9d0a5f1..4f8e816 100644 --- a/README.md +++ b/README.md @@ -31,7 +31,7 @@ which can be found in the file [`COPYING`](COPYING). Installation ------------ -See [`INSTALL`](INSTALL) for installation instructions. +See [`INSTALL.md`](INSTALL.md) for installation instructions. Feedback -------- From 22139efe2b4da77776cc683f5b98a4c632bb9a7a Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Mon, 16 Nov 2015 22:35:56 +0000 Subject: [PATCH 223/482] fix breakage caused by converting files to Markdown --- MANIFEST | 4 ++-- Makefile.am | 2 +- configure.ac | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/MANIFEST b/MANIFEST index 93becf6..8fc5729 100644 --- a/MANIFEST +++ b/MANIFEST @@ -21,7 +21,7 @@ doc/stow.info doc/stow.texi doc/texinfo.tex doc/version.texi -INSTALL +INSTALL.md lib/Stow.pm lib/Stow.pm.in lib/Stow/Util.pm @@ -31,7 +31,7 @@ Makefile.in MANIFEST This list of files MANIFEST.SKIP NEWS -README +README.md t/chkstow.t t/cleanup_invalid_links.t t/cli_options.t diff --git a/Makefile.am b/Makefile.am index 7a1a808..d3f9841 100644 --- a/Makefile.am +++ b/Makefile.am @@ -6,7 +6,7 @@ dist_man_MANS = doc/stow.8 PDF = doc/manual.pdf HTML = doc/manual-single.html dist_doc_DATA = \ - README \ + README.md INSTALL.md \ $(PDF) $(HTML) doc/version.texi \ ChangeLog doc/ChangeLog.OLD diff --git a/configure.ac b/configure.ac index 4b3bd49..6631a6f 100644 --- a/configure.ac +++ b/configure.ac @@ -6,7 +6,7 @@ AC_CONFIG_AUX_DIR([automake]) # Unfortunately we have to disable warnings for overrides, because we # need to override the built-in `check' rule and also the TEXI2DVI # variable. -AM_INIT_AUTOMAKE([-Wall -Werror -Wno-override dist-bzip2]) +AM_INIT_AUTOMAKE([-Wall -Werror -Wno-override dist-bzip2 foreign]) AC_PROG_INSTALL dnl Check for perl on our system. From fcdb1af67aa08e0f1d9846a8cb57c45a87487687 Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Mon, 16 Nov 2015 22:39:53 +0000 Subject: [PATCH 224/482] add Travis CI badge to README.md --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 4f8e816..e7d7ce5 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,5 @@ +[![Build Status](https://travis-ci.org/aspiers/stow.svg)](https://travis-ci.org/aspiers/stow) + README for GNU Stow =================== From d527094bb44468093b3c674eab3d931ce57f3e28 Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Tue, 17 Nov 2015 01:34:23 +0000 Subject: [PATCH 225/482] fix make distcheck Stow/Util.pm was not being installed correctly --- Makefile.am | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/Makefile.am b/Makefile.am index d3f9841..fa1e96c 100644 --- a/Makefile.am +++ b/Makefile.am @@ -11,9 +11,7 @@ dist_doc_DATA = \ ChangeLog doc/ChangeLog.OLD pmdir = $(PMDIR) -pm_DATA = lib/Stow.pm -pmstowdir = $(pmdir)/Stow -dist_pmstow_DATA = lib/Stow/Util.pm +pm_DATA = lib/Stow.pm lib/Stow/Util.pm TEXINFO_TEX = doc/texinfo.tex export TEXI2DVI_BUILD_MODE = clean From b52d7890f86385ca7892a58a4624c6ae3e5169d9 Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Mon, 16 Nov 2015 22:50:58 +0000 Subject: [PATCH 226/482] add .travis.yml to MANIFEST.SKIP --- MANIFEST.SKIP | 1 + 1 file changed, 1 insertion(+) diff --git a/MANIFEST.SKIP b/MANIFEST.SKIP index df1f41f..8930b2b 100644 --- a/MANIFEST.SKIP +++ b/MANIFEST.SKIP @@ -82,3 +82,4 @@ # Avoid test files tmp-testing-trees +.travis.yml From 21ffd2dfece9cb3064d8e684ed52fd018de2ddb2 Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Mon, 16 Nov 2015 22:47:34 +0000 Subject: [PATCH 227/482] add make distcheck and Module::Build to Travis tests --- .travis.yml | 7 +++++-- Makefile.am | 10 ++++++++++ 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index a7ac3d3..21a16eb 100644 --- a/.travis.yml +++ b/.travis.yml @@ -11,8 +11,11 @@ addons: - texinfo - texlive - texi2html -before_install: +install: - autoreconf --install - eval `perl -V:siteprefix` - ./configure --prefix=$siteprefix && make -after_failure: find /home/travis/.cpanm/ -name build.log | xargs grep . + - make cpanm +script: + - make distcheck + - perl Build.PL && ./Build distcheck diff --git a/Makefile.am b/Makefile.am index fa1e96c..fd59c77 100644 --- a/Makefile.am +++ b/Makefile.am @@ -147,6 +147,16 @@ lib/Stow/Util.pm: lib/Stow/Util.pm.in Makefile.am # The below rules should only be needed by developers. ############################################################################## +cpanm: + cpanm --quiet --installdeps --notest .; \ + CPANM_RESULT=$$?; \ + if [ $$CPANM_RESULT != 0 ]; then \ + echo ---------------------------------------------------; \ + cat ~/.cpanm/build.log; \ + echo ---------------------------------------------------; \ + exit $$CPANM_RESULT; \ + fi + doc/stow.8: bin/stow.in Makefile.am [ -d doc ] || mkdir doc # required in vpath mode $(edit) < $< | pod2man > $@ From c512ff6357175d7503158cd1d4bc5696c01b6246 Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Tue, 17 Nov 2015 01:43:38 +0000 Subject: [PATCH 228/482] add coveralls --- .travis.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 21a16eb..38d4943 100644 --- a/.travis.yml +++ b/.travis.yml @@ -11,6 +11,8 @@ addons: - texinfo - texlive - texi2html +before_install: + - cpanm -n Devel::Cover::Report::Coveralls install: - autoreconf --install - eval `perl -V:siteprefix` @@ -18,4 +20,5 @@ install: - make cpanm script: - make distcheck - - perl Build.PL && ./Build distcheck + - perl Build.PL && ./Build build && cover -test -report coveralls + - ./Build distcheck From 1664be4125082ee2e56ee5586228e841d912b02c Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Tue, 17 Nov 2015 01:50:27 +0000 Subject: [PATCH 229/482] add coveralls badge --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index e7d7ce5..29d760d 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,5 @@ [![Build Status](https://travis-ci.org/aspiers/stow.svg)](https://travis-ci.org/aspiers/stow) +[![Coverage Status](https://coveralls.io/repos/aspiers/stow/badge.svg?branch=master&service=github)](https://coveralls.io/github/aspiers/stow?branch=master) README for GNU Stow =================== From cc0767597e5f9e23400323b42550e4672160b3c0 Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Tue, 17 Nov 2015 17:27:39 +0000 Subject: [PATCH 230/482] another attempt to fix automake config d527094b was not the right fix - Util.pm was being installed alongside Stow.pm under $(PMDIR). This should be the correct fix. --- Makefile.am | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/Makefile.am b/Makefile.am index fd59c77..a5e4fff 100644 --- a/Makefile.am +++ b/Makefile.am @@ -10,8 +10,12 @@ dist_doc_DATA = \ $(PDF) $(HTML) doc/version.texi \ ChangeLog doc/ChangeLog.OLD +# automake magic to define where *_DATA files get installed: pmdir = $(PMDIR) -pm_DATA = lib/Stow.pm lib/Stow/Util.pm +pmstowdir = $(pmdir)/Stow + +pm_DATA = lib/Stow.pm +pmstow_DATA = lib/Stow/Util.pm TEXINFO_TEX = doc/texinfo.tex export TEXI2DVI_BUILD_MODE = clean @@ -79,7 +83,7 @@ EXTRA_DIST = \ $(TEXINFO_TEX) \ $(DEFAULT_IGNORE_LIST) \ $(CPAN_FILES) -CLEANFILES = $(bin_SCRIPTS) $(pm_DATA) +CLEANFILES = $(bin_SCRIPTS) $(pm_DATA) $(pmstow_DATA) MAINTAINERCLEANFILES = $(dist_man_MANS) $(HTML) $(PDF) ChangeLog # clean up auto-generated files From c171ca8d839e0cd3d67d754b442c38865b6a8c4f Mon Sep 17 00:00:00 2001 From: Lucas Theisen Date: Sat, 27 Feb 2016 12:19:57 -0500 Subject: [PATCH 231/482] fixed testutil to support cygwin which reports -z = true on directories --- t/testutil.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/t/testutil.pm b/t/testutil.pm index 32fc2f1..1e73dfe 100755 --- a/t/testutil.pm +++ b/t/testutil.pm @@ -228,7 +228,7 @@ sub remove_dir { next NODE if $node eq '..'; my $path = "$dir/$node"; - if (-l $path or -z $path or $node eq $Stow::LOCAL_IGNORE_FILE) { + if (-l $path or (-f $path and -z $path) or $node eq $Stow::LOCAL_IGNORE_FILE) { unlink $path or die "cannot unlink $path ($!)\n"; } elsif (-d "$path") { From 95ffbc5ebdab2eb812ace06ee5181ea188e314fd Mon Sep 17 00:00:00 2001 From: Charles LeDoux Date: Tue, 10 May 2016 15:00:13 -0500 Subject: [PATCH 232/482] Add docker files for local testing. * Use docker to locally run tests on multiple perl versions * perlbrew used to install multiple perls * perl environments bootstrapped when image built * Based on travis configuration * Adds docker folder to MANIFEST.SKIP * Running image runs all tests. * If exit with no error, then all tests pass. * ./build-docker.sh builds stow testing image. * ./test-docker.sh runs stow testing image. * Assumes built with options in build-docker.sh * *-docker.sh scripts added to MANIFEST.SKIP --- MANIFEST.SKIP | 2 ++ build-docker.sh | 7 ++++++ docker/Dockerfile | 47 +++++++++++++++++++++++++++++++++++++++ docker/bootstrap-perls.sh | 15 +++++++++++++ docker/run-stow-tests.sh | 31 ++++++++++++++++++++++++++ test-docker.sh | 4 ++++ 6 files changed, 106 insertions(+) create mode 100755 build-docker.sh create mode 100644 docker/Dockerfile create mode 100755 docker/bootstrap-perls.sh create mode 100755 docker/run-stow-tests.sh create mode 100755 test-docker.sh diff --git a/MANIFEST.SKIP b/MANIFEST.SKIP index 8930b2b..b356572 100644 --- a/MANIFEST.SKIP +++ b/MANIFEST.SKIP @@ -83,3 +83,5 @@ # Avoid test files tmp-testing-trees .travis.yml +^docker/ +^[a-zA-Z]*-docker.sh diff --git a/build-docker.sh b/build-docker.sh new file mode 100755 index 0000000..02d4590 --- /dev/null +++ b/build-docker.sh @@ -0,0 +1,7 @@ +#!/bin/bash + +set -eu + +pushd docker +docker build -t stowtest . +popd diff --git a/docker/Dockerfile b/docker/Dockerfile new file mode 100644 index 0000000..c3a24db --- /dev/null +++ b/docker/Dockerfile @@ -0,0 +1,47 @@ +# Build docker image: `docker build -t stowtest` +# Run tests: (from stow src directory) +# `docker run --rm -it -v $(pwd):$(pwd) -w $(pwd) stowtest` +FROM debian:jessie +RUN DEBIAN_FRONTEND=noninteractive \ +apt-get clean && \ +apt-get update -qq && \ +apt-get install -y -q \ + autoconf \ + bzip2 \ + cpanminus \ + gawk \ + git \ + libssl-dev \ + make \ + patch \ + perlbrew \ + texinfo \ + texlive \ + texi2html \ +&& rm -rf /var/lib/apt/lists/* + +# Set up perlbrew +ENV HOME=/root \ + PERLBREW_ROOT=/usr/local/perlbrew \ + PERLBREW_HOME=/root/.perlbrew \ + PERLBREW_PATH=/usr/local/perlbrew/bin +RUN mkdir -p /usr/local/perlbrew /root \ + && perlbrew init \ + && perlbrew install-cpanm \ + && perlbrew install-patchperl \ + && perlbrew install-multiple -j 4 --notest \ + perl-5.22.2 \ + perl-5.20.3 \ + perl-5.18.4 \ + perl-5.16.3 \ + perl-5.14.4 \ +&& perlbrew clean + +# Bootstrap the perl environments +COPY ./bootstrap-perls.sh /bootstrap-perls.sh +RUN /bootstrap-perls.sh && rm /bootstrap-perls.sh + +# Add test script to container filesystem +COPY ./run-stow-tests.sh /run-stow-tests.sh + +ENTRYPOINT ["/run-stow-tests.sh"] diff --git a/docker/bootstrap-perls.sh b/docker/bootstrap-perls.sh new file mode 100755 index 0000000..1ee87bd --- /dev/null +++ b/docker/bootstrap-perls.sh @@ -0,0 +1,15 @@ +#!/bin/bash + +# Load perlbrew environment +. /usr/local/perlbrew/etc/bashrc + +# For each perl version installed. +for p_version in $(perlbrew list | sed 's/ //g'); do + # Switch to it. + perlbrew use $p_version + # and install the needed modules. + /usr/local/perlbrew/bin/cpanm -n Devel::Cover::Report::Coveralls Test::More Test::Output +done + +# Cleanup to remove any temp files. +perlbrew clean diff --git a/docker/run-stow-tests.sh b/docker/run-stow-tests.sh new file mode 100755 index 0000000..950d0ba --- /dev/null +++ b/docker/run-stow-tests.sh @@ -0,0 +1,31 @@ +#!/bin/bash + +# Load perlbrew environment +# Load before setting safety to keep +# perlbrew scripts from breaking due to +# unset variables. +. /usr/local/perlbrew/etc/bashrc + +# Standard safety protocol +set -euf -o pipefail +IFS=$'\n\t' + +for p_version in $(perlbrew list | sed 's/ //g'); do + + perlbrew use $p_version + + echo $(perl --version) + + # Install stow + autoreconf --install + eval `perl -V:siteprefix` + ./configure --prefix=$siteprefix && make + make cpanm + + # Run tests + make distcheck + perl Build.PL && ./Build build && cover -test + ./Build distcheck +done + +make distclean diff --git a/test-docker.sh b/test-docker.sh new file mode 100755 index 0000000..5d9ac31 --- /dev/null +++ b/test-docker.sh @@ -0,0 +1,4 @@ +#!/bin/bash + +# Run the docker image that test. +docker run --rm -it -v $(pwd):$(pwd) -w $(pwd) stowtest From f5e12670d653324251827b8ceb45424ffdd162fd Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Tue, 23 Aug 2016 10:37:12 +0100 Subject: [PATCH 233/482] remove superfluous space in function call Be consistent with style elsewhere. --- lib/Stow.pm.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Stow.pm.in b/lib/Stow.pm.in index 851bb86..633d584 100755 --- a/lib/Stow.pm.in +++ b/lib/Stow.pm.in @@ -559,7 +559,7 @@ sub should_skip_target_which_is_stow_dir { return 1; } - debug (4, "$target not protected"); + debug(4, "$target not protected"); return 0; } From 7ede3c8df0cecbe7e8934b04970d792cdbddb672 Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Tue, 20 Sep 2016 18:27:46 +0100 Subject: [PATCH 234/482] fix naming of man page The title of the generated man page was ending up as something like IO::FILE=IO(0XA719C0)(1) Also, with newer perls (e.g. v5.22.1), pod2man requires --name if used within a pipeline. Closes #18. https://github.com/aspiers/stow/issues/18 --- Makefile.am | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile.am b/Makefile.am index a5e4fff..ef3520a 100644 --- a/Makefile.am +++ b/Makefile.am @@ -163,7 +163,7 @@ cpanm: doc/stow.8: bin/stow.in Makefile.am [ -d doc ] || mkdir doc # required in vpath mode - $(edit) < $< | pod2man > $@ + $(edit) < $< | pod2man --name stow --section 8 > $@ # We use automake's built-in rule to generate stow.info. The built-in # rules would also generate doc/stow.html and doc/stow.pdf, but after From 182acbbb64425bf95008cb6d42d266f6185032c9 Mon Sep 17 00:00:00 2001 From: Joris Vankerschaver Date: Sun, 31 Jul 2016 21:55:55 +0100 Subject: [PATCH 235/482] Special processing for dotfiles --- MANIFEST | 1 + bin/stow.in | 18 ++++++- lib/Stow.pm.in | 23 ++++++++- lib/Stow/Util.pm.in | 16 +++++- t/dotfiles.t | 116 ++++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 171 insertions(+), 3 deletions(-) create mode 100644 t/dotfiles.t diff --git a/MANIFEST b/MANIFEST index 8fc5729..056d512 100644 --- a/MANIFEST +++ b/MANIFEST @@ -36,6 +36,7 @@ t/chkstow.t t/cleanup_invalid_links.t t/cli_options.t t/defer.t +t/dotfiles.t t/examples.t t/find_stowed_path.t t/foldable.t diff --git a/bin/stow.in b/bin/stow.in index ec83f59..6e5673f 100755 --- a/bin/stow.in +++ b/bin/stow.in @@ -214,6 +214,22 @@ stowed to another package. Force stowing files beginning with this Perl regex if the file is already stowed to another package. +=item --dotfiles + +Enable special handling for "dotfiles" (files or folders whose name +begins with a period) in the package directory. If this option is +enabled, Stow will add a preprocessing step for each file or folder +whose name begins with "dot-", and replace the "dot-" prefix in the +name by a period (.). This is useful when Stow is used to manage +collections of dotfiles, to avoid having a package directory full of +hidden files. + +For example, suppose we have a package containing two files, +F and F. With this option, +Stow will create symlinks from F<.bashrc> to F and +from F<.emacs.d/init.el> to F. Any other +files, whose name does not begin with "dot-", will be processed as usual. + =item -V =item --version @@ -481,7 +497,7 @@ sub process_options { \%options, 'verbose|v:+', 'help|h', 'simulate|n|no', 'version|V', 'compat|p', 'dir|d=s', 'target|t=s', - 'adopt', 'no-folding', + 'adopt', 'no-folding', 'dotfiles', # clean and pre-compile any regex's at parse time 'ignore=s' => diff --git a/lib/Stow.pm.in b/lib/Stow.pm.in index 851bb86..2f66446 100755 --- a/lib/Stow.pm.in +++ b/lib/Stow.pm.in @@ -41,7 +41,7 @@ use File::Spec; use POSIX qw(getcwd); use Stow::Util qw(set_debug_level debug error set_test_mode - join_paths restore_cwd canon_path parent); + join_paths restore_cwd canon_path parent adjust_dotfile); our $ProgramName = 'stow'; our $VERSION = '@VERSION@'; @@ -60,6 +60,7 @@ our %DEFAULT_OPTIONS = ( paranoid => 0, compat => 0, test_mode => 0, + dotfiles => 0, adopt => 0, 'no-folding' => 0, ignore => [], @@ -377,6 +378,13 @@ sub stow_contents { next NODE if $node eq '..'; my $node_target = join_paths($target, $node); next NODE if $self->ignore($stow_path, $package, $node_target); + + if ($self->{dotfiles}) { + my $adj_node_target = adjust_dotfile($node_target); + debug(4, " Adjusting: $node_target => $adj_node_target"); + $node_target = $adj_node_target; + } + $self->stow_node( $stow_path, $package, @@ -744,6 +752,13 @@ sub unstow_contents { next NODE if $node eq '..'; my $node_target = join_paths($target, $node); next NODE if $self->ignore($stow_path, $package, $node_target); + + if ($self->{dotfiles}) { + my $adj_node_target = adjust_dotfile($node_target); + debug(4, " Adjusting: $node_target => $adj_node_target"); + $node_target = $adj_node_target; + } + $self->unstow_node($stow_path, $package, $node_target); } if (-d $target) { @@ -801,6 +816,12 @@ sub unstow_node { # Does the existing $target actually point to anything? if (-e $existing_path) { # Does link points to the right place? + + # Adjust for dotfile if necessary. + if ($self->{dotfiles}) { + $existing_path = adjust_dotfile($existing_path); + } + if ($existing_path eq $path) { $self->do_unlink($target); } diff --git a/lib/Stow/Util.pm.in b/lib/Stow/Util.pm.in index b709e7e..451a143 100644 --- a/lib/Stow/Util.pm.in +++ b/lib/Stow/Util.pm.in @@ -22,7 +22,7 @@ use POSIX qw(getcwd); use base qw(Exporter); our @EXPORT_OK = qw( error debug set_debug_level set_test_mode - join_paths parent canon_path restore_cwd + join_paths parent canon_path restore_cwd adjust_dotfile ); our $ProgramName = 'stow'; @@ -193,6 +193,20 @@ sub restore_cwd { chdir($prev) or error("Your current directory $prev seems to have vanished"); } +sub adjust_dotfile { + my ($target) = @_; + + my @result = (); + for my $part (split m{/+}, $target) { + if (($part ne "dot-") && ($part ne "dot-.")) { + $part =~ s/^dot-/./; + } + push @result, $part; + } + + return join '/', @result; +} + =head1 BUGS =head1 SEE ALSO diff --git a/t/dotfiles.t b/t/dotfiles.t new file mode 100644 index 0000000..e6fa69e --- /dev/null +++ b/t/dotfiles.t @@ -0,0 +1,116 @@ +#!/usr/local/bin/perl + +# +# Test case for dotfiles special processing +# + +use strict; +use warnings; + +use testutil; + +use Test::More tests => 6; +use English qw(-no_match_vars); + +use testutil; + +init_test_dirs(); +cd("$OUT_DIR/target"); + +my $stow; + +# +# process a dotfile marked with 'dot' prefix +# + +$stow = new_Stow(dir => '../stow', dotfiles => 1); + +make_dir('../stow/dotfiles'); +make_file('../stow/dotfiles/dot-foo'); + +$stow->plan_stow('dotfiles'); +$stow->process_tasks(); +is( + readlink('.foo'), + '../stow/dotfiles/dot-foo', + => 'processed dotfile' +); + +# +# ensure that turning off dotfile processing links files as usual +# + +$stow = new_Stow(dir => '../stow', dotfiles => 0); + +make_dir('../stow/dotfiles'); +make_file('../stow/dotfiles/dot-foo'); + +$stow->plan_stow('dotfiles'); +$stow->process_tasks(); +is( + readlink('dot-foo'), + '../stow/dotfiles/dot-foo', + => 'unprocessed dotfile' +); + + +# +# process folder marked with 'dot' prefix +# + +$stow = new_Stow(dir => '../stow', dotfiles => 1); + +make_dir('../stow/dotfiles/dot-emacs'); +make_file('../stow/dotfiles/dot-emacs/init.el'); + +$stow->plan_stow('dotfiles'); +$stow->process_tasks(); +is( + readlink('.emacs'), + '../stow/dotfiles/dot-emacs', + => 'processed dotfile folder' +); + +# +# corner case: paths that have a part in them that's just "$DOT_PREFIX" or +# "$DOT_PREFIX." should not have that part expanded. +# + +$stow = new_Stow(dir => '../stow', dotfiles => 1); + +make_dir('../stow/dotfiles'); +make_file('../stow/dotfiles/dot-'); + +make_dir('../stow/dotfiles/dot-.'); +make_file('../stow/dotfiles/dot-./foo'); + +$stow->plan_stow('dotfiles'); +$stow->process_tasks(); +is( + readlink('dot-'), + '../stow/dotfiles/dot-', + => 'processed dotfile' +); +is( + readlink('dot-.'), + '../stow/dotfiles/dot-.', + => 'unprocessed dotfile' +); + +# +# simple unstow scenario +# + +$stow = new_Stow(dir => '../stow', dotfiles => 1); + +make_dir('../stow/dotfiles'); +make_file('../stow/dotfiles/dot-bar'); +make_link('.bar', '../stow/dotfiles/dot-bar'); + +$stow->plan_unstow('dotfiles'); +$stow->process_tasks(); +ok( + $stow->get_conflict_count == 0 && + -f '../stow/dotfiles/dot-bar' && ! -e '.bar' + => 'unstow a simple dotfile' +); From 0bc06e58e1a71ad490b7b12e94afa82ff68332fa Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Sun, 20 Nov 2016 20:55:14 +0000 Subject: [PATCH 236/482] HOWTO-RELEASE: add a reminder to update THANKS Make sure the maintainer always gives credit to contributors :-) --- doc/HOWTO-RELEASE | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/doc/HOWTO-RELEASE b/doc/HOWTO-RELEASE index 65f5afd..7242d74 100644 --- a/doc/HOWTO-RELEASE +++ b/doc/HOWTO-RELEASE @@ -11,7 +11,8 @@ First read the official information for maintainers of GNU software: Release procedure ----------------- -- Ensure NEWS contains the latest changes. +- Ensure NEWS contains the latest changes, and that any new + contributors have been added to THANKS. - Ensure configure.ac contains the new version number. This should follow Semantic Versioning as described at: From b2fdd2759666da0ee5cff853e4ba9bc4a2ab9dff Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Sun, 20 Nov 2016 21:17:46 +0000 Subject: [PATCH 237/482] THANKS: clarify mention of Bob Glickstein --- THANKS | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/THANKS b/THANKS index bd3b5a9..cf0eb06 100644 --- a/THANKS +++ b/THANKS @@ -1,8 +1,7 @@ -Bob Glickstein: - Thanks to the following people for testing, using, commenting on, and otherwise aiding the creation of Stow: +Bob Glickstein (original author) Miles Bader Greg Fox David Hartmann From 68838c8d9d806f9b17f07e55a3fceeef563bda51 Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Sun, 20 Nov 2016 21:18:08 +0000 Subject: [PATCH 238/482] THANKS: add some recent contributors --- THANKS | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/THANKS b/THANKS index cf0eb06..d241781 100644 --- a/THANKS +++ b/THANKS @@ -23,3 +23,11 @@ Adam Spiers Stefano Lattarini Adam Sampson Cuong Manh Le +Lucas Theisen +Charles LeDoux +Joris Vankerschaver +@Corin-EU on GitHub + +Email addresses of new contributors are no longer being added by default +for privacy reasons; however please contact the maintainer if you are +happy for your email address to be listed here. From 08bff6df00ab8194e32afa7144cdd4b111a2c6b8 Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Sun, 20 Nov 2016 21:51:41 +0000 Subject: [PATCH 239/482] whitespace cleanups --- doc/HOWTO-RELEASE | 2 +- docker/Dockerfile | 2 +- docker/bootstrap-perls.sh | 6 +++--- docker/run-stow-tests.sh | 15 +++++++-------- test-docker.sh | 2 +- 5 files changed, 13 insertions(+), 14 deletions(-) diff --git a/doc/HOWTO-RELEASE b/doc/HOWTO-RELEASE index 7242d74..76812df 100644 --- a/doc/HOWTO-RELEASE +++ b/doc/HOWTO-RELEASE @@ -91,7 +91,7 @@ Release procedure - Copy gnulib/build-aux/gnupload to somewhere on your $PATH - Run gnupload --to ftp.gnu.org:stow --symlink-regex stow-7.8.9.tar.* -- Send release announcements to +- Send release announcements to - info-stow@gnu.org - stow-devel@gnu.org diff --git a/docker/Dockerfile b/docker/Dockerfile index c3a24db..3796e26 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -1,5 +1,5 @@ # Build docker image: `docker build -t stowtest` -# Run tests: (from stow src directory) +# Run tests: (from stow src directory) # `docker run --rm -it -v $(pwd):$(pwd) -w $(pwd) stowtest` FROM debian:jessie RUN DEBIAN_FRONTEND=noninteractive \ diff --git a/docker/bootstrap-perls.sh b/docker/bootstrap-perls.sh index 1ee87bd..00061b6 100755 --- a/docker/bootstrap-perls.sh +++ b/docker/bootstrap-perls.sh @@ -6,10 +6,10 @@ # For each perl version installed. for p_version in $(perlbrew list | sed 's/ //g'); do # Switch to it. - perlbrew use $p_version + perlbrew use $p_version # and install the needed modules. - /usr/local/perlbrew/bin/cpanm -n Devel::Cover::Report::Coveralls Test::More Test::Output + /usr/local/perlbrew/bin/cpanm -n Devel::Cover::Report::Coveralls Test::More Test::Output done -# Cleanup to remove any temp files. +# Cleanup to remove any temp files. perlbrew clean diff --git a/docker/run-stow-tests.sh b/docker/run-stow-tests.sh index 950d0ba..8adf155 100755 --- a/docker/run-stow-tests.sh +++ b/docker/run-stow-tests.sh @@ -11,21 +11,20 @@ set -euf -o pipefail IFS=$'\n\t' for p_version in $(perlbrew list | sed 's/ //g'); do - perlbrew use $p_version echo $(perl --version) # Install stow - autoreconf --install - eval `perl -V:siteprefix` - ./configure --prefix=$siteprefix && make - make cpanm + autoreconf --install + eval `perl -V:siteprefix` + ./configure --prefix=$siteprefix && make + make cpanm # Run tests - make distcheck - perl Build.PL && ./Build build && cover -test - ./Build distcheck + make distcheck + perl Build.PL && ./Build build && cover -test + ./Build distcheck done make distclean diff --git a/test-docker.sh b/test-docker.sh index 5d9ac31..f6fe978 100755 --- a/test-docker.sh +++ b/test-docker.sh @@ -1,4 +1,4 @@ #!/bin/bash -# Run the docker image that test. +# Run the docker image that test. docker run --rm -it -v $(pwd):$(pwd) -w $(pwd) stowtest From 17bbfb05c6826089c660acce586400553512a808 Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Sun, 20 Nov 2016 21:58:31 +0000 Subject: [PATCH 240/482] further refine the release process Let's try a new approach where we increment the version number immediately after publishing a release, not just before. This will mean that anyone who builds from git gets a version of Stow which is higher than the release which was just cut, and this could provide valuable debugging hints in case a bug report does not clearly state whether the problem arose with the latest release or with a build from git. --- doc/HOWTO-RELEASE | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/doc/HOWTO-RELEASE b/doc/HOWTO-RELEASE index 76812df..7be57bb 100644 --- a/doc/HOWTO-RELEASE +++ b/doc/HOWTO-RELEASE @@ -11,9 +11,17 @@ First read the official information for maintainers of GNU software: Release procedure ----------------- +- Set a shell variable to the version to be released, e.g. if the + final step of this document was carried out after the previous + release was published: + + version=$( git describe --match v* --abbrev=0 ) + - Ensure NEWS contains the latest changes, and that any new contributors have been added to THANKS. +- git commit -m "Prepare NEWS and THANKS for $version release" + - Ensure configure.ac contains the new version number. This should follow Semantic Versioning as described at: @@ -39,6 +47,11 @@ Release procedure ./Build distmeta - Check META.yaml and META.json have the new version number. + They already should if the final step of this document was + carried out after the previous release was published, but + if not: + + git commit -m "Bump version to X.Y.Z" - Ensure all changes are committed to git. @@ -47,7 +60,7 @@ Release procedure - Tag the current git HEAD with the new version number: - git tag -s v7.8.9 + git tag -s $version -m "Release $version" - Push HEAD and tag to savannah @@ -100,3 +113,18 @@ Release procedure See http://www.gnu.org/prep/maintain/html_node/Announcements.html for more on making release announcements. + +- Update the git repositories to the next expected version, so that anyone + who builds from git gets a version of Stow which is higher than the release + which was just cut: + + - Increment the patchlevel of the version number in configure.ac. + + - Repeat the same procedure listed in the Module::Build section + above, in order to update META.yaml and META.json. + + - git commit -m "Bump version to X.Y.Z for development of next release" + + - git push savannah + + - git push github From a9f79c6a5b11784bfe1bf5bd18dc48d63420cd14 Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Sun, 20 Nov 2016 22:00:46 +0000 Subject: [PATCH 241/482] make sure release tags are also pushed to GitHub --- doc/HOWTO-RELEASE | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/doc/HOWTO-RELEASE b/doc/HOWTO-RELEASE index 7be57bb..a8763c8 100644 --- a/doc/HOWTO-RELEASE +++ b/doc/HOWTO-RELEASE @@ -62,10 +62,12 @@ Release procedure git tag -s $version -m "Release $version" -- Push HEAD and tag to savannah +- Push HEAD and tag to savannah and GitHub: - git push - git push --tags + git push savannah + git push --tags savannah + git push github + git push --tags github - Regenerate the documentation for the website: From 98a8f7e3e751ac9114a42a6a73ae748c7e05d686 Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Sun, 20 Nov 2016 22:02:00 +0000 Subject: [PATCH 242/482] use PAUSE upload for final validation step of release --- doc/HOWTO-RELEASE | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/doc/HOWTO-RELEASE b/doc/HOWTO-RELEASE index a8763c8..fd84bc7 100644 --- a/doc/HOWTO-RELEASE +++ b/doc/HOWTO-RELEASE @@ -62,6 +62,14 @@ Release procedure git tag -s $version -m "Release $version" +- Run ./Build dist + +- Upload the resulting Stow-v7.8.9.tar.gz to CPAN via https://pause.perl.org/ + +- Wait until PAUSE has accepted the upload as a valid module. + This provides some valuable final validation, as shown by the + non-release of 2.2.1. + - Push HEAD and tag to savannah and GitHub: git push savannah @@ -96,10 +104,6 @@ Release procedure # Then commit cvs commit -m 'Update manual to v7.8.9' -- Run ./Build dist - -- Upload the resulting Stow-v7.8.9.tar.gz to CPAN via https://pause.perl.org/ - - Upload to ftp.gnu.org. This is easiest using gnupload: - git clone git://git.savannah.gnu.org/gnulib.git From 03480626a26dd2b946fece2e4cb1e66101e8f174 Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Sun, 20 Nov 2016 22:16:10 +0000 Subject: [PATCH 243/482] tag Docker images with the corresponding version number --- build-docker.sh | 7 ++++++- test-docker.sh | 8 ++++++-- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/build-docker.sh b/build-docker.sh index 02d4590..4808691 100755 --- a/build-docker.sh +++ b/build-docker.sh @@ -2,6 +2,11 @@ set -eu +version=$( git describe --match v* --abbrev=0 ) +imagename=stowtest +image=$imagename:$version + pushd docker -docker build -t stowtest . +echo "Building Docker image $image ..." +docker build -t $image . popd diff --git a/test-docker.sh b/test-docker.sh index f6fe978..2bedcae 100755 --- a/test-docker.sh +++ b/test-docker.sh @@ -1,4 +1,8 @@ #!/bin/bash -# Run the docker image that test. -docker run --rm -it -v $(pwd):$(pwd) -w $(pwd) stowtest +# Test Stow across multiple Perl versions, by executing the +# Docker image built via build-docker.sh. + +version=$( git describe --match v* --abbrev=0 ) + +docker run --rm -it -v $(pwd):$(pwd) -w $(pwd) stowtest:$version From 5123a585a2d1720af0781f956291113840a30534 Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Sun, 20 Nov 2016 22:57:08 +0000 Subject: [PATCH 244/482] ignore cover_db generated by Coveralls --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index eb004eb..6440a89 100644 --- a/.gitignore +++ b/.gitignore @@ -16,6 +16,7 @@ blib/ config.log config.status configure +/cover_db/ /doc/ChangeLog.OLD /doc/manual.pdf /doc/manual-single.html From fd10706ce30381182e2a09536b7d0485b8044f41 Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Sun, 20 Nov 2016 22:16:43 +0000 Subject: [PATCH 245/482] HOWTO-RELEASE: use Docker to test before releasing Charles LeDoux did some awesome work providing this Docker environment which can test across multiple Perl versions using perlbrew, so it would be crazy not to use it. --- doc/HOWTO-RELEASE | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/doc/HOWTO-RELEASE b/doc/HOWTO-RELEASE index fd84bc7..0c55b0e 100644 --- a/doc/HOWTO-RELEASE +++ b/doc/HOWTO-RELEASE @@ -62,6 +62,11 @@ Release procedure git tag -s $version -m "Release $version" +- Run the tests on various Perl versions via Docker: + + ./build-docker.sh + ./test-docker.sh + - Run ./Build dist - Upload the resulting Stow-v7.8.9.tar.gz to CPAN via https://pause.perl.org/ From 94b155d99b9276d9ead42f5fd2ed88663dca39c1 Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Sun, 20 Nov 2016 21:45:17 +0000 Subject: [PATCH 246/482] Prepare NEWS file for 2.3.0 release --- NEWS | 70 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 70 insertions(+) diff --git a/NEWS b/NEWS index cbcd10c..9178d23 100644 --- a/NEWS +++ b/NEWS @@ -1,5 +1,75 @@ News file for Stow. +* Changes in version 2.3.0 + +** New --dotfiles option + + Enable special handling for "dotfiles" (files or folders whose name + begins with a period) in the package directory. If this option is + enabled, Stow will add a preprocessing step for each file or folder + whose name begins with "dot-", and replace the "dot-" prefix in the + name by a period ("."). This is useful when Stow is used to manage + collections of dotfiles, to avoid having a package directory full + of hidden files. + + For example, suppose we have a package containing two files, + stow/dot-bashrc and stow/dot-emacs.d/init.el. With this option, + Stow will create symlinks from .bashrc to stow/dot-bashrc and from + .emacs.d/init.el to stow/dot-emacs.d/init.el. Any other files, + whose name does not begin with "dot-", will be processed as usual. + + Thanks to Joris Vankerschaver for this feature! + +** Fixed naming of man page + + The title of the generated man page was previously ending up as + something like: + + IO::FILE=IO(0XA719C0)(1) + + Thanks to @Corin-EU on GitHub highlighting this and proposing a + fix. + +** Fix for test suite on Cygwin + + Thanks to Lucas Theisen for this fix! + +** Convert README and INSTALL to Markdown + +** Add Docker files for convenient testing across multiple Perl versions + + This is the first release which has been tested across 5 different + versions of Perl prior to release! The versions are: + + perl-5.22.2 + perl-5.20.3 + perl-5.18.4 + perl-5.16.3 + perl-5.14.4 + + Thanks to Charles LeDoux for this! + +** Add Coveralls integration with GitHub + + This means that test coverage analysis will be automatically be run + on any pull requests submitted to GitHub. + +** Set up continuous testing via Travis CI + + This means that the test suite will be automatically run on any + pull requests submitted to GitHub, as well as "make distcheck" + and "./Build distcheck". + +** Miscellaneous fixes to the build and distribution process + +** Improve handling of directories with unusual names + + Various fixes for corner cases where directories are named "0" + or begin with a space character, or where STOW_DIR is empty. + + Thanks to Cuong Manh Le for highlighting some of the issues and + proposing fixes! + * Changes in version 2.2.2 ** @VERSION@ substitution was set up for the Stow::Util module. From 6e5209fb2d4ffc47c91cdc75abe226d1efd88ca0 Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Sun, 20 Nov 2016 22:02:19 +0000 Subject: [PATCH 247/482] Bump version to 2.3.0 --- META.json | 10 +++++----- META.yml | 8 ++++---- configure.ac | 2 +- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/META.json b/META.json index 443f81c..2a455a4 100644 --- a/META.json +++ b/META.json @@ -4,7 +4,7 @@ "unknown" ], "dynamic_config" : 1, - "generated_by" : "Module::Build version 0.4212", + "generated_by" : "Module::Build version 0.422", "license" : [ "gpl_1" ], @@ -37,11 +37,11 @@ "provides" : { "Stow" : { "file" : "lib/Stow.pm", - "version" : "v2.2.2" + "version" : "v2.3.0" }, "Stow::Util" : { "file" : "lib/Stow/Util.pm", - "version" : "v2.2.2" + "version" : "v2.3.0" } }, "release_status" : "stable", @@ -55,6 +55,6 @@ "url" : "git://git.savannah.gnu.org/stow.git" } }, - "version" : "v2.2.2", - "x_serialization_backend" : "JSON::PP version 2.27203" + "version" : "v2.3.0", + "x_serialization_backend" : "JSON::PP version 2.27300" } diff --git a/META.yml b/META.yml index d72d950..f94d472 100644 --- a/META.yml +++ b/META.yml @@ -9,7 +9,7 @@ build_requires: configure_requires: Module::Build: '0' dynamic_config: 1 -generated_by: 'Module::Build version 0.4212, CPAN::Meta::Converter version 2.150005' +generated_by: 'Module::Build version 0.422, CPAN::Meta::Converter version 2.150010' license: gpl meta-spec: url: http://module-build.sourceforge.net/META-spec-v1.4.html @@ -18,10 +18,10 @@ name: Stow provides: Stow: file: lib/Stow.pm - version: v2.2.2 + version: v2.3.0 Stow::Util: file: lib/Stow/Util.pm - version: v2.2.2 + version: v2.3.0 requires: Carp: '0' IO::File: '0' @@ -30,5 +30,5 @@ resources: homepage: https://savannah.gnu.org/projects/stow license: http://www.gnu.org/licenses/gpl-2.0.html repository: git://git.savannah.gnu.org/stow.git -version: v2.2.2 +version: v2.3.0 x_serialization_backend: 'CPAN::Meta::YAML version 0.012' diff --git a/configure.ac b/configure.ac index 6631a6f..e23eae0 100644 --- a/configure.ac +++ b/configure.ac @@ -1,6 +1,6 @@ dnl Process this file with Autoconf to produce configure dnl -AC_INIT([stow], [2.2.2], [bug-stow@gnu.org]) +AC_INIT([stow], [2.3.0], [bug-stow@gnu.org]) AC_PREREQ([2.61]) AC_CONFIG_AUX_DIR([automake]) # Unfortunately we have to disable warnings for overrides, because we From 8d738353f8fb177e3bad900e45496e23e5f90745 Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Sun, 18 Dec 2016 23:10:13 +0000 Subject: [PATCH 248/482] fix documentation for --verbose It actually goes up to 5 these days. Thanks to Kristoffer Haugsbakk for spotting that: http://lists.gnu.org/archive/html/bug-stow/2016-08/msg00000.html --- THANKS | 1 + bin/stow.in | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/THANKS b/THANKS index d241781..77a3a66 100644 --- a/THANKS +++ b/THANKS @@ -27,6 +27,7 @@ Lucas Theisen Charles LeDoux Joris Vankerschaver @Corin-EU on GitHub +Kristoffer Haugsbakk Email addresses of new contributors are no longer being added by default for privacy reasons; however please contact the maintainer if you are diff --git a/bin/stow.in b/bin/stow.in index 6e5673f..98b576e 100755 --- a/bin/stow.in +++ b/bin/stow.in @@ -152,7 +152,7 @@ directory. =item --verbose[=N] Send verbose output to standard error describing what Stow is -doing. Verbosity levels are 0, 1, 2, 3, and 4; 0 is the default. +doing. Verbosity levels are from 0 to 5; 0 is the default. Using C<-v> or C<--verbose> increases the verbosity by one; using `--verbose=N' sets it to N. @@ -654,7 +654,7 @@ OPTIONS: -p, --compat Use legacy algorithm for unstowing -n, --no, --simulate Do not actually make any filesystem changes - -v, --verbose[=N] Increase verbosity (levels are 0,1,2,3; + -v, --verbose[=N] Increase verbosity (levels are from 0 to 5; -v or --verbose adds 1; --verbose=N sets level) -V, --version Show stow version number -h, --help Show this help From 5a8d275c47e22605f43407e825c9ba3e94fc1616 Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Sun, 18 Dec 2016 23:14:39 +0000 Subject: [PATCH 249/482] replace a "you" typo with better text The contents are prepended to the arguments; they still come after the stow executable. --- doc/stow.texi | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/doc/stow.texi b/doc/stow.texi index 6690e45..160edf3 100644 --- a/doc/stow.texi +++ b/doc/stow.texi @@ -848,10 +848,10 @@ directory. @cindex resource files @cindex configuration files -Default command line options may be set in @file{.stowrc} (current directory) or -@file{~/.stowrc} (home directory). These are parsed in that order, and effectively -prepended to you command line. This feature can be used for some interesting -effects. +Default command line options may be set in @file{.stowrc} (current +directory) or @file{~/.stowrc} (home directory). These are parsed in +that order, and effectively prepended to the command line arguments. +This feature can be used for some interesting effects. For example, suppose your site uses more than one stow directory, perhaps in order to share around responsibilities with a number of systems From b160a1c807fe6441517444136661d91425ae9673 Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Sun, 18 Dec 2016 23:16:41 +0000 Subject: [PATCH 250/482] clarify that ~/.stowrc args don't get processed by a shell Address confusion reported here: http://lists.gnu.org/archive/html/bug-stow/2016-08/msg00000.html --- doc/stow.texi | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/doc/stow.texi b/doc/stow.texi index 160edf3..e6e45c7 100644 --- a/doc/stow.texi +++ b/doc/stow.texi @@ -850,7 +850,8 @@ directory. Default command line options may be set in @file{.stowrc} (current directory) or @file{~/.stowrc} (home directory). These are parsed in -that order, and effectively prepended to the command line arguments. +that order, and effectively prepended to the command line arguments +(with the notable difference that they won't be processed by the shell). This feature can be used for some interesting effects. For example, suppose your site uses more than one stow directory, perhaps in From ea11f266a57bea96dc0728284ad9d2d85aeaa0d2 Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Sat, 4 Mar 2017 14:28:19 +0000 Subject: [PATCH 251/482] fix typo in "Deleting Packages" chapter Thanks to Hongyi Zhao for spotting this error and reporting it. --- THANKS | 1 + doc/stow.texi | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/THANKS b/THANKS index 77a3a66..f9ef1de 100644 --- a/THANKS +++ b/THANKS @@ -28,6 +28,7 @@ Charles LeDoux Joris Vankerschaver @Corin-EU on GitHub Kristoffer Haugsbakk +Hongyi Zhao Email addresses of new contributors are no longer being added by default for privacy reasons; however please contact the maintainer if you are diff --git a/doc/stow.texi b/doc/stow.texi index e6e45c7..03aff99 100644 --- a/doc/stow.texi +++ b/doc/stow.texi @@ -688,7 +688,7 @@ use the @option{--badlinks} option get stow to search for dangling links in your For example, if the target directory is @file{/usr/local} and the installation image for the package being deleted has only a @file{bin} directory and a @file{man} directory at the top level, then we only scan -@file{/usr/local/bin} and @file{/usr/local/bin/man}, and not +@file{/usr/local/bin} and @file{/usr/local/man}, and not @file{/usr/local/lib} or @file{/usr/local/share}, or for that matter @file{/usr/local/stow}. Any symlink it finds that points into the package being deleted is removed. Any directory that contained only symlinks to the From 655e8e4a3d9a6b00e0edb4b5df8674307ad0074b Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Sun, 19 Mar 2017 21:12:46 +0000 Subject: [PATCH 252/482] INSTALL.md: document how to build from git (#20) Fixes https://github.com/aspiers/stow/issues/20 --- INSTALL.md | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/INSTALL.md b/INSTALL.md index f962755..eb80171 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -32,6 +32,26 @@ Advantages of the `Module::Build` approach: - It performs dependency checking to ensure you have the necessary Perl modules installed. +Both approaches are described in detail below. However if you are +building from the git repository rather than an official release, +you first need to perform some extra steps: + +Preparatory steps required only when building from git +------------------------------------------------------ + +`configure` and `Makefile` are included in official releases of Stow, +but they are deliberately omitted from the git repository because they +are autogenerated. Therefore if you are installing directly from git, +you first need to generate them as follows. + +First `cd` to the directory containing the source code (and this +file), and then run: + + autoreconf -iv + +If this runs successfully then you are ready to continue with one of +the two installation methods below. + Basic Installation via `Module::Build` -------------------------------------- From e7e6c7fbde2532b83cb7ef5b8026316c99242bf3 Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Sun, 11 Feb 2018 11:47:39 +0000 Subject: [PATCH 253/482] update the introductory text to clarify Stow's common usage Thanks to Jean Louis for some suggestions on this. --- doc/stow.texi | 36 ++++++++++++++++++++++++++++-------- 1 file changed, 28 insertions(+), 8 deletions(-) diff --git a/doc/stow.texi b/doc/stow.texi index 03aff99..ba676c6 100644 --- a/doc/stow.texi +++ b/doc/stow.texi @@ -82,7 +82,10 @@ approved by the Free Software Foundation. @ifinfo This manual describes GNU Stow @value{VERSION} (@value{UPDATED}), a -program for managing the installation of software packages. +program for managing sets of symbolic links, in order to make groups +of related files (such as distinct packages of software, or +configuration files) in one place in the filesystem appear to be +located in another place. @end ifinfo @end ifnottex @@ -128,14 +131,19 @@ Advice on changing compilation and installation parameters @node Introduction, Terminology, Top, Top @chapter Introduction -Stow is a tool for managing the installation of multiple software -packages in the same run-time directory tree. One historical difficulty -of this task has been the need to administer, upgrade, install, and -remove files in independent packages without confusing them with other -files sharing the same file system space. For instance, it is common to -install Perl and Emacs in @file{/usr/local}. When one does so, one +Stow is a tool for managing sets of symbolic links in order to +facilitate the installation of multiple software packages, or other +groups of related files, such as configuration files, into a single +directory tree. + +Originally Stow was born to address the need to administer, upgrade, +install, and remove files in independent software packages without +confusing them with other files sharing the same file system space. +For instance, it used to be common to compile Perl and Emacs from +source and install them in @file{/usr/local}. When one does so, one winds up with the following files@footnote{As of Perl 4.036 and Emacs -19.22.} in @file{/usr/local/man/man1}: +19.22. These are now ancient releases but the example still holds +valid.} in @file{/usr/local/man/man1}: @example a2p.1 @@ -163,6 +171,18 @@ tree; i.e. (in the typical case) there should be a @file{bin} directory containing executables, a @file{man/man1} directory containing section 1 man pages, and so on. +In more recent times, software packages are often managed by more +sophisticated package management software such as +@uref{https://en.wikipedia.org/wiki/Rpm_(software), @command{rpm}}, +@uref{https://en.wikipedia.org/wiki/Dpkg, @command{dpkg}}, and +@uref{https://en.wikipedia.org/wiki/Nix_package_manager, Nix}. +However Stow is still used not only for software package management, +but also for other purposes, such as facilitating a more controlled +approach to management of configuration files in the user's home +directory@footnote{@uref{http://brandon.invergo.net/news/2012-05-26-using-gnu-stow-to-manage-your-dotfiles.html}}, +especially when coupled with version control +systems@footnote{@uref{http://lists.gnu.org/archive/html/info-stow/2011-12/msg00000.html}}. + Stow was inspired by Carnegie Mellon's Depot program, but is substantially simpler and safer. Whereas Depot required database files to keep things in sync, Stow stores no extra state between runs, so From e2af22c11a8b766d27f38c1bad9d60fd8c39a968 Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Sun, 11 Feb 2018 11:52:56 +0000 Subject: [PATCH 254/482] update aclocal.m4 using aclocal 1.15.1 --- aclocal.m4 | 99 ++++++++++++++++++++++++++++++++++++++++-------------- 1 file changed, 74 insertions(+), 25 deletions(-) diff --git a/aclocal.m4 b/aclocal.m4 index 7ea634c..9ad3397 100644 --- a/aclocal.m4 +++ b/aclocal.m4 @@ -1,6 +1,6 @@ -# generated automatically by aclocal 1.13.4 -*- Autoconf -*- +# generated automatically by aclocal 1.15.1 -*- Autoconf -*- -# Copyright (C) 1996-2013 Free Software Foundation, Inc. +# Copyright (C) 1996-2017 Free Software Foundation, Inc. # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -20,7 +20,7 @@ You have another version of autoconf. It may work, but is not guaranteed to. If you have problems, you may need to regenerate the build system entirely. To do so, use the procedure documented by the package, typically 'autoreconf'.])]) -# Copyright (C) 2002-2013 Free Software Foundation, Inc. +# Copyright (C) 2002-2017 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -32,10 +32,10 @@ To do so, use the procedure documented by the package, typically 'autoreconf'.]) # generated from the m4 files accompanying Automake X.Y. # (This private macro should not be called outside this file.) AC_DEFUN([AM_AUTOMAKE_VERSION], -[am__api_version='1.13' +[am__api_version='1.15' dnl Some users find AM_AUTOMAKE_VERSION and mistake it for a way to dnl require some minimum version. Point them to the right macro. -m4_if([$1], [1.13.4], [], +m4_if([$1], [1.15.1], [], [AC_FATAL([Do not call $0, use AM_INIT_AUTOMAKE([$1]).])])dnl ]) @@ -51,14 +51,14 @@ m4_define([_AM_AUTOCONF_VERSION], []) # Call AM_AUTOMAKE_VERSION and AM_AUTOMAKE_VERSION so they can be traced. # This function is AC_REQUIREd by AM_INIT_AUTOMAKE. AC_DEFUN([AM_SET_CURRENT_AUTOMAKE_VERSION], -[AM_AUTOMAKE_VERSION([1.13.4])dnl +[AM_AUTOMAKE_VERSION([1.15.1])dnl m4_ifndef([AC_AUTOCONF_VERSION], [m4_copy([m4_PACKAGE_VERSION], [AC_AUTOCONF_VERSION])])dnl _AM_AUTOCONF_VERSION(m4_defn([AC_AUTOCONF_VERSION]))]) # AM_AUX_DIR_EXPAND -*- Autoconf -*- -# Copyright (C) 2001-2013 Free Software Foundation, Inc. +# Copyright (C) 2001-2017 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -103,15 +103,14 @@ _AM_AUTOCONF_VERSION(m4_defn([AC_AUTOCONF_VERSION]))]) # configured tree to be moved without reconfiguration. AC_DEFUN([AM_AUX_DIR_EXPAND], -[dnl Rely on autoconf to set up CDPATH properly. -AC_PREREQ([2.50])dnl -# expand $ac_aux_dir to an absolute path -am_aux_dir=`cd $ac_aux_dir && pwd` +[AC_REQUIRE([AC_CONFIG_AUX_DIR_DEFAULT])dnl +# Expand $ac_aux_dir to an absolute path. +am_aux_dir=`cd "$ac_aux_dir" && pwd` ]) # Do all the work for Automake. -*- Autoconf -*- -# Copyright (C) 1996-2013 Free Software Foundation, Inc. +# Copyright (C) 1996-2017 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -120,6 +119,12 @@ am_aux_dir=`cd $ac_aux_dir && pwd` # This macro actually does too much. Some checks are only needed if # your package does certain things. But this isn't really a big deal. +dnl Redefine AC_PROG_CC to automatically invoke _AM_PROG_CC_C_O. +m4_define([AC_PROG_CC], +m4_defn([AC_PROG_CC]) +[_AM_PROG_CC_C_O +]) + # AM_INIT_AUTOMAKE(PACKAGE, VERSION, [NO-DEFINE]) # AM_INIT_AUTOMAKE([OPTIONS]) # ----------------------------------------------- @@ -195,8 +200,8 @@ AC_REQUIRE([AC_PROG_MKDIR_P])dnl # # AC_SUBST([mkdir_p], ['$(MKDIR_P)']) -# We need awk for the "check" target. The system "awk" is bad on -# some platforms. +# We need awk for the "check" target (and possibly the TAP driver). The +# system "awk" is bad on some platforms. AC_REQUIRE([AC_PROG_AWK])dnl AC_REQUIRE([AC_PROG_MAKE_SET])dnl AC_REQUIRE([AM_SET_LEADING_DOT])dnl @@ -228,6 +233,51 @@ dnl macro is hooked onto _AC_COMPILER_EXEEXT early, see below. AC_CONFIG_COMMANDS_PRE(dnl [m4_provide_if([_AM_COMPILER_EXEEXT], [AM_CONDITIONAL([am__EXEEXT], [test -n "$EXEEXT"])])])dnl + +# POSIX will say in a future version that running "rm -f" with no argument +# is OK; and we want to be able to make that assumption in our Makefile +# recipes. So use an aggressive probe to check that the usage we want is +# actually supported "in the wild" to an acceptable degree. +# See automake bug#10828. +# To make any issue more visible, cause the running configure to be aborted +# by default if the 'rm' program in use doesn't match our expectations; the +# user can still override this though. +if rm -f && rm -fr && rm -rf; then : OK; else + cat >&2 <<'END' +Oops! + +Your 'rm' program seems unable to run without file operands specified +on the command line, even when the '-f' option is present. This is contrary +to the behaviour of most rm programs out there, and not conforming with +the upcoming POSIX standard: + +Please tell bug-automake@gnu.org about your system, including the value +of your $PATH and any error possibly output before this message. This +can help us improve future automake versions. + +END + if test x"$ACCEPT_INFERIOR_RM_PROGRAM" = x"yes"; then + echo 'Configuration will proceed anyway, since you have set the' >&2 + echo 'ACCEPT_INFERIOR_RM_PROGRAM variable to "yes"' >&2 + echo >&2 + else + cat >&2 <<'END' +Aborting the configuration process, to ensure you take notice of the issue. + +You can download and install GNU coreutils to get an 'rm' implementation +that behaves properly: . + +If you want to complete the configuration process using your problematic +'rm' anyway, export the environment variable ACCEPT_INFERIOR_RM_PROGRAM +to "yes", and re-run configure. + +END + AC_MSG_ERROR([Your 'rm' program is bad, sorry.]) + fi +fi +dnl The trailing newline in this macro's definition is deliberate, for +dnl backward compatibility and to allow trailing 'dnl'-style comments +dnl after the AM_INIT_AUTOMAKE invocation. See automake bug#16841. ]) dnl Hook into '_AC_COMPILER_EXEEXT' early to learn its expansion. Do not @@ -236,7 +286,6 @@ dnl mangled by Autoconf and run in a shell conditional statement. m4_define([_AC_COMPILER_EXEEXT], m4_defn([_AC_COMPILER_EXEEXT])[m4_provide([_AM_COMPILER_EXEEXT])]) - # When config.status generates a header, we must update the stamp-h file. # This file resides in the same directory as the config header # that is generated. The stamp files are numbered to have different names. @@ -258,7 +307,7 @@ for _am_header in $config_headers :; do done echo "timestamp for $_am_arg" >`AS_DIRNAME(["$_am_arg"])`/stamp-h[]$_am_stamp_count]) -# Copyright (C) 2001-2013 Free Software Foundation, Inc. +# Copyright (C) 2001-2017 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -269,7 +318,7 @@ echo "timestamp for $_am_arg" >`AS_DIRNAME(["$_am_arg"])`/stamp-h[]$_am_stamp_co # Define $install_sh. AC_DEFUN([AM_PROG_INSTALL_SH], [AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl -if test x"${install_sh}" != xset; then +if test x"${install_sh+set}" != xset; then case $am_aux_dir in *\ * | *\ *) install_sh="\${SHELL} '$am_aux_dir/install-sh'" ;; @@ -279,7 +328,7 @@ if test x"${install_sh}" != xset; then fi AC_SUBST([install_sh])]) -# Copyright (C) 2003-2013 Free Software Foundation, Inc. +# Copyright (C) 2003-2017 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -300,7 +349,7 @@ AC_SUBST([am__leading_dot])]) # Fake the existence of programs that GNU maintainers use. -*- Autoconf -*- -# Copyright (C) 1997-2013 Free Software Foundation, Inc. +# Copyright (C) 1997-2017 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -339,7 +388,7 @@ fi # Helper functions for option handling. -*- Autoconf -*- -# Copyright (C) 2001-2013 Free Software Foundation, Inc. +# Copyright (C) 2001-2017 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -370,7 +419,7 @@ AC_DEFUN([_AM_IF_OPTION], # Check to make sure that the build environment is sane. -*- Autoconf -*- -# Copyright (C) 1996-2013 Free Software Foundation, Inc. +# Copyright (C) 1996-2017 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -451,7 +500,7 @@ AC_CONFIG_COMMANDS_PRE( rm -f conftest.file ]) -# Copyright (C) 2009-2013 Free Software Foundation, Inc. +# Copyright (C) 2009-2017 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -511,7 +560,7 @@ AC_SUBST([AM_BACKSLASH])dnl _AM_SUBST_NOTMAKE([AM_BACKSLASH])dnl ]) -# Copyright (C) 2001-2013 Free Software Foundation, Inc. +# Copyright (C) 2001-2017 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -539,7 +588,7 @@ fi INSTALL_STRIP_PROGRAM="\$(install_sh) -c -s" AC_SUBST([INSTALL_STRIP_PROGRAM])]) -# Copyright (C) 2006-2013 Free Software Foundation, Inc. +# Copyright (C) 2006-2017 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -558,7 +607,7 @@ AC_DEFUN([AM_SUBST_NOTMAKE], [_AM_SUBST_NOTMAKE($@)]) # Check how to create a tarball. -*- Autoconf -*- -# Copyright (C) 2004-2013 Free Software Foundation, Inc. +# Copyright (C) 2004-2017 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, From c84de4eb146f1dba9cb49e60b715c65bd98360ae Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Sun, 11 Feb 2018 17:47:06 +0000 Subject: [PATCH 255/482] fix erroneous glob examples in --ignore documentation Many thanks to Daniel Shahaf for noticing this. http://lists.gnu.org/archive/html/bug-stow/2017-07/msg00000.html --- THANKS | 1 + doc/stow.texi | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/THANKS b/THANKS index f9ef1de..f93b91d 100644 --- a/THANKS +++ b/THANKS @@ -29,6 +29,7 @@ Joris Vankerschaver @Corin-EU on GitHub Kristoffer Haugsbakk Hongyi Zhao +Daniel Shahaf Email addresses of new contributors are no longer being added by default for privacy reasons; however please contact the maintainer if you are diff --git a/doc/stow.texi b/doc/stow.texi index ba676c6..f93f035 100644 --- a/doc/stow.texi +++ b/doc/stow.texi @@ -288,10 +288,10 @@ execute @command{stow} from the directory @file{/usr/local/stow}. @item --ignore=@var{regexp} This (repeatable) option lets you suppress acting on files that match the -given perl regular expression. For example, using the options +given Perl regular expression. For example, using the options @example ---ignore='*.orig' --ignore='*.dist' +--ignore='.*\.orig' --ignore='.*\.dist' @end example @noindent From dd42b09a5bd59083417e8706137346cd76753f74 Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Sun, 11 Feb 2018 17:55:40 +0000 Subject: [PATCH 256/482] avoid "regex" abbreviation for consistency --- doc/stow.texi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/stow.texi b/doc/stow.texi index f93f035..118fd77 100644 --- a/doc/stow.texi +++ b/doc/stow.texi @@ -325,7 +325,7 @@ For example, the following options will cause stow to skip over pre-existing man and info pages. Equivalently, you could use @samp{--defer='man|info'} since the -argument is just a Perl regex. +argument is just a Perl regular expression. Note that the regular expression is anchored to the beginning of the path relative to the target directory, because this is what you will want to do most From 88ec3f58aa4272b4e5473f4dd08a5accc7bdcda1 Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Sun, 11 Feb 2018 17:58:33 +0000 Subject: [PATCH 257/482] add Jean Louis to THANKS file Forgot to do this in e7e6c7f. --- THANKS | 1 + 1 file changed, 1 insertion(+) diff --git a/THANKS b/THANKS index f93b91d..84f7357 100644 --- a/THANKS +++ b/THANKS @@ -29,6 +29,7 @@ Joris Vankerschaver @Corin-EU on GitHub Kristoffer Haugsbakk Hongyi Zhao +Jean Louis Daniel Shahaf Email addresses of new contributors are no longer being added by default From 1a752bf70b7f53080446057c81c5d59eaa0b3ae7 Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Sat, 9 Feb 2019 17:02:47 +0000 Subject: [PATCH 258/482] make chkstow honour $STOW_DIR environment variable Thanks to Matan Nassau for reporting this deficiency. --- THANKS | 1 + bin/chkstow.in | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/THANKS b/THANKS index 84f7357..9a9072a 100644 --- a/THANKS +++ b/THANKS @@ -31,6 +31,7 @@ Kristoffer Haugsbakk Hongyi Zhao Jean Louis Daniel Shahaf +Matan Nassau Email addresses of new contributors are no longer being added by default for privacy reasons; however please contact the maintainer if you are diff --git a/bin/chkstow.in b/bin/chkstow.in index c35ba26..4887640 100755 --- a/bin/chkstow.in +++ b/bin/chkstow.in @@ -8,7 +8,7 @@ require 5.006_001; use File::Find; use Getopt::Long; -my $DEFAULT_TARGET = '/usr/local/'; +my $DEFAULT_TARGET = $ENV{STOW_DIR} || '/usr/local/'; our $Wanted = \&bad_links; our %Package = (); From b42cb89fddf34882faabb7d6abcac256308faca1 Mon Sep 17 00:00:00 2001 From: Will Aoki Date: Wed, 3 Apr 2019 09:48:15 -0600 Subject: [PATCH 259/482] Avoid dereferencing $ENV{HOME} if it is undefined --- bin/stow.in | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/bin/stow.in b/bin/stow.in index 98b576e..367657a 100755 --- a/bin/stow.in +++ b/bin/stow.in @@ -598,7 +598,11 @@ sub check_packages { #============================================================================= sub get_config_file_options { my @defaults = (); - for my $file ("$ENV{HOME}/.stowrc", '.stowrc') { + my @dirlist = ('.stowrc'); + if (defined($ENV{HOME})) { + unshift(@dirlist, "$ENV{HOME}/.stowrc"); + } + for my $file (@dirlist) { if (-r $file) { warn "Loading defaults from $file\n"; open my $FILE, '<', $file From d6924bdbc365a0827c0a6d0502e720ab4e25672b Mon Sep 17 00:00:00 2001 From: Brice Waegeneire Date: Tue, 11 Jun 2019 10:28:25 +0200 Subject: [PATCH 260/482] fix dockerfile apt-get lock issue E: Could not open lock file /var/cache/apt/archives/lock - open (2: No such file or directory) E: Unable to lock the download directory --- docker/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker/Dockerfile b/docker/Dockerfile index 3796e26..ad4678e 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -3,7 +3,6 @@ # `docker run --rm -it -v $(pwd):$(pwd) -w $(pwd) stowtest` FROM debian:jessie RUN DEBIAN_FRONTEND=noninteractive \ -apt-get clean && \ apt-get update -qq && \ apt-get install -y -q \ autoconf \ @@ -18,6 +17,7 @@ apt-get install -y -q \ texinfo \ texlive \ texi2html \ +&& apt-get clean \ && rm -rf /var/lib/apt/lists/* # Set up perlbrew From c86d9aa14830ab1e0af42d83a39ca71cdbbef051 Mon Sep 17 00:00:00 2001 From: Brice Waegeneire Date: Tue, 11 Jun 2019 10:53:28 +0200 Subject: [PATCH 261/482] make non docker scripts more portable --- build-docker.sh | 2 +- test-docker.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/build-docker.sh b/build-docker.sh index 4808691..c8fab5e 100755 --- a/build-docker.sh +++ b/build-docker.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash set -eu diff --git a/test-docker.sh b/test-docker.sh index 2bedcae..81e820e 100755 --- a/test-docker.sh +++ b/test-docker.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash # Test Stow across multiple Perl versions, by executing the # Docker image built via build-docker.sh. From 77b0cf8f451c0607160b19f306ddbbbb755cba52 Mon Sep 17 00:00:00 2001 From: Brice Waegeneire Date: Tue, 11 Jun 2019 14:13:51 +0200 Subject: [PATCH 262/482] retrun exit code 1 when unknown option --- bin/stow.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/stow.in b/bin/stow.in index 98b576e..a5229eb 100755 --- a/bin/stow.in +++ b/bin/stow.in @@ -539,7 +539,7 @@ sub process_options { push @pkgs_to_stow, $_[0]; } }, - ) or usage(); + ) or usage(0); usage() if $options{help}; version() if $options{version}; From e618ef1526f79c7c556891d9672b5630088e9a3d Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Tue, 25 Jun 2019 13:44:17 +0100 Subject: [PATCH 263/482] remove duplicate "the" typo --- bin/chkstow.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/chkstow.in b/bin/chkstow.in index 4887640..2156bb5 100755 --- a/bin/chkstow.in +++ b/bin/chkstow.in @@ -93,7 +93,7 @@ sub aliens { !-l && !-d && print "Unstowed file: $File::Find::name\n"; } -# just list the packages in the the target directory +# just list the packages in the target directory # FIXME: what if the stow dir is not called 'stow'? sub list { if (-l) { From bd4241b3e46fa5e68177bb035fb1c0e11f6d6d49 Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Tue, 25 Jun 2019 14:30:08 +0100 Subject: [PATCH 264/482] Make dotfiles.t executable for consistency with other tests --- t/dotfiles.t | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100644 => 100755 t/dotfiles.t diff --git a/t/dotfiles.t b/t/dotfiles.t old mode 100644 new mode 100755 From 839450789197713bd906a3802b0f4b5afc9b983a Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Tue, 25 Jun 2019 14:27:56 +0100 Subject: [PATCH 265/482] Add cli.t for testing invocation of stow executable Unlike the other tests, this actually treats stow(1) as a black box script, running it directly rather than require-ing it as a library. This allows us to check things like the exit codes returned. --- MANIFEST | 1 + t/cli.t | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 51 insertions(+) create mode 100644 t/cli.t diff --git a/MANIFEST b/MANIFEST index 056d512..91ae7bf 100644 --- a/MANIFEST +++ b/MANIFEST @@ -34,6 +34,7 @@ NEWS README.md t/chkstow.t t/cleanup_invalid_links.t +t/cli.t t/cli_options.t t/defer.t t/dotfiles.t diff --git a/t/cli.t b/t/cli.t new file mode 100644 index 0000000..0fc0528 --- /dev/null +++ b/t/cli.t @@ -0,0 +1,50 @@ +#!/usr/local/bin/perl + +# +# Test processing of CLI options. +# + +use strict; +use warnings; + +use File::Basename; +use Test::More tests => 1; + +use testutil; + +#init_test_dirs(); + +# Since here we're doing black-box testing on the stow executable, +# this looks like it should be robust: +# +#my $STOW = dirname(__FILE__) . '/../bin/stow'; +# +# but unfortunately it breaks things like "make distcheck", which +# builds the stow script into a separate path like +# +# stow-2.3.0/_build/sub/bin +# +# before cd'ing to something like +# +# stow-2.3.0/_build/sub +# +# and then running the tests via: +# +# make check-TESTS +# make[2]: Entering directory '/path/to/stow/src/stow-2.3.0/_build/sub' +# dir=../../t; \ +# /usr/bin/perl -Ibin -Ilib -I../../t -MTest::Harness -e 'runtests(@ARGV)' "${dir#./}"/*.t +# +# So the simplest solution is to hardcode an assumption that we run +# tests either from somewhere like this during distcheck: +# +# stow-2.3.0/_build/sub +# +# or from the top of the source tree during development. This can be done +# via the following, which also follows the KISS principle: +my $STOW = 'bin/stow'; + +`$STOW --help`; +is($?, 0, "--help should return 0 exit code"); + +# vim:ft=perl From e79c5938bc8bc756990c0eb80c52bb1302d02997 Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Tue, 25 Jun 2019 13:44:35 +0100 Subject: [PATCH 266/482] Return non-zero exit code when invalid option is specified (#34) Also add a unit test for this. Fixes #34: https://github.com/aspiers/stow/issues/34 --- bin/stow.in | 2 +- t/cli.t | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) mode change 100644 => 100755 t/cli.t diff --git a/bin/stow.in b/bin/stow.in index 98b576e..adff6de 100755 --- a/bin/stow.in +++ b/bin/stow.in @@ -539,7 +539,7 @@ sub process_options { push @pkgs_to_stow, $_[0]; } }, - ) or usage(); + ) or usage(''); usage() if $options{help}; version() if $options{version}; diff --git a/t/cli.t b/t/cli.t old mode 100644 new mode 100755 index 0fc0528..010fc79 --- a/t/cli.t +++ b/t/cli.t @@ -8,7 +8,7 @@ use strict; use warnings; use File::Basename; -use Test::More tests => 1; +use Test::More tests => 3; use testutil; @@ -47,4 +47,8 @@ my $STOW = 'bin/stow'; `$STOW --help`; is($?, 0, "--help should return 0 exit code"); +my $err = `$STOW --foo 2>&1`; +is($? >> 8, 1, "unrecognised option should return 1 exit code"); +like($err, qr/^Unknown option: foo$/m, "unrecognised option should be listed"); + # vim:ft=perl From 72ef83cebd645a0051e16b5d3c04be8b5e3de1e2 Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Mon, 21 Nov 2016 14:56:26 +0000 Subject: [PATCH 267/482] Fix old descriptions of Stow (#22) De-emphasise the package management aspects, since these days almost everyone prefers to use modern package managers such as rpm / dpkg / Nix for (system-wide) package management. Also include more popular modern use cases for Stow such as management of dotfiles and software compiled in the user's $HOME directory. Fixes #22: https://github.com/aspiers/stow/issues/22 --- README.md | 55 +++++++++++++++++++++++++++++++++++++--------- bin/stow.in | 58 ++++++++++++++++++++++++++----------------------- doc/stow.texi | 59 ++++++++++++++++++++++++++++++-------------------- lib/Stow.pm.in | 2 +- 4 files changed, 112 insertions(+), 62 deletions(-) diff --git a/README.md b/README.md index 29d760d..bde1cf0 100644 --- a/README.md +++ b/README.md @@ -4,19 +4,54 @@ README for GNU Stow =================== -This is GNU Stow, a symlink farm manager program which takes distinct -packages of software and/or data located in separate directories on -the filesystem, and makes them appear to be installed in the same -place. For example, `/usr/local/bin` could contain symlinks to files -within `/usr/local/stow/emacs/bin`, `/usr/local/stow/perl/bin` etc., and +This README describes GNU Stow. This is not the definitive +documentation for Stow; for that, see the [info +manual](https://www.gnu.org/software/stow/manual/). + +Stow is a symlink farm manager program which takes distinct sets +of software and/or data located in separate directories on the +filesystem, and makes them all appear to be installed in a single +directory tree. + +Originally Stow was born to address the need to administer, upgrade, +install, and remove files in independent software packages without +confusing them with other files sharing the same file system space. +For instance, many years ago it used to be common to compile programs +such as Perl and Emacs from source and install them in `/usr/local`. +By using Stow, `/usr/local/bin` could contain symlinks to files within +`/usr/local/stow/emacs/bin`, `/usr/local/stow/perl/bin` etc., and likewise recursively for any other subdirectories such as `.../share`, `.../man`, and so on. -This is particularly useful for keeping track of system-wide and -per-user installations of software built from source, but can also -facilitate a more controlled approach to management of configuration -files in the user's home directory, especially when coupled with -version control systems. +While this is useful for keeping track of system-wide and per-user +installations of software built from source, in more recent times +software packages are often managed by more sophisticated package +management software such as +[`rpm`](https://en.wikipedia.org/wiki/Rpm_(software)), +[`dpkg`](https://en.wikipedia.org/wiki/Dpkg), and +[Nix](https://en.wikipedia.org/wiki/Nix_package_manager) / [GNU +Guix](https://en.wikipedia.org/wiki/GNU_Guix), or language-native +package managers such as Ruby's +[`gem`](https://en.wikipedia.org/wiki/RubyGems), Python's +[`pip`](https://en.wikipedia.org/wiki/Pip_(package_manager)), +Javascript's [`npm`](https://en.wikipedia.org/wiki/Npm_(software)), +and so on. + +However Stow is still used not only for software package management, +but also for other purposes, such as facilitating [a more controlled +approach to management of configuration files in the user's home +directory](http://brandon.invergo.net/news/2012-05-26-using-gnu-stow-to-manage-your-dotfiles.html), +especially when [coupled with version control +systems](http://lists.gnu.org/archive/html/info-stow/2011-12/msg00000.html). + +Stow was inspired by Carnegie Mellon's Depot program, but is +substantially simpler and safer. Whereas Depot required database files +to keep things in sync, Stow stores no extra state between runs, so +there's no danger (as there was in Depot) of mangling directories when +file hierarchies don't match the database. Also unlike Depot, Stow will +never delete any files, directories, or links that appear in a Stow +directory (e.g., `/usr/local/stow/emacs`), so it's always possible +to rebuild the target tree (e.g., `/usr/local`). Stow is implemented as a combination of a Perl script providing a CLI interface, and a backend Perl module which does most of the work. diff --git a/bin/stow.in b/bin/stow.in index adff6de..d64c381 100755 --- a/bin/stow.in +++ b/bin/stow.in @@ -1,6 +1,6 @@ #!@PERL@ -# GNU Stow - manage the installation of multiple software packages +# GNU Stow - manage farms of symbolic links # Copyright (C) 1993, 1994, 1995, 1996 by Bob Glickstein # Copyright (C) 2000, 2001 Guillaume Morin # Copyright (C) 2007 Kahlil Hodgson @@ -21,7 +21,7 @@ =head1 NAME -stow - software package installation manager +stow - manage farms of symbolic links =head1 SYNOPSIS @@ -29,33 +29,34 @@ stow [ options ] package ... =head1 DESCRIPTION -This manual page describes GNU Stow @VERSION@, a program for managing -the installation of software packages. This is not the definitive -documentation for stow; for that, see the info manual. +This manual page describes GNU Stow @VERSION@. This is not the +definitive documentation for Stow; for that, see the accompanying info +manual, e.g. by typing C. -Stow is a tool for managing the installation of multiple software -packages in the same run-time directory tree. One historical -difficulty of this task has been the need to administer, upgrade, -install, and remove files in independent packages without confusing -them with other files sharing the same filesystem space. For instance, -it is common to install Perl and Emacs in F. When one -does so, one winds up (as of Perl 4.036 and Emacs 19.22) with the -following files in F: F; F; -F; F; F; F; and F. Now -suppose it's time to uninstall Perl. Which man pages get removed? -Obviously F is one of them, but it should not be the -administrator's responsibility to memorize the ownership of individual -files by separate packages. +Stow is a symlink farm manager which takes distinct sets of software +and/or data located in separate directories on the filesystem, and +makes them all appear to be installed in a single directory tree. -The approach used by Stow is to install each package into its own -tree, then use symbolic links to make it appear as though the files -are installed in the common tree. Administration can be performed in -the package's private tree in isolation from clutter from other -packages. Stow can then be used to update the symbolic links. The -structure of each private tree should reflect the desired structure in -the common tree; i.e. (in the typical case) there should be a F -directory containing executables, a F directory containing -section 1 man pages, and so on. +Originally Stow was born to address the need to administer, upgrade, +install, and remove files in independent software packages without +confusing them with other files sharing the same file system space. +For instance, many years ago it used to be common to compile programs +such as Perl and Emacs from source. By using Stow, F +could contain symlinks to files within F, +F etc., and likewise recursively for any +other subdirectories such as F<.../share>, F<.../man>, and so on. + +While this is useful for keeping track of system-wide and per-user +installations of software built from source, in more recent times +software packages are often managed by more sophisticated package +management software such as rpm, dpkg, and Nix / GNU Guix, or +language-native package managers such as Ruby's gem, Python's pip, +Javascript's npm, and so on. + +However Stow is still used not only for software package management, +but also for other purposes, such as facilitating a more controlled +approach to management of configuration files in the user's home +directory, especially when coupled with version control systems. Stow was inspired by Carnegie Mellon's Depot program, but is substantially simpler and safer. Whereas Depot required database files @@ -66,6 +67,9 @@ will never delete any files, directories, or links that appear in a Stow directory (e.g., F), so it's always possible to rebuild the target tree (e.g., F). +Stow is implemented as a combination of a Perl script providing a CLI +interface, and a backend Perl module which does most of the work. + =head1 TERMINOLOGY A "package" is a related collection of files and directories that diff --git a/doc/stow.texi b/doc/stow.texi index 118fd77..f7ae2d1 100644 --- a/doc/stow.texi +++ b/doc/stow.texi @@ -15,8 +15,7 @@ @copying This manual describes GNU Stow version @value{VERSION} -(@value{UPDATED}), a program for managing the installation of software -packages. +(@value{UPDATED}), a program for managing farms of symbolic links. Software and documentation is copyrighted by the following: @@ -82,10 +81,9 @@ approved by the Free Software Foundation. @ifinfo This manual describes GNU Stow @value{VERSION} (@value{UPDATED}), a -program for managing sets of symbolic links, in order to make groups -of related files (such as distinct packages of software, or -configuration files) in one place in the filesystem appear to be -located in another place. +symlink farm manager which takes distinct sets of software and/or data +located in separate directories on the filesystem, and makes them +appear to be installed in a single directory tree. @end ifinfo @end ifnottex @@ -131,19 +129,20 @@ Advice on changing compilation and installation parameters @node Introduction, Terminology, Top, Top @chapter Introduction -Stow is a tool for managing sets of symbolic links in order to -facilitate the installation of multiple software packages, or other -groups of related files, such as configuration files, into a single +GNU Stow is a symlink farm manager which takes distinct sets of +software and/or data located in separate directories on the +filesystem, and makes them all appear to be installed in a single directory tree. Originally Stow was born to address the need to administer, upgrade, install, and remove files in independent software packages without confusing them with other files sharing the same file system space. -For instance, it used to be common to compile Perl and Emacs from -source and install them in @file{/usr/local}. When one does so, one -winds up with the following files@footnote{As of Perl 4.036 and Emacs -19.22. These are now ancient releases but the example still holds -valid.} in @file{/usr/local/man/man1}: +For instance, many years ago it used to be common to compile programs +such as Perl and Emacs from source and install them in +@file{/usr/local}. When one does so, one winds up with the following +files@footnote{As of Perl 4.036 and Emacs 19.22. These are now +ancient releases but the example still holds valid.} in +@file{/usr/local/man/man1}: @example a2p.1 @@ -171,11 +170,20 @@ tree; i.e. (in the typical case) there should be a @file{bin} directory containing executables, a @file{man/man1} directory containing section 1 man pages, and so on. -In more recent times, software packages are often managed by more -sophisticated package management software such as +While this is useful for keeping track of system-wide and per-user +installations of software built from source, in more recent times +software packages are often managed by more sophisticated package +management software such as @uref{https://en.wikipedia.org/wiki/Rpm_(software), @command{rpm}}, @uref{https://en.wikipedia.org/wiki/Dpkg, @command{dpkg}}, and -@uref{https://en.wikipedia.org/wiki/Nix_package_manager, Nix}. +@uref{https://en.wikipedia.org/wiki/Nix_package_manager, Nix} / +@uref{https://en.wikipedia.org/wiki/GNU_Guix, GNU Guix}, or +language-native package managers such as +@uref{https://en.wikipedia.org/wiki/RubyGems, Ruby's @command{gem}}, +@uref{https://en.wikipedia.org/wiki/Pip_(package_manager), Python's +@command{pip}}, @uref{https://en.wikipedia.org/wiki/Npm_(software), +Javascript's @command{npm}}, and so on. + However Stow is still used not only for software package management, but also for other purposes, such as facilitating a more controlled approach to management of configuration files in the user's home @@ -184,13 +192,16 @@ especially when coupled with version control systems@footnote{@uref{http://lists.gnu.org/archive/html/info-stow/2011-12/msg00000.html}}. Stow was inspired by Carnegie Mellon's Depot program, but is -substantially simpler and safer. Whereas Depot required database files -to keep things in sync, Stow stores no extra state between runs, so -there's no danger (as there was in Depot) of mangling directories when -file hierarchies don't match the database. Also unlike Depot, Stow will -never delete any files, directories, or links that appear in a Stow -directory (e.g., @file{/usr/local/stow/emacs}), so it's always possible -to rebuild the target tree (e.g., @file{/usr/local}). +substantially simpler and safer. Whereas Depot required database +files to keep things in sync, Stow stores no extra state between runs, +so there's no danger (as there was in Depot) of mangling directories +when file hierarchies don't match the database. Also unlike Depot, +Stow will never delete any files, directories, or links that appear in +a Stow directory (e.g., @file{/usr/local/stow/emacs}), so it's always +possible to rebuild the target tree (e.g., @file{/usr/local}). + +Stow is implemented as a combination of a Perl script providing a CLI +interface, and a backend Perl module which does most of the work. For information about the latest version of Stow, you can refer to @uref{http://www.gnu.org/software/stow/}. diff --git a/lib/Stow.pm.in b/lib/Stow.pm.in index e190c6c..fac2c9c 100755 --- a/lib/Stow.pm.in +++ b/lib/Stow.pm.in @@ -4,7 +4,7 @@ package Stow; =head1 NAME -Stow - manage the installation of multiple software packages +Stow - manage farms of symbolic links =head1 SYNOPSIS From c3cbdeb8127407a632c086cc1b9342a2d471404c Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Tue, 25 Jun 2019 17:25:33 +0100 Subject: [PATCH 268/482] Synchronise --verbose documentation The man page was updated with regard to higher --verbose levels but not the info manual, so fix that. --- doc/stow.texi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/stow.texi b/doc/stow.texi index f7ae2d1..1042ad4 100644 --- a/doc/stow.texi +++ b/doc/stow.texi @@ -403,7 +403,7 @@ Do not perform any operations that modify the file system; in combination with @item -v @itemx --verbose[=@var{n}] Send verbose output to standard error describing what Stow is -doing. Verbosity levels are 0, 1, 2, and 3; 0 is the default. Using +doing. Verbosity levels are from 0 to 5; 0 is the default. Using @option{-v} or @option{--verbose} increases the verbosity by one; using @samp{--verbose=@var{n}} sets it to @var{n}. From f6bf45af9c5f13be85b70085a508b55df8e35fc1 Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Tue, 25 Jun 2019 17:21:53 +0100 Subject: [PATCH 269/482] Update NEWS and THANKS according to recent commits --- NEWS | 36 ++++++++++++++++++++++++++++++++++++ THANKS | 1 + 2 files changed, 37 insertions(+) diff --git a/NEWS b/NEWS index 9178d23..cdb0f04 100644 --- a/NEWS +++ b/NEWS @@ -36,6 +36,42 @@ News file for Stow. ** Convert README and INSTALL to Markdown +** Update documentation to reflect more modern use cases + + The README.md, stow(8) man page, and info manual have been updated + to de-emphasise the package management use, since these days almost + everyone prefers to use modern package managers such as rpm / dpkg + / Nix for (system-wide) package management. + + To compensate, more popular modern use cases for Stow have been + added, such as management of dotfiles and software compiled in the + user's $HOME directory. + +** Stow now has a non-zero exit code if option parsing failed + + Thanks to Brice Waegeneire for reporting this. + +** chkstow now honours the $STOW_DIR environment variable + + The stow script already honoured the $STOW_DIR environment + variable. Now chkstow does too, for consistency. + +** Miscellaneous documentation fixes + + - Various typos were fixed. + + - The documentation for --verbose was updated to indicate that + verbosity levels now go up to 5. + + - Erroneous glob examples in the --ignore documentation were fixed. + + - The abbreviation "regex" was removed from the info manual for + consistency. + + - INSTALL.md now also documents how to build directly from git. + +** aclocal.m4 was updated using aclocal 1.15.1. + ** Add Docker files for convenient testing across multiple Perl versions This is the first release which has been tested across 5 different diff --git a/THANKS b/THANKS index 9a9072a..b038a32 100644 --- a/THANKS +++ b/THANKS @@ -32,6 +32,7 @@ Hongyi Zhao Jean Louis Daniel Shahaf Matan Nassau +Brice Waegeneire Email addresses of new contributors are no longer being added by default for privacy reasons; however please contact the maintainer if you are From 0f3e1b33fca2574bdce743ae2e280aaab140e630 Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Tue, 25 Jun 2019 19:36:49 +0100 Subject: [PATCH 270/482] Group news items for 2.3.0 Since 2.3.0 is a long overdue release and has many changes, document them in NEWS in three groups: - New features / changes in behaviour - Documentation fixes and enhancements - Fixes for bugs and technical debt --- NEWS | 141 +++++++++++++++++++++++++++++++---------------------------- 1 file changed, 74 insertions(+), 67 deletions(-) diff --git a/NEWS b/NEWS index cdb0f04..3cc5562 100644 --- a/NEWS +++ b/NEWS @@ -2,109 +2,116 @@ News file for Stow. * Changes in version 2.3.0 -** New --dotfiles option +** New features / changes in behaviour - Enable special handling for "dotfiles" (files or folders whose name - begins with a period) in the package directory. If this option is - enabled, Stow will add a preprocessing step for each file or folder - whose name begins with "dot-", and replace the "dot-" prefix in the - name by a period ("."). This is useful when Stow is used to manage - collections of dotfiles, to avoid having a package directory full - of hidden files. +*** New --dotfiles option - For example, suppose we have a package containing two files, - stow/dot-bashrc and stow/dot-emacs.d/init.el. With this option, - Stow will create symlinks from .bashrc to stow/dot-bashrc and from - .emacs.d/init.el to stow/dot-emacs.d/init.el. Any other files, - whose name does not begin with "dot-", will be processed as usual. + Enable special handling for "dotfiles" (files or folders whose name + begins with a period) in the package directory. If this option is + enabled, Stow will add a preprocessing step for each file or folder + whose name begins with "dot-", and replace the "dot-" prefix in the + name by a period ("."). This is useful when Stow is used to manage + collections of dotfiles, to avoid having a package directory full + of hidden files. - Thanks to Joris Vankerschaver for this feature! + For example, suppose we have a package containing two files, + stow/dot-bashrc and stow/dot-emacs.d/init.el. With this option, + Stow will create symlinks from .bashrc to stow/dot-bashrc and from + .emacs.d/init.el to stow/dot-emacs.d/init.el. Any other files, + whose name does not begin with "dot-", will be processed as usual. -** Fixed naming of man page + Thanks to Joris Vankerschaver for this feature! - The title of the generated man page was previously ending up as - something like: +*** chkstow now honours the $STOW_DIR environment variable - IO::FILE=IO(0XA719C0)(1) + The stow script already honoured the $STOW_DIR environment + variable. Now chkstow does too, for consistency. - Thanks to @Corin-EU on GitHub highlighting this and proposing a - fix. +*** Stow now has a non-zero exit code if option parsing failed -** Fix for test suite on Cygwin + Thanks to Brice Waegeneire for reporting this. - Thanks to Lucas Theisen for this fix! +** Documentation fixes and enhancements -** Convert README and INSTALL to Markdown +*** Fixed naming of man page -** Update documentation to reflect more modern use cases + The title of the generated man page was previously ending up as + something like: - The README.md, stow(8) man page, and info manual have been updated - to de-emphasise the package management use, since these days almost - everyone prefers to use modern package managers such as rpm / dpkg - / Nix for (system-wide) package management. + IO::FILE=IO(0XA719C0)(1) - To compensate, more popular modern use cases for Stow have been - added, such as management of dotfiles and software compiled in the - user's $HOME directory. + Thanks to @Corin-EU on GitHub highlighting this and proposing a + fix. -** Stow now has a non-zero exit code if option parsing failed +*** Convert README and INSTALL to Markdown - Thanks to Brice Waegeneire for reporting this. + They are now named README.md and INSTALL.md, and render nicely + when viewed via git hosting services which support Markdown. -** chkstow now honours the $STOW_DIR environment variable +*** Update documentation to reflect more modern use cases - The stow script already honoured the $STOW_DIR environment - variable. Now chkstow does too, for consistency. + The README.md, stow(8) man page, and info manual have been updated + to de-emphasise the package management use, since these days almost + everyone prefers to use modern package managers such as rpm / dpkg + / Nix for (system-wide) package management. -** Miscellaneous documentation fixes + To compensate, more popular modern use cases for Stow have been + added, such as management of dotfiles and software compiled in the + user's $HOME directory. - - Various typos were fixed. +*** Miscellaneous documentation fixes - - The documentation for --verbose was updated to indicate that - verbosity levels now go up to 5. + - Various typos were fixed. - - Erroneous glob examples in the --ignore documentation were fixed. + - The documentation for --verbose was updated to indicate that + verbosity levels now go up to 5. - - The abbreviation "regex" was removed from the info manual for - consistency. + - Erroneous glob examples in the --ignore documentation were fixed. - - INSTALL.md now also documents how to build directly from git. + - The abbreviation "regex" was removed from the info manual for + consistency. -** aclocal.m4 was updated using aclocal 1.15.1. + - INSTALL.md now also documents how to build directly from git. +** Fixes for bugs and technical debt +*** Fix for test suite on Cygwin -** Add Docker files for convenient testing across multiple Perl versions + Thanks to Lucas Theisen for this fix! - This is the first release which has been tested across 5 different - versions of Perl prior to release! The versions are: +*** aclocal.m4 was updated using aclocal 1.15.1. - perl-5.22.2 - perl-5.20.3 - perl-5.18.4 - perl-5.16.3 - perl-5.14.4 +*** Add Docker files for convenient testing across multiple Perl versions - Thanks to Charles LeDoux for this! + This is the first release which has been tested across 5 different + versions of Perl prior to release! The versions are: -** Add Coveralls integration with GitHub + perl-5.22.2 + perl-5.20.3 + perl-5.18.4 + perl-5.16.3 + perl-5.14.4 - This means that test coverage analysis will be automatically be run - on any pull requests submitted to GitHub. + Thanks to Charles LeDoux for this! -** Set up continuous testing via Travis CI +*** Add Coveralls integration with GitHub - This means that the test suite will be automatically run on any - pull requests submitted to GitHub, as well as "make distcheck" - and "./Build distcheck". + This means that test coverage analysis will be automatically be run + on any pull requests submitted to GitHub. -** Miscellaneous fixes to the build and distribution process +*** Set up continuous testing via Travis CI -** Improve handling of directories with unusual names + This means that the test suite will be automatically run on any + pull requests submitted to GitHub, as well as "make distcheck" + and "./Build distcheck". - Various fixes for corner cases where directories are named "0" - or begin with a space character, or where STOW_DIR is empty. +*** Miscellaneous fixes to the build and distribution process - Thanks to Cuong Manh Le for highlighting some of the issues and - proposing fixes! +*** Improve handling of directories with unusual names + + Various fixes for corner cases where directories are named "0" + or begin with a space character, or where STOW_DIR is empty. + + Thanks to Cuong Manh Le for highlighting some of the issues and + proposing fixes! * Changes in version 2.2.2 From bb8b79e0313fbf7bb2762a791406548323e98ffe Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Tue, 25 Jun 2019 19:05:38 +0100 Subject: [PATCH 271/482] Don't warn when .stowrc is used We fully support and expect some users using .stowrc, so there is no reason to issue a warning when they do. --- bin/stow.in | 1 - 1 file changed, 1 deletion(-) diff --git a/bin/stow.in b/bin/stow.in index d64c381..56fc8fb 100755 --- a/bin/stow.in +++ b/bin/stow.in @@ -604,7 +604,6 @@ sub get_config_file_options { my @defaults = (); for my $file ("$ENV{HOME}/.stowrc", '.stowrc') { if (-r $file) { - warn "Loading defaults from $file\n"; open my $FILE, '<', $file or die "Could not open $file for reading\n"; while (my $line = <$FILE>){ From 048203b7f9808acbaec10acbd5892104d3129760 Mon Sep 17 00:00:00 2001 From: Charles LeDoux Date: Fri, 24 Jun 2016 15:06:06 -0500 Subject: [PATCH 272/482] Change init_test_dirs to point $HOME at $OUT_DIRS Why: * Want to add a new feature to parsing of stowrc files. * Need ability to write .stowrc files for testing without risk of squashing existing files. This change addresses the need by: * Reusing logic in init_test_dirs * init_test_dirs already creates new directory structure and overwrites $HOME to point into /tmp. * This commit changes init_test_dirs to point $HOME at the newly created directory structure ($OUT_DIR) instead of /tmp. * Grants ability to write .stowrc to $HOME without fear. * Pointing $HOME at $OUT_DIR instead of /tmp also makes cleanup easier. * Remove $OUT_DIR vs remove specific files in /tmp. --- t/testutil.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/t/testutil.pm b/t/testutil.pm index 1e73dfe..a9d673f 100755 --- a/t/testutil.pm +++ b/t/testutil.pm @@ -55,7 +55,7 @@ sub init_test_dirs { } # Don't let user's ~/.stow-global-ignore affect test results - $ENV{HOME} = '/tmp/fake/home'; + $ENV{HOME} = $OUT_DIR; } sub new_Stow { From 237288fb7e87edd0a27348293bd7bd09d820c7d4 Mon Sep 17 00:00:00 2001 From: Charles LeDoux Date: Fri, 1 Jul 2016 18:38:25 -0500 Subject: [PATCH 273/482] Add test harness for stowrc files Why: * Planning on developing a new feature for parsing of stowrc files. * Need a test harness that performs initialization and clean up * Initialization: Create directory structure that allows creation of stowrc files without worrying about squashing existing files. * Clean up: Remove all files created during testing. This change addresses the need by: * Add intialization and cleanup harness in t/rc_options.t * Define the location to write stowrc files to in $RC_FILE * Ensures that location $RC_FILE does not already exist. * Calls the init_test_dirs to bootstrap directory tree. * After all tests are run, removes $RC_FILE and the testing directory tree. * Add basic test of stowrc parsing to t/rc_options.t * Provides a template of how to create and test a stowrc file. * Newly created t/rc_options.t file added to MANIFEST --- MANIFEST | 1 + t/rc_options.t | 53 ++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 54 insertions(+) create mode 100755 t/rc_options.t diff --git a/MANIFEST b/MANIFEST index 91ae7bf..ed1b9b8 100644 --- a/MANIFEST +++ b/MANIFEST @@ -45,6 +45,7 @@ t/ignore.t t/join_paths.t t/parent.t t/stow.t +t/rc_options.t t/testutil.pm t/unstow.t t/unstow_orig.t diff --git a/t/rc_options.t b/t/rc_options.t new file mode 100755 index 0000000..bf88c68 --- /dev/null +++ b/t/rc_options.t @@ -0,0 +1,53 @@ +#!/usr/local/bin/perl + +# +# Test processing of stowrc file. +# + +use strict; +use warnings; + +use Test::More tests => 2; + +use testutil; + +require 'stow'; + +# stowrc file used for testing. +my $RC_FILE = "$OUT_DIR/.stowrc"; +# Take the safe route and cowardly refuse to continue if there's +# already a file at $RC_FILE. +if (-e $RC_FILE) { + die "RC file location $RC_FILE already exists!\n"; +} + +# Define the variable that will be used to write stowrc. +my $rc_contents; + +# Init testing directory structure and overwrite ENV{HOME} to prevent +# squashing existing stowrc file. +init_test_dirs(); + +# =========== RC Loading Tests =========== +# Basic parsing and loading rc file tests. +# ======================================== + +# +# Test stowrc file with one options per line. +# +local @ARGV = ('dummy'); +$rc_contents = <{target}, "$OUT_DIR/target", "rc options different lines"); +is($options->{dir}, "$OUT_DIR/stow", "rc options different lines"); + +# +# Clean up files used for testing. +# +unlink $RC_FILE or die "Unable to clean up $RC_FILE.\n"; +remove_dir($OUT_DIR); + From ebc895a540e17058042250e351d33da083d5d1dd Mon Sep 17 00:00:00 2001 From: Charles LeDoux Date: Thu, 14 Jul 2016 08:55:55 -0500 Subject: [PATCH 274/482] Add test for conflicting stowrc and cli args Why: * Want to add feature to stowrc parsing. * Missing regression test for conflicting cli and stowrc options. This change addresses the need by: * Add missing regression tests to rc_options.t * Two types of tests for the two types of options possible. * For scalar options such as --target, cli arguments should overwrite stowrc arguments. * For options that result in a list, such as --ignore, the arguments from cli and stowrc files should be merged. --- t/rc_options.t | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/t/rc_options.t b/t/rc_options.t index bf88c68..5f0fe87 100755 --- a/t/rc_options.t +++ b/t/rc_options.t @@ -7,7 +7,7 @@ use strict; use warnings; -use Test::More tests => 2; +use Test::More tests => 4; use testutil; @@ -46,6 +46,32 @@ is($options->{target}, "$OUT_DIR/target", "rc options different lines"); is($options->{dir}, "$OUT_DIR/stow", "rc options different lines"); # +# Test that scalar cli option overwrites conflicting stowrc option. +# +local @ARGV = ('-d', "$OUT_DIR/stow",'dummy'); +$rc_contents = <{dir}, "$OUT_DIR/stow", "cli overwrite scalar rc option."); + +# +# Test that list cli option merges with conflicting stowrc option. +# Documentation states that stowrc options are prepended to cli options. +# +local @ARGV = ( + '--defer=man', + 'dummy' +); +$rc_contents = <{defer}, [qr(\Ainfo), qr(\Aman)], + 'defer man and info'); + # Clean up files used for testing. # unlink $RC_FILE or die "Unable to clean up $RC_FILE.\n"; From feb885fda6ce3e8adb455f9aad638da56722bf10 Mon Sep 17 00:00:00 2001 From: Charles LeDoux Date: Fri, 24 Jun 2016 16:34:13 -0500 Subject: [PATCH 275/482] Factor out parsing of options Why: * Want to be able to selectively apply filepath expansion to: 1. Only options in a stowrc file. 2. Only options that take a file path. * Because of need 1, any expansion must be performed on stowrc options before merging with cli options. * Because of need 2, stowrc options need to be parsed before expansion in order to know which options need expanding. This change addresses the need by: * Create parse_options() * Implements option parsing logic previously in process_options() * Takes an array as parameter instead of assuming ARGV * Edit process_options() to still work as expected. * Only change was to call parse_options() instead of directly parsing ARGV * By factoring out the option parsing code, we can reuse the existing parsing code for stowrc options. * Allows expansion of only the option itself, i.e expansion on "$HOME/target" rather than "--target=$HOME/target" * Allows easy determination of which options need expansion. --- bin/stow.in | 42 ++++++++++++++++++++++++++++++++---------- 1 file changed, 32 insertions(+), 10 deletions(-) diff --git a/bin/stow.in b/bin/stow.in index 56fc8fb..fb42dbf 100755 --- a/bin/stow.in +++ b/bin/stow.in @@ -432,7 +432,7 @@ use warnings; require 5.006_001; use POSIX qw(getcwd); -use Getopt::Long; +use Getopt::Long qw(GetOptionsFromArray); @USE_LIB_PMDIR@ use Stow; @@ -481,23 +481,49 @@ sub main { #===== SUBROUTINE =========================================================== # Name : process_options() -# Purpose : parse command line options +# Purpose : Parse and process command line and .stowrc file options # Parameters: none # Returns : (\%options, \@pkgs_to_unstow, \@pkgs_to_stow) -# Throws : a fatal error if a bad command line option is given +# Throws : a fatal error if a bad option is given # Comments : checks @ARGV for valid package names #============================================================================ sub process_options { + + unshift @ARGV, get_config_file_options(); + #$,="\n"; print @ARGV,"\n"; # for debugging rc file + + my ($options, + $pkgs_to_unstow, + $pkgs_to_stow) = parse_options(@ARGV); + + sanitize_path_options($options); + check_packages($pkgs_to_unstow, $pkgs_to_stow); + + return ($options, $pkgs_to_unstow, $pkgs_to_stow); +} + +#===== SUBROUTINE =========================================================== +# Name : parse_options() +# Purpose : parse command line options +# Parameters: @arg_array => array of options to parse +# Example: parse_options(@ARGV) +# Returns : (\%options, \@pkgs_to_unstow, \@pkgs_to_stow) +# Throws : a fatal error if a bad command line option is given +# Comments : Used for parsing both command line options and rc file. Used +# for parsing only. Sanity checks and post-processing belong in +# process_options(). +#============================================================================ +sub parse_options { my %options = (); my @pkgs_to_unstow = (); my @pkgs_to_stow = (); my $action = 'stow'; - unshift @ARGV, get_config_file_options(); - #$,="\n"; print @ARGV,"\n"; # for debugging rc file + #$,="\n"; print @_,"\n"; # for debugging rc file Getopt::Long::config('no_ignore_case', 'bundling', 'permute'); - GetOptions( + GetOptionsFromArray( + \@_, \%options, 'verbose|v:+', 'help|h', 'simulate|n|no', 'version|V', 'compat|p', 'dir|d=s', 'target|t=s', @@ -548,12 +574,8 @@ sub process_options { usage() if $options{help}; version() if $options{version}; - sanitize_path_options(\%options); - check_packages(\@pkgs_to_unstow, \@pkgs_to_stow); - return (\%options, \@pkgs_to_unstow, \@pkgs_to_stow); } - sub sanitize_path_options { my ($options) = @_; From 4d1167ffd72c77748a22a8dc1646a0d944be1441 Mon Sep 17 00:00:00 2001 From: Charles LeDoux Date: Fri, 1 Jul 2016 20:07:28 -0500 Subject: [PATCH 276/482] Parse cli and stowrc files separately Why: * We want to selectively apply expansion to: * Only options from stowrc files. * Only options that take a path. * This requires ability to: * Differentiate cli options from stowrc options * Distinguish between individual stowrc options. This change addresses the need by: * Options from ARGV and stowrc files are separately parsed, resulting in two options hashes. * Creating an option hash from stowrc files allows modification of specific arguments without having to rely on something like regex parsing of the options. * get_config_file_options modified to return options hash. * Uses the same parse_options function that parses ARGV * Add Hash:Merge to dependencies in order to merge the two option hashes. * process_options() merges the two option hashes. * Get option hash for ARGV * Get option hash from get_config_file_options(). * Merge the two hashes with Hash::Merge. * Sanitation and checks are ran on the merged options. * The options -S, -D, and -R are ignored in stowrc files. * Due to the way argument parsing happens, the effect of these actions is not carried from stowrc into parsing of cli options. * It doesn't seem to make sense to put these options in stowrc anyway. --- Build.PL | 1 + META.json | 1 + META.yml | 1 + bin/stow.in | 38 +++++++++++++++++++++++++------------- 4 files changed, 28 insertions(+), 13 deletions(-) diff --git a/Build.PL b/Build.PL index a14b93b..3f63c0c 100644 --- a/Build.PL +++ b/Build.PL @@ -45,6 +45,7 @@ my $build = Module::Build->new( 'perl' => '5.006', 'Carp' => 0, 'IO::File' => 0, + 'Hash::Merge' => 0, }, script_files => [ 'bin/stow', 'bin/chkstow' ], all_from => 'lib/Stow.pm.in', diff --git a/META.json b/META.json index 2a455a4..dd806c9 100644 --- a/META.json +++ b/META.json @@ -17,6 +17,7 @@ "build" : { "requires" : { "IO::Scalar" : "0", + "Hash::Merge": "0", "Test::More" : "0", "Test::Output" : "0" } diff --git a/META.yml b/META.yml index f94d472..9bcbadb 100644 --- a/META.yml +++ b/META.yml @@ -4,6 +4,7 @@ author: - unknown build_requires: IO::Scalar: '0' + Hash::Merge: '0' Test::More: '0' Test::Output: '0' configure_requires: diff --git a/bin/stow.in b/bin/stow.in index fb42dbf..d056cec 100755 --- a/bin/stow.in +++ b/bin/stow.in @@ -438,6 +438,8 @@ use Getopt::Long qw(GetOptionsFromArray); use Stow; use Stow::Util qw(parent error); +use Hash::Merge qw( merge ); + my $ProgramName = $0; $ProgramName =~ s{.*/}{}; @@ -488,17 +490,29 @@ sub main { # Comments : checks @ARGV for valid package names #============================================================================ sub process_options { - - unshift @ARGV, get_config_file_options(); - #$,="\n"; print @ARGV,"\n"; # for debugging rc file - - my ($options, + # Get cli options. + my ($cli_options, $pkgs_to_unstow, $pkgs_to_stow) = parse_options(@ARGV); + # Get the .stowrc options. + # Note that rc_pkgs_to_unstow and rc_pkgs_to_stow are ignored. + my ($rc_options, + $rc_pkgs_to_unstow, + $rc_pkgs_to_stow) = get_config_file_options(); + + # Merge .stowrc and command line options. + # Preference is given to cli options. + # rc options come first in merged arrays. + # cli options overwrite conflicting rc options. + Hash::Merge::set_behavior('RIGHT_PRECEDENT'); + my $options = merge($rc_options, $cli_options); + + # Run checks on the merged options. sanitize_path_options($options); check_packages($pkgs_to_unstow, $pkgs_to_stow); + # Return merged and processed options. return ($options, $pkgs_to_unstow, $pkgs_to_stow); } @@ -611,16 +625,14 @@ sub check_packages { } } - #===== SUBROUTINE ============================================================ # Name : get_config_file_options() # Purpose : search for default settings in any .stowrc files # Parameters: none -# Returns : a list of default options -# Throws : no exceptions -# Comments : prepends the contents of '~/.stowrc' and '.stowrc' to the command -# : line so they get parsed just like normal arguments. (This was -# : hacked in so that Emil and I could set different preferences). +# Returns : (\%rc_options, \@rc_pkgs_to_unstow, \@rc_pkgs_to_stow) +# Throws : a fatal error if a bad option is given +# Comments : Parses the contents of '~/.stowrc' and '.stowrc' with the same +# parser as the command line options. #============================================================================= sub get_config_file_options { my @defaults = (); @@ -635,7 +647,7 @@ sub get_config_file_options { close $FILE or die "Could not close open file: $file\n"; } } - return @defaults; + return parse_options(@defaults); } #===== SUBROUTINE =========================================================== @@ -650,7 +662,7 @@ sub usage { my ($msg) = @_; if ($msg) { - print "$ProgramName: $msg\n\n"; + warn "$ProgramName: $msg\n\n"; } print <<"EOT"; From 9674738792a1edf1d08726d704d8cf00ad45d896 Mon Sep 17 00:00:00 2001 From: Charles LeDoux Date: Thu, 14 Jul 2016 11:37:42 -0500 Subject: [PATCH 277/482] Apply environment expansion to options in .stowrc files Expand environment variables used in stowrc, as requested in https://savannah.gnu.org/bugs/?41826 This is achieved by creating a new function expand_environment() that replaces any substring of the form '$VAR' or '${VAR}' with contents of environment variable $VAR. Literal '$' can be given by '\$'. N.B. The function is only applied to the --target and --dir options, and only for options specified in .stowrc; cli options are left untouched. Undefined variables are expanded to the empty string, as they would be in normal shell parameter expansion. Unit tests added accordingly: - Test expand_environment(): * Expand $HOME * Expand ${HOME} * Expand ${WITH SPACE} * Expand '\$HOME'. Expected is '$HOME' * Expand ${UNDEFINED}. Expected is ''. - Test that it's applied to the correct options. - Test that CLI options are not expanded. --- bin/stow.in | 54 ++++++++++++++++++++++++++++++++++++++++++-- t/cli_options.t | 13 ++++++++++- t/rc_options.t | 60 ++++++++++++++++++++++++++++++++++++++++++++++++- 3 files changed, 123 insertions(+), 4 deletions(-) diff --git a/bin/stow.in b/bin/stow.in index d056cec..dd6fb8e 100755 --- a/bin/stow.in +++ b/bin/stow.in @@ -632,7 +632,8 @@ sub check_packages { # Returns : (\%rc_options, \@rc_pkgs_to_unstow, \@rc_pkgs_to_stow) # Throws : a fatal error if a bad option is given # Comments : Parses the contents of '~/.stowrc' and '.stowrc' with the same -# parser as the command line options. +# parser as the command line options. Additionally expands any +# environment variables in --target or --dir options. #============================================================================= sub get_config_file_options { my @defaults = (); @@ -647,7 +648,56 @@ sub get_config_file_options { close $FILE or die "Could not close open file: $file\n"; } } - return parse_options(@defaults); + + # Parse the options + my ($rc_options, $rc_pkgs_to_unstow, $rc_pkgs_to_stow) = parse_options(@defaults); + + # Expand environment variables and glob characters. + if (exists $rc_options->{target}) { + $rc_options->{target} = + expand_environment($rc_options->{target}, '--target option'); + } + if (exists $rc_options->{dir}) { + $rc_options->{dir} = + expand_environment($rc_options->{dir}, '--dir option'); + } + + return ($rc_options, $rc_pkgs_to_unstow, $rc_pkgs_to_stow); +} + +#===== SUBROUTINE ============================================================ +# Name : expand_environment() +# Purpose : Expands evironment variables. +# Parameters: $path => string to perform expansion on. +# : $source => where the string came from +# Returns : String with replacements performed. +# Throws : n/a +# Comments : Variable replacement mostly based on SO answer +# : http://stackoverflow.com/a/24675093/558820 +#============================================================================= +sub expand_environment { + my ($path, $source) = @_; + # Replace non-escaped $VAR and ${VAR} with $ENV{VAR} + # If $ENV{VAR} does not exist, perl will raise a warning + # and then happily treat it as an empty string. + $path =~ s/(? 9; +use Test::More tests => 10; use testutil; @@ -82,5 +82,16 @@ local @ARGV = ( ($options, $pkgs_to_delete, $pkgs_to_stow) = process_options(); is_deeply($options->{ignore}, [ qr(~\z), qr(\.#.*\z) ] => 'ignore temp files'); +# +# Check that expansion not applied. +# +local @ARGV = ( + "--target=$OUT_DIR/".'$HOME', + 'dummy' +); +make_dir("$OUT_DIR/".'$HOME'); +($options, $pkgs_to_delete, $pkgs_to_stow) = process_options(); +is($options->{target}, "$OUT_DIR/".'$HOME', 'no expansion'); +remove_dir("$OUT_DIR/".'$HOME'); # vim:ft=perl diff --git a/t/rc_options.t b/t/rc_options.t index 5f0fe87..c6c2061 100755 --- a/t/rc_options.t +++ b/t/rc_options.t @@ -7,7 +7,7 @@ use strict; use warnings; -use Test::More tests => 4; +use Test::More tests => 15; use testutil; @@ -72,6 +72,64 @@ make_file($RC_FILE, $rc_contents); is_deeply($options->{defer}, [qr(\Ainfo), qr(\Aman)], 'defer man and info'); +# ======== Filepath Expansion Tests ======== +# Test proper filepath expansion in rc file. +# Expansion is only applied to options that +# take a filepath, namely target and dir. +# ========================================== + + +# +# Test environment variable expansion function. +# +# Basic expansion +is(expand_environment('$HOME/stow'), "$OUT_DIR/stow", 'expand $HOME'); +is(expand_environment('${HOME}/stow'), "$OUT_DIR/stow", 'expand ${HOME}'); + +delete $ENV{UNDEFINED}; # just in case +foreach my $var ('$UNDEFINED', '${UNDEFINED}') { + eval { + expand_environment($var, "--foo option"); + }; + is( + $@, + "--foo option references undefined environment variable \$UNDEFINED; " . + "aborting!\n", + "expand $var" + ); +} + +# Expansion with an underscore. +$ENV{'WITH_UNDERSCORE'} = 'test string'; +is(expand_environment('${WITH_UNDERSCORE}'), 'test string', + 'expand ${WITH_UNDERSCORE}'); +delete $ENV{'WITH_UNDERSCORE'}; +# Expansion with escaped $ +is(expand_environment('\$HOME/stow'), '$HOME/stow', 'expand \$HOME'); + +# +# Test that environment variable expansion is applied. +# +$rc_contents = <<'HERE'; +--dir=$HOME/stow +--target=$HOME/stow +--ignore=\$HOME +--defer=\$HOME +--override=\$HOME +HERE +make_file($RC_FILE, $rc_contents); +($options, $pkgs_to_delete, $pkgs_to_stow) = get_config_file_options(); +is($options->{dir}, "$OUT_DIR/stow", + "apply environment expansion on stowrc --dir"); +is($options->{target}, "$OUT_DIR/stow", + "apply environment expansion on stowrc --target"); +is_deeply($options->{ignore}, [qr(\$HOME\z)], + "environment expansion not applied on --ignore"); +is_deeply($options->{defer}, [qr(\A\$HOME)], + "environment expansion not applied on --defer"); +is_deeply($options->{override}, [qr(\A\$HOME)], + "environment expansion not applied on --override"); + # Clean up files used for testing. # unlink $RC_FILE or die "Unable to clean up $RC_FILE.\n"; From dc42c34107ff1ad6173b418695bc6d0e4ddbfaf5 Mon Sep 17 00:00:00 2001 From: Charles LeDoux Date: Thu, 14 Jul 2016 14:48:40 -0500 Subject: [PATCH 278/482] Add function to expand ~ in .stowrc files (#14) Add a new expand_tilde() function that performs tilde expansion of strings, and corresponding unit tests: * A ~ at the beginning of a path is expanded to the user's home directory. * Literal '~' can be provided with '\~' Combine this with expand_environment() in a new expand_filepath() function which applies all (both) required expansion functions to a string, and use that in get_config_file_options() to expand .stowrc options. Add more tests to check that tilde expanded in correct places, i.e.: * expanded for --target and --dir * not expanded for --ignore, --defer, or --override Update documentation on stowrc files according to this functionality change. Fixes #14: https://github.com/aspiers/stow/issues/14 --- NEWS | 10 +++++++ bin/stow.in | 73 +++++++++++++++++++++++++++++++++++++++++++++++--- doc/stow.texi | 23 +++++++++++++--- t/rc_options.t | 35 +++++++++++++++++++++++- 4 files changed, 134 insertions(+), 7 deletions(-) diff --git a/NEWS b/NEWS index 3cc5562..3b676da 100644 --- a/NEWS +++ b/NEWS @@ -22,6 +22,16 @@ News file for Stow. Thanks to Joris Vankerschaver for this feature! +*** Shell-like expansion in .stowrc files + + For options within .stowrc files which describe file paths, "~" can + be included to expand to the current value of $HOME, and + environment variables can be referenced e.g. via "$FOO" or + "${FOO}". To prevent expansion, escape with a backslash. + + Thanks a lot to Charles LeDoux for his diligent work on this + feature! + *** chkstow now honours the $STOW_DIR environment variable The stow script already honoured the $STOW_DIR environment diff --git a/bin/stow.in b/bin/stow.in index dd6fb8e..9afe2a1 100755 --- a/bin/stow.in +++ b/bin/stow.in @@ -343,6 +343,28 @@ Stow will re-fold the tree by removing the symlinks to the surviving package, removing the directory, then linking the directory back to the surviving package. +=head1 RESOURCE FILES + +F searches for default command line options at F<.stowrc> (current +directory) and F<~/.stowrc> (home directory) in that order. If both +locations are present, the files are effectively appended together. + +The effect of options in the resource file is similar to simply prepending +the options to the command line. For options that provide a single value, +such as F<--target> or F<--dir>, the command line option will overwrite any +options in the resource file. For options that can be given more than once, +F<--ignore> for example, command line options and resource options are +appended together. + +Environment variables and the tilde character (F<~>) will be expanded for +options that take a file path. + +The options F<-D>, F<-R>, F<-S>, and any packages listed in the resource +file are ignored. + +See the info manual for more information on how stow handles resource +file. + =head1 SEE ALSO The full documentation for F is maintained as a Texinfo manual. @@ -633,7 +655,8 @@ sub check_packages { # Throws : a fatal error if a bad option is given # Comments : Parses the contents of '~/.stowrc' and '.stowrc' with the same # parser as the command line options. Additionally expands any -# environment variables in --target or --dir options. +# environment variables or ~ character in --target or --dir +# options. #============================================================================= sub get_config_file_options { my @defaults = (); @@ -655,16 +678,36 @@ sub get_config_file_options { # Expand environment variables and glob characters. if (exists $rc_options->{target}) { $rc_options->{target} = - expand_environment($rc_options->{target}, '--target option'); + expand_filepath($rc_options->{target}, '--target option'); } if (exists $rc_options->{dir}) { $rc_options->{dir} = - expand_environment($rc_options->{dir}, '--dir option'); + expand_filepath($rc_options->{dir}, '--dir option'); } return ($rc_options, $rc_pkgs_to_unstow, $rc_pkgs_to_stow); } +#===== SUBROUTINE ============================================================ +# Name : expand_filepath() +# Purpose : Handles expansions that need to be applied to +# : file paths. Currently expands environment +# : variables and the tilde. +# Parameters: $path => string to perform expansion on. +# : $source => where the string came from +# Returns : String with replacements performed. +# Throws : n/a +# Comments : n/a +#============================================================================= +sub expand_filepath { + my ($path, $source) = @_; + + $path = expand_environment($path, $source); + $path = expand_tilde($path); + + return $path; +} + #===== SUBROUTINE ============================================================ # Name : expand_environment() # Purpose : Expands evironment variables. @@ -700,6 +743,30 @@ sub _safe_expand_env_var { return $ENV{$var}; } +#===== SUBROUTINE ============================================================ +# Name : expand_tilde() +# Purpose : Expands tilde to user's home directory path. +# Parameters: $path => string to perform expansion on. +# Returns : String with replacements performed. +# Throws : n/a +# Comments : http://docstore.mik.ua/orelly/perl4/cook/ch07_04.htm +#============================================================================= +sub expand_tilde { + my ($path) = @_; + # Replace tilde with home path. + $path =~ s{ ^ ~ ( [^/]* ) } + { $1 + ? (getpwnam($1))[7] + : ( $ENV{HOME} || $ENV{LOGDIR} + || (getpwuid($<))[7] + ) + }ex; + # Replace espaced tilde with regular tilde. + $path =~ s/\\~/~/g; + return $path +} + + #===== SUBROUTINE =========================================================== # Name : usage() # Purpose : print program usage message and exit diff --git a/doc/stow.texi b/doc/stow.texi index 1042ad4..d4e4087 100644 --- a/doc/stow.texi +++ b/doc/stow.texi @@ -881,9 +881,10 @@ directory. Default command line options may be set in @file{.stowrc} (current directory) or @file{~/.stowrc} (home directory). These are parsed in -that order, and effectively prepended to the command line arguments -(with the notable difference that they won't be processed by the shell). -This feature can be used for some interesting effects. +that order, and are appended together if they both exist. The effect of +the options in the resource file is similar to simply prepending the +options to the command line. This feature can be used for some +interesting effects. For example, suppose your site uses more than one stow directory, perhaps in order to share around responsibilities with a number of systems @@ -922,6 +923,22 @@ immediate parent directory @file{/usr/local/stow}), overriding any pre-existing links to bin files or man pages, and ignoring some cruft that gets installed by default. +If an option is provided both on the command line and in a resource file, +the command line option takes precedence. For options that provide a single +value, such as @command{--target} or @command{--dir}, the command line +option will overwrite any options in the resource file. For options that can +be given more than once, @command{--ignore} for example, command line +options and resource options are appended together. + +For options that take a file path, environment variables and the tilde +character (@command{~}) are expanded. An environment variable can be +given in either the @command{$VAR} or @command{$@{VAR@}} form. To +prevent expansion, escape the @command{$} or @command{~} with a +backslash. + +The options @command{-D}, @command{-S}, and @command{-R} are ignored in +resource files. This is also true of any package names given in the +resource file. @c =========================================================================== @node Compile-time vs Install-time, Bootstrapping, Resource Files, Top diff --git a/t/rc_options.t b/t/rc_options.t index c6c2061..6905df5 100755 --- a/t/rc_options.t +++ b/t/rc_options.t @@ -7,7 +7,7 @@ use strict; use warnings; -use Test::More tests => 15; +use Test::More tests => 23; use testutil; @@ -107,6 +107,16 @@ delete $ENV{'WITH_UNDERSCORE'}; # Expansion with escaped $ is(expand_environment('\$HOME/stow'), '$HOME/stow', 'expand \$HOME'); +# +# Test tilde (~) expansion +# +# Basic expansion +is(expand_tilde('~/path'), "$ENV{HOME}/path", 'tilde expansion to $HOME'); +# Should not expand if middle of path +is(expand_tilde('/path/~/here'), '/path/~/here', 'middle ~ not expanded'); +# Test escaped ~ +is(expand_tilde('\~/path'), '~/path', 'escaped tilde'); + # # Test that environment variable expansion is applied. # @@ -130,6 +140,29 @@ is_deeply($options->{defer}, [qr(\A\$HOME)], is_deeply($options->{override}, [qr(\A\$HOME)], "environment expansion not applied on --override"); +# +# Test that tilde expansion is applied in correct places. +# +$rc_contents = <<'HERE'; +--dir=~/stow +--target=~/stow +--ignore=~/stow +--defer=~/stow +--override=~/stow +HERE +make_file($RC_FILE, $rc_contents); +($options, $pkgs_to_delete, $pkgs_to_stow) = get_config_file_options(); +is($options->{dir}, "$OUT_DIR/stow", + "apply environment expansion on stowrc --dir"); +is($options->{target}, "$OUT_DIR/stow", + "apply environment expansion on stowrc --target"); +is_deeply($options->{ignore}, [qr(~/stow\z)], + "environment expansion not applied on --ignore"); +is_deeply($options->{defer}, [qr(\A~/stow)], + "environment expansion not applied on --defer"); +is_deeply($options->{override}, [qr(\A~/stow)], + "environment expansion not applied on --override"); + # Clean up files used for testing. # unlink $RC_FILE or die "Unable to clean up $RC_FILE.\n"; From e647c53af1f5c3265593ddc909c745192347a442 Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Tue, 25 Jun 2019 20:04:11 +0100 Subject: [PATCH 279/482] Add some polish to the release process --- doc/HOWTO-RELEASE | 40 ++++++++++++++++++++++------------------ tools/get-version | 14 ++++++++++++++ 2 files changed, 36 insertions(+), 18 deletions(-) create mode 100755 tools/get-version diff --git a/doc/HOWTO-RELEASE b/doc/HOWTO-RELEASE index 0c55b0e..a5dd55f 100644 --- a/doc/HOWTO-RELEASE +++ b/doc/HOWTO-RELEASE @@ -11,22 +11,22 @@ First read the official information for maintainers of GNU software: Release procedure ----------------- -- Set a shell variable to the version to be released, e.g. if the - final step of this document was carried out after the previous - release was published: - - version=$( git describe --match v* --abbrev=0 ) - -- Ensure NEWS contains the latest changes, and that any new - contributors have been added to THANKS. - -- git commit -m "Prepare NEWS and THANKS for $version release" - -- Ensure configure.ac contains the new version number. - This should follow Semantic Versioning as described at: +- Ensure configure.ac contains the number of the new unreleased + version. This should follow Semantic Versioning as described at: http://semver.org/ +- To make the following steps easier, set the $version shell variable + to the same version number as above, e.g. + + version=$( tools/get-version ) && echo $version + +- Ensure NEWS contains the latest changes, and that any new + contributors have been added to THANKS. If necessary, commit + any additions: + + git commit -m "Prepare NEWS and THANKS for $version release" + - Check CPAN distribution will work via Module::Build: - Generate stow, chkstow, and lib/Stow.pm via: @@ -51,22 +51,26 @@ Release procedure carried out after the previous release was published, but if not: - git commit -m "Bump version to X.Y.Z" + git commit -m "Bump version to $version" - Ensure all changes are committed to git. - Run make distcheck and ensure that everything looks good. It should generate the distribution files for you. -- Tag the current git HEAD with the new version number: - - git tag -s $version -m "Release $version" - - Run the tests on various Perl versions via Docker: ./build-docker.sh ./test-docker.sh + Obviously if there are any failures, they will need to be fixed + first, and then repeat the above steps. + +- At this point we have a release candidate. Tag the current git HEAD + with the new version number: + + git tag -s $version -m "Release $version" + - Run ./Build dist - Upload the resulting Stow-v7.8.9.tar.gz to CPAN via https://pause.perl.org/ diff --git a/tools/get-version b/tools/get-version new file mode 100755 index 0000000..90d6a1b --- /dev/null +++ b/tools/get-version @@ -0,0 +1,14 @@ +#!/usr/bin/perl -w + +use strict; + +open(CONF, "configure.ac") or die "Couldn't open configure.ac: $!\n"; + +while () { + if (/^AC_INIT\(\[stow\], \[(.+?)\]/) { + print "$1\n"; + exit 0; + } +} + +exit 1; From 8b0733a8a0b2c2a857c87f8470e772dcaeb3da9c Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Tue, 25 Jun 2019 20:33:48 +0100 Subject: [PATCH 280/482] add tools/get-version to MANIFEST Forgot to do this, and it broke ./Build.PL distcheck. --- MANIFEST | 1 + 1 file changed, 1 insertion(+) diff --git a/MANIFEST b/MANIFEST index ed1b9b8..ae4a0cd 100644 --- a/MANIFEST +++ b/MANIFEST @@ -49,6 +49,7 @@ t/rc_options.t t/testutil.pm t/unstow.t t/unstow_orig.t +tools/get-version THANKS TODO META.yml From 6764788f713fdf5fcac74fa18be8a3d50ba780e9 Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Wed, 26 Jun 2019 13:25:53 +0100 Subject: [PATCH 281/482] remove trailing whitespace from lines --- AUTHORS | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/AUTHORS b/AUTHORS index 65b0ebc..0c5e88f 100644 --- a/AUTHORS +++ b/AUTHORS @@ -6,7 +6,7 @@ Contributions from Gord Matzigkeit . John Bazik wrote `fastcwd', the Perl subroutine for computing the current working directory. -Charles Briscoe-Smith wrote the fix to prevent +Charles Briscoe-Smith wrote the fix to prevent stow -D / stow -R removing initially-empty directories. Adam Lackorzynski wrote the fix to prevente @@ -19,17 +19,17 @@ in order to implement: 1. defered operations, 2. option parsing via Getopt::Long, - 3. options to support shared files, + 3. options to support shared files, 4. support for multiple operations per invocation, - 5. default command line arguments via '.stowrc' and '~/.stowrc' files, + 5. default command line arguments via '.stowrc' and '~/.stowrc' files, 6. better cooperation between multiple stow directories, - 7. a test suite (and support code) to ensure that everything still works. + 7. a test suite (and support code) to ensure that everything still works. As these changes required a dramatic reorganisation of the code, very little was left untouched, and so Stow's major version was bumped up to version 2. Austin Wood and Chris Hoobin - helped clean up the documentation for + helped clean up the documentation for version 2 and created the texi2man script. Adam Spiers refactored the backend code into new From b4cb6e775a6761445208e0eea5b48c3628508a4b Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Wed, 26 Jun 2019 13:33:48 +0100 Subject: [PATCH 282/482] Add Guillaume and myself to the list of @authors --- doc/stow.texi | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/doc/stow.texi b/doc/stow.texi index d4e4087..e9b95fa 100644 --- a/doc/stow.texi +++ b/doc/stow.texi @@ -63,7 +63,9 @@ approved by the Free Software Foundation. @title Stow @value{VERSION} @subtitle Managing the installation of software packages @author Bob Glickstein, Zanshin Software, Inc. -@author Kahlil Hodgson, RMIT Univerity, Australia. +@author Kahlil Hodgson, RMIT University, Australia. +@author Guillaume Morin +@author Adam Spiers @page @vskip 0pt plus 1filll @insertcopying From 9c402559d2d223f505685b0bead9a75a4dae365a Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Wed, 26 Jun 2019 13:34:09 +0100 Subject: [PATCH 283/482] Include the preamble in online versions of the manual This is more inline with the suggestion in the texinfo manual: https://www.gnu.org/software/texinfo/manual/texinfo/html_node/_0040top-Command.html and also the preamble is useful in all cases. --- doc/stow.texi | 2 -- 1 file changed, 2 deletions(-) diff --git a/doc/stow.texi b/doc/stow.texi index e9b95fa..6e36b97 100644 --- a/doc/stow.texi +++ b/doc/stow.texi @@ -81,12 +81,10 @@ approved by the Free Software Foundation. @node Top @top -@ifinfo This manual describes GNU Stow @value{VERSION} (@value{UPDATED}), a symlink farm manager which takes distinct sets of software and/or data located in separate directories on the filesystem, and makes them appear to be installed in a single directory tree. -@end ifinfo @end ifnottex @menu From 22ca973d59c903d1dd7d877a8368ea7d48d9f6aa Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Wed, 26 Jun 2019 13:37:07 +0100 Subject: [PATCH 284/482] Switch to makeinfo --html --no-split for single-page HTML manual (#21) Remove the dependency on the ancient and unmaintained texi2html, which was difficult to get running on most distros other than openSUSE. There are two more modern alternative approaches which can replace this: - Use texi2any - Use makeinfo --html --no-split The latter seems to be the standard way these days, so we switch to that; however we keep Makefile rules for all three, and a phony meta-rule 'manual-single-html-all' to allow quick comparison between them. Make tweaks accordingly to minimise the differences and improve the output. The rules for the older two approaches do not get triggered by default. Fixes #21: https://github.com/aspiers/stow/issues/21 --- .gitignore | 2 ++ MANIFEST.SKIP | 2 ++ Makefile.am | 34 +++++++++++++++++++++++++++++++++- NEWS | 16 ++++++++++++++++ 4 files changed, 53 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 6440a89..dcb7f4d 100644 --- a/.gitignore +++ b/.gitignore @@ -20,6 +20,8 @@ configure /doc/ChangeLog.OLD /doc/manual.pdf /doc/manual-single.html +/doc/manual-single-old-texi2html.html +/doc/manual-single-texi2html-wrapper.html /doc/manual-split/ /doc/manual.texi /doc/stow.pdf diff --git a/MANIFEST.SKIP b/MANIFEST.SKIP index b356572..259024a 100644 --- a/MANIFEST.SKIP +++ b/MANIFEST.SKIP @@ -76,6 +76,8 @@ ^autom4te\.cache/.+$ ^config\.(log|status)$ ^doc/\.dirstamp$ +^doc/manual-single-old-texi2html\.html +^doc/manual-single-texi2html-wrapper\.html ^doc/manual-split/ ^doc/stamp-vti$ ^doc/HOWTO-RELEASE$ diff --git a/Makefile.am b/Makefile.am index ef3520a..29c6a6b 100644 --- a/Makefile.am +++ b/Makefile.am @@ -181,10 +181,42 @@ doc/stow.8: bin/stow.in Makefile.am # install. Instead, by overriding the built-in rules with modified # versions, we can kill both birds with one stone. +# Generating the single-page HTML version used to be done with the old +# texi2html, which is no longer maintained. This rule is not used, +# but is kept to allow comparing of results during the transition, and +# potentially longer for posterity. +doc/manual-single-old-texi2html.html: $(doc_deps) + texi2html --P=$(srcdir) --output=$@ -expandinfo -menu -monolithic -verbose $< + +# One alternative to the old texi2html approach is to use the texi2html +# wrapper around texi2any which is provided as a partial drop-in replacement: +# +# https://www.gnu.org/software/texinfo/manual/texinfo/html_node/texi2html.html#texi2html +# +# Differences to the old texi2html: +# +# - Doesn't wrap @file{foo} paths with quotes, which looks better. +# - Missing certain sections +doc/manual-single-texi2html-wrapper.html: $(doc_deps) + texi2any -P $(srcdir) --output=$@ --verbose \ + -c TEXI2HTML=1 -c SHOW_MENU=1 -c MONOLITHIC=1 $< + +.PHONY: manual-single-html-all +manual-single-html-all: \ + $(HTML) \ + doc/manual-single-texi2html-wrapper.html \ + doc/manual-single-old-texi2html.html + +# Modern approach using $(MAKEINFOHTML) --no-split +# Differences to the older two approaches: +# +# - Nicer navigation links between sections $(HTML): $(doc_deps) [ -d doc ] || mkdir doc # required in vpath mode -rm -f $@ - texi2html --P=$(srcdir) --output=$@ -expandinfo -menu -monolithic -verbose $< + $(MAKEINFOHTML) $(AM_MAKEINFOHTMLFLAGS) $(MAKEINFOFLAGS) -I doc -I $(srcdir)/doc \ + -c USE_TITLEPAGE_FOR_TITLE=1 --no-split -o $@ \ + `test -f 'doc/stow.texi' || echo '$(srcdir)/'`doc/stow.texi $(PDF): $(doc_deps) TEXINPUTS="$(am__TEXINFO_TEX_DIR)$(PATH_SEPARATOR)$$TEXINPUTS" \ diff --git a/NEWS b/NEWS index 3b676da..51b7e38 100644 --- a/NEWS +++ b/NEWS @@ -43,6 +43,22 @@ News file for Stow. ** Documentation fixes and enhancements +*** Remove dependency on unmaintained texi2html + + The dependency on the ancient and unmaintained texi2html for + building the single-page HTML version of the manual has been + removed, since it was difficult to get running on most distros + other than openSUSE. + + Instead use the more modern "makeinfo --html --no-split" approach. + Rules have been kept for posterity in the Makefile for the old + approach and also an "in-between" approach based on texi2any; + however these are not triggered by default. Run + + make manual-single-html-all + + to compare the three versions. + *** Fixed naming of man page The title of the generated man page was previously ending up as From 833abc4d934ce42ca8afc14fe537461622d344bb Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Wed, 26 Jun 2019 13:26:08 +0100 Subject: [PATCH 285/482] Update maintainership to reflect reality Troy hasn't been active on the project for many years. https://lists.gnu.org/archive/html/stow-devel/2011-11/msg00009.html --- AUTHORS | 2 +- THANKS | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/AUTHORS b/AUTHORS index 65b0ebc..d8bf80d 100644 --- a/AUTHORS +++ b/AUTHORS @@ -37,4 +37,4 @@ Stow.pm and Stow/Util.pm modules providing an OO interface, tightened up the test suite, added support for ignore lists, `make test', and distribution via CPAN, and cleaned up numerous other minor issues. -Stow is currently co-maintained by Adam Spiers and Troy Mill. +Stow is currently maintained by Adam Spiers. diff --git a/THANKS b/THANKS index b038a32..2940859 100644 --- a/THANKS +++ b/THANKS @@ -20,6 +20,7 @@ Emil Mikulic Austin Wood Christopher Hoobin Adam Spiers +Troy Will Stefano Lattarini Adam Sampson Cuong Manh Le From c2a399985ae37207d61ca6cc0ebc8441a44c9846 Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Wed, 26 Jun 2019 13:25:53 +0100 Subject: [PATCH 286/482] remove trailing whitespace from lines --- doc/stow.texi | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/doc/stow.texi b/doc/stow.texi index 6e36b97..be1f467 100644 --- a/doc/stow.texi +++ b/doc/stow.texi @@ -111,16 +111,16 @@ appear to be installed in a single directory tree. Ignore Lists -* Motivation For Ignore Lists:: -* Types And Syntax Of Ignore Lists:: -* Justification For Yet Another Set Of Ignore Files:: +* Motivation For Ignore Lists:: +* Types And Syntax Of Ignore Lists:: +* Justification For Yet Another Set Of Ignore Files:: Advice on changing compilation and installation parameters -* GNU Emacs:: -* Other FSF Software:: -* Cygnus Software:: -* Perl and Perl 5 Modules:: +* GNU Emacs:: +* Other FSF Software:: +* Cygnus Software:: +* Perl and Perl 5 Modules:: @end detailmenu @end menu @@ -460,9 +460,9 @@ of times. @cindex ignoring files and directories @menu -* Motivation For Ignore Lists:: -* Types And Syntax Of Ignore Lists:: -* Justification For Yet Another Set Of Ignore Files:: +* Motivation For Ignore Lists:: +* Types And Syntax Of Ignore Lists:: +* Justification For Yet Another Set Of Ignore Files:: @end menu @c =========================================================================== @@ -581,7 +581,7 @@ justified. However there are good reasons why Stow does not simply check for the presence of say, @file{.cvsignore}, and use that if it exists. Firstly, there is no guarantee that a stow package would contain any version control meta-data, or permit introducing this if -it didn't already exist. +it didn't already exist. Secondly even if it did, version control system ignore lists generally reflect @emph{build-time} ignores rather than @emph{install-time}, and @@ -1017,10 +1017,10 @@ The details of stowing some specific packages are described in the following sections. @menu -* GNU Emacs:: -* Other FSF Software:: -* Cygnus Software:: -* Perl and Perl 5 Modules:: +* GNU Emacs:: +* Other FSF Software:: +* Cygnus Software:: +* Perl and Perl 5 Modules:: @end menu @c --------------------------------------------------------------------------- From fd17b807f520ab12d4aedf1d809bc4c0543da0b4 Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Thu, 27 Jun 2019 13:55:35 +0100 Subject: [PATCH 287/482] Fix Travis failure after merging #42 Something weird happened with https://travis-ci.org/aspiers/stow/jobs/551290921 after merging #42, as shown below. Maybe removing texi2html from the list of packages for Travis to install will help. --- Installing APT Packages 15.50s$ travis_apt_get_update 0.11s$ sudo -E apt-get -yq --no-install-suggests --no-install-recommends $(travis_apt_get_options) install texinfo texlive texi2html Reading package lists... Building dependency tree... Reading state information... Package texinfo is not available, but is referred to by another package. This may mean that the package is missing, has been obsoleted, or is only available from another source However the following packages replace it: info install-info E: Package 'texinfo' has no installation candidate E: Unable to locate package texi2html apt-get.diagnostics apt-get install failed $ cat ${TRAVIS_HOME}/apt-get-update.log Get:2 http://dl.hhvm.com/ubuntu trusty InRelease [3,106 B] Get:3 http://security.ubuntu.com/ubuntu trusty-security InRelease [65.9 kB] Get:4 http://ppa.launchpad.net/chris-lea/redis-server/ubuntu trusty InRelease [15.4 kB] Ign:5 http://repo.mongodb.org/apt/ubuntu trusty/mongodb-org/3.4 InRelease Get:6 http://repo.mongodb.org/apt/ubuntu trusty/mongodb-org/3.4 Release [2,495 B] Get:7 http://repo.mongodb.org/apt/ubuntu trusty/mongodb-org/3.4 Release.gpg [801 B] Get:8 http://dl.hhvm.com/ubuntu trusty/main amd64 Packages [1,812 B] Get:9 http://security.ubuntu.com/ubuntu trusty-security/main Sources [220 kB] Get:10 http://security.ubuntu.com/ubuntu trusty-security/restricted Sources [5,050 B] Get:11 http://security.ubuntu.com/ubuntu trusty-security/universe Sources [126 kB] Get:12 http://security.ubuntu.com/ubuntu trusty-security/multiverse Sources [3,070 B] Get:13 http://security.ubuntu.com/ubuntu trusty-security/main amd64 Packages [1,032 kB] Get:14 http://security.ubuntu.com/ubuntu trusty-security/main i386 Packages [934 kB] Get:15 http://security.ubuntu.com/ubuntu trusty-security/main Translation-en [541 kB] Get:16 http://security.ubuntu.com/ubuntu trusty-security/restricted amd64 Packages [18.1 kB] Get:17 http://security.ubuntu.com/ubuntu trusty-security/restricted i386 Packages [17.8 kB] Get:18 http://security.ubuntu.com/ubuntu trusty-security/restricted Translation-en [3,272 B] Get:19 http://security.ubuntu.com/ubuntu trusty-security/universe amd64 Packages [377 kB] Get:20 http://security.ubuntu.com/ubuntu trusty-security/universe i386 Packages [355 kB] Get:21 http://security.ubuntu.com/ubuntu trusty-security/universe Translation-en [203 kB] Get:22 http://security.ubuntu.com/ubuntu trusty-security/multiverse amd64 Packages [4,730 B] Get:23 http://security.ubuntu.com/ubuntu trusty-security/multiverse i386 Packages [4,887 B] Get:24 http://security.ubuntu.com/ubuntu trusty-security/multiverse Translation-en [2,426 B] Get:25 https://download.docker.com/linux/ubuntu trusty InRelease [37.1 kB] Get:26 http://repo.mongodb.org/apt/ubuntu trusty/mongodb-org/3.4/multiverse amd64 Packages [14.1 kB] Get:27 https://download.docker.com/linux/ubuntu trusty/stable amd64 Packages [5,763 B] Get:28 https://download.docker.com/linux/ubuntu trusty/edge amd64 Packages [6,911 B] Ign:29 http://ppa.launchpad.net/couchdb/stable/ubuntu trusty InRelease Get:30 http://ppa.launchpad.net/git-core/ppa/ubuntu trusty InRelease [20.8 kB] Get:31 http://ppa.launchpad.net/hvr/ghc/ubuntu trusty InRelease [15.4 kB] Get:32 http://ppa.launchpad.net/pollinate/ppa/ubuntu trusty InRelease [15.4 kB] Get:33 http://ppa.launchpad.net/webupd8team/java/ubuntu trusty InRelease [15.5 kB] Get:34 http://ppa.launchpad.net/chris-lea/redis-server/ubuntu trusty/main amd64 Packages [1,843 B] Get:35 http://ppa.launchpad.net/chris-lea/redis-server/ubuntu trusty/main i386 Packages [1,842 B] Get:36 http://ppa.launchpad.net/chris-lea/redis-server/ubuntu trusty/main Translation-en [990 B] Get:37 http://ppa.launchpad.net/couchdb/stable/ubuntu trusty Release [15.1 kB] Get:38 http://ppa.launchpad.net/couchdb/stable/ubuntu trusty Release.gpg [316 B] Ign:39 http://dl.google.com/linux/chrome/deb stable InRelease Get:40 http://dl.google.com/linux/chrome/deb stable Release [943 B] Get:41 http://dl.google.com/linux/chrome/deb stable Release.gpg [819 B] Get:42 http://ppa.launchpad.net/git-core/ppa/ubuntu trusty/main amd64 Packages [3,494 B] Get:43 http://ppa.launchpad.net/git-core/ppa/ubuntu trusty/main i386 Packages [3,496 B] Get:44 http://ppa.launchpad.net/git-core/ppa/ubuntu trusty/main Translation-en [2,368 B] Get:45 http://ppa.launchpad.net/hvr/ghc/ubuntu trusty/main amd64 Packages [18.5 kB] Get:46 http://ppa.launchpad.net/hvr/ghc/ubuntu trusty/main i386 Packages [15.7 kB] Get:47 http://ppa.launchpad.net/hvr/ghc/ubuntu trusty/main Translation-en [1,107 B] Get:48 http://ppa.launchpad.net/pollinate/ppa/ubuntu trusty/main amd64 Packages [430 B] Get:49 http://ppa.launchpad.net/pollinate/ppa/ubuntu trusty/main i386 Packages [430 B] Get:50 http://ppa.launchpad.net/pollinate/ppa/ubuntu trusty/main Translation-en [374 B] Get:51 http://ppa.launchpad.net/webupd8team/java/ubuntu trusty/main amd64 Packages [20 B] Get:52 http://ppa.launchpad.net/webupd8team/java/ubuntu trusty/main i386 Packages [20 B] Get:53 http://ppa.launchpad.net/webupd8team/java/ubuntu trusty/main Translation-en [20 B] Get:54 http://ppa.launchpad.net/couchdb/stable/ubuntu trusty/main amd64 Packages [985 B] Get:55 http://ppa.launchpad.net/couchdb/stable/ubuntu trusty/main i386 Packages [985 B] Get:56 http://ppa.launchpad.net/couchdb/stable/ubuntu trusty/main Translation-en [644 B] Get:57 http://dl.google.com/linux/chrome/deb stable/main amd64 Packages [1,107 B] Err:58 https://packagecloud.io/computology/apt-backport/ubuntu trusty InRelease Failed to connect to packagecloud.io port 443: Connection timed out Err:59 http://us-east-1.ec2.archive.ubuntu.com/ubuntu trusty InRelease Could not connect to apt.cache.travis-ci.com:80 (34.96.81.152), connection timed out Err:60 http://us-east-1.ec2.archive.ubuntu.com/ubuntu trusty-updates InRelease Unable to connect to apt.cache.travis-ci.com:http: Err:61 http://toolbelt.heroku.com/ubuntu ./ InRelease Could not connect to apt.cache.travis-ci.com:80 (34.96.81.152), connection timed out Err:62 http://us-east-1.ec2.archive.ubuntu.com/ubuntu trusty-backports InRelease Unable to connect to apt.cache.travis-ci.com:http: Err:63 http://apt.postgresql.org/pub/repos/apt trusty-pgdg InRelease Could not connect to apt.cache.travis-ci.com:80 (34.96.81.152), connection timed out Err:1 http://dl.bintray.com/apache/cassandra 39x InRelease Could not connect to apt.cache.travis-ci.com:80 (34.96.81.152), connection timed out Get:64 https://packagecloud.io/github/git-lfs/ubuntu trusty InRelease [23.2 kB] Ign:64 https://packagecloud.io/github/git-lfs/ubuntu trusty InRelease Get:65 https://packagecloud.io/rabbitmq/rabbitmq-server/ubuntu trusty InRelease [23.7 kB] Get:66 https://packagecloud.io/github/git-lfs/ubuntu trusty/main Sources [20 B] Get:67 https://packagecloud.io/github/git-lfs/ubuntu trusty/main amd64 Packages [8,003 B] Get:68 https://packagecloud.io/github/git-lfs/ubuntu trusty/main i386 Packages [7,761 B] Get:69 https://packagecloud.io/rabbitmq/rabbitmq-server/ubuntu trusty/main Sources [20 B] Get:70 https://packagecloud.io/rabbitmq/rabbitmq-server/ubuntu trusty/main amd64 Packages [7,866 B] Get:71 https://packagecloud.io/rabbitmq/rabbitmq-server/ubuntu trusty/main i386 Packages [7,866 B] Fetched 4,218 kB in 15s (279 kB/s) Reading package lists... W: http://ppa.launchpad.net/couchdb/stable/ubuntu/dists/trusty/Release.gpg: Signature by key 15866BAFD9BCC4F3C1E0DFC7D69548E1C17EAB57 uses weak digest algorithm (SHA1) W: GPG error: https://packagecloud.io/github/git-lfs/ubuntu trusty InRelease: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 6B05F25D762E3157 W: The repository 'https://packagecloud.io/github/git-lfs/ubuntu trusty InRelease' is not signed. W: There is no public key available for the following key IDs: 6B05F25D762E3157 W: Failed to fetch http://us-east-1.ec2.archive.ubuntu.com/ubuntu/dists/trusty/InRelease Could not connect to apt.cache.travis-ci.com:80 (34.96.81.152), connection timed out W: Failed to fetch http://us-east-1.ec2.archive.ubuntu.com/ubuntu/dists/trusty-updates/InRelease Unable to connect to apt.cache.travis-ci.com:http: W: Failed to fetch http://us-east-1.ec2.archive.ubuntu.com/ubuntu/dists/trusty-backports/InRelease Unable to connect to apt.cache.travis-ci.com:http: W: Failed to fetch http://www.apache.org/dist/cassandra/debian/dists/39x/InRelease Could not connect to apt.cache.travis-ci.com:80 (34.96.81.152), connection timed out W: Failed to fetch https://packagecloud.io/computology/apt-backport/ubuntu/dists/trusty/InRelease Failed to connect to packagecloud.io port 443: Connection timed out W: Failed to fetch http://toolbelt.heroku.com/ubuntu/./InRelease Could not connect to apt.cache.travis-ci.com:80 (34.96.81.152), connection timed out W: Failed to fetch http://apt.postgresql.org/pub/repos/apt/dists/trusty-pgdg/InRelease Could not connect to apt.cache.travis-ci.com:80 (34.96.81.152), connection timed out W: Some index files failed to download. They have been ignored, or old ones used instead. The command "sudo -E apt-get -yq --no-install-suggests --no-install-recommends $(travis_apt_get_options) install texinfo texlive texi2html" failed and exited with 100 during . Your build has been stopped. --- .travis.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 38d4943..f41c75f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -10,7 +10,6 @@ addons: packages: - texinfo - texlive - - texi2html before_install: - cpanm -n Devel::Cover::Report::Coveralls install: From 27796720d5504f12b73b57c8fab2d167267e6b6e Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Thu, 27 Jun 2019 14:02:19 +0100 Subject: [PATCH 288/482] Upgrade to GPL v3 and add headers to files (#44) Following advice from maintainers@gnu.org, bring Stow in line with other GNU projects by upgrading it from GPL v2 to v3 https://www.gnu.org/prep/maintain/html_node/Licensing-of-GNU-Packages.html#Licensing-of-GNU-Packages as obtained in plain text and texinfo formats from https://www.gnu.org/licenses/ and adding appropriate headers: https://www.gnu.org/prep/maintain/html_node/License-Notices-for-Code.html#License-Notices-for-Code Fixes #44: https://github.com/aspiers/stow/issues/44 --- Build.PL | 15 + COPYING | 848 +++++++++++++++++++++++----------- INSTALL.md | 7 + Makefile.am | 15 + README.md | 5 + TODO | 2 - bin/chkstow.in | 15 + bin/stow.in | 14 +- configure.ac | 15 + doc/stow.texi | 927 +++++++++++++++++++++++++------------- docker/Dockerfile | 15 + docker/bootstrap-perls.sh | 15 + docker/run-stow-tests.sh | 15 + lib/Stow.pm.in | 15 + lib/Stow/Util.pm.in | 15 + t/chkstow.t | 15 + t/cleanup_invalid_links.t | 15 + t/cli.t | 15 + t/cli_options.t | 17 +- t/defer.t | 15 + t/dotfiles.t | 15 + t/examples.t | 15 + t/find_stowed_path.t | 15 + t/foldable.t | 15 + t/ignore.t | 17 +- t/join_paths.t | 15 + t/parent.t | 15 + t/rc_options.t | 15 + t/stow.t | 15 + t/testutil.pm | 15 + t/unstow.t | 15 + t/unstow_orig.t | 15 + 32 files changed, 1628 insertions(+), 569 deletions(-) diff --git a/Build.PL b/Build.PL index 3f63c0c..6e4c553 100644 --- a/Build.PL +++ b/Build.PL @@ -1,3 +1,18 @@ +# This file is part of GNU Stow. +# +# GNU Stow is free software: you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# GNU Stow is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see https://www.gnu.org/licenses/. + use strict; use warnings; diff --git a/COPYING b/COPYING index 623b625..f288702 100644 --- a/COPYING +++ b/COPYING @@ -1,285 +1,626 @@ - GNU GENERAL PUBLIC LICENSE - Version 2, June 1991 + GNU GENERAL PUBLIC LICENSE + Version 3, 29 June 2007 - Copyright (C) 1989, 1991 Free Software Foundation, Inc. - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + Copyright (C) 2007 Free Software Foundation, Inc. Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. - Preamble + Preamble - The licenses for most software are designed to take away your -freedom to share and change it. By contrast, the GNU General Public -License is intended to guarantee your freedom to share and change free -software--to make sure the software is free for all its users. This -General Public License applies to most of the Free Software -Foundation's software and to any other program whose authors commit to -using it. (Some other Free Software Foundation software is covered by -the GNU Library General Public License instead.) You can apply it to + The GNU General Public License is a free, copyleft license for +software and other kinds of works. + + The licenses for most software and other practical works are designed +to take away your freedom to share and change the works. By contrast, +the GNU General Public License is intended to guarantee your freedom to +share and change all versions of a program--to make sure it remains free +software for all its users. We, the Free Software Foundation, use the +GNU General Public License for most of our software; it applies also to +any other work released this way by its authors. You can apply it to your programs, too. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for -this service if you wish), that you receive source code or can get it -if you want it, that you can change the software or use pieces of it -in new free programs; and that you know you can do these things. +them if you wish), that you receive source code or can get it if you +want it, that you can change the software or use pieces of it in new +free programs, and that you know you can do these things. - To protect your rights, we need to make restrictions that forbid -anyone to deny you these rights or to ask you to surrender the rights. -These restrictions translate to certain responsibilities for you if you -distribute copies of the software, or if you modify it. + To protect your rights, we need to prevent others from denying you +these rights or asking you to surrender the rights. Therefore, you have +certain responsibilities if you distribute copies of the software, or if +you modify it: responsibilities to respect the freedom of others. For example, if you distribute copies of such a program, whether -gratis or for a fee, you must give the recipients all the rights that -you have. You must make sure that they, too, receive or can get the -source code. And you must show them these terms so they know their -rights. +gratis or for a fee, you must pass on to the recipients the same +freedoms that you received. You must make sure that they, too, receive +or can get the source code. And you must show them these terms so they +know their rights. - We protect your rights with two steps: (1) copyright the software, and -(2) offer you this license which gives you legal permission to copy, -distribute and/or modify the software. + Developers that use the GNU GPL protect your rights with two steps: +(1) assert copyright on the software, and (2) offer you this License +giving you legal permission to copy, distribute and/or modify it. - Also, for each author's protection and ours, we want to make certain -that everyone understands that there is no warranty for this free -software. If the software is modified by someone else and passed on, we -want its recipients to know that what they have is not the original, so -that any problems introduced by others will not reflect on the original -authors' reputations. + For the developers' and authors' protection, the GPL clearly explains +that there is no warranty for this free software. For both users' and +authors' sake, the GPL requires that modified versions be marked as +changed, so that their problems will not be attributed erroneously to +authors of previous versions. - Finally, any free program is threatened constantly by software -patents. We wish to avoid the danger that redistributors of a free -program will individually obtain patent licenses, in effect making the -program proprietary. To prevent this, we have made it clear that any -patent must be licensed for everyone's free use or not licensed at all. + Some devices are designed to deny users access to install or run +modified versions of the software inside them, although the manufacturer +can do so. This is fundamentally incompatible with the aim of +protecting users' freedom to change the software. The systematic +pattern of such abuse occurs in the area of products for individuals to +use, which is precisely where it is most unacceptable. Therefore, we +have designed this version of the GPL to prohibit the practice for those +products. If such problems arise substantially in other domains, we +stand ready to extend this provision to those domains in future versions +of the GPL, as needed to protect the freedom of users. + + Finally, every program is threatened constantly by software patents. +States should not allow patents to restrict development and use of +software on general-purpose computers, but in those that do, we wish to +avoid the special danger that patents applied to a free program could +make it effectively proprietary. To prevent this, the GPL assures that +patents cannot be used to render the program non-free. The precise terms and conditions for copying, distribution and modification follow. - - GNU GENERAL PUBLIC LICENSE - TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION - 0. This License applies to any program or other work which contains -a notice placed by the copyright holder saying it may be distributed -under the terms of this General Public License. The "Program", below, -refers to any such program or work, and a "work based on the Program" -means either the Program or any derivative work under copyright law: -that is to say, a work containing the Program or a portion of it, -either verbatim or with modifications and/or translated into another -language. (Hereinafter, translation is included without limitation in -the term "modification".) Each licensee is addressed as "you". + TERMS AND CONDITIONS -Activities other than copying, distribution and modification are not -covered by this License; they are outside its scope. The act of -running the Program is not restricted, and the output from the Program -is covered only if its contents constitute a work based on the -Program (independent of having been made by running the Program). -Whether that is true depends on what the Program does. + 0. Definitions. - 1. You may copy and distribute verbatim copies of the Program's -source code as you receive it, in any medium, provided that you -conspicuously and appropriately publish on each copy an appropriate -copyright notice and disclaimer of warranty; keep intact all the -notices that refer to this License and to the absence of any warranty; -and give any other recipients of the Program a copy of this License -along with the Program. + "This License" refers to version 3 of the GNU General Public License. -You may charge a fee for the physical act of transferring a copy, and -you may at your option offer warranty protection in exchange for a fee. + "Copyright" also means copyright-like laws that apply to other kinds of +works, such as semiconductor masks. - 2. You may modify your copy or copies of the Program or any portion -of it, thus forming a work based on the Program, and copy and -distribute such modifications or work under the terms of Section 1 -above, provided that you also meet all of these conditions: + "The Program" refers to any copyrightable work licensed under this +License. Each licensee is addressed as "you". "Licensees" and +"recipients" may be individuals or organizations. - a) You must cause the modified files to carry prominent notices - stating that you changed the files and the date of any change. + To "modify" a work means to copy from or adapt all or part of the work +in a fashion requiring copyright permission, other than the making of an +exact copy. The resulting work is called a "modified version" of the +earlier work or a work "based on" the earlier work. - b) You must cause any work that you distribute or publish, that in - whole or in part contains or is derived from the Program or any - part thereof, to be licensed as a whole at no charge to all third - parties under the terms of this License. + A "covered work" means either the unmodified Program or a work based +on the Program. - c) If the modified program normally reads commands interactively - when run, you must cause it, when started running for such - interactive use in the most ordinary way, to print or display an - announcement including an appropriate copyright notice and a - notice that there is no warranty (or else, saying that you provide - a warranty) and that users may redistribute the program under - these conditions, and telling the user how to view a copy of this - License. (Exception: if the Program itself is interactive but - does not normally print such an announcement, your work based on - the Program is not required to print an announcement.) - -These requirements apply to the modified work as a whole. If -identifiable sections of that work are not derived from the Program, -and can be reasonably considered independent and separate works in -themselves, then this License, and its terms, do not apply to those -sections when you distribute them as separate works. But when you -distribute the same sections as part of a whole which is a work based -on the Program, the distribution of the whole must be on the terms of -this License, whose permissions for other licensees extend to the -entire whole, and thus to each and every part regardless of who wrote it. + To "propagate" a work means to do anything with it that, without +permission, would make you directly or secondarily liable for +infringement under applicable copyright law, except executing it on a +computer or modifying a private copy. Propagation includes copying, +distribution (with or without modification), making available to the +public, and in some countries other activities as well. -Thus, it is not the intent of this section to claim rights or contest -your rights to work written entirely by you; rather, the intent is to -exercise the right to control the distribution of derivative or -collective works based on the Program. + To "convey" a work means any kind of propagation that enables other +parties to make or receive copies. Mere interaction with a user through +a computer network, with no transfer of a copy, is not conveying. -In addition, mere aggregation of another work not based on the Program -with the Program (or with a work based on the Program) on a volume of -a storage or distribution medium does not bring the other work under -the scope of this License. + An interactive user interface displays "Appropriate Legal Notices" +to the extent that it includes a convenient and prominently visible +feature that (1) displays an appropriate copyright notice, and (2) +tells the user that there is no warranty for the work (except to the +extent that warranties are provided), that licensees may convey the +work under this License, and how to view a copy of this License. If +the interface presents a list of user commands or options, such as a +menu, a prominent item in the list meets this criterion. - 3. You may copy and distribute the Program (or a work based on it, -under Section 2) in object code or executable form under the terms of -Sections 1 and 2 above provided that you also do one of the following: + 1. Source Code. - a) Accompany it with the complete corresponding machine-readable - source code, which must be distributed under the terms of Sections - 1 and 2 above on a medium customarily used for software interchange; or, + The "source code" for a work means the preferred form of the work +for making modifications to it. "Object code" means any non-source +form of a work. - b) Accompany it with a written offer, valid for at least three - years, to give any third party, for a charge no more than your - cost of physically performing source distribution, a complete - machine-readable copy of the corresponding source code, to be - distributed under the terms of Sections 1 and 2 above on a medium - customarily used for software interchange; or, + A "Standard Interface" means an interface that either is an official +standard defined by a recognized standards body, or, in the case of +interfaces specified for a particular programming language, one that +is widely used among developers working in that language. - c) Accompany it with the information you received as to the offer - to distribute corresponding source code. (This alternative is - allowed only for noncommercial distribution and only if you - received the program in object code or executable form with such - an offer, in accord with Subsection b above.) + The "System Libraries" of an executable work include anything, other +than the work as a whole, that (a) is included in the normal form of +packaging a Major Component, but which is not part of that Major +Component, and (b) serves only to enable use of the work with that +Major Component, or to implement a Standard Interface for which an +implementation is available to the public in source code form. A +"Major Component", in this context, means a major essential component +(kernel, window system, and so on) of the specific operating system +(if any) on which the executable work runs, or a compiler used to +produce the work, or an object code interpreter used to run it. -The source code for a work means the preferred form of the work for -making modifications to it. For an executable work, complete source -code means all the source code for all modules it contains, plus any -associated interface definition files, plus the scripts used to -control compilation and installation of the executable. However, as a -special exception, the source code distributed need not include -anything that is normally distributed (in either source or binary -form) with the major components (compiler, kernel, and so on) of the -operating system on which the executable runs, unless that component -itself accompanies the executable. + The "Corresponding Source" for a work in object code form means all +the source code needed to generate, install, and (for an executable +work) run the object code and to modify the work, including scripts to +control those activities. However, it does not include the work's +System Libraries, or general-purpose tools or generally available free +programs which are used unmodified in performing those activities but +which are not part of the work. For example, Corresponding Source +includes interface definition files associated with source files for +the work, and the source code for shared libraries and dynamically +linked subprograms that the work is specifically designed to require, +such as by intimate data communication or control flow between those +subprograms and other parts of the work. -If distribution of executable or object code is made by offering -access to copy from a designated place, then offering equivalent -access to copy the source code from the same place counts as -distribution of the source code, even though third parties are not -compelled to copy the source along with the object code. - - 4. You may not copy, modify, sublicense, or distribute the Program -except as expressly provided under this License. Any attempt -otherwise to copy, modify, sublicense or distribute the Program is -void, and will automatically terminate your rights under this License. -However, parties who have received copies, or rights, from you under -this License will not have their licenses terminated so long as such -parties remain in full compliance. + The Corresponding Source need not include anything that users +can regenerate automatically from other parts of the Corresponding +Source. - 5. You are not required to accept this License, since you have not -signed it. However, nothing else grants you permission to modify or -distribute the Program or its derivative works. These actions are -prohibited by law if you do not accept this License. Therefore, by -modifying or distributing the Program (or any work based on the -Program), you indicate your acceptance of this License to do so, and -all its terms and conditions for copying, distributing or modifying -the Program or works based on it. + The Corresponding Source for a work in source code form is that +same work. - 6. Each time you redistribute the Program (or any work based on the -Program), the recipient automatically receives a license from the -original licensor to copy, distribute or modify the Program subject to -these terms and conditions. You may not impose any further -restrictions on the recipients' exercise of the rights granted herein. -You are not responsible for enforcing compliance by third parties to + 2. Basic Permissions. + + All rights granted under this License are granted for the term of +copyright on the Program, and are irrevocable provided the stated +conditions are met. This License explicitly affirms your unlimited +permission to run the unmodified Program. The output from running a +covered work is covered by this License only if the output, given its +content, constitutes a covered work. This License acknowledges your +rights of fair use or other equivalent, as provided by copyright law. + + You may make, run and propagate covered works that you do not +convey, without conditions so long as your license otherwise remains +in force. You may convey covered works to others for the sole purpose +of having them make modifications exclusively for you, or provide you +with facilities for running those works, provided that you comply with +the terms of this License in conveying all material for which you do +not control copyright. Those thus making or running the covered works +for you must do so exclusively on your behalf, under your direction +and control, on terms that prohibit them from making any copies of +your copyrighted material outside their relationship with you. + + Conveying under any other circumstances is permitted solely under +the conditions stated below. Sublicensing is not allowed; section 10 +makes it unnecessary. + + 3. Protecting Users' Legal Rights From Anti-Circumvention Law. + + No covered work shall be deemed part of an effective technological +measure under any applicable law fulfilling obligations under article +11 of the WIPO copyright treaty adopted on 20 December 1996, or +similar laws prohibiting or restricting circumvention of such +measures. + + When you convey a covered work, you waive any legal power to forbid +circumvention of technological measures to the extent such circumvention +is effected by exercising rights under this License with respect to +the covered work, and you disclaim any intention to limit operation or +modification of the work as a means of enforcing, against the work's +users, your or third parties' legal rights to forbid circumvention of +technological measures. + + 4. Conveying Verbatim Copies. + + You may convey verbatim copies of the Program's source code as you +receive it, in any medium, provided that you conspicuously and +appropriately publish on each copy an appropriate copyright notice; +keep intact all notices stating that this License and any +non-permissive terms added in accord with section 7 apply to the code; +keep intact all notices of the absence of any warranty; and give all +recipients a copy of this License along with the Program. + + You may charge any price or no price for each copy that you convey, +and you may offer support or warranty protection for a fee. + + 5. Conveying Modified Source Versions. + + You may convey a work based on the Program, or the modifications to +produce it from the Program, in the form of source code under the +terms of section 4, provided that you also meet all of these conditions: + + a) The work must carry prominent notices stating that you modified + it, and giving a relevant date. + + b) The work must carry prominent notices stating that it is + released under this License and any conditions added under section + 7. This requirement modifies the requirement in section 4 to + "keep intact all notices". + + c) You must license the entire work, as a whole, under this + License to anyone who comes into possession of a copy. This + License will therefore apply, along with any applicable section 7 + additional terms, to the whole of the work, and all its parts, + regardless of how they are packaged. This License gives no + permission to license the work in any other way, but it does not + invalidate such permission if you have separately received it. + + d) If the work has interactive user interfaces, each must display + Appropriate Legal Notices; however, if the Program has interactive + interfaces that do not display Appropriate Legal Notices, your + work need not make them do so. + + A compilation of a covered work with other separate and independent +works, which are not by their nature extensions of the covered work, +and which are not combined with it such as to form a larger program, +in or on a volume of a storage or distribution medium, is called an +"aggregate" if the compilation and its resulting copyright are not +used to limit the access or legal rights of the compilation's users +beyond what the individual works permit. Inclusion of a covered work +in an aggregate does not cause this License to apply to the other +parts of the aggregate. + + 6. Conveying Non-Source Forms. + + You may convey a covered work in object code form under the terms +of sections 4 and 5, provided that you also convey the +machine-readable Corresponding Source under the terms of this License, +in one of these ways: + + a) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by the + Corresponding Source fixed on a durable physical medium + customarily used for software interchange. + + b) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by a + written offer, valid for at least three years and valid for as + long as you offer spare parts or customer support for that product + model, to give anyone who possesses the object code either (1) a + copy of the Corresponding Source for all the software in the + product that is covered by this License, on a durable physical + medium customarily used for software interchange, for a price no + more than your reasonable cost of physically performing this + conveying of source, or (2) access to copy the + Corresponding Source from a network server at no charge. + + c) Convey individual copies of the object code with a copy of the + written offer to provide the Corresponding Source. This + alternative is allowed only occasionally and noncommercially, and + only if you received the object code with such an offer, in accord + with subsection 6b. + + d) Convey the object code by offering access from a designated + place (gratis or for a charge), and offer equivalent access to the + Corresponding Source in the same way through the same place at no + further charge. You need not require recipients to copy the + Corresponding Source along with the object code. If the place to + copy the object code is a network server, the Corresponding Source + may be on a different server (operated by you or a third party) + that supports equivalent copying facilities, provided you maintain + clear directions next to the object code saying where to find the + Corresponding Source. Regardless of what server hosts the + Corresponding Source, you remain obligated to ensure that it is + available for as long as needed to satisfy these requirements. + + e) Convey the object code using peer-to-peer transmission, provided + you inform other peers where the object code and Corresponding + Source of the work are being offered to the general public at no + charge under subsection 6d. + + A separable portion of the object code, whose source code is excluded +from the Corresponding Source as a System Library, need not be +included in conveying the object code work. + + A "User Product" is either (1) a "consumer product", which means any +tangible personal property which is normally used for personal, family, +or household purposes, or (2) anything designed or sold for incorporation +into a dwelling. In determining whether a product is a consumer product, +doubtful cases shall be resolved in favor of coverage. For a particular +product received by a particular user, "normally used" refers to a +typical or common use of that class of product, regardless of the status +of the particular user or of the way in which the particular user +actually uses, or expects or is expected to use, the product. A product +is a consumer product regardless of whether the product has substantial +commercial, industrial or non-consumer uses, unless such uses represent +the only significant mode of use of the product. + + "Installation Information" for a User Product means any methods, +procedures, authorization keys, or other information required to install +and execute modified versions of a covered work in that User Product from +a modified version of its Corresponding Source. The information must +suffice to ensure that the continued functioning of the modified object +code is in no case prevented or interfered with solely because +modification has been made. + + If you convey an object code work under this section in, or with, or +specifically for use in, a User Product, and the conveying occurs as +part of a transaction in which the right of possession and use of the +User Product is transferred to the recipient in perpetuity or for a +fixed term (regardless of how the transaction is characterized), the +Corresponding Source conveyed under this section must be accompanied +by the Installation Information. But this requirement does not apply +if neither you nor any third party retains the ability to install +modified object code on the User Product (for example, the work has +been installed in ROM). + + The requirement to provide Installation Information does not include a +requirement to continue to provide support service, warranty, or updates +for a work that has been modified or installed by the recipient, or for +the User Product in which it has been modified or installed. Access to a +network may be denied when the modification itself materially and +adversely affects the operation of the network or violates the rules and +protocols for communication across the network. + + Corresponding Source conveyed, and Installation Information provided, +in accord with this section must be in a format that is publicly +documented (and with an implementation available to the public in +source code form), and must require no special password or key for +unpacking, reading or copying. + + 7. Additional Terms. + + "Additional permissions" are terms that supplement the terms of this +License by making exceptions from one or more of its conditions. +Additional permissions that are applicable to the entire Program shall +be treated as though they were included in this License, to the extent +that they are valid under applicable law. If additional permissions +apply only to part of the Program, that part may be used separately +under those permissions, but the entire Program remains governed by +this License without regard to the additional permissions. + + When you convey a copy of a covered work, you may at your option +remove any additional permissions from that copy, or from any part of +it. (Additional permissions may be written to require their own +removal in certain cases when you modify the work.) You may place +additional permissions on material, added by you to a covered work, +for which you have or can give appropriate copyright permission. + + Notwithstanding any other provision of this License, for material you +add to a covered work, you may (if authorized by the copyright holders of +that material) supplement the terms of this License with terms: + + a) Disclaiming warranty or limiting liability differently from the + terms of sections 15 and 16 of this License; or + + b) Requiring preservation of specified reasonable legal notices or + author attributions in that material or in the Appropriate Legal + Notices displayed by works containing it; or + + c) Prohibiting misrepresentation of the origin of that material, or + requiring that modified versions of such material be marked in + reasonable ways as different from the original version; or + + d) Limiting the use for publicity purposes of names of licensors or + authors of the material; or + + e) Declining to grant rights under trademark law for use of some + trade names, trademarks, or service marks; or + + f) Requiring indemnification of licensors and authors of that + material by anyone who conveys the material (or modified versions of + it) with contractual assumptions of liability to the recipient, for + any liability that these contractual assumptions directly impose on + those licensors and authors. + + All other non-permissive additional terms are considered "further +restrictions" within the meaning of section 10. If the Program as you +received it, or any part of it, contains a notice stating that it is +governed by this License along with a term that is a further +restriction, you may remove that term. If a license document contains +a further restriction but permits relicensing or conveying under this +License, you may add to a covered work material governed by the terms +of that license document, provided that the further restriction does +not survive such relicensing or conveying. + + If you add terms to a covered work in accord with this section, you +must place, in the relevant source files, a statement of the +additional terms that apply to those files, or a notice indicating +where to find the applicable terms. + + Additional terms, permissive or non-permissive, may be stated in the +form of a separately written license, or stated as exceptions; +the above requirements apply either way. + + 8. Termination. + + You may not propagate or modify a covered work except as expressly +provided under this License. Any attempt otherwise to propagate or +modify it is void, and will automatically terminate your rights under +this License (including any patent licenses granted under the third +paragraph of section 11). + + However, if you cease all violation of this License, then your +license from a particular copyright holder is reinstated (a) +provisionally, unless and until the copyright holder explicitly and +finally terminates your license, and (b) permanently, if the copyright +holder fails to notify you of the violation by some reasonable means +prior to 60 days after the cessation. + + Moreover, your license from a particular copyright holder is +reinstated permanently if the copyright holder notifies you of the +violation by some reasonable means, this is the first time you have +received notice of violation of this License (for any work) from that +copyright holder, and you cure the violation prior to 30 days after +your receipt of the notice. + + Termination of your rights under this section does not terminate the +licenses of parties who have received copies or rights from you under +this License. If your rights have been terminated and not permanently +reinstated, you do not qualify to receive new licenses for the same +material under section 10. + + 9. Acceptance Not Required for Having Copies. + + You are not required to accept this License in order to receive or +run a copy of the Program. Ancillary propagation of a covered work +occurring solely as a consequence of using peer-to-peer transmission +to receive a copy likewise does not require acceptance. However, +nothing other than this License grants you permission to propagate or +modify any covered work. These actions infringe copyright if you do +not accept this License. Therefore, by modifying or propagating a +covered work, you indicate your acceptance of this License to do so. + + 10. Automatic Licensing of Downstream Recipients. + + Each time you convey a covered work, the recipient automatically +receives a license from the original licensors, to run, modify and +propagate that work, subject to this License. You are not responsible +for enforcing compliance by third parties with this License. + + An "entity transaction" is a transaction transferring control of an +organization, or substantially all assets of one, or subdividing an +organization, or merging organizations. If propagation of a covered +work results from an entity transaction, each party to that +transaction who receives a copy of the work also receives whatever +licenses to the work the party's predecessor in interest had or could +give under the previous paragraph, plus a right to possession of the +Corresponding Source of the work from the predecessor in interest, if +the predecessor has it or can get it with reasonable efforts. + + You may not impose any further restrictions on the exercise of the +rights granted or affirmed under this License. For example, you may +not impose a license fee, royalty, or other charge for exercise of +rights granted under this License, and you may not initiate litigation +(including a cross-claim or counterclaim in a lawsuit) alleging that +any patent claim is infringed by making, using, selling, offering for +sale, or importing the Program or any portion of it. + + 11. Patents. + + A "contributor" is a copyright holder who authorizes use under this +License of the Program or a work on which the Program is based. The +work thus licensed is called the contributor's "contributor version". + + A contributor's "essential patent claims" are all patent claims +owned or controlled by the contributor, whether already acquired or +hereafter acquired, that would be infringed by some manner, permitted +by this License, of making, using, or selling its contributor version, +but do not include claims that would be infringed only as a +consequence of further modification of the contributor version. For +purposes of this definition, "control" includes the right to grant +patent sublicenses in a manner consistent with the requirements of this License. - 7. If, as a consequence of a court judgment or allegation of patent -infringement or for any other reason (not limited to patent issues), -conditions are imposed on you (whether by court order, agreement or + Each contributor grants you a non-exclusive, worldwide, royalty-free +patent license under the contributor's essential patent claims, to +make, use, sell, offer for sale, import and otherwise run, modify and +propagate the contents of its contributor version. + + In the following three paragraphs, a "patent license" is any express +agreement or commitment, however denominated, not to enforce a patent +(such as an express permission to practice a patent or covenant not to +sue for patent infringement). To "grant" such a patent license to a +party means to make such an agreement or commitment not to enforce a +patent against the party. + + If you convey a covered work, knowingly relying on a patent license, +and the Corresponding Source of the work is not available for anyone +to copy, free of charge and under the terms of this License, through a +publicly available network server or other readily accessible means, +then you must either (1) cause the Corresponding Source to be so +available, or (2) arrange to deprive yourself of the benefit of the +patent license for this particular work, or (3) arrange, in a manner +consistent with the requirements of this License, to extend the patent +license to downstream recipients. "Knowingly relying" means you have +actual knowledge that, but for the patent license, your conveying the +covered work in a country, or your recipient's use of the covered work +in a country, would infringe one or more identifiable patents in that +country that you have reason to believe are valid. + + If, pursuant to or in connection with a single transaction or +arrangement, you convey, or propagate by procuring conveyance of, a +covered work, and grant a patent license to some of the parties +receiving the covered work authorizing them to use, propagate, modify +or convey a specific copy of the covered work, then the patent license +you grant is automatically extended to all recipients of the covered +work and works based on it. + + A patent license is "discriminatory" if it does not include within +the scope of its coverage, prohibits the exercise of, or is +conditioned on the non-exercise of one or more of the rights that are +specifically granted under this License. You may not convey a covered +work if you are a party to an arrangement with a third party that is +in the business of distributing software, under which you make payment +to the third party based on the extent of your activity of conveying +the work, and under which the third party grants, to any of the +parties who would receive the covered work from you, a discriminatory +patent license (a) in connection with copies of the covered work +conveyed by you (or copies made from those copies), or (b) primarily +for and in connection with specific products or compilations that +contain the covered work, unless you entered into that arrangement, +or that patent license was granted, prior to 28 March 2007. + + Nothing in this License shall be construed as excluding or limiting +any implied license or other defenses to infringement that may +otherwise be available to you under applicable patent law. + + 12. No Surrender of Others' Freedom. + + If conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not -excuse you from the conditions of this License. If you cannot -distribute so as to satisfy simultaneously your obligations under this -License and any other pertinent obligations, then as a consequence you -may not distribute the Program at all. For example, if a patent -license would not permit royalty-free redistribution of the Program by -all those who receive copies directly or indirectly through you, then -the only way you could satisfy both it and this License would be to -refrain entirely from distribution of the Program. +excuse you from the conditions of this License. If you cannot convey a +covered work so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you may +not convey it at all. For example, if you agree to terms that obligate you +to collect a royalty for further conveying from those to whom you convey +the Program, the only way you could satisfy both those terms and this +License would be to refrain entirely from conveying the Program. -If any portion of this section is held invalid or unenforceable under -any particular circumstance, the balance of the section is intended to -apply and the section as a whole is intended to apply in other -circumstances. + 13. Use with the GNU Affero General Public License. -It is not the purpose of this section to induce you to infringe any -patents or other property right claims or to contest validity of any -such claims; this section has the sole purpose of protecting the -integrity of the free software distribution system, which is -implemented by public license practices. Many people have made -generous contributions to the wide range of software distributed -through that system in reliance on consistent application of that -system; it is up to the author/donor to decide if he or she is willing -to distribute software through any other system and a licensee cannot -impose that choice. + Notwithstanding any other provision of this License, you have +permission to link or combine any covered work with a work licensed +under version 3 of the GNU Affero General Public License into a single +combined work, and to convey the resulting work. The terms of this +License will continue to apply to the part which is the covered work, +but the special requirements of the GNU Affero General Public License, +section 13, concerning interaction through a network will apply to the +combination as such. -This section is intended to make thoroughly clear what is believed to -be a consequence of the rest of this License. - - 8. If the distribution and/or use of the Program is restricted in -certain countries either by patents or by copyrighted interfaces, the -original copyright holder who places the Program under this License -may add an explicit geographical distribution limitation excluding -those countries, so that distribution is permitted only in or among -countries not thus excluded. In such case, this License incorporates -the limitation as if written in the body of this License. + 14. Revised Versions of this License. - 9. The Free Software Foundation may publish revised and/or new versions -of the General Public License from time to time. Such new versions will + The Free Software Foundation may publish revised and/or new versions of +the GNU General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. -Each version is given a distinguishing version number. If the Program -specifies a version number of this License which applies to it and "any -later version", you have the option of following the terms and conditions -either of that version or of any later version published by the Free -Software Foundation. If the Program does not specify a version number of -this License, you may choose any version ever published by the Free Software -Foundation. + Each version is given a distinguishing version number. If the +Program specifies that a certain numbered version of the GNU General +Public License "or any later version" applies to it, you have the +option of following the terms and conditions either of that numbered +version or of any later version published by the Free Software +Foundation. If the Program does not specify a version number of the +GNU General Public License, you may choose any version ever published +by the Free Software Foundation. - 10. If you wish to incorporate parts of the Program into other free -programs whose distribution conditions are different, write to the author -to ask for permission. For software which is copyrighted by the Free -Software Foundation, write to the Free Software Foundation; we sometimes -make exceptions for this. Our decision will be guided by the two goals -of preserving the free status of all derivatives of our free software and -of promoting the sharing and reuse of software generally. + If the Program specifies that a proxy can decide which future +versions of the GNU General Public License can be used, that proxy's +public statement of acceptance of a version permanently authorizes you +to choose that version for the Program. - NO WARRANTY + Later license versions may give you additional or different +permissions. However, no additional obligations are imposed on any +author or copyright holder as a result of your choosing to follow a +later version. - 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY -FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN -OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES -PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED -OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS -TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE -PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, -REPAIR OR CORRECTION. + 15. Disclaimer of Warranty. - 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING -WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR -REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, -INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING -OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED -TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY -YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER -PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE -POSSIBILITY OF SUCH DAMAGES. + THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY +APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT +HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY +OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, +THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM +IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF +ALL NECESSARY SERVICING, REPAIR OR CORRECTION. - END OF TERMS AND CONDITIONS - - How to Apply These Terms to Your New Programs + 16. Limitation of Liability. + + IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS +THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY +GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE +USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF +DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD +PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), +EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF +SUCH DAMAGES. + + 17. Interpretation of Sections 15 and 16. + + If the disclaimer of warranty and limitation of liability provided +above cannot be given local legal effect according to their terms, +reviewing courts shall apply local law that most closely approximates +an absolute waiver of all civil liability in connection with the +Program, unless a warranty or assumption of liability accompanies a +copy of the Program in return for a fee. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it @@ -287,15 +628,15 @@ free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively -convey the exclusion of warranty; and each file should have at least +state the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. Copyright (C) - This program is free software; you can redistribute it and/or modify + This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or + the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, @@ -304,37 +645,30 @@ the "copyright" line and a pointer to where the full notice is found. GNU General Public License for more details. You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - + along with this program. If not, see . Also add information on how to contact you by electronic and paper mail. -If the program is interactive, make it output a short notice like this -when it starts in an interactive mode: + If the program does terminal interaction, make it output a short +notice like this when it starts in an interactive mode: - Gnomovision version 69, Copyright (C) year name of author - Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + Copyright (C) + This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. The hypothetical commands `show w' and `show c' should show the appropriate -parts of the General Public License. Of course, the commands you use may -be called something other than `show w' and `show c'; they could even be -mouse-clicks or menu items--whatever suits your program. +parts of the General Public License. Of course, your program's commands +might be different; for a GUI interface, you would use an "about box". -You should also get your employer (if you work as a programmer) or your -school, if any, to sign a "copyright disclaimer" for the program, if -necessary. Here is a sample; alter the names: + You should also get your employer (if you work as a programmer) or school, +if any, to sign a "copyright disclaimer" for the program, if necessary. +For more information on this, and how to apply and follow the GNU GPL, see +. - Yoyodyne, Inc., hereby disclaims all copyright interest in the program - `Gnomovision' (which makes passes at compilers) written by James Hacker. - - , 1 April 1989 - Ty Coon, President of Vice - -This General Public License does not permit incorporating your program into -proprietary programs. If your program is a subroutine library, you may -consider it more useful to permit linking proprietary applications with the -library. If this is what you want to do, use the GNU Library General -Public License instead of this License. + The GNU General Public License does not permit incorporating your program +into proprietary programs. If your program is a subroutine library, you +may consider it more useful to permit linking proprietary applications with +the library. If this is what you want to do, use the GNU Lesser General +Public License instead of this License. But first, please read +. diff --git a/INSTALL.md b/INSTALL.md index eb80171..a85ad87 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -193,3 +193,10 @@ operates. `configure` also accepts some other, not widely useful, options. +License for this file +--------------------- + +Copying and distribution of this file, with or without modification, +are permitted in any medium without royalty provided the copyright +notice and this notice are preserved. This file is offered as-is, +without any warranty. diff --git a/Makefile.am b/Makefile.am index 29c6a6b..9917653 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1,3 +1,18 @@ +# This file is part of GNU Stow. +# +# GNU Stow is free software: you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# GNU Stow is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see https://www.gnu.org/licenses/. + ## Process this file with Automake to produce Makefile.in bin_SCRIPTS = bin/stow bin/chkstow diff --git a/README.md b/README.md index bde1cf0..faebd96 100644 --- a/README.md +++ b/README.md @@ -66,6 +66,11 @@ License Stow is free software, licensed under the GNU General Public License, which can be found in the file [`COPYING`](COPYING). +Copying and distribution of this file, with or without modification, +are permitted in any medium without royalty provided the copyright +notice and this notice are preserved. This file is offered as-is, +without any warranty. + Installation ------------ diff --git a/TODO b/TODO index e0ba300..a42d4cb 100644 --- a/TODO +++ b/TODO @@ -6,8 +6,6 @@ *** http://unix.stackexchange.com/questions/73426/dealing-with-gnu-stow-conflicts *** http://article.gmane.org/gmane.comp.gnu.stow.general/6661 -* Next release should be under GPL v3 - * Get permission for next documentation release to be under FDL 1.3 * Import a debian/ tree from an older package and update it. diff --git a/bin/chkstow.in b/bin/chkstow.in index 2156bb5..b583b32 100755 --- a/bin/chkstow.in +++ b/bin/chkstow.in @@ -1,4 +1,19 @@ #!@PERL@ +# +# This file is part of GNU Stow. +# +# GNU Stow is free software: you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# GNU Stow is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see https://www.gnu.org/licenses/. use strict; use warnings; diff --git a/bin/stow.in b/bin/stow.in index 9afe2a1..84dfbd2 100755 --- a/bin/stow.in +++ b/bin/stow.in @@ -6,18 +6,20 @@ # Copyright (C) 2007 Kahlil Hodgson # Copyright (C) 2011 Adam Spiers # -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or +# This file is part of GNU Stow. +# +# GNU Stow is free software: you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # -# This program is distributed in the hope that it will be useful, but +# GNU Stow is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # General Public License for more details. # # You should have received a copy of the GNU General Public License -# along with this program; if not, see . +# along with this program. If not, see https://www.gnu.org/licenses/. =head1 NAME diff --git a/configure.ac b/configure.ac index e23eae0..d22b1d4 100644 --- a/configure.ac +++ b/configure.ac @@ -1,3 +1,18 @@ +dnl This file is part of GNU Stow. +dnl +dnl GNU Stow is free software: you can redistribute it and/or modify it +dnl under the terms of the GNU General Public License as published by +dnl the Free Software Foundation, either version 3 of the License, or +dnl (at your option) any later version. +dnl +dnl GNU Stow is distributed in the hope that it will be useful, but +dnl WITHOUT ANY WARRANTY; without even the implied warranty of +dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +dnl General Public License for more details. +dnl +dnl You should have received a copy of the GNU General Public License +dnl along with this program. If not, see https://www.gnu.org/licenses/. + dnl Process this file with Autoconf to produce configure dnl AC_INIT([stow], [2.3.0], [bug-stow@gnu.org]) diff --git a/doc/stow.texi b/doc/stow.texi index be1f467..b7ef78d 100644 --- a/doc/stow.texi +++ b/doc/stow.texi @@ -1296,399 +1296,722 @@ If you think you have found one, please @pxref{Reporting Bugs}. @node GNU General Public License, Index, Known Bugs, Top @unnumbered GNU General Public License -@center Version 2, June 1991 +@center Version 3, 29 June 2007 + +@c This file is intended to be included within another document, +@c hence no sectioning command or @node. @display -Copyright @copyright{} 1989, 1991 Free Software Foundation, Inc. -675 Mass Ave, Cambridge, MA 02139, USA +Copyright @copyright{} 2007 Free Software Foundation, Inc. @url{https://fsf.org/} -Everyone is permitted to copy and distribute verbatim copies -of this license document, but changing it is not allowed. +Everyone is permitted to copy and distribute verbatim copies of this +license document, but changing it is not allowed. @end display -@unnumberedsec Preamble +@heading Preamble - The licenses for most software are designed to take away your -freedom to share and change it. By contrast, the GNU General Public -License is intended to guarantee your freedom to share and change free -software---to make sure the software is free for all its users. This -General Public License applies to most of the Free Software -Foundation's software and to any other program whose authors commit to -using it. (Some other Free Software Foundation software is covered by -the GNU Library General Public License instead.) You can apply it to -your programs, too. +The GNU General Public License is a free, copyleft license for +software and other kinds of works. - When we speak of free software, we are referring to freedom, not +The licenses for most software and other practical works are designed +to take away your freedom to share and change the works. By contrast, +the GNU General Public License is intended to guarantee your freedom +to share and change all versions of a program---to make sure it remains +free software for all its users. We, the Free Software Foundation, +use the GNU General Public License for most of our software; it +applies also to any other work released this way by its authors. You +can apply it to your programs, too. + +When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for -this service if you wish), that you receive source code or can get it -if you want it, that you can change the software or use pieces of it -in new free programs; and that you know you can do these things. +them if you wish), that you receive source code or can get it if you +want it, that you can change the software or use pieces of it in new +free programs, and that you know you can do these things. - To protect your rights, we need to make restrictions that forbid -anyone to deny you these rights or to ask you to surrender the rights. -These restrictions translate to certain responsibilities for you if you -distribute copies of the software, or if you modify it. +To protect your rights, we need to prevent others from denying you +these rights or asking you to surrender the rights. Therefore, you +have certain responsibilities if you distribute copies of the +software, or if you modify it: responsibilities to respect the freedom +of others. - For example, if you distribute copies of such a program, whether -gratis or for a fee, you must give the recipients all the rights that -you have. You must make sure that they, too, receive or can get the -source code. And you must show them these terms so they know their -rights. +For example, if you distribute copies of such a program, whether +gratis or for a fee, you must pass on to the recipients the same +freedoms that you received. You must make sure that they, too, +receive or can get the source code. And you must show them these +terms so they know their rights. - We protect your rights with two steps: (1) copyright the software, and -(2) offer you this license which gives you legal permission to copy, -distribute and/or modify the software. +Developers that use the GNU GPL protect your rights with two steps: +(1) assert copyright on the software, and (2) offer you this License +giving you legal permission to copy, distribute and/or modify it. - Also, for each author's protection and ours, we want to make certain -that everyone understands that there is no warranty for this free -software. If the software is modified by someone else and passed on, we -want its recipients to know that what they have is not the original, so -that any problems introduced by others will not reflect on the original -authors' reputations. +For the developers' and authors' protection, the GPL clearly explains +that there is no warranty for this free software. For both users' and +authors' sake, the GPL requires that modified versions be marked as +changed, so that their problems will not be attributed erroneously to +authors of previous versions. - Finally, any free program is threatened constantly by software -patents. We wish to avoid the danger that redistributors of a free -program will individually obtain patent licenses, in effect making the -program proprietary. To prevent this, we have made it clear that any -patent must be licensed for everyone's free use or not licensed at all. +Some devices are designed to deny users access to install or run +modified versions of the software inside them, although the +manufacturer can do so. This is fundamentally incompatible with the +aim of protecting users' freedom to change the software. The +systematic pattern of such abuse occurs in the area of products for +individuals to use, which is precisely where it is most unacceptable. +Therefore, we have designed this version of the GPL to prohibit the +practice for those products. If such problems arise substantially in +other domains, we stand ready to extend this provision to those +domains in future versions of the GPL, as needed to protect the +freedom of users. - The precise terms and conditions for copying, distribution and +Finally, every program is threatened constantly by software patents. +States should not allow patents to restrict development and use of +software on general-purpose computers, but in those that do, we wish +to avoid the special danger that patents applied to a free program +could make it effectively proprietary. To prevent this, the GPL +assures that patents cannot be used to render the program non-free. + +The precise terms and conditions for copying, distribution and modification follow. -@iftex -@unnumberedsec TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION -@end iftex -@ifinfo -@center TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION -@end ifinfo +@heading TERMS AND CONDITIONS @enumerate 0 -@item -This License applies to any program or other work which contains -a notice placed by the copyright holder saying it may be distributed -under the terms of this General Public License. The ``Program'', below, -refers to any such program or work, and a ``work based on the Program'' -means either the Program or any derivative work under copyright law: -that is to say, a work containing the Program or a portion of it, -either verbatim or with modifications and/or translated into another -language. (Hereinafter, translation is included without limitation in -the term ``modification''.) Each licensee is addressed as ``you''. +@item Definitions. -Activities other than copying, distribution and modification are not -covered by this License; they are outside its scope. The act of -running the Program is not restricted, and the output from the Program -is covered only if its contents constitute a work based on the -Program (independent of having been made by running the Program). -Whether that is true depends on what the Program does. +``This License'' refers to version 3 of the GNU General Public License. -@item -You may copy and distribute verbatim copies of the Program's -source code as you receive it, in any medium, provided that you -conspicuously and appropriately publish on each copy an appropriate -copyright notice and disclaimer of warranty; keep intact all the -notices that refer to this License and to the absence of any warranty; -and give any other recipients of the Program a copy of this License -along with the Program. +``Copyright'' also means copyright-like laws that apply to other kinds +of works, such as semiconductor masks. -You may charge a fee for the physical act of transferring a copy, and -you may at your option offer warranty protection in exchange for a fee. +``The Program'' refers to any copyrightable work licensed under this +License. Each licensee is addressed as ``you''. ``Licensees'' and +``recipients'' may be individuals or organizations. -@item -You may modify your copy or copies of the Program or any portion -of it, thus forming a work based on the Program, and copy and -distribute such modifications or work under the terms of Section 1 -above, provided that you also meet all of these conditions: +To ``modify'' a work means to copy from or adapt all or part of the work +in a fashion requiring copyright permission, other than the making of +an exact copy. The resulting work is called a ``modified version'' of +the earlier work or a work ``based on'' the earlier work. + +A ``covered work'' means either the unmodified Program or a work based +on the Program. + +To ``propagate'' a work means to do anything with it that, without +permission, would make you directly or secondarily liable for +infringement under applicable copyright law, except executing it on a +computer or modifying a private copy. Propagation includes copying, +distribution (with or without modification), making available to the +public, and in some countries other activities as well. + +To ``convey'' a work means any kind of propagation that enables other +parties to make or receive copies. Mere interaction with a user +through a computer network, with no transfer of a copy, is not +conveying. + +An interactive user interface displays ``Appropriate Legal Notices'' to +the extent that it includes a convenient and prominently visible +feature that (1) displays an appropriate copyright notice, and (2) +tells the user that there is no warranty for the work (except to the +extent that warranties are provided), that licensees may convey the +work under this License, and how to view a copy of this License. If +the interface presents a list of user commands or options, such as a +menu, a prominent item in the list meets this criterion. + +@item Source Code. + +The ``source code'' for a work means the preferred form of the work for +making modifications to it. ``Object code'' means any non-source form +of a work. + +A ``Standard Interface'' means an interface that either is an official +standard defined by a recognized standards body, or, in the case of +interfaces specified for a particular programming language, one that +is widely used among developers working in that language. + +The ``System Libraries'' of an executable work include anything, other +than the work as a whole, that (a) is included in the normal form of +packaging a Major Component, but which is not part of that Major +Component, and (b) serves only to enable use of the work with that +Major Component, or to implement a Standard Interface for which an +implementation is available to the public in source code form. A +``Major Component'', in this context, means a major essential component +(kernel, window system, and so on) of the specific operating system +(if any) on which the executable work runs, or a compiler used to +produce the work, or an object code interpreter used to run it. + +The ``Corresponding Source'' for a work in object code form means all +the source code needed to generate, install, and (for an executable +work) run the object code and to modify the work, including scripts to +control those activities. However, it does not include the work's +System Libraries, or general-purpose tools or generally available free +programs which are used unmodified in performing those activities but +which are not part of the work. For example, Corresponding Source +includes interface definition files associated with source files for +the work, and the source code for shared libraries and dynamically +linked subprograms that the work is specifically designed to require, +such as by intimate data communication or control flow between those +subprograms and other parts of the work. + +The Corresponding Source need not include anything that users can +regenerate automatically from other parts of the Corresponding Source. + +The Corresponding Source for a work in source code form is that same +work. + +@item Basic Permissions. + +All rights granted under this License are granted for the term of +copyright on the Program, and are irrevocable provided the stated +conditions are met. This License explicitly affirms your unlimited +permission to run the unmodified Program. The output from running a +covered work is covered by this License only if the output, given its +content, constitutes a covered work. This License acknowledges your +rights of fair use or other equivalent, as provided by copyright law. + +You may make, run and propagate covered works that you do not convey, +without conditions so long as your license otherwise remains in force. +You may convey covered works to others for the sole purpose of having +them make modifications exclusively for you, or provide you with +facilities for running those works, provided that you comply with the +terms of this License in conveying all material for which you do not +control copyright. Those thus making or running the covered works for +you must do so exclusively on your behalf, under your direction and +control, on terms that prohibit them from making any copies of your +copyrighted material outside their relationship with you. + +Conveying under any other circumstances is permitted solely under the +conditions stated below. Sublicensing is not allowed; section 10 +makes it unnecessary. + +@item Protecting Users' Legal Rights From Anti-Circumvention Law. + +No covered work shall be deemed part of an effective technological +measure under any applicable law fulfilling obligations under article +11 of the WIPO copyright treaty adopted on 20 December 1996, or +similar laws prohibiting or restricting circumvention of such +measures. + +When you convey a covered work, you waive any legal power to forbid +circumvention of technological measures to the extent such +circumvention is effected by exercising rights under this License with +respect to the covered work, and you disclaim any intention to limit +operation or modification of the work as a means of enforcing, against +the work's users, your or third parties' legal rights to forbid +circumvention of technological measures. + +@item Conveying Verbatim Copies. + +You may convey verbatim copies of the Program's source code as you +receive it, in any medium, provided that you conspicuously and +appropriately publish on each copy an appropriate copyright notice; +keep intact all notices stating that this License and any +non-permissive terms added in accord with section 7 apply to the code; +keep intact all notices of the absence of any warranty; and give all +recipients a copy of this License along with the Program. + +You may charge any price or no price for each copy that you convey, +and you may offer support or warranty protection for a fee. + +@item Conveying Modified Source Versions. + +You may convey a work based on the Program, or the modifications to +produce it from the Program, in the form of source code under the +terms of section 4, provided that you also meet all of these +conditions: @enumerate a @item -You must cause the modified files to carry prominent notices -stating that you changed the files and the date of any change. +The work must carry prominent notices stating that you modified it, +and giving a relevant date. @item -You must cause any work that you distribute or publish, that in -whole or in part contains or is derived from the Program or any -part thereof, to be licensed as a whole at no charge to all third -parties under the terms of this License. +The work must carry prominent notices stating that it is released +under this License and any conditions added under section 7. This +requirement modifies the requirement in section 4 to ``keep intact all +notices''. @item -If the modified program normally reads commands interactively -when run, you must cause it, when started running for such -interactive use in the most ordinary way, to print or display an -announcement including an appropriate copyright notice and a -notice that there is no warranty (or else, saying that you provide -a warranty) and that users may redistribute the program under -these conditions, and telling the user how to view a copy of this -License. (Exception: if the Program itself is interactive but -does not normally print such an announcement, your work based on -the Program is not required to print an announcement.) +You must license the entire work, as a whole, under this License to +anyone who comes into possession of a copy. This License will +therefore apply, along with any applicable section 7 additional terms, +to the whole of the work, and all its parts, regardless of how they +are packaged. This License gives no permission to license the work in +any other way, but it does not invalidate such permission if you have +separately received it. + +@item +If the work has interactive user interfaces, each must display +Appropriate Legal Notices; however, if the Program has interactive +interfaces that do not display Appropriate Legal Notices, your work +need not make them do so. @end enumerate -These requirements apply to the modified work as a whole. If -identifiable sections of that work are not derived from the Program, -and can be reasonably considered independent and separate works in -themselves, then this License, and its terms, do not apply to those -sections when you distribute them as separate works. But when you -distribute the same sections as part of a whole which is a work based -on the Program, the distribution of the whole must be on the terms of -this License, whose permissions for other licensees extend to the -entire whole, and thus to each and every part regardless of who wrote it. +A compilation of a covered work with other separate and independent +works, which are not by their nature extensions of the covered work, +and which are not combined with it such as to form a larger program, +in or on a volume of a storage or distribution medium, is called an +``aggregate'' if the compilation and its resulting copyright are not +used to limit the access or legal rights of the compilation's users +beyond what the individual works permit. Inclusion of a covered work +in an aggregate does not cause this License to apply to the other +parts of the aggregate. -Thus, it is not the intent of this section to claim rights or contest -your rights to work written entirely by you; rather, the intent is to -exercise the right to control the distribution of derivative or -collective works based on the Program. +@item Conveying Non-Source Forms. -In addition, mere aggregation of another work not based on the Program -with the Program (or with a work based on the Program) on a volume of -a storage or distribution medium does not bring the other work under -the scope of this License. - -@item -You may copy and distribute the Program (or a work based on it, -under Section 2) in object code or executable form under the terms of -Sections 1 and 2 above provided that you also do one of the following: +You may convey a covered work in object code form under the terms of +sections 4 and 5, provided that you also convey the machine-readable +Corresponding Source under the terms of this License, in one of these +ways: @enumerate a @item -Accompany it with the complete corresponding machine-readable -source code, which must be distributed under the terms of Sections -1 and 2 above on a medium customarily used for software interchange; or, +Convey the object code in, or embodied in, a physical product +(including a physical distribution medium), accompanied by the +Corresponding Source fixed on a durable physical medium customarily +used for software interchange. @item -Accompany it with a written offer, valid for at least three -years, to give any third party, for a charge no more than your -cost of physically performing source distribution, a complete -machine-readable copy of the corresponding source code, to be -distributed under the terms of Sections 1 and 2 above on a medium -customarily used for software interchange; or, +Convey the object code in, or embodied in, a physical product +(including a physical distribution medium), accompanied by a written +offer, valid for at least three years and valid for as long as you +offer spare parts or customer support for that product model, to give +anyone who possesses the object code either (1) a copy of the +Corresponding Source for all the software in the product that is +covered by this License, on a durable physical medium customarily used +for software interchange, for a price no more than your reasonable +cost of physically performing this conveying of source, or (2) access +to copy the Corresponding Source from a network server at no charge. @item -Accompany it with the information you received as to the offer -to distribute corresponding source code. (This alternative is -allowed only for noncommercial distribution and only if you -received the program in object code or executable form with such -an offer, in accord with Subsection b above.) +Convey individual copies of the object code with a copy of the written +offer to provide the Corresponding Source. This alternative is +allowed only occasionally and noncommercially, and only if you +received the object code with such an offer, in accord with subsection +6b. + +@item +Convey the object code by offering access from a designated place +(gratis or for a charge), and offer equivalent access to the +Corresponding Source in the same way through the same place at no +further charge. You need not require recipients to copy the +Corresponding Source along with the object code. If the place to copy +the object code is a network server, the Corresponding Source may be +on a different server (operated by you or a third party) that supports +equivalent copying facilities, provided you maintain clear directions +next to the object code saying where to find the Corresponding Source. +Regardless of what server hosts the Corresponding Source, you remain +obligated to ensure that it is available for as long as needed to +satisfy these requirements. + +@item +Convey the object code using peer-to-peer transmission, provided you +inform other peers where the object code and Corresponding Source of +the work are being offered to the general public at no charge under +subsection 6d. + @end enumerate -The source code for a work means the preferred form of the work for -making modifications to it. For an executable work, complete source -code means all the source code for all modules it contains, plus any -associated interface definition files, plus the scripts used to -control compilation and installation of the executable. However, as a -special exception, the source code distributed need not include -anything that is normally distributed (in either source or binary -form) with the major components (compiler, kernel, and so on) of the -operating system on which the executable runs, unless that component -itself accompanies the executable. +A separable portion of the object code, whose source code is excluded +from the Corresponding Source as a System Library, need not be +included in conveying the object code work. -If distribution of executable or object code is made by offering -access to copy from a designated place, then offering equivalent -access to copy the source code from the same place counts as -distribution of the source code, even though third parties are not -compelled to copy the source along with the object code. +A ``User Product'' is either (1) a ``consumer product'', which means any +tangible personal property which is normally used for personal, +family, or household purposes, or (2) anything designed or sold for +incorporation into a dwelling. In determining whether a product is a +consumer product, doubtful cases shall be resolved in favor of +coverage. For a particular product received by a particular user, +``normally used'' refers to a typical or common use of that class of +product, regardless of the status of the particular user or of the way +in which the particular user actually uses, or expects or is expected +to use, the product. A product is a consumer product regardless of +whether the product has substantial commercial, industrial or +non-consumer uses, unless such uses represent the only significant +mode of use of the product. + +``Installation Information'' for a User Product means any methods, +procedures, authorization keys, or other information required to +install and execute modified versions of a covered work in that User +Product from a modified version of its Corresponding Source. The +information must suffice to ensure that the continued functioning of +the modified object code is in no case prevented or interfered with +solely because modification has been made. + +If you convey an object code work under this section in, or with, or +specifically for use in, a User Product, and the conveying occurs as +part of a transaction in which the right of possession and use of the +User Product is transferred to the recipient in perpetuity or for a +fixed term (regardless of how the transaction is characterized), the +Corresponding Source conveyed under this section must be accompanied +by the Installation Information. But this requirement does not apply +if neither you nor any third party retains the ability to install +modified object code on the User Product (for example, the work has +been installed in ROM). + +The requirement to provide Installation Information does not include a +requirement to continue to provide support service, warranty, or +updates for a work that has been modified or installed by the +recipient, or for the User Product in which it has been modified or +installed. Access to a network may be denied when the modification +itself materially and adversely affects the operation of the network +or violates the rules and protocols for communication across the +network. + +Corresponding Source conveyed, and Installation Information provided, +in accord with this section must be in a format that is publicly +documented (and with an implementation available to the public in +source code form), and must require no special password or key for +unpacking, reading or copying. + +@item Additional Terms. + +``Additional permissions'' are terms that supplement the terms of this +License by making exceptions from one or more of its conditions. +Additional permissions that are applicable to the entire Program shall +be treated as though they were included in this License, to the extent +that they are valid under applicable law. If additional permissions +apply only to part of the Program, that part may be used separately +under those permissions, but the entire Program remains governed by +this License without regard to the additional permissions. + +When you convey a copy of a covered work, you may at your option +remove any additional permissions from that copy, or from any part of +it. (Additional permissions may be written to require their own +removal in certain cases when you modify the work.) You may place +additional permissions on material, added by you to a covered work, +for which you have or can give appropriate copyright permission. + +Notwithstanding any other provision of this License, for material you +add to a covered work, you may (if authorized by the copyright holders +of that material) supplement the terms of this License with terms: + +@enumerate a +@item +Disclaiming warranty or limiting liability differently from the terms +of sections 15 and 16 of this License; or @item -You may not copy, modify, sublicense, or distribute the Program -except as expressly provided under this License. Any attempt -otherwise to copy, modify, sublicense or distribute the Program is -void, and will automatically terminate your rights under this License. -However, parties who have received copies, or rights, from you under -this License will not have their licenses terminated so long as such -parties remain in full compliance. +Requiring preservation of specified reasonable legal notices or author +attributions in that material or in the Appropriate Legal Notices +displayed by works containing it; or @item -You are not required to accept this License, since you have not -signed it. However, nothing else grants you permission to modify or -distribute the Program or its derivative works. These actions are -prohibited by law if you do not accept this License. Therefore, by -modifying or distributing the Program (or any work based on the -Program), you indicate your acceptance of this License to do so, and -all its terms and conditions for copying, distributing or modifying -the Program or works based on it. +Prohibiting misrepresentation of the origin of that material, or +requiring that modified versions of such material be marked in +reasonable ways as different from the original version; or @item -Each time you redistribute the Program (or any work based on the -Program), the recipient automatically receives a license from the -original licensor to copy, distribute or modify the Program subject to -these terms and conditions. You may not impose any further -restrictions on the recipients' exercise of the rights granted herein. -You are not responsible for enforcing compliance by third parties to +Limiting the use for publicity purposes of names of licensors or +authors of the material; or + +@item +Declining to grant rights under trademark law for use of some trade +names, trademarks, or service marks; or + +@item +Requiring indemnification of licensors and authors of that material by +anyone who conveys the material (or modified versions of it) with +contractual assumptions of liability to the recipient, for any +liability that these contractual assumptions directly impose on those +licensors and authors. +@end enumerate + +All other non-permissive additional terms are considered ``further +restrictions'' within the meaning of section 10. If the Program as you +received it, or any part of it, contains a notice stating that it is +governed by this License along with a term that is a further +restriction, you may remove that term. If a license document contains +a further restriction but permits relicensing or conveying under this +License, you may add to a covered work material governed by the terms +of that license document, provided that the further restriction does +not survive such relicensing or conveying. + +If you add terms to a covered work in accord with this section, you +must place, in the relevant source files, a statement of the +additional terms that apply to those files, or a notice indicating +where to find the applicable terms. + +Additional terms, permissive or non-permissive, may be stated in the +form of a separately written license, or stated as exceptions; the +above requirements apply either way. + +@item Termination. + +You may not propagate or modify a covered work except as expressly +provided under this License. Any attempt otherwise to propagate or +modify it is void, and will automatically terminate your rights under +this License (including any patent licenses granted under the third +paragraph of section 11). + +However, if you cease all violation of this License, then your license +from a particular copyright holder is reinstated (a) provisionally, +unless and until the copyright holder explicitly and finally +terminates your license, and (b) permanently, if the copyright holder +fails to notify you of the violation by some reasonable means prior to +60 days after the cessation. + +Moreover, your license from a particular copyright holder is +reinstated permanently if the copyright holder notifies you of the +violation by some reasonable means, this is the first time you have +received notice of violation of this License (for any work) from that +copyright holder, and you cure the violation prior to 30 days after +your receipt of the notice. + +Termination of your rights under this section does not terminate the +licenses of parties who have received copies or rights from you under +this License. If your rights have been terminated and not permanently +reinstated, you do not qualify to receive new licenses for the same +material under section 10. + +@item Acceptance Not Required for Having Copies. + +You are not required to accept this License in order to receive or run +a copy of the Program. Ancillary propagation of a covered work +occurring solely as a consequence of using peer-to-peer transmission +to receive a copy likewise does not require acceptance. However, +nothing other than this License grants you permission to propagate or +modify any covered work. These actions infringe copyright if you do +not accept this License. Therefore, by modifying or propagating a +covered work, you indicate your acceptance of this License to do so. + +@item Automatic Licensing of Downstream Recipients. + +Each time you convey a covered work, the recipient automatically +receives a license from the original licensors, to run, modify and +propagate that work, subject to this License. You are not responsible +for enforcing compliance by third parties with this License. + +An ``entity transaction'' is a transaction transferring control of an +organization, or substantially all assets of one, or subdividing an +organization, or merging organizations. If propagation of a covered +work results from an entity transaction, each party to that +transaction who receives a copy of the work also receives whatever +licenses to the work the party's predecessor in interest had or could +give under the previous paragraph, plus a right to possession of the +Corresponding Source of the work from the predecessor in interest, if +the predecessor has it or can get it with reasonable efforts. + +You may not impose any further restrictions on the exercise of the +rights granted or affirmed under this License. For example, you may +not impose a license fee, royalty, or other charge for exercise of +rights granted under this License, and you may not initiate litigation +(including a cross-claim or counterclaim in a lawsuit) alleging that +any patent claim is infringed by making, using, selling, offering for +sale, or importing the Program or any portion of it. + +@item Patents. + +A ``contributor'' is a copyright holder who authorizes use under this +License of the Program or a work on which the Program is based. The +work thus licensed is called the contributor's ``contributor version''. + +A contributor's ``essential patent claims'' are all patent claims owned +or controlled by the contributor, whether already acquired or +hereafter acquired, that would be infringed by some manner, permitted +by this License, of making, using, or selling its contributor version, +but do not include claims that would be infringed only as a +consequence of further modification of the contributor version. For +purposes of this definition, ``control'' includes the right to grant +patent sublicenses in a manner consistent with the requirements of this License. -@item -If, as a consequence of a court judgment or allegation of patent -infringement or for any other reason (not limited to patent issues), -conditions are imposed on you (whether by court order, agreement or +Each contributor grants you a non-exclusive, worldwide, royalty-free +patent license under the contributor's essential patent claims, to +make, use, sell, offer for sale, import and otherwise run, modify and +propagate the contents of its contributor version. + +In the following three paragraphs, a ``patent license'' is any express +agreement or commitment, however denominated, not to enforce a patent +(such as an express permission to practice a patent or covenant not to +sue for patent infringement). To ``grant'' such a patent license to a +party means to make such an agreement or commitment not to enforce a +patent against the party. + +If you convey a covered work, knowingly relying on a patent license, +and the Corresponding Source of the work is not available for anyone +to copy, free of charge and under the terms of this License, through a +publicly available network server or other readily accessible means, +then you must either (1) cause the Corresponding Source to be so +available, or (2) arrange to deprive yourself of the benefit of the +patent license for this particular work, or (3) arrange, in a manner +consistent with the requirements of this License, to extend the patent +license to downstream recipients. ``Knowingly relying'' means you have +actual knowledge that, but for the patent license, your conveying the +covered work in a country, or your recipient's use of the covered work +in a country, would infringe one or more identifiable patents in that +country that you have reason to believe are valid. + +If, pursuant to or in connection with a single transaction or +arrangement, you convey, or propagate by procuring conveyance of, a +covered work, and grant a patent license to some of the parties +receiving the covered work authorizing them to use, propagate, modify +or convey a specific copy of the covered work, then the patent license +you grant is automatically extended to all recipients of the covered +work and works based on it. + +A patent license is ``discriminatory'' if it does not include within the +scope of its coverage, prohibits the exercise of, or is conditioned on +the non-exercise of one or more of the rights that are specifically +granted under this License. You may not convey a covered work if you +are a party to an arrangement with a third party that is in the +business of distributing software, under which you make payment to the +third party based on the extent of your activity of conveying the +work, and under which the third party grants, to any of the parties +who would receive the covered work from you, a discriminatory patent +license (a) in connection with copies of the covered work conveyed by +you (or copies made from those copies), or (b) primarily for and in +connection with specific products or compilations that contain the +covered work, unless you entered into that arrangement, or that patent +license was granted, prior to 28 March 2007. + +Nothing in this License shall be construed as excluding or limiting +any implied license or other defenses to infringement that may +otherwise be available to you under applicable patent law. + +@item No Surrender of Others' Freedom. + +If conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not -excuse you from the conditions of this License. If you cannot -distribute so as to satisfy simultaneously your obligations under this -License and any other pertinent obligations, then as a consequence you -may not distribute the Program at all. For example, if a patent -license would not permit royalty-free redistribution of the Program by -all those who receive copies directly or indirectly through you, then -the only way you could satisfy both it and this License would be to -refrain entirely from distribution of the Program. +excuse you from the conditions of this License. If you cannot convey +a covered work so as to satisfy simultaneously your obligations under +this License and any other pertinent obligations, then as a +consequence you may not convey it at all. For example, if you agree +to terms that obligate you to collect a royalty for further conveying +from those to whom you convey the Program, the only way you could +satisfy both those terms and this License would be to refrain entirely +from conveying the Program. -If any portion of this section is held invalid or unenforceable under -any particular circumstance, the balance of the section is intended to -apply and the section as a whole is intended to apply in other -circumstances. +@item Use with the GNU Affero General Public License. -It is not the purpose of this section to induce you to infringe any -patents or other property right claims or to contest validity of any -such claims; this section has the sole purpose of protecting the -integrity of the free software distribution system, which is -implemented by public license practices. Many people have made -generous contributions to the wide range of software distributed -through that system in reliance on consistent application of that -system; it is up to the author/donor to decide if he or she is willing -to distribute software through any other system and a licensee cannot -impose that choice. +Notwithstanding any other provision of this License, you have +permission to link or combine any covered work with a work licensed +under version 3 of the GNU Affero General Public License into a single +combined work, and to convey the resulting work. The terms of this +License will continue to apply to the part which is the covered work, +but the special requirements of the GNU Affero General Public License, +section 13, concerning interaction through a network will apply to the +combination as such. -This section is intended to make thoroughly clear what is believed to -be a consequence of the rest of this License. +@item Revised Versions of this License. -@item -If the distribution and/or use of the Program is restricted in -certain countries either by patents or by copyrighted interfaces, the -original copyright holder who places the Program under this License -may add an explicit geographical distribution limitation excluding -those countries, so that distribution is permitted only in or among -countries not thus excluded. In such case, this License incorporates -the limitation as if written in the body of this License. - -@item The Free Software Foundation may publish revised and/or new versions -of the General Public License from time to time. Such new versions will -be similar in spirit to the present version, but may differ in detail to -address new problems or concerns. +of the GNU General Public License from time to time. Such new +versions will be similar in spirit to the present version, but may +differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program -specifies a version number of this License which applies to it and ``any -later version'', you have the option of following the terms and conditions -either of that version or of any later version published by the Free -Software Foundation. If the Program does not specify a version number of -this License, you may choose any version ever published by the Free Software -Foundation. +specifies that a certain numbered version of the GNU General Public +License ``or any later version'' applies to it, you have the option of +following the terms and conditions either of that numbered version or +of any later version published by the Free Software Foundation. If +the Program does not specify a version number of the GNU General +Public License, you may choose any version ever published by the Free +Software Foundation. -@item -If you wish to incorporate parts of the Program into other free -programs whose distribution conditions are different, write to the author -to ask for permission. For software which is copyrighted by the Free -Software Foundation, write to the Free Software Foundation; we sometimes -make exceptions for this. Our decision will be guided by the two goals -of preserving the free status of all derivatives of our free software and -of promoting the sharing and reuse of software generally. +If the Program specifies that a proxy can decide which future versions +of the GNU General Public License can be used, that proxy's public +statement of acceptance of a version permanently authorizes you to +choose that version for the Program. -@iftex -@heading NO WARRANTY -@end iftex -@ifinfo -@center NO WARRANTY -@end ifinfo +Later license versions may give you additional or different +permissions. However, no additional obligations are imposed on any +author or copyright holder as a result of your choosing to follow a +later version. -@item -BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY -FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW@. EXCEPT WHEN -OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES -PROVIDE THE PROGRAM ``AS IS'' WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED -OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE@. THE ENTIRE RISK AS -TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU@. SHOULD THE -PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, -REPAIR OR CORRECTION. +@item Disclaimer of Warranty. + +THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY +APPLICABLE LAW@. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT +HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM ``AS IS'' WITHOUT +WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE@. THE ENTIRE RISK AS TO THE QUALITY AND +PERFORMANCE OF THE PROGRAM IS WITH YOU@. SHOULD THE PROGRAM PROVE +DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR +CORRECTION. + +@item Limitation of Liability. -@item IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING -WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR -REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, -INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING -OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED -TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY -YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER -PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE -POSSIBILITY OF SUCH DAMAGES. +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR +CONVEYS THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, +INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES +ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT +NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR +LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM +TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER +PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. + +@item Interpretation of Sections 15 and 16. + +If the disclaimer of warranty and limitation of liability provided +above cannot be given local legal effect according to their terms, +reviewing courts shall apply local law that most closely approximates +an absolute waiver of all civil liability in connection with the +Program, unless a warranty or assumption of liability accompanies a +copy of the Program in return for a fee. + @end enumerate -@iftex @heading END OF TERMS AND CONDITIONS -@end iftex -@ifinfo -@center END OF TERMS AND CONDITIONS -@end ifinfo -@page -@unnumberedsec How to Apply These Terms to Your New Programs +@heading How to Apply These Terms to Your New Programs - If you develop a new program, and you want it to be of the greatest +If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it -free software which everyone can redistribute and change under these terms. +free software which everyone can redistribute and change under these +terms. - To do so, attach the following notices to the program. It is safest +To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively -convey the exclusion of warranty; and each file should have at least +state the exclusion of warranty; and each file should have at least the ``copyright'' line and a pointer to where the full notice is found. @smallexample -@var{one line to give the program's name and an idea of what it does.} -Copyright (C) 19@var{yy} @var{name of author} +@var{one line to give the program's name and a brief idea of what it does.} +Copyright (C) @var{year} @var{name of author} -This program is free software; you can redistribute it and/or -modify it under the terms of the GNU General Public License -as published by the Free Software Foundation; either version 2 -of the License, or (at your option) any later version. +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 3 of the License, or (at +your option) any later version. -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE@. See the -GNU General Public License for more details. +This program is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE@. See the GNU +General Public License for more details. You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +along with this program. If not, see @url{https://www.gnu.org/licenses/}. @end smallexample Also add information on how to contact you by electronic and paper mail. -If the program is interactive, make it output a short notice like this -when it starts in an interactive mode: +If the program does terminal interaction, make it output a short +notice like this when it starts in an interactive mode: @smallexample -Gnomovision version 69, Copyright (C) 19@var{yy} @var{name of author} -Gnomovision comes with ABSOLUTELY NO WARRANTY; for details -type `show w'. This is free software, and you are welcome -to redistribute it under certain conditions; type `show c' -for details. +@var{program} Copyright (C) @var{year} @var{name of author} +This program comes with ABSOLUTELY NO WARRANTY; for details type @samp{show w}. +This is free software, and you are welcome to redistribute it +under certain conditions; type @samp{show c} for details. @end smallexample The hypothetical commands @samp{show w} and @samp{show c} should show -the appropriate parts of the General Public License. Of course, the -commands you use may be called something other than @samp{show w} and -@samp{show c}; they could even be mouse-clicks or menu items---whatever -suits your program. +the appropriate parts of the General Public License. Of course, your +program's commands might be different; for a GUI interface, you would +use an ``about box''. -You should also get your employer (if you work as a programmer) or your -school, if any, to sign a ``copyright disclaimer'' for the program, if -necessary. Here is a sample; alter the names: +You should also get your employer (if you work as a programmer) or school, +if any, to sign a ``copyright disclaimer'' for the program, if necessary. +For more information on this, and how to apply and follow the GNU GPL, see +@url{https://www.gnu.org/licenses/}. -@smallexample -@group -Yoyodyne, Inc., hereby disclaims all copyright -interest in the program `Gnomovision' -(which makes passes at compilers) written -by James Hacker. - -@var{signature of Ty Coon}, 1 April 1989 -Ty Coon, President of Vice -@end group -@end smallexample - -This General Public License does not permit incorporating your program -into proprietary programs. If your program is a subroutine library, you -may consider it more useful to permit linking proprietary applications -with the library. If this is what you want to do, use the GNU Library -General Public License instead of this License. +The GNU General Public License does not permit incorporating your +program into proprietary programs. If your program is a subroutine +library, you may consider it more useful to permit linking proprietary +applications with the library. If this is what you want to do, use +the GNU Lesser General Public License instead of this License. But +first, please read @url{https://www.gnu.org/licenses/why-not-lgpl.html}. @node Index, , GNU General Public License, Top @unnumbered Index diff --git a/docker/Dockerfile b/docker/Dockerfile index ad4678e..1314a2d 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -1,3 +1,18 @@ +# This file is part of GNU Stow. +# +# GNU Stow is free software: you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# GNU Stow is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see https://www.gnu.org/licenses/. + # Build docker image: `docker build -t stowtest` # Run tests: (from stow src directory) # `docker run --rm -it -v $(pwd):$(pwd) -w $(pwd) stowtest` diff --git a/docker/bootstrap-perls.sh b/docker/bootstrap-perls.sh index 00061b6..2efdd5e 100755 --- a/docker/bootstrap-perls.sh +++ b/docker/bootstrap-perls.sh @@ -1,4 +1,19 @@ #!/bin/bash +# +# This file is part of GNU Stow. +# +# GNU Stow is free software: you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# GNU Stow is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see https://www.gnu.org/licenses/. # Load perlbrew environment . /usr/local/perlbrew/etc/bashrc diff --git a/docker/run-stow-tests.sh b/docker/run-stow-tests.sh index 8adf155..416594c 100755 --- a/docker/run-stow-tests.sh +++ b/docker/run-stow-tests.sh @@ -1,4 +1,19 @@ #!/bin/bash +# +# This file is part of GNU Stow. +# +# GNU Stow is free software: you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# GNU Stow is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see https://www.gnu.org/licenses/. # Load perlbrew environment # Load before setting safety to keep diff --git a/lib/Stow.pm.in b/lib/Stow.pm.in index fac2c9c..fb454ab 100755 --- a/lib/Stow.pm.in +++ b/lib/Stow.pm.in @@ -1,4 +1,19 @@ #!/usr/bin/perl +# +# This file is part of GNU Stow. +# +# GNU Stow is free software: you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# GNU Stow is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see https://www.gnu.org/licenses/. package Stow; diff --git a/lib/Stow/Util.pm.in b/lib/Stow/Util.pm.in index 451a143..e3e932b 100644 --- a/lib/Stow/Util.pm.in +++ b/lib/Stow/Util.pm.in @@ -1,3 +1,18 @@ +# This file is part of GNU Stow. +# +# GNU Stow is free software: you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# GNU Stow is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see https://www.gnu.org/licenses/. + package Stow::Util; =head1 NAME diff --git a/t/chkstow.t b/t/chkstow.t index e18a476..15c08da 100755 --- a/t/chkstow.t +++ b/t/chkstow.t @@ -1,4 +1,19 @@ #!/usr/local/bin/perl +# +# This file is part of GNU Stow. +# +# GNU Stow is free software: you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# GNU Stow is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see https://www.gnu.org/licenses/. # # Testing cleanup_invalid_links() diff --git a/t/cleanup_invalid_links.t b/t/cleanup_invalid_links.t index b9c62af..d24479c 100755 --- a/t/cleanup_invalid_links.t +++ b/t/cleanup_invalid_links.t @@ -1,4 +1,19 @@ #!/usr/local/bin/perl +# +# This file is part of GNU Stow. +# +# GNU Stow is free software: you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# GNU Stow is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see https://www.gnu.org/licenses/. # # Testing cleanup_invalid_links() diff --git a/t/cli.t b/t/cli.t index 010fc79..b3d01bc 100755 --- a/t/cli.t +++ b/t/cli.t @@ -1,4 +1,19 @@ #!/usr/local/bin/perl +# +# This file is part of GNU Stow. +# +# GNU Stow is free software: you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# GNU Stow is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see https://www.gnu.org/licenses/. # # Test processing of CLI options. diff --git a/t/cli_options.t b/t/cli_options.t index 0e99cd1..05fc016 100755 --- a/t/cli_options.t +++ b/t/cli_options.t @@ -1,4 +1,19 @@ -#!/usr/local/bin/perl +#!/usr/local/bin/perl +# +# This file is part of GNU Stow. +# +# GNU Stow is free software: you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# GNU Stow is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see https://www.gnu.org/licenses/. # # Test processing of CLI options. diff --git a/t/defer.t b/t/defer.t index ca47fb3..4bdd504 100755 --- a/t/defer.t +++ b/t/defer.t @@ -1,4 +1,19 @@ #!/usr/local/bin/perl +# +# This file is part of GNU Stow. +# +# GNU Stow is free software: you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# GNU Stow is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see https://www.gnu.org/licenses/. # # Testing defer(). diff --git a/t/dotfiles.t b/t/dotfiles.t index e6fa69e..d276457 100755 --- a/t/dotfiles.t +++ b/t/dotfiles.t @@ -1,4 +1,19 @@ #!/usr/local/bin/perl +# +# This file is part of GNU Stow. +# +# GNU Stow is free software: you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# GNU Stow is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see https://www.gnu.org/licenses/. # # Test case for dotfiles special processing diff --git a/t/examples.t b/t/examples.t index b784592..2592c39 100755 --- a/t/examples.t +++ b/t/examples.t @@ -1,4 +1,19 @@ #!/usr/local/bin/perl +# +# This file is part of GNU Stow. +# +# GNU Stow is free software: you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# GNU Stow is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see https://www.gnu.org/licenses/. # # Testing examples from the documentation diff --git a/t/find_stowed_path.t b/t/find_stowed_path.t index 2d5425d..c073562 100755 --- a/t/find_stowed_path.t +++ b/t/find_stowed_path.t @@ -1,4 +1,19 @@ #!/usr/local/bin/perl +# +# This file is part of GNU Stow. +# +# GNU Stow is free software: you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# GNU Stow is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see https://www.gnu.org/licenses/. # # Testing find_stowed_path() diff --git a/t/foldable.t b/t/foldable.t index ebb3b82..d01816a 100755 --- a/t/foldable.t +++ b/t/foldable.t @@ -1,4 +1,19 @@ #!/usr/local/bin/perl +# +# This file is part of GNU Stow. +# +# GNU Stow is free software: you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# GNU Stow is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see https://www.gnu.org/licenses/. # # Testing foldable() diff --git a/t/ignore.t b/t/ignore.t index d50c94c..ce9976c 100755 --- a/t/ignore.t +++ b/t/ignore.t @@ -1,4 +1,19 @@ #!/usr/local/bin/perl +# +# This file is part of GNU Stow. +# +# GNU Stow is free software: you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# GNU Stow is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see https://www.gnu.org/licenses/. # # Testing ignore lists. @@ -40,7 +55,7 @@ sub test_local_ignore_list_always_ignored_at_top_level { $Stow::LOCAL_IGNORE_FILE => 1, "subdir/" . $Stow::LOCAL_IGNORE_FILE => 0, ); -} +} sub test_built_in_list { my ($stow_path, $package, $context, $expect_ignores) = @_; diff --git a/t/join_paths.t b/t/join_paths.t index 585cae9..f45b138 100755 --- a/t/join_paths.t +++ b/t/join_paths.t @@ -1,4 +1,19 @@ #!/usr/local/bin/perl +# +# This file is part of GNU Stow. +# +# GNU Stow is free software: you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# GNU Stow is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see https://www.gnu.org/licenses/. # # Testing join_paths(); diff --git a/t/parent.t b/t/parent.t index 2265f88..6e77d75 100755 --- a/t/parent.t +++ b/t/parent.t @@ -1,4 +1,19 @@ #!/usr/local/bin/perl +# +# This file is part of GNU Stow. +# +# GNU Stow is free software: you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# GNU Stow is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see https://www.gnu.org/licenses/. # # Testing parent() diff --git a/t/rc_options.t b/t/rc_options.t index 6905df5..f346ebd 100755 --- a/t/rc_options.t +++ b/t/rc_options.t @@ -1,4 +1,19 @@ #!/usr/local/bin/perl +# +# This file is part of GNU Stow. +# +# GNU Stow is free software: you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# GNU Stow is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see https://www.gnu.org/licenses/. # # Test processing of stowrc file. diff --git a/t/stow.t b/t/stow.t index 92141fc..ac97411 100755 --- a/t/stow.t +++ b/t/stow.t @@ -1,4 +1,19 @@ #!/usr/local/bin/perl +# +# This file is part of GNU Stow. +# +# GNU Stow is free software: you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# GNU Stow is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see https://www.gnu.org/licenses/. # # Test stowing packages. diff --git a/t/testutil.pm b/t/testutil.pm index a9d673f..139369b 100755 --- a/t/testutil.pm +++ b/t/testutil.pm @@ -1,4 +1,19 @@ #!/usr/bin/perl +# +# This file is part of GNU Stow. +# +# GNU Stow is free software: you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# GNU Stow is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see https://www.gnu.org/licenses/. # # Utilities shared by test scripts diff --git a/t/unstow.t b/t/unstow.t index 7de78c9..0549fd3 100755 --- a/t/unstow.t +++ b/t/unstow.t @@ -1,4 +1,19 @@ #!/usr/local/bin/perl +# +# This file is part of GNU Stow. +# +# GNU Stow is free software: you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# GNU Stow is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see https://www.gnu.org/licenses/. # # Test unstowing packages diff --git a/t/unstow_orig.t b/t/unstow_orig.t index 8be5094..2166af3 100755 --- a/t/unstow_orig.t +++ b/t/unstow_orig.t @@ -1,4 +1,19 @@ #!/usr/local/bin/perl +# +# This file is part of GNU Stow. +# +# GNU Stow is free software: you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# GNU Stow is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see https://www.gnu.org/licenses/. # # Test unstowing packages in compat mode From 0979a9c7bd968c1a856d881d4ab68ad6c6f3f1d5 Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Thu, 27 Jun 2019 20:37:50 +0100 Subject: [PATCH 289/482] Change #!/usr/local/bin/perl to #!/usr/bin/perl in t/*.t This doesn't really matter, since these are not executed directly, but it's more consistent with everything else and modern systems. --- t/chkstow.t | 2 +- t/cleanup_invalid_links.t | 2 +- t/cli.t | 2 +- t/cli_options.t | 2 +- t/defer.t | 2 +- t/dotfiles.t | 2 +- t/examples.t | 2 +- t/find_stowed_path.t | 2 +- t/foldable.t | 2 +- t/ignore.t | 2 +- t/join_paths.t | 2 +- t/parent.t | 2 +- t/rc_options.t | 2 +- t/stow.t | 2 +- t/unstow.t | 2 +- t/unstow_orig.t | 2 +- 16 files changed, 16 insertions(+), 16 deletions(-) diff --git a/t/chkstow.t b/t/chkstow.t index 15c08da..439775f 100755 --- a/t/chkstow.t +++ b/t/chkstow.t @@ -1,4 +1,4 @@ -#!/usr/local/bin/perl +#!/usr/bin/perl # # This file is part of GNU Stow. # diff --git a/t/cleanup_invalid_links.t b/t/cleanup_invalid_links.t index d24479c..916a6b9 100755 --- a/t/cleanup_invalid_links.t +++ b/t/cleanup_invalid_links.t @@ -1,4 +1,4 @@ -#!/usr/local/bin/perl +#!/usr/bin/perl # # This file is part of GNU Stow. # diff --git a/t/cli.t b/t/cli.t index b3d01bc..cf324ed 100755 --- a/t/cli.t +++ b/t/cli.t @@ -1,4 +1,4 @@ -#!/usr/local/bin/perl +#!/usr/bin/perl # # This file is part of GNU Stow. # diff --git a/t/cli_options.t b/t/cli_options.t index 05fc016..719c78c 100755 --- a/t/cli_options.t +++ b/t/cli_options.t @@ -1,4 +1,4 @@ -#!/usr/local/bin/perl +#!/usr/bin/perl # # This file is part of GNU Stow. # diff --git a/t/defer.t b/t/defer.t index 4bdd504..003cf64 100755 --- a/t/defer.t +++ b/t/defer.t @@ -1,4 +1,4 @@ -#!/usr/local/bin/perl +#!/usr/bin/perl # # This file is part of GNU Stow. # diff --git a/t/dotfiles.t b/t/dotfiles.t index d276457..386359e 100755 --- a/t/dotfiles.t +++ b/t/dotfiles.t @@ -1,4 +1,4 @@ -#!/usr/local/bin/perl +#!/usr/bin/perl # # This file is part of GNU Stow. # diff --git a/t/examples.t b/t/examples.t index 2592c39..56aa5b6 100755 --- a/t/examples.t +++ b/t/examples.t @@ -1,4 +1,4 @@ -#!/usr/local/bin/perl +#!/usr/bin/perl # # This file is part of GNU Stow. # diff --git a/t/find_stowed_path.t b/t/find_stowed_path.t index c073562..44aabe0 100755 --- a/t/find_stowed_path.t +++ b/t/find_stowed_path.t @@ -1,4 +1,4 @@ -#!/usr/local/bin/perl +#!/usr/bin/perl # # This file is part of GNU Stow. # diff --git a/t/foldable.t b/t/foldable.t index d01816a..8f4f417 100755 --- a/t/foldable.t +++ b/t/foldable.t @@ -1,4 +1,4 @@ -#!/usr/local/bin/perl +#!/usr/bin/perl # # This file is part of GNU Stow. # diff --git a/t/ignore.t b/t/ignore.t index ce9976c..d0b5444 100755 --- a/t/ignore.t +++ b/t/ignore.t @@ -1,4 +1,4 @@ -#!/usr/local/bin/perl +#!/usr/bin/perl # # This file is part of GNU Stow. # diff --git a/t/join_paths.t b/t/join_paths.t index f45b138..fa96d66 100755 --- a/t/join_paths.t +++ b/t/join_paths.t @@ -1,4 +1,4 @@ -#!/usr/local/bin/perl +#!/usr/bin/perl # # This file is part of GNU Stow. # diff --git a/t/parent.t b/t/parent.t index 6e77d75..1fae871 100755 --- a/t/parent.t +++ b/t/parent.t @@ -1,4 +1,4 @@ -#!/usr/local/bin/perl +#!/usr/bin/perl # # This file is part of GNU Stow. # diff --git a/t/rc_options.t b/t/rc_options.t index f346ebd..dee156a 100755 --- a/t/rc_options.t +++ b/t/rc_options.t @@ -1,4 +1,4 @@ -#!/usr/local/bin/perl +#!/usr/bin/perl # # This file is part of GNU Stow. # diff --git a/t/stow.t b/t/stow.t index ac97411..e86b79a 100755 --- a/t/stow.t +++ b/t/stow.t @@ -1,4 +1,4 @@ -#!/usr/local/bin/perl +#!/usr/bin/perl # # This file is part of GNU Stow. # diff --git a/t/unstow.t b/t/unstow.t index 0549fd3..34b463d 100755 --- a/t/unstow.t +++ b/t/unstow.t @@ -1,4 +1,4 @@ -#!/usr/local/bin/perl +#!/usr/bin/perl # # This file is part of GNU Stow. # diff --git a/t/unstow_orig.t b/t/unstow_orig.t index 2166af3..a4e3142 100755 --- a/t/unstow_orig.t +++ b/t/unstow_orig.t @@ -1,4 +1,4 @@ -#!/usr/local/bin/perl +#!/usr/bin/perl # # This file is part of GNU Stow. # From 157f39385ac8205ffd25a61c948349ccc88c5f20 Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Thu, 27 Jun 2019 20:39:16 +0100 Subject: [PATCH 290/482] Change -w to "use warnings;" in tools/get-version This is more idiomatic and consistent with everywhere else. --- tools/get-version | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tools/get-version b/tools/get-version index 90d6a1b..a184ed7 100755 --- a/tools/get-version +++ b/tools/get-version @@ -1,6 +1,7 @@ -#!/usr/bin/perl -w +#!/usr/bin/perl use strict; +use warnings; open(CONF, "configure.ac") or die "Couldn't open configure.ac: $!\n"; From 311c2d139e1f8dd8681fafcd7c23485d61867d2e Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Thu, 27 Jun 2019 20:28:17 +0100 Subject: [PATCH 291/482] Improve the history of individual contributions and repositories The source code has been through a rather complicated journey, and it's occasionally useful to understand this history from CVS to a private Subversion repository to its current location in git. So document this more thoroughly, and ensure that everyone involved is in the THANKS file. --- AUTHORS | 73 ++++++++++++++++++++++++++++++++++++++++--------------- README.md | 9 +++++-- THANKS | 6 +++++ 3 files changed, 67 insertions(+), 21 deletions(-) diff --git a/AUTHORS b/AUTHORS index aae08e0..58d7ad1 100644 --- a/AUTHORS +++ b/AUTHORS @@ -1,23 +1,36 @@ -Stow was written by Bob Glickstein , Zanshin -Software, Inc. +Stow was originally written by Bob Glickstein , +Zanshin Software, Inc. -Contributions from Gord Matzigkeit . +Gord Matzigkeit made some early contributions. John Bazik wrote `fastcwd', the Perl subroutine for computing the -current working directory. +current working directory (later removed in 1.3.3). Charles Briscoe-Smith wrote the fix to prevent -stow -D / stow -R removing initially-empty directories. +stow -D / stow -R removing initially-empty directories (mentioned +in 1.3.3 section of NEWS). -Adam Lackorzynski wrote the fix to prevente +Adam Lackorzynski wrote the fix to prevent the generation of wrong links if there are links in the stow directory. -Stow was maintained by Guillaume Morin up to November 2007. +Stow was maintained by Guillaume Morin up to November +2007. Guillaume originally imported the source code into the Savannah +CVS repository on 2001/12/24 with the tag "v1_3_2". This history was +later imported into git as described below. -Kahlil (Kal) Hodgson performed a major rewrite -in order to implement: +1.3.3 was the last release of the 1.x series. The CVS history +contains a few commits after 1.3.3 preparing for a 1.3.4 release which +was never published (see the "import-cvs" tag in git). - 1. defered operations, +Between 2007 and 2009, a small team of people collaborated on a +private in-house project on Stow: + + https://lists.gnu.org/archive/html/stow-devel/2011-11/msg00003.html + +Kahlil (Kal) Hodgson performed a major +rewrite in order to implement: + + 1. deferred operations, 2. option parsing via Getopt::Long, 3. options to support shared files, 4. support for multiple operations per invocation, @@ -25,16 +38,38 @@ in order to implement: 6. better cooperation between multiple stow directories, 7. a test suite (and support code) to ensure that everything still works. -As these changes required a dramatic reorganisation of the code, very little -was left untouched, and so Stow's major version was bumped up to version 2. +As these changes required a dramatic reorganisation of the code, very +little was left untouched, and so Stow's major version number was +bumped up to 2. Austin Wood and Chris +Hoobin helped clean up the +documentation for the new 2.x.y series, and created the texi2man +script. -Austin Wood and Chris Hoobin - helped clean up the documentation for -version 2 and created the texi2man script. +Kahlil obtained permission to donate these changes back to GNU. The +Subversion history from this period is no longer accessible, so the +breakdown of the individual changes to the source code between 1.3.3 +and the unreleased 2.0.2 version have been lost; however some details +are still visible in ChangeLog.OLD, which also acknowledges the +contributions of Geoffrey Giesemann and Emil Mikulc. -Adam Spiers refactored the backend code into new -Stow.pm and Stow/Util.pm modules providing an OO interface, tightened -up the test suite, added support for ignore lists, `make test', and -distribution via CPAN, and cleaned up numerous other minor issues. +Sometime after this, Troy Will took over maintainership and imported +the unreleased 2.0.2 code base as the original root commit into +Savannah git repository. + +On 25th November 2011, Adam Spiers took over +maintainership. He imported the CVS history into the Savannah git +repository, grafting it onto the previous root commit imported by +Troy, and tagged this as v2.0.2: + + https://lists.gnu.org/archive/html/stow-devel/2011-11/msg00001.html + https://lists.gnu.org/archive/html/stow-devel/2011-11/msg00002.html + +refactored the backend code into new Stow.pm and Stow/Util.pm modules +providing an OO interface, tightened up the test suite, added support +for ignore lists, `make test', and distribution via CPAN, and cleaned +up numerous other minor issues. + +These changes were included in 2.1.0, which was the first official +release since 1.3.3 in 2002. Stow is currently maintained by Adam Spiers. diff --git a/README.md b/README.md index bde1cf0..6381fbc 100644 --- a/README.md +++ b/README.md @@ -78,8 +78,8 @@ Please do send comments, questions, and constructive criticism. The mailing lists and any other communication channels are detailed on the above home page. -Brief history -------------- +Brief history and authorship +---------------------------- Stow was inspired by Carnegie Mellon's "Depot" program, but is substantially simpler. Whereas Depot requires database files to keep @@ -89,3 +89,8 @@ hierarchies don't match the database. Also unlike Depot, Stow will never delete any files, directories, or links that appear in a Stow directory (e.g., `/usr/local/stow/emacs`), so it's always possible to rebuild the target tree (e.g., `/usr/local`). + +For a high-level overview of the contributions of the main developers +over the years, see [the `AUTHORS` file](AUTHORS). + +For a more detailed history, please see the `ChangeLog` file. diff --git a/THANKS b/THANKS index 2940859..64147fb 100644 --- a/THANKS +++ b/THANKS @@ -7,6 +7,7 @@ Greg Fox David Hartmann Ben Liblit Gord Matzigkeit +Adam Lackorzynski Roland McGrath Jim Meyering Fritz Mueller @@ -15,6 +16,7 @@ Richard Stallman Spencer Sun Tom Tromey Steve Webster +Kahlil Hodgson Geoffrey Giesemann Emil Mikulic Austin Wood @@ -38,3 +40,7 @@ Brice Waegeneire Email addresses of new contributors are no longer being added by default for privacy reasons; however please contact the maintainer if you are happy for your email address to be listed here. + +More authorship and contribution details can be found in the AUTHORS +and ChangeLog files, and of course also in the git version control +history. From ba48fd39089010c6a0a40aecc6a9e8f0a2241e04 Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Fri, 28 Jun 2019 00:53:12 +0100 Subject: [PATCH 292/482] Rename $OUT_DIR to $TEST_DIR This is a more accurate reflection of what it is. --- t/chkstow.t | 2 +- t/cleanup_invalid_links.t | 2 +- t/cli_options.t | 14 ++++++------- t/defer.t | 2 +- t/dotfiles.t | 2 +- t/examples.t | 2 +- t/find_stowed_path.t | 26 ++++++++++++------------ t/foldable.t | 2 +- t/ignore.t | 2 +- t/rc_options.t | 28 +++++++++++++------------- t/stow.t | 32 ++++++++++++++--------------- t/testutil.pm | 8 ++++---- t/unstow.t | 42 +++++++++++++++++++-------------------- t/unstow_orig.t | 40 ++++++++++++++++++------------------- 14 files changed, 102 insertions(+), 102 deletions(-) diff --git a/t/chkstow.t b/t/chkstow.t index 439775f..36516a6 100755 --- a/t/chkstow.t +++ b/t/chkstow.t @@ -30,7 +30,7 @@ use Test::Output; use English qw(-no_match_vars); init_test_dirs(); -cd("$OUT_DIR/target"); +cd("$TEST_DIR/target"); # setup stow directory make_dir('stow'); diff --git a/t/cleanup_invalid_links.t b/t/cleanup_invalid_links.t index 916a6b9..3fd5e0d 100755 --- a/t/cleanup_invalid_links.t +++ b/t/cleanup_invalid_links.t @@ -28,7 +28,7 @@ use English qw(-no_match_vars); use testutil; init_test_dirs(); -cd("$OUT_DIR/target"); +cd("$TEST_DIR/target"); my $stow; diff --git a/t/cli_options.t b/t/cli_options.t index 719c78c..c63e33e 100755 --- a/t/cli_options.t +++ b/t/cli_options.t @@ -32,15 +32,15 @@ init_test_dirs(); local @ARGV = ( '-v', - '-d', "$OUT_DIR/stow", - '-t', "$OUT_DIR/target", + '-d', "$TEST_DIR/stow", + '-t', "$TEST_DIR/target", 'dummy' ); my ($options, $pkgs_to_delete, $pkgs_to_stow) = process_options(); is($options->{verbose}, 1, 'verbose option'); -is($options->{dir}, "$OUT_DIR/stow", 'stow dir option'); +is($options->{dir}, "$TEST_DIR/stow", 'stow dir option'); my $stow = new_Stow(%$options); @@ -101,12 +101,12 @@ is_deeply($options->{ignore}, [ qr(~\z), qr(\.#.*\z) ] => 'ignore temp files'); # Check that expansion not applied. # local @ARGV = ( - "--target=$OUT_DIR/".'$HOME', + "--target=$TEST_DIR/".'$HOME', 'dummy' ); -make_dir("$OUT_DIR/".'$HOME'); +make_dir("$TEST_DIR/".'$HOME'); ($options, $pkgs_to_delete, $pkgs_to_stow) = process_options(); -is($options->{target}, "$OUT_DIR/".'$HOME', 'no expansion'); -remove_dir("$OUT_DIR/".'$HOME'); +is($options->{target}, "$TEST_DIR/".'$HOME', 'no expansion'); +remove_dir("$TEST_DIR/".'$HOME'); # vim:ft=perl diff --git a/t/defer.t b/t/defer.t index 003cf64..4434e0f 100755 --- a/t/defer.t +++ b/t/defer.t @@ -27,7 +27,7 @@ use testutil; use Test::More tests => 4; init_test_dirs(); -cd("$OUT_DIR/target"); +cd("$TEST_DIR/target"); my $stow; diff --git a/t/dotfiles.t b/t/dotfiles.t index 386359e..db5a8bb 100755 --- a/t/dotfiles.t +++ b/t/dotfiles.t @@ -30,7 +30,7 @@ use English qw(-no_match_vars); use testutil; init_test_dirs(); -cd("$OUT_DIR/target"); +cd("$TEST_DIR/target"); my $stow; diff --git a/t/examples.t b/t/examples.t index 56aa5b6..ead89c3 100755 --- a/t/examples.t +++ b/t/examples.t @@ -28,7 +28,7 @@ use Test::More tests => 10; use English qw(-no_match_vars); init_test_dirs(); -cd("$OUT_DIR/target"); +cd("$TEST_DIR/target"); my $stow; diff --git a/t/find_stowed_path.t b/t/find_stowed_path.t index 44aabe0..b4bd28a 100755 --- a/t/find_stowed_path.t +++ b/t/find_stowed_path.t @@ -28,15 +28,15 @@ use Test::More tests => 6; init_test_dirs(); -my $stow = new_Stow(dir => "$OUT_DIR/stow"); +my $stow = new_Stow(dir => "$TEST_DIR/stow"); is_deeply( - [ $stow->find_stowed_path("$OUT_DIR/target/a/b/c", '../../../stow/a/b/c') ], - [ "$OUT_DIR/stow/a/b/c", "$OUT_DIR/stow", 'a' ] + [ $stow->find_stowed_path("$TEST_DIR/target/a/b/c", '../../../stow/a/b/c') ], + [ "$TEST_DIR/stow/a/b/c", "$TEST_DIR/stow", 'a' ] => 'from root' ); -cd("$OUT_DIR/target"); +cd("$TEST_DIR/target"); $stow->set_stow_dir('../stow'); is_deeply( [ $stow->find_stowed_path('a/b/c','../../../stow/a/b/c') ], @@ -46,33 +46,33 @@ is_deeply( make_dir('stow'); cd('../..'); -$stow->set_stow_dir("$OUT_DIR/target/stow"); +$stow->set_stow_dir("$TEST_DIR/target/stow"); is_deeply( - [ $stow->find_stowed_path("$OUT_DIR/target/a/b/c", '../../stow/a/b/c') ], - [ "$OUT_DIR/target/stow/a/b/c", "$OUT_DIR/target/stow", 'a' ] + [ $stow->find_stowed_path("$TEST_DIR/target/a/b/c", '../../stow/a/b/c') ], + [ "$TEST_DIR/target/stow/a/b/c", "$TEST_DIR/target/stow", 'a' ] => 'stow is subdir of target directory' ); is_deeply( - [ $stow->find_stowed_path("$OUT_DIR/target/a/b/c",'../../empty') ], + [ $stow->find_stowed_path("$TEST_DIR/target/a/b/c",'../../empty') ], [ '', '', '' ] => 'target is not stowed' ); -make_dir("$OUT_DIR/target/stow2"); -make_file("$OUT_DIR/target/stow2/.stow"); +make_dir("$TEST_DIR/target/stow2"); +make_file("$TEST_DIR/target/stow2/.stow"); is_deeply( - [ $stow->find_stowed_path("$OUT_DIR/target/a/b/c",'../../stow2/a/b/c') ], - [ "$OUT_DIR/target/stow2/a/b/c", "$OUT_DIR/target/stow2", 'a' ] + [ $stow->find_stowed_path("$TEST_DIR/target/a/b/c",'../../stow2/a/b/c') ], + [ "$TEST_DIR/target/stow2/a/b/c", "$TEST_DIR/target/stow2", 'a' ] => q(detect alternate stow directory) ); # Possible corner case with rogue symlink pointing to ancestor of # stow dir. is_deeply( - [ $stow->find_stowed_path("$OUT_DIR/target/a/b/c",'../../..') ], + [ $stow->find_stowed_path("$TEST_DIR/target/a/b/c",'../../..') ], [ '', '', '' ] => q(corner case - link points to ancestor of stow dir) ); diff --git a/t/foldable.t b/t/foldable.t index 8f4f417..78096d7 100755 --- a/t/foldable.t +++ b/t/foldable.t @@ -28,7 +28,7 @@ use Test::More tests => 4; use English qw(-no_match_vars); init_test_dirs(); -cd("$OUT_DIR/target"); +cd("$TEST_DIR/target"); my $stow = new_Stow(dir => '../stow'); diff --git a/t/ignore.t b/t/ignore.t index d0b5444..840c6e7 100755 --- a/t/ignore.t +++ b/t/ignore.t @@ -29,7 +29,7 @@ use testutil; use Stow::Util qw(join_paths); init_test_dirs(); -cd("$OUT_DIR/target"); +cd("$TEST_DIR/target"); my $stow = new_Stow(); diff --git a/t/rc_options.t b/t/rc_options.t index dee156a..419f8c3 100755 --- a/t/rc_options.t +++ b/t/rc_options.t @@ -29,7 +29,7 @@ use testutil; require 'stow'; # stowrc file used for testing. -my $RC_FILE = "$OUT_DIR/.stowrc"; +my $RC_FILE = "$TEST_DIR/.stowrc"; # Take the safe route and cowardly refuse to continue if there's # already a file at $RC_FILE. if (-e $RC_FILE) { @@ -52,24 +52,24 @@ init_test_dirs(); # local @ARGV = ('dummy'); $rc_contents = <{target}, "$OUT_DIR/target", "rc options different lines"); -is($options->{dir}, "$OUT_DIR/stow", "rc options different lines"); +is($options->{target}, "$TEST_DIR/target", "rc options different lines"); +is($options->{dir}, "$TEST_DIR/stow", "rc options different lines"); # # Test that scalar cli option overwrites conflicting stowrc option. # -local @ARGV = ('-d', "$OUT_DIR/stow",'dummy'); +local @ARGV = ('-d', "$TEST_DIR/stow",'dummy'); $rc_contents = <{dir}, "$OUT_DIR/stow", "cli overwrite scalar rc option."); +is($options->{dir}, "$TEST_DIR/stow", "cli overwrite scalar rc option."); # # Test that list cli option merges with conflicting stowrc option. @@ -98,8 +98,8 @@ is_deeply($options->{defer}, [qr(\Ainfo), qr(\Aman)], # Test environment variable expansion function. # # Basic expansion -is(expand_environment('$HOME/stow'), "$OUT_DIR/stow", 'expand $HOME'); -is(expand_environment('${HOME}/stow'), "$OUT_DIR/stow", 'expand ${HOME}'); +is(expand_environment('$HOME/stow'), "$TEST_DIR/stow", 'expand $HOME'); +is(expand_environment('${HOME}/stow'), "$TEST_DIR/stow", 'expand ${HOME}'); delete $ENV{UNDEFINED}; # just in case foreach my $var ('$UNDEFINED', '${UNDEFINED}') { @@ -144,9 +144,9 @@ $rc_contents = <<'HERE'; HERE make_file($RC_FILE, $rc_contents); ($options, $pkgs_to_delete, $pkgs_to_stow) = get_config_file_options(); -is($options->{dir}, "$OUT_DIR/stow", +is($options->{dir}, "$TEST_DIR/stow", "apply environment expansion on stowrc --dir"); -is($options->{target}, "$OUT_DIR/stow", +is($options->{target}, "$TEST_DIR/stow", "apply environment expansion on stowrc --target"); is_deeply($options->{ignore}, [qr(\$HOME\z)], "environment expansion not applied on --ignore"); @@ -167,9 +167,9 @@ $rc_contents = <<'HERE'; HERE make_file($RC_FILE, $rc_contents); ($options, $pkgs_to_delete, $pkgs_to_stow) = get_config_file_options(); -is($options->{dir}, "$OUT_DIR/stow", +is($options->{dir}, "$TEST_DIR/stow", "apply environment expansion on stowrc --dir"); -is($options->{target}, "$OUT_DIR/stow", +is($options->{target}, "$TEST_DIR/stow", "apply environment expansion on stowrc --target"); is_deeply($options->{ignore}, [qr(~/stow\z)], "environment expansion not applied on --ignore"); @@ -181,5 +181,5 @@ is_deeply($options->{override}, [qr(\A~/stow)], # Clean up files used for testing. # unlink $RC_FILE or die "Unable to clean up $RC_FILE.\n"; -remove_dir($OUT_DIR); +remove_dir($TEST_DIR); diff --git a/t/stow.t b/t/stow.t index e86b79a..8960916 100755 --- a/t/stow.t +++ b/t/stow.t @@ -30,7 +30,7 @@ use Stow::Util qw(canon_path); use testutil; init_test_dirs(); -cd("$OUT_DIR/target"); +cd("$TEST_DIR/target"); my $stow; my %conflicts; @@ -400,16 +400,16 @@ uncapture_stderr(); # stow a simple tree minimally when cwd isn't target # cd('../..'); -$stow = new_Stow(dir => "$OUT_DIR/stow", target => "$OUT_DIR/target"); +$stow = new_Stow(dir => "$TEST_DIR/stow", target => "$TEST_DIR/target"); -make_dir("$OUT_DIR/stow/pkg16/bin16"); -make_file("$OUT_DIR/stow/pkg16/bin16/file16"); +make_dir("$TEST_DIR/stow/pkg16/bin16"); +make_file("$TEST_DIR/stow/pkg16/bin16/file16"); $stow->plan_stow('pkg16'); $stow->process_tasks(); is_deeply([ $stow->get_conflicts ], [], 'no conflicts with minimal stow'); is( - readlink("$OUT_DIR/target/bin16"), + readlink("$TEST_DIR/target/bin16"), '../stow/pkg16/bin16', => "minimal stow of a simple tree when cwd isn't target" ); @@ -418,17 +418,17 @@ is( # stow a simple tree minimally to absolute stow dir when cwd isn't # target # -$stow = new_Stow(dir => canon_path("$OUT_DIR/stow"), - target => "$OUT_DIR/target"); +$stow = new_Stow(dir => canon_path("$TEST_DIR/stow"), + target => "$TEST_DIR/target"); -make_dir("$OUT_DIR/stow/pkg17/bin17"); -make_file("$OUT_DIR/stow/pkg17/bin17/file17"); +make_dir("$TEST_DIR/stow/pkg17/bin17"); +make_file("$TEST_DIR/stow/pkg17/bin17/file17"); $stow->plan_stow('pkg17'); $stow->process_tasks(); is_deeply([ $stow->get_conflicts ], [], 'no conflicts with minimal stow'); is( - readlink("$OUT_DIR/target/bin17"), + readlink("$TEST_DIR/target/bin17"), '../stow/pkg17/bin17', => "minimal stow of a simple tree with absolute stow dir" ); @@ -437,17 +437,17 @@ is( # stow a simple tree minimally with absolute stow AND target dirs when # cwd isn't target # -$stow = new_Stow(dir => canon_path("$OUT_DIR/stow"), - target => canon_path("$OUT_DIR/target")); +$stow = new_Stow(dir => canon_path("$TEST_DIR/stow"), + target => canon_path("$TEST_DIR/target")); -make_dir("$OUT_DIR/stow/pkg18/bin18"); -make_file("$OUT_DIR/stow/pkg18/bin18/file18"); +make_dir("$TEST_DIR/stow/pkg18/bin18"); +make_file("$TEST_DIR/stow/pkg18/bin18/file18"); $stow->plan_stow('pkg18'); $stow->process_tasks(); is_deeply([ $stow->get_conflicts ], [], 'no conflicts with minimal stow'); is( - readlink("$OUT_DIR/target/bin18"), + readlink("$TEST_DIR/target/bin18"), '../stow/pkg18/bin18', => "minimal stow of a simple tree with absolute stow and target dirs" ); @@ -458,7 +458,7 @@ is( # folded directories should be split open (unfolded) where # (and only where) necessary # -cd("$OUT_DIR/target"); +cd("$TEST_DIR/target"); sub create_pkg { my ($id, $pkg) = @_; diff --git a/t/testutil.pm b/t/testutil.pm index 139369b..a3eb69a 100755 --- a/t/testutil.pm +++ b/t/testutil.pm @@ -36,7 +36,7 @@ use Stow::Util qw(parent canon_path); use base qw(Exporter); our @EXPORT = qw( - $OUT_DIR + $TEST_DIR $stderr init_test_dirs cd @@ -48,7 +48,7 @@ our @EXPORT = qw( capture_stderr uncapture_stderr ); -our $OUT_DIR = 'tmp-testing-trees'; +our $TEST_DIR = 'tmp-testing-trees'; our $stderr; my $tied_err; @@ -64,13 +64,13 @@ sub uncapture_stderr { } sub init_test_dirs { - for my $dir ("$OUT_DIR/target", "$OUT_DIR/stow") { + for my $dir ("$TEST_DIR/target", "$TEST_DIR/stow") { -d $dir and remove_tree($dir); make_dir($dir); } # Don't let user's ~/.stow-global-ignore affect test results - $ENV{HOME} = $OUT_DIR; + $ENV{HOME} = $TEST_DIR; } sub new_Stow { diff --git a/t/unstow.t b/t/unstow.t index 34b463d..b25e8ad 100755 --- a/t/unstow.t +++ b/t/unstow.t @@ -30,7 +30,7 @@ use testutil; use Stow::Util qw(canon_path); init_test_dirs(); -cd("$OUT_DIR/target"); +cd("$TEST_DIR/target"); # Note that each of the following tests use a distinct set of files @@ -279,8 +279,8 @@ ok( # Unstow a never stowed package # -eval { remove_dir("$OUT_DIR/target"); }; -mkdir("$OUT_DIR/target"); +eval { remove_dir("$TEST_DIR/target"); }; +mkdir("$TEST_DIR/target"); $stow = new_Stow(); $stow->plan_unstow('pkg12'); @@ -310,17 +310,17 @@ ok( # unstow a simple tree minimally when cwd isn't target # cd('../..'); -$stow = new_Stow(dir => "$OUT_DIR/stow", target => "$OUT_DIR/target"); +$stow = new_Stow(dir => "$TEST_DIR/stow", target => "$TEST_DIR/target"); -make_dir("$OUT_DIR/stow/pkg13/bin13"); -make_file("$OUT_DIR/stow/pkg13/bin13/file13"); -make_link("$OUT_DIR/target/bin13", '../stow/pkg13/bin13'); +make_dir("$TEST_DIR/stow/pkg13/bin13"); +make_file("$TEST_DIR/stow/pkg13/bin13/file13"); +make_link("$TEST_DIR/target/bin13", '../stow/pkg13/bin13'); $stow->plan_unstow('pkg13'); $stow->process_tasks(); ok( $stow->get_conflict_count == 0 && - -f "$OUT_DIR/stow/pkg13/bin13/file13" && ! -e "$OUT_DIR/target/bin13" + -f "$TEST_DIR/stow/pkg13/bin13/file13" && ! -e "$TEST_DIR/target/bin13" => 'unstow a simple tree' ); @@ -328,18 +328,18 @@ ok( # unstow a simple tree minimally with absolute stow dir when cwd isn't # target # -$stow = new_Stow(dir => canon_path("$OUT_DIR/stow"), - target => "$OUT_DIR/target"); +$stow = new_Stow(dir => canon_path("$TEST_DIR/stow"), + target => "$TEST_DIR/target"); -make_dir("$OUT_DIR/stow/pkg14/bin14"); -make_file("$OUT_DIR/stow/pkg14/bin14/file14"); -make_link("$OUT_DIR/target/bin14", '../stow/pkg14/bin14'); +make_dir("$TEST_DIR/stow/pkg14/bin14"); +make_file("$TEST_DIR/stow/pkg14/bin14/file14"); +make_link("$TEST_DIR/target/bin14", '../stow/pkg14/bin14'); $stow->plan_unstow('pkg14'); $stow->process_tasks(); ok( $stow->get_conflict_count == 0 && - -f "$OUT_DIR/stow/pkg14/bin14/file14" && ! -e "$OUT_DIR/target/bin14" + -f "$TEST_DIR/stow/pkg14/bin14/file14" && ! -e "$TEST_DIR/target/bin14" => 'unstow a simple tree with absolute stow dir' ); @@ -347,18 +347,18 @@ ok( # unstow a simple tree minimally with absolute stow AND target dirs # when cwd isn't target # -$stow = new_Stow(dir => canon_path("$OUT_DIR/stow"), - target => canon_path("$OUT_DIR/target")); +$stow = new_Stow(dir => canon_path("$TEST_DIR/stow"), + target => canon_path("$TEST_DIR/target")); -make_dir("$OUT_DIR/stow/pkg15/bin15"); -make_file("$OUT_DIR/stow/pkg15/bin15/file15"); -make_link("$OUT_DIR/target/bin15", '../stow/pkg15/bin15'); +make_dir("$TEST_DIR/stow/pkg15/bin15"); +make_file("$TEST_DIR/stow/pkg15/bin15/file15"); +make_link("$TEST_DIR/target/bin15", '../stow/pkg15/bin15'); $stow->plan_unstow('pkg15'); $stow->process_tasks(); ok( $stow->get_conflict_count == 0 && - -f "$OUT_DIR/stow/pkg15/bin15/file15" && ! -e "$OUT_DIR/target/bin15" + -f "$TEST_DIR/stow/pkg15/bin15/file15" && ! -e "$TEST_DIR/target/bin15" => 'unstow a simple tree with absolute stow and target dirs' ); @@ -366,7 +366,7 @@ ok( # unstow a tree with no-folding enabled - # no refolding should take place # -cd("$OUT_DIR/target"); +cd("$TEST_DIR/target"); sub create_and_stow_pkg { my ($id, $pkg) = @_; diff --git a/t/unstow_orig.t b/t/unstow_orig.t index a4e3142..4b62068 100755 --- a/t/unstow_orig.t +++ b/t/unstow_orig.t @@ -30,7 +30,7 @@ use testutil; use Stow::Util qw(canon_path); init_test_dirs(); -cd("$OUT_DIR/target"); +cd("$TEST_DIR/target"); # Note that each of the following tests use a distinct set of files @@ -308,8 +308,8 @@ check_protected_dirs_skipped(); # Unstow a never stowed package # -eval { remove_dir("$OUT_DIR/target"); }; -mkdir("$OUT_DIR/target"); +eval { remove_dir("$TEST_DIR/target"); }; +mkdir("$TEST_DIR/target"); $stow = new_compat_Stow(); capture_stderr(); @@ -343,17 +343,17 @@ check_protected_dirs_skipped(); # unstow a simple tree minimally when cwd isn't target # cd('../..'); -$stow = new_Stow(dir => "$OUT_DIR/stow", target => "$OUT_DIR/target"); +$stow = new_Stow(dir => "$TEST_DIR/stow", target => "$TEST_DIR/target"); -make_dir("$OUT_DIR/stow/pkg13/bin13"); -make_file("$OUT_DIR/stow/pkg13/bin13/file13"); -make_link("$OUT_DIR/target/bin13", '../stow/pkg13/bin13'); +make_dir("$TEST_DIR/stow/pkg13/bin13"); +make_file("$TEST_DIR/stow/pkg13/bin13/file13"); +make_link("$TEST_DIR/target/bin13", '../stow/pkg13/bin13'); $stow->plan_unstow('pkg13'); $stow->process_tasks(); ok( $stow->get_conflict_count == 0 && - -f "$OUT_DIR/stow/pkg13/bin13/file13" && ! -e "$OUT_DIR/target/bin13" + -f "$TEST_DIR/stow/pkg13/bin13/file13" && ! -e "$TEST_DIR/target/bin13" => 'unstow a simple tree' ); @@ -361,18 +361,18 @@ ok( # unstow a simple tree minimally with absolute stow dir when cwd isn't # target # -$stow = new_Stow(dir => canon_path("$OUT_DIR/stow"), - target => "$OUT_DIR/target"); +$stow = new_Stow(dir => canon_path("$TEST_DIR/stow"), + target => "$TEST_DIR/target"); -make_dir("$OUT_DIR/stow/pkg14/bin14"); -make_file("$OUT_DIR/stow/pkg14/bin14/file14"); -make_link("$OUT_DIR/target/bin14", '../stow/pkg14/bin14'); +make_dir("$TEST_DIR/stow/pkg14/bin14"); +make_file("$TEST_DIR/stow/pkg14/bin14/file14"); +make_link("$TEST_DIR/target/bin14", '../stow/pkg14/bin14'); $stow->plan_unstow('pkg14'); $stow->process_tasks(); ok( $stow->get_conflict_count == 0 && - -f "$OUT_DIR/stow/pkg14/bin14/file14" && ! -e "$OUT_DIR/target/bin14" + -f "$TEST_DIR/stow/pkg14/bin14/file14" && ! -e "$TEST_DIR/target/bin14" => 'unstow a simple tree with absolute stow dir' ); @@ -380,18 +380,18 @@ ok( # unstow a simple tree minimally with absolute stow AND target dirs # when cwd isn't target # -$stow = new_Stow(dir => canon_path("$OUT_DIR/stow"), - target => canon_path("$OUT_DIR/target")); +$stow = new_Stow(dir => canon_path("$TEST_DIR/stow"), + target => canon_path("$TEST_DIR/target")); -make_dir("$OUT_DIR/stow/pkg15/bin15"); -make_file("$OUT_DIR/stow/pkg15/bin15/file15"); -make_link("$OUT_DIR/target/bin15", '../stow/pkg15/bin15'); +make_dir("$TEST_DIR/stow/pkg15/bin15"); +make_file("$TEST_DIR/stow/pkg15/bin15/file15"); +make_link("$TEST_DIR/target/bin15", '../stow/pkg15/bin15'); $stow->plan_unstow('pkg15'); $stow->process_tasks(); ok( $stow->get_conflict_count == 0 && - -f "$OUT_DIR/stow/pkg15/bin15/file15" && ! -e "$OUT_DIR/target/bin15" + -f "$TEST_DIR/stow/pkg15/bin15/file15" && ! -e "$TEST_DIR/target/bin15" => 'unstow a simple tree with absolute stow and target dirs' ); From 6233298a9112f8637a9a99e3590ef1d2b2e96b84 Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Fri, 28 Jun 2019 01:02:48 +0100 Subject: [PATCH 293/482] Replace testutil::make_dir with File::Path::make_path No need for a custom function here. --- t/chkstow.t | 26 ++++++------ t/cleanup_invalid_links.t | 10 ++--- t/cli_options.t | 2 +- t/dotfiles.t | 12 +++--- t/examples.t | 30 +++++++------- t/find_stowed_path.t | 4 +- t/foldable.t | 18 ++++----- t/ignore.t | 6 +-- t/stow.t | 84 +++++++++++++++++++-------------------- t/testutil.pm | 29 ++------------ t/unstow.t | 78 ++++++++++++++++++------------------ t/unstow_orig.t | 57 +++++++++++++------------- 12 files changed, 167 insertions(+), 189 deletions(-) diff --git a/t/chkstow.t b/t/chkstow.t index 36516a6..6e066c2 100755 --- a/t/chkstow.t +++ b/t/chkstow.t @@ -33,43 +33,43 @@ init_test_dirs(); cd("$TEST_DIR/target"); # setup stow directory -make_dir('stow'); +make_path('stow'); make_file('stow/.stow'); # perl -make_dir('stow/perl/bin'); +make_path('stow/perl/bin'); make_file('stow/perl/bin/perl'); make_file('stow/perl/bin/a2p'); -make_dir('stow/perl/info'); +make_path('stow/perl/info'); make_file('stow/perl/info/perl'); -make_dir('stow/perl/lib/perl'); -make_dir('stow/perl/man/man1'); +make_path('stow/perl/lib/perl'); +make_path('stow/perl/man/man1'); make_file('stow/perl/man/man1/perl.1'); # emacs -make_dir('stow/emacs/bin'); +make_path('stow/emacs/bin'); make_file('stow/emacs/bin/emacs'); make_file('stow/emacs/bin/etags'); -make_dir('stow/emacs/info'); +make_path('stow/emacs/info'); make_file('stow/emacs/info/emacs'); -make_dir('stow/emacs/libexec/emacs'); -make_dir('stow/emacs/man/man1'); +make_path('stow/emacs/libexec/emacs'); +make_path('stow/emacs/man/man1'); make_file('stow/emacs/man/man1/emacs.1'); #setup target directory -make_dir('bin'); +make_path('bin'); make_link('bin/a2p', '../stow/perl/bin/a2p'); make_link('bin/emacs', '../stow/emacs/bin/emacs'); make_link('bin/etags', '../stow/emacs/bin/etags'); make_link('bin/perl', '../stow/perl/bin/perl'); -make_dir('info'); +make_path('info'); make_link('info/emacs', '../stow/emacs/info/emacs'); make_link('info/perl', '../stow/perl/info/perl'); make_link('lib', 'stow/perl/lib'); make_link('libexec', 'stow/emacs/libexec'); -make_dir('man'); -make_dir('man/man1'); +make_path('man'); +make_path('man/man1'); make_link('man/man1/emacs', '../../stow/emacs/man/man1/emacs.1'); make_link('man/man1/perl', '../../stow/perl/man/man1/perl.1'); diff --git a/t/cleanup_invalid_links.t b/t/cleanup_invalid_links.t index 3fd5e0d..3b54b71 100755 --- a/t/cleanup_invalid_links.t +++ b/t/cleanup_invalid_links.t @@ -39,7 +39,7 @@ my $stow; # -make_dir('../stow/pkg1/bin1'); +make_path('../stow/pkg1/bin1'); make_file('../stow/pkg1/bin1/file1'); make_link('bin1', '../stow/pkg1/bin1'); @@ -53,8 +53,8 @@ is( # # cleanup a bad link in a simple tree # -make_dir('bin2'); -make_dir('../stow/pkg2/bin2'); +make_path('bin2'); +make_path('../stow/pkg2/bin2'); make_file('../stow/pkg2/bin2/file2a'); make_link('bin2/file2a', '../../stow/pkg2/bin2/file2a'); make_invalid_link('bin2/file2b', '../../stow/pkg2/bin2/file2b'); @@ -69,8 +69,8 @@ is($stow->link_task_action('bin2/file2b'), 'remove', 'removal task for bad link' # dont cleanup a bad link not owned by stow # -make_dir('bin3'); -make_dir('../stow/pkg3/bin3'); +make_path('bin3'); +make_path('../stow/pkg3/bin3'); make_file('../stow/pkg3/bin3/file3a'); make_link('bin3/file3a', '../../stow/pkg3/bin3/file3a'); make_invalid_link('bin3/file3b', '../../empty'); diff --git a/t/cli_options.t b/t/cli_options.t index c63e33e..8b73bf5 100755 --- a/t/cli_options.t +++ b/t/cli_options.t @@ -104,7 +104,7 @@ local @ARGV = ( "--target=$TEST_DIR/".'$HOME', 'dummy' ); -make_dir("$TEST_DIR/".'$HOME'); +make_path("$TEST_DIR/".'$HOME'); ($options, $pkgs_to_delete, $pkgs_to_stow) = process_options(); is($options->{target}, "$TEST_DIR/".'$HOME', 'no expansion'); remove_dir("$TEST_DIR/".'$HOME'); diff --git a/t/dotfiles.t b/t/dotfiles.t index db5a8bb..a4a45c8 100755 --- a/t/dotfiles.t +++ b/t/dotfiles.t @@ -40,7 +40,7 @@ my $stow; $stow = new_Stow(dir => '../stow', dotfiles => 1); -make_dir('../stow/dotfiles'); +make_path('../stow/dotfiles'); make_file('../stow/dotfiles/dot-foo'); $stow->plan_stow('dotfiles'); @@ -57,7 +57,7 @@ is( $stow = new_Stow(dir => '../stow', dotfiles => 0); -make_dir('../stow/dotfiles'); +make_path('../stow/dotfiles'); make_file('../stow/dotfiles/dot-foo'); $stow->plan_stow('dotfiles'); @@ -75,7 +75,7 @@ is( $stow = new_Stow(dir => '../stow', dotfiles => 1); -make_dir('../stow/dotfiles/dot-emacs'); +make_path('../stow/dotfiles/dot-emacs'); make_file('../stow/dotfiles/dot-emacs/init.el'); $stow->plan_stow('dotfiles'); @@ -93,10 +93,10 @@ is( $stow = new_Stow(dir => '../stow', dotfiles => 1); -make_dir('../stow/dotfiles'); +make_path('../stow/dotfiles'); make_file('../stow/dotfiles/dot-'); -make_dir('../stow/dotfiles/dot-.'); +make_path('../stow/dotfiles/dot-.'); make_file('../stow/dotfiles/dot-./foo'); $stow->plan_stow('dotfiles'); @@ -118,7 +118,7 @@ is( $stow = new_Stow(dir => '../stow', dotfiles => 1); -make_dir('../stow/dotfiles'); +make_path('../stow/dotfiles'); make_file('../stow/dotfiles/dot-bar'); make_link('.bar', '../stow/dotfiles/dot-bar'); diff --git a/t/examples.t b/t/examples.t index ead89c3..376de39 100755 --- a/t/examples.t +++ b/t/examples.t @@ -35,23 +35,23 @@ my $stow; ## set up some fake packages to stow # perl -make_dir('stow/perl/bin'); +make_path('stow/perl/bin'); make_file('stow/perl/bin/perl'); make_file('stow/perl/bin/a2p'); -make_dir('stow/perl/info'); +make_path('stow/perl/info'); make_file('stow/perl/info/perl'); -make_dir('stow/perl/lib/perl'); -make_dir('stow/perl/man/man1'); +make_path('stow/perl/lib/perl'); +make_path('stow/perl/man/man1'); make_file('stow/perl/man/man1/perl.1'); # emacs -make_dir('stow/emacs/bin'); +make_path('stow/emacs/bin'); make_file('stow/emacs/bin/emacs'); make_file('stow/emacs/bin/etags'); -make_dir('stow/emacs/info'); +make_path('stow/emacs/info'); make_file('stow/emacs/info/emacs'); -make_dir('stow/emacs/libexec/emacs'); -make_dir('stow/emacs/man/man1'); +make_path('stow/emacs/libexec/emacs'); +make_path('stow/emacs/man/man1'); make_file('stow/emacs/man/man1/emacs.1'); # @@ -81,9 +81,9 @@ remove_link('info'); remove_link('lib'); remove_link('man'); -make_dir('bin'); -make_dir('lib'); -make_dir('man/man1'); +make_path('bin'); +make_path('lib'); +make_path('man/man1'); $stow = new_Stow(dir => 'stow'); $stow->plan_stow('perl'); @@ -157,8 +157,8 @@ ok( # behaviour is the same as if the empty directory had nothing to do with stow # -make_dir('stow/pkg1a/bin1'); -make_dir('stow/pkg1b/bin1'); +make_path('stow/pkg1a/bin1'); +make_path('stow/pkg1b/bin1'); make_file('stow/pkg1b/bin1/file1b'); $stow = new_Stow(dir => 'stow'); @@ -172,10 +172,10 @@ ok(-d 'bin1' => 'bug 1: stowing empty dirs'); # BUG 2: split open tree-folding symlinks pointing inside different stow # directories # -make_dir('stow2a/pkg2a/bin2'); +make_path('stow2a/pkg2a/bin2'); make_file('stow2a/pkg2a/bin2/file2a'); make_file('stow2a/.stow'); -make_dir('stow2b/pkg2b/bin2'); +make_path('stow2b/pkg2b/bin2'); make_file('stow2b/pkg2b/bin2/file2b'); make_file('stow2b/.stow'); diff --git a/t/find_stowed_path.t b/t/find_stowed_path.t index b4bd28a..8111e66 100755 --- a/t/find_stowed_path.t +++ b/t/find_stowed_path.t @@ -44,7 +44,7 @@ is_deeply( => 'from target directory' ); -make_dir('stow'); +make_path('stow'); cd('../..'); $stow->set_stow_dir("$TEST_DIR/target/stow"); @@ -60,7 +60,7 @@ is_deeply( => 'target is not stowed' ); -make_dir("$TEST_DIR/target/stow2"); +make_path("$TEST_DIR/target/stow2"); make_file("$TEST_DIR/target/stow2/.stow"); is_deeply( diff --git a/t/foldable.t b/t/foldable.t index 78096d7..e528723 100755 --- a/t/foldable.t +++ b/t/foldable.t @@ -38,9 +38,9 @@ my $stow = new_Stow(dir => '../stow'); # can fold a simple tree # -make_dir('../stow/pkg1/bin1'); +make_path('../stow/pkg1/bin1'); make_file('../stow/pkg1/bin1/file1'); -make_dir('bin1'); +make_path('bin1'); make_link('bin1/file1','../../stow/pkg1/bin1/file1'); is( $stow->foldable('bin1'), '../stow/pkg1/bin1' => q(can fold a simple tree) ); @@ -49,9 +49,9 @@ is( $stow->foldable('bin1'), '../stow/pkg1/bin1' => q(can fold a simple tree) ); # can't fold an empty directory # -make_dir('../stow/pkg2/bin2'); +make_path('../stow/pkg2/bin2'); make_file('../stow/pkg2/bin2/file2'); -make_dir('bin2'); +make_path('bin2'); is( $stow->foldable('bin2'), '' => q(can't fold an empty directory) ); @@ -59,9 +59,9 @@ is( $stow->foldable('bin2'), '' => q(can't fold an empty directory) ); # can't fold if dir contains a non-link # -make_dir('../stow/pkg3/bin3'); +make_path('../stow/pkg3/bin3'); make_file('../stow/pkg3/bin3/file3'); -make_dir('bin3'); +make_path('bin3'); make_link('bin3/file3','../../stow/pkg3/bin3/file3'); make_file('bin3/non-link'); @@ -71,11 +71,11 @@ is( $stow->foldable('bin3'), '' => q(can't fold a dir containing non-links) ); # can't fold if links point to different directories # -make_dir('bin4'); -make_dir('../stow/pkg4a/bin4'); +make_path('bin4'); +make_path('../stow/pkg4a/bin4'); make_file('../stow/pkg4a/bin4/file4a'); make_link('bin4/file4a','../../stow/pkg4a/bin4/file4a'); -make_dir('../stow/pkg4b/bin4'); +make_path('../stow/pkg4b/bin4'); make_file('../stow/pkg4b/bin4/file4b'); make_link('bin4/file4b','../../stow/pkg4b/bin4/file4b'); diff --git a/t/ignore.t b/t/ignore.t index 840c6e7..3da9dd4 100755 --- a/t/ignore.t +++ b/t/ignore.t @@ -123,7 +123,7 @@ EOF sub setup_package_local_list { my ($stow_path, $package, $list) = @_; my $package_path = join_paths($stow_path, $package); - make_dir($package_path); + make_path($package_path); my $local_ignore = join_paths($package_path, $Stow::LOCAL_IGNORE_FILE); make_file($local_ignore, $list); $stow->invalidate_memoized_regexp($local_ignore); @@ -278,7 +278,7 @@ sub test_ignore_via_stow { my ($stow_path) = @_; my $package = 'pkg1'; - make_dir("$stow_path/$package/foo/bar"); + make_path("$stow_path/$package/foo/bar"); make_file("$stow_path/$package/foo/bar/baz"); setup_package_local_list($stow_path, $package, 'foo'); @@ -286,7 +286,7 @@ sub test_ignore_via_stow { is($stow->get_tasks(), 0, 'top dir ignored'); is($stow->get_conflicts(), 0, 'top dir ignored, no conflicts'); - make_dir("foo"); + make_path("foo"); for my $ignore ('bar', 'foo/bar', '/foo/bar', '^/foo/bar', '^/fo.+ar') { setup_package_local_list($stow_path, $package, $ignore); $stow->plan_stow($package); diff --git a/t/stow.t b/t/stow.t index 8960916..1755e19 100755 --- a/t/stow.t +++ b/t/stow.t @@ -42,7 +42,7 @@ my %conflicts; # $stow = new_Stow(dir => '../stow'); -make_dir('../stow/pkg1/bin1'); +make_path('../stow/pkg1/bin1'); make_file('../stow/pkg1/bin1/file1'); $stow->plan_stow('pkg1'); @@ -59,9 +59,9 @@ is( # $stow = new_Stow(); -make_dir('../stow/pkg2/lib2'); +make_path('../stow/pkg2/lib2'); make_file('../stow/pkg2/lib2/file2'); -make_dir('lib2'); +make_path('lib2'); $stow->plan_stow('pkg2'); $stow->process_tasks(); @@ -76,11 +76,11 @@ is( # $stow = new_Stow(); -make_dir('../stow/pkg3a/bin3'); +make_path('../stow/pkg3a/bin3'); make_file('../stow/pkg3a/bin3/file3a'); make_link('bin3' => '../stow/pkg3a/bin3'); # emulate stow -make_dir('../stow/pkg3b/bin3'); +make_path('../stow/pkg3b/bin3'); make_file('../stow/pkg3b/bin3/file3b'); $stow->plan_stow('pkg3b'); @@ -99,7 +99,7 @@ ok( $stow = new_Stow(); make_file('bin4'); # this is a file but named like a directory -make_dir('../stow/pkg4/bin4'); +make_path('../stow/pkg4/bin4'); make_file('../stow/pkg4/bin4/file4'); $stow->plan_stow('pkg4'); @@ -119,7 +119,7 @@ ok( $stow = new_Stow(); make_file('bin4a'); # this is a file but named like a directory -make_dir('../stow/pkg4a/bin4a'); +make_path('../stow/pkg4a/bin4a'); make_file('../stow/pkg4a/bin4a/file4a'); $stow->plan_stow('pkg4a'); @@ -139,11 +139,11 @@ $stow = new_Stow(); # Populate target make_file('file4b', 'file4b - version originally in target'); -make_dir ('bin4b'); +make_path ('bin4b'); make_file('bin4b/file4b', 'bin4b/file4b - version originally in target'); # Populate -make_dir ('../stow/pkg4b/bin4b'); +make_path ('../stow/pkg4b/bin4b'); make_file('../stow/pkg4b/file4b', 'file4b - version originally in stow package'); make_file('../stow/pkg4b/bin4b/file4b', 'bin4b/file4b - version originally in stow package'); @@ -166,11 +166,11 @@ $stow = new_Stow(adopt => 1); # Populate target make_file('file4c', "file4c - version originally in target\n"); -make_dir ('bin4c'); +make_path ('bin4c'); make_file('bin4c/file4c', "bin4c/file4c - version originally in target\n"); # Populate -make_dir ('../stow/pkg4c/bin4c'); +make_path ('../stow/pkg4c/bin4c'); make_file('../stow/pkg4c/file4c', "file4c - version originally in stow package\n"); make_file('../stow/pkg4c/bin4c/file4c', "bin4c/file4c - version originally in stow package\n"); @@ -194,9 +194,9 @@ for my $file ('file4c', 'bin4c/file4c') { # $stow = new_Stow(); -make_dir('bin5'); +make_path('bin5'); make_invalid_link('bin5/file5','../../empty'); -make_dir('../stow/pkg5/bin5/file5'); +make_path('../stow/pkg5/bin5/file5'); $stow->plan_stow('pkg5'); %conflicts = $stow->get_conflicts(); @@ -212,7 +212,7 @@ like( $stow = new_Stow(); make_invalid_link('file6','../stow/path-does-not-exist'); -make_dir('../stow/pkg6'); +make_path('../stow/pkg6'); make_file('../stow/pkg6/file6'); $stow->plan_stow('pkg6'); @@ -229,11 +229,11 @@ is( # $stow = new_Stow(); -make_dir('bin7'); -make_dir('../stow/pkg7a/bin7'); +make_path('bin7'); +make_path('../stow/pkg7a/bin7'); make_file('../stow/pkg7a/bin7/node7'); make_link('bin7/node7','../../stow/pkg7a/bin7/node7'); -make_dir('../stow/pkg7b/bin7/node7'); +make_path('../stow/pkg7b/bin7/node7'); make_file('../stow/pkg7b/bin7/node7/file7'); $stow->plan_stow('pkg7b'); @@ -249,11 +249,11 @@ like( # $stow = new_Stow(); -make_dir('../stow/pkg8a/0'); +make_path('../stow/pkg8a/0'); make_file('../stow/pkg8a/0/file8a'); make_link('0' => '../stow/pkg8a/0'); # emulate stow -make_dir('../stow/pkg8b/0'); +make_path('../stow/pkg8b/0'); make_file('../stow/pkg8b/0/file8b'); $stow->plan_stow('pkg8b'); @@ -271,12 +271,12 @@ ok( # $stow = new_Stow(override => ['man9', 'info9']); -make_dir('../stow/pkg9a/man9/man1'); +make_path('../stow/pkg9a/man9/man1'); make_file('../stow/pkg9a/man9/man1/file9.1'); -make_dir('man9/man1'); +make_path('man9/man1'); make_link('man9/man1/file9.1' => '../../../stow/pkg9a/man9/man1/file9.1'); # emulate stow -make_dir('../stow/pkg9b/man9/man1'); +make_path('../stow/pkg9b/man9/man1'); make_file('../stow/pkg9b/man9/man1/file9.1'); $stow->plan_stow('pkg9b'); @@ -292,12 +292,12 @@ ok( # $stow = new_Stow(defer => ['man10', 'info10']); -make_dir('../stow/pkg10a/man10/man1'); +make_path('../stow/pkg10a/man10/man1'); make_file('../stow/pkg10a/man10/man1/file10.1'); -make_dir('man10/man1'); +make_path('man10/man1'); make_link('man10/man1/file10.1' => '../../../stow/pkg10a/man10/man1/file10.1'); # emulate stow -make_dir('../stow/pkg10b/man10/man1'); +make_path('../stow/pkg10b/man10/man1'); make_file('../stow/pkg10b/man10/man1/file10.1'); $stow->plan_stow('pkg10b'); @@ -313,11 +313,11 @@ ok( # $stow = new_Stow(ignore => ['~', '\.#.*']); -make_dir('../stow/pkg11/man11/man1'); +make_path('../stow/pkg11/man11/man1'); make_file('../stow/pkg11/man11/man1/file11.1'); make_file('../stow/pkg11/man11/man1/file11.1~'); make_file('../stow/pkg11/man11/man1/.#file11.1'); -make_dir('man11/man1'); +make_path('man11/man1'); $stow->plan_stow('pkg11'); $stow->process_tasks(); @@ -334,11 +334,11 @@ ok( # $stow = new_Stow(); -make_dir('../stow/pkg12/lib12/'); +make_path('../stow/pkg12/lib12/'); make_file('../stow/pkg12/lib12/lib.so.1'); make_link('../stow/pkg12/lib12/lib.so', 'lib.so.1'); -make_dir('lib12/'); +make_path('lib12/'); $stow->plan_stow('pkg12'); $stow->process_tasks(); @@ -354,12 +354,12 @@ ok( # $stow = new_Stow(); -make_dir('../stow/pkg13a/lib13/'); +make_path('../stow/pkg13a/lib13/'); make_file('../stow/pkg13a/lib13/liba.so.1'); make_link('../stow/pkg13a/lib13/liba.so', 'liba.so.1'); make_link('lib13','../stow/pkg13a/lib13'); -make_dir('../stow/pkg13b/lib13/'); +make_path('../stow/pkg13b/lib13/'); make_file('../stow/pkg13b/lib13/libb.so.1'); make_link('../stow/pkg13b/lib13/libb.so', 'libb.so.1'); @@ -377,10 +377,10 @@ ok( # # stowing to stow dir should fail # -make_dir('stow'); +make_path('stow'); $stow = new_Stow(dir => 'stow'); -make_dir('stow/pkg14/stow/pkg15'); +make_path('stow/pkg14/stow/pkg15'); make_file('stow/pkg14/stow/pkg15/node15'); capture_stderr(); @@ -402,7 +402,7 @@ uncapture_stderr(); cd('../..'); $stow = new_Stow(dir => "$TEST_DIR/stow", target => "$TEST_DIR/target"); -make_dir("$TEST_DIR/stow/pkg16/bin16"); +make_path("$TEST_DIR/stow/pkg16/bin16"); make_file("$TEST_DIR/stow/pkg16/bin16/file16"); $stow->plan_stow('pkg16'); @@ -421,7 +421,7 @@ is( $stow = new_Stow(dir => canon_path("$TEST_DIR/stow"), target => "$TEST_DIR/target"); -make_dir("$TEST_DIR/stow/pkg17/bin17"); +make_path("$TEST_DIR/stow/pkg17/bin17"); make_file("$TEST_DIR/stow/pkg17/bin17/file17"); $stow->plan_stow('pkg17'); @@ -440,7 +440,7 @@ is( $stow = new_Stow(dir => canon_path("$TEST_DIR/stow"), target => canon_path("$TEST_DIR/target")); -make_dir("$TEST_DIR/stow/pkg18/bin18"); +make_path("$TEST_DIR/stow/pkg18/bin18"); make_file("$TEST_DIR/stow/pkg18/bin18/file18"); $stow->plan_stow('pkg18'); @@ -464,32 +464,32 @@ sub create_pkg { my ($id, $pkg) = @_; my $stow_pkg = "../stow/$id-$pkg"; - make_dir ($stow_pkg); + make_path ($stow_pkg); make_file("$stow_pkg/$id-file-$pkg"); # create a shallow hierarchy specific to this package which isn't # yet stowed - make_dir ("$stow_pkg/$id-$pkg-only-new"); + make_path ("$stow_pkg/$id-$pkg-only-new"); make_file("$stow_pkg/$id-$pkg-only-new/$id-file-$pkg"); # create a deeper hierarchy specific to this package which isn't # yet stowed - make_dir ("$stow_pkg/$id-$pkg-only-new2/subdir"); + make_path ("$stow_pkg/$id-$pkg-only-new2/subdir"); make_file("$stow_pkg/$id-$pkg-only-new2/subdir/$id-file-$pkg"); make_link("$stow_pkg/$id-$pkg-only-new2/current", "subdir"); # create a hierarchy specific to this package which is already # stowed via a folded tree - make_dir ("$stow_pkg/$id-$pkg-only-old"); + make_path ("$stow_pkg/$id-$pkg-only-old"); make_link("$id-$pkg-only-old", "$stow_pkg/$id-$pkg-only-old"); make_file("$stow_pkg/$id-$pkg-only-old/$id-file-$pkg"); # create a shared hierarchy which this package uses - make_dir ("$stow_pkg/$id-shared"); + make_path ("$stow_pkg/$id-shared"); make_file("$stow_pkg/$id-shared/$id-file-$pkg"); # create a partially shared hierarchy which this package uses - make_dir ("$stow_pkg/$id-shared2/subdir-$pkg"); + make_path ("$stow_pkg/$id-shared2/subdir-$pkg"); make_file("$stow_pkg/$id-shared2/$id-file-$pkg"); make_file("$stow_pkg/$id-shared2/subdir-$pkg/$id-file-$pkg"); } diff --git a/t/testutil.pm b/t/testutil.pm index a3eb69a..3510ab5 100755 --- a/t/testutil.pm +++ b/t/testutil.pm @@ -26,7 +26,7 @@ use warnings; use Carp qw(croak); use File::Basename; -use File::Path qw(remove_tree); +use File::Path qw(make_path remove_tree); use File::Spec; use IO::Scalar; use Test::More; @@ -41,7 +41,7 @@ our @EXPORT = qw( init_test_dirs cd new_Stow new_compat_Stow - make_dir make_link make_invalid_link make_file + make_path make_link make_invalid_link make_file remove_dir remove_link cat_file is_link is_dir_not_symlink is_nonexistent_path @@ -66,7 +66,7 @@ sub uncapture_stderr { sub init_test_dirs { for my $dir ("$TEST_DIR/target", "$TEST_DIR/stow") { -d $dir and remove_tree($dir); - make_dir($dir); + make_path($dir); } # Don't let user's ~/.stow-global-ignore affect test results @@ -138,29 +138,6 @@ sub make_invalid_link { make_link($target, $source, 1); } -#===== SUBROUTINE =========================================================== -# Name : make_dir() -# Purpose : create a directory and any requisite parents -# Parameters: $dir => path to the new directory -# Returns : n/a -# Throws : fatal error if the directory or any of its parents cannot be -# : created -# Comments : none -#============================================================================ -sub make_dir { - my ($dir) = @_; - - my @parents = (); - for my $part (split '/', $dir) { - my $path = join '/', @parents, $part; - if (not -d $path and not mkdir $path) { - die "could not create directory: $path ($!)\n"; - } - push @parents, $part; - } - return; -} - #===== SUBROUTINE =========================================================== # Name : create_file() # Purpose : create an empty file diff --git a/t/unstow.t b/t/unstow.t index b25e8ad..5cabf26 100755 --- a/t/unstow.t +++ b/t/unstow.t @@ -42,7 +42,7 @@ my %conflicts; # $stow = new_Stow(); -make_dir('../stow/pkg1/bin1'); +make_path('../stow/pkg1/bin1'); make_file('../stow/pkg1/bin1/file1'); make_link('bin1', '../stow/pkg1/bin1'); @@ -59,8 +59,8 @@ ok( # $stow = new_Stow(); -make_dir('lib2'); -make_dir('../stow/pkg2/lib2'); +make_path('lib2'); +make_path('../stow/pkg2/lib2'); make_file('../stow/pkg2/lib2/file2'); make_link('lib2/file2', '../../stow/pkg2/lib2/file2'); $stow->plan_unstow('pkg2'); @@ -76,13 +76,13 @@ ok( # $stow = new_Stow(); -make_dir('bin3'); +make_path('bin3'); -make_dir('../stow/pkg3a/bin3'); +make_path('../stow/pkg3a/bin3'); make_file('../stow/pkg3a/bin3/file3a'); make_link('bin3/file3a' => '../../stow/pkg3a/bin3/file3a'); # emulate stow -make_dir('../stow/pkg3b/bin3'); +make_path('../stow/pkg3b/bin3'); make_file('../stow/pkg3b/bin3/file3b'); make_link('bin3/file3b' => '../../stow/pkg3b/bin3/file3b'); # emulate stow $stow->plan_unstow('pkg3b'); @@ -99,8 +99,8 @@ ok( # $stow = new_Stow(); -make_dir('bin4'); -make_dir('../stow/pkg4/bin4'); +make_path('bin4'); +make_path('../stow/pkg4/bin4'); make_file('../stow/pkg4/bin4/file4'); make_invalid_link('bin4/file4', '../../stow/pkg4/bin4/does-not-exist'); @@ -117,7 +117,7 @@ ok( # $stow = new_Stow(); -make_dir('../stow/pkg5/bin5'); +make_path('../stow/pkg5/bin5'); make_invalid_link('bin5', '../not-stow'); $stow->plan_unstow('pkg5'); @@ -133,12 +133,12 @@ like( # $stow = new_Stow(); -make_dir('bin6'); -make_dir('../stow/pkg6a/bin6'); +make_path('bin6'); +make_path('../stow/pkg6a/bin6'); make_file('../stow/pkg6a/bin6/file6'); make_link('bin6/file6', '../../stow/pkg6a/bin6/file6'); -make_dir('../stow/pkg6b/bin6'); +make_path('../stow/pkg6b/bin6'); make_file('../stow/pkg6b/bin6/file6'); $stow->plan_unstow('pkg6b'); @@ -152,11 +152,11 @@ ok( # # Don't unlink anything under the stow directory # -make_dir('stow'); # make out stow dir a subdir of target +make_path('stow'); # make out stow dir a subdir of target $stow = new_Stow(dir => 'stow'); # emulate stowing into ourself (bizarre corner case or accident) -make_dir('stow/pkg7a/stow/pkg7b'); +make_path('stow/pkg7a/stow/pkg7b'); make_file('stow/pkg7a/stow/pkg7b/file7b'); make_link('stow/pkg7b', '../stow/pkg7a/stow/pkg7b'); @@ -175,11 +175,11 @@ ok( # $stow = new_Stow(dir => 'stow'); -make_dir('stow2'); # make our alternate stow dir a subdir of target +make_path('stow2'); # make our alternate stow dir a subdir of target make_file('stow2/.stow'); # emulate stowing into ourself (bizarre corner case or accident) -make_dir('stow/pkg8a/stow2/pkg8b'); +make_path('stow/pkg8a/stow2/pkg8b'); make_file('stow/pkg8a/stow2/pkg8b/file8b'); make_link('stow2/pkg8b', '../stow/pkg8a/stow2/pkg8b'); @@ -203,12 +203,12 @@ uncapture_stderr(); $stow = new_Stow(override => ['man9', 'info9']); make_file('stow/.stow'); -make_dir('../stow/pkg9a/man9/man1'); +make_path('../stow/pkg9a/man9/man1'); make_file('../stow/pkg9a/man9/man1/file9.1'); -make_dir('man9/man1'); +make_path('man9/man1'); make_link('man9/man1/file9.1' => '../../../stow/pkg9a/man9/man1/file9.1'); # emulate stow -make_dir('../stow/pkg9b/man9/man1'); +make_path('../stow/pkg9b/man9/man1'); make_file('../stow/pkg9b/man9/man1/file9.1'); $stow->plan_unstow('pkg9b'); $stow->process_tasks(); @@ -223,18 +223,18 @@ ok( # $stow = new_Stow(defer => ['man10', 'info10']); -make_dir('../stow/pkg10a/man10/man1'); +make_path('../stow/pkg10a/man10/man1'); make_file('../stow/pkg10a/man10/man1/file10a.1'); -make_dir('man10/man1'); +make_path('man10/man1'); make_link('man10/man1/file10a.1' => '../../../stow/pkg10a/man10/man1/file10a.1'); # need this to block folding -make_dir('../stow/pkg10b/man10/man1'); +make_path('../stow/pkg10b/man10/man1'); make_file('../stow/pkg10b/man10/man1/file10b.1'); make_link('man10/man1/file10b.1' => '../../../stow/pkg10b/man10/man1/file10b.1'); -make_dir('../stow/pkg10c/man10/man1'); +make_path('../stow/pkg10c/man10/man1'); make_file('../stow/pkg10c/man10/man1/file10a.1'); $stow->plan_unstow('pkg10c'); is($stow->get_tasks, 0, 'no tasks to process when unstowing pkg10c'); @@ -249,11 +249,11 @@ ok( # $stow = new_Stow(ignore => ['~', '\.#.*']); -make_dir('../stow/pkg12/man12/man1'); +make_path('../stow/pkg12/man12/man1'); make_file('../stow/pkg12/man12/man1/file12.1'); make_file('../stow/pkg12/man12/man1/file12.1~'); make_file('../stow/pkg12/man12/man1/.#file12.1'); -make_dir('man12/man1'); +make_path('man12/man1'); make_link('man12/man1/file12.1' => '../../../stow/pkg12/man12/man1/file12.1'); $stow->plan_unstow('pkg12'); @@ -312,7 +312,7 @@ ok( cd('../..'); $stow = new_Stow(dir => "$TEST_DIR/stow", target => "$TEST_DIR/target"); -make_dir("$TEST_DIR/stow/pkg13/bin13"); +make_path("$TEST_DIR/stow/pkg13/bin13"); make_file("$TEST_DIR/stow/pkg13/bin13/file13"); make_link("$TEST_DIR/target/bin13", '../stow/pkg13/bin13'); @@ -331,7 +331,7 @@ ok( $stow = new_Stow(dir => canon_path("$TEST_DIR/stow"), target => "$TEST_DIR/target"); -make_dir("$TEST_DIR/stow/pkg14/bin14"); +make_path("$TEST_DIR/stow/pkg14/bin14"); make_file("$TEST_DIR/stow/pkg14/bin14/file14"); make_link("$TEST_DIR/target/bin14", '../stow/pkg14/bin14'); @@ -350,7 +350,7 @@ ok( $stow = new_Stow(dir => canon_path("$TEST_DIR/stow"), target => canon_path("$TEST_DIR/target")); -make_dir("$TEST_DIR/stow/pkg15/bin15"); +make_path("$TEST_DIR/stow/pkg15/bin15"); make_file("$TEST_DIR/stow/pkg15/bin15/file15"); make_link("$TEST_DIR/target/bin15", '../stow/pkg15/bin15'); @@ -372,52 +372,52 @@ sub create_and_stow_pkg { my ($id, $pkg) = @_; my $stow_pkg = "../stow/$id-$pkg"; - make_dir ($stow_pkg); + make_path ($stow_pkg); make_file("$stow_pkg/$id-file-$pkg"); # create a shallow hierarchy specific to this package and stow # via folding - make_dir ("$stow_pkg/$id-$pkg-only-folded"); + make_path ("$stow_pkg/$id-$pkg-only-folded"); make_file("$stow_pkg/$id-$pkg-only-folded/file-$pkg"); make_link("$id-$pkg-only-folded", "$stow_pkg/$id-$pkg-only-folded"); # create a deeper hierarchy specific to this package and stow # via folding - make_dir ("$stow_pkg/$id-$pkg-only-folded2/subdir"); + make_path ("$stow_pkg/$id-$pkg-only-folded2/subdir"); make_file("$stow_pkg/$id-$pkg-only-folded2/subdir/file-$pkg"); make_link("$id-$pkg-only-folded2", "$stow_pkg/$id-$pkg-only-folded2"); # create a shallow hierarchy specific to this package and stow # without folding - make_dir ("$stow_pkg/$id-$pkg-only-unfolded"); + make_path ("$stow_pkg/$id-$pkg-only-unfolded"); make_file("$stow_pkg/$id-$pkg-only-unfolded/file-$pkg"); - make_dir ("$id-$pkg-only-unfolded"); + make_path ("$id-$pkg-only-unfolded"); make_link("$id-$pkg-only-unfolded/file-$pkg", "../$stow_pkg/$id-$pkg-only-unfolded/file-$pkg"); # create a deeper hierarchy specific to this package and stow # without folding - make_dir ("$stow_pkg/$id-$pkg-only-unfolded2/subdir"); + make_path ("$stow_pkg/$id-$pkg-only-unfolded2/subdir"); make_file("$stow_pkg/$id-$pkg-only-unfolded2/subdir/file-$pkg"); - make_dir ("$id-$pkg-only-unfolded2/subdir"); + make_path ("$id-$pkg-only-unfolded2/subdir"); make_link("$id-$pkg-only-unfolded2/subdir/file-$pkg", "../../$stow_pkg/$id-$pkg-only-unfolded2/subdir/file-$pkg"); # create a shallow shared hierarchy which this package uses, and stow # its contents without folding - make_dir ("$stow_pkg/$id-shared"); + make_path ("$stow_pkg/$id-shared"); make_file("$stow_pkg/$id-shared/file-$pkg"); - make_dir ("$id-shared"); + make_path ("$id-shared"); make_link("$id-shared/file-$pkg", "../$stow_pkg/$id-shared/file-$pkg"); # create a deeper shared hierarchy which this package uses, and stow # its contents without folding - make_dir ("$stow_pkg/$id-shared2/subdir"); + make_path ("$stow_pkg/$id-shared2/subdir"); make_file("$stow_pkg/$id-shared2/file-$pkg"); make_file("$stow_pkg/$id-shared2/subdir/file-$pkg"); - make_dir ("$id-shared2/subdir"); + make_path ("$id-shared2/subdir"); make_link("$id-shared2/file-$pkg", "../$stow_pkg/$id-shared2/file-$pkg"); make_link("$id-shared2/subdir/file-$pkg", diff --git a/t/unstow_orig.t b/t/unstow_orig.t index 4b62068..6d5ff8d 100755 --- a/t/unstow_orig.t +++ b/t/unstow_orig.t @@ -22,6 +22,7 @@ use strict; use warnings; +use File::Spec qw(make_path); use Test::More tests => 37; use Test::Output; use English qw(-no_match_vars); @@ -43,7 +44,7 @@ my %conflicts; $stow = new_compat_Stow(); -make_dir('../stow/pkg1/bin1'); +make_path('../stow/pkg1/bin1'); make_file('../stow/pkg1/bin1/file1'); make_link('bin1', '../stow/pkg1/bin1'); @@ -60,8 +61,8 @@ ok( # $stow = new_compat_Stow(); -make_dir('lib2'); -make_dir('../stow/pkg2/lib2'); +make_path('lib2'); +make_path('../stow/pkg2/lib2'); make_file('../stow/pkg2/lib2/file2'); make_link('lib2/file2', '../../stow/pkg2/lib2/file2'); $stow->plan_unstow('pkg2'); @@ -77,13 +78,13 @@ ok( # $stow = new_compat_Stow(); -make_dir('bin3'); +make_path('bin3'); -make_dir('../stow/pkg3a/bin3'); +make_path('../stow/pkg3a/bin3'); make_file('../stow/pkg3a/bin3/file3a'); make_link('bin3/file3a' => '../../stow/pkg3a/bin3/file3a'); # emulate stow -make_dir('../stow/pkg3b/bin3'); +make_path('../stow/pkg3b/bin3'); make_file('../stow/pkg3b/bin3/file3b'); make_link('bin3/file3b' => '../../stow/pkg3b/bin3/file3b'); # emulate stow $stow->plan_unstow('pkg3b'); @@ -100,8 +101,8 @@ ok( # $stow = new_compat_Stow(); -make_dir('bin4'); -make_dir('../stow/pkg4/bin4'); +make_path('bin4'); +make_path('../stow/pkg4/bin4'); make_file('../stow/pkg4/bin4/file4'); make_invalid_link('bin4/file4', '../../stow/pkg4/bin4/does-not-exist'); @@ -118,7 +119,7 @@ ok( # $stow = new_compat_Stow(); -make_dir('../stow/pkg5/bin5'); +make_path('../stow/pkg5/bin5'); make_invalid_link('bin5', '../not-stow'); $stow->plan_unstow('pkg5'); @@ -139,12 +140,12 @@ ok( # $stow = new_compat_Stow(); -make_dir('bin6'); -make_dir('../stow/pkg6a/bin6'); +make_path('bin6'); +make_path('../stow/pkg6a/bin6'); make_file('../stow/pkg6a/bin6/file6'); make_link('bin6/file6', '../../stow/pkg6a/bin6/file6'); -make_dir('../stow/pkg6b/bin6'); +make_path('../stow/pkg6b/bin6'); make_file('../stow/pkg6b/bin6/file6'); $stow->plan_unstow('pkg6b'); @@ -158,11 +159,11 @@ ok( # # Don't unlink anything under the stow directory # -make_dir('stow'); # make out stow dir a subdir of target +make_path('stow'); # make out stow dir a subdir of target $stow = new_compat_Stow(dir => 'stow'); # emulate stowing into ourself (bizarre corner case or accident) -make_dir('stow/pkg7a/stow/pkg7b'); +make_path('stow/pkg7a/stow/pkg7b'); make_file('stow/pkg7a/stow/pkg7b/file7b'); make_link('stow/pkg7b', '../stow/pkg7a/stow/pkg7b'); @@ -185,11 +186,11 @@ uncapture_stderr(); # $stow = new_compat_Stow(dir => 'stow'); -make_dir('stow2'); # make our alternate stow dir a subdir of target +make_path('stow2'); # make our alternate stow dir a subdir of target make_file('stow2/.stow'); # emulate stowing into ourself (bizarre corner case or accident) -make_dir('stow/pkg8a/stow2/pkg8b'); +make_path('stow/pkg8a/stow2/pkg8b'); make_file('stow/pkg8a/stow2/pkg8b/file8b'); make_link('stow2/pkg8b', '../stow/pkg8a/stow2/pkg8b'); @@ -224,12 +225,12 @@ sub check_protected_dirs_skipped { $stow = new_compat_Stow(override => ['man9', 'info9']); make_file('stow/.stow'); -make_dir('../stow/pkg9a/man9/man1'); +make_path('../stow/pkg9a/man9/man1'); make_file('../stow/pkg9a/man9/man1/file9.1'); -make_dir('man9/man1'); +make_path('man9/man1'); make_link('man9/man1/file9.1' => '../../../stow/pkg9a/man9/man1/file9.1'); # emulate stow -make_dir('../stow/pkg9b/man9/man1'); +make_path('../stow/pkg9b/man9/man1'); make_file('../stow/pkg9b/man9/man1/file9.1'); capture_stderr(); $stow->plan_unstow('pkg9b'); @@ -246,18 +247,18 @@ check_protected_dirs_skipped(); # $stow = new_compat_Stow(defer => ['man10', 'info10']); -make_dir('../stow/pkg10a/man10/man1'); +make_path('../stow/pkg10a/man10/man1'); make_file('../stow/pkg10a/man10/man1/file10a.1'); -make_dir('man10/man1'); +make_path('man10/man1'); make_link('man10/man1/file10a.1' => '../../../stow/pkg10a/man10/man1/file10a.1'); # need this to block folding -make_dir('../stow/pkg10b/man10/man1'); +make_path('../stow/pkg10b/man10/man1'); make_file('../stow/pkg10b/man10/man1/file10b.1'); make_link('man10/man1/file10b.1' => '../../../stow/pkg10b/man10/man1/file10b.1'); -make_dir('../stow/pkg10c/man10/man1'); +make_path('../stow/pkg10c/man10/man1'); make_file('../stow/pkg10c/man10/man1/file10a.1'); capture_stderr(); $stow->plan_unstow('pkg10c'); @@ -274,11 +275,11 @@ check_protected_dirs_skipped(); # $stow = new_compat_Stow(ignore => ['~', '\.#.*']); -make_dir('../stow/pkg12/man12/man1'); +make_path('../stow/pkg12/man12/man1'); make_file('../stow/pkg12/man12/man1/file12.1'); make_file('../stow/pkg12/man12/man1/file12.1~'); make_file('../stow/pkg12/man12/man1/.#file12.1'); -make_dir('man12/man1'); +make_path('man12/man1'); make_link('man12/man1/file12.1' => '../../../stow/pkg12/man12/man1/file12.1'); capture_stderr(); @@ -345,7 +346,7 @@ check_protected_dirs_skipped(); cd('../..'); $stow = new_Stow(dir => "$TEST_DIR/stow", target => "$TEST_DIR/target"); -make_dir("$TEST_DIR/stow/pkg13/bin13"); +make_path("$TEST_DIR/stow/pkg13/bin13"); make_file("$TEST_DIR/stow/pkg13/bin13/file13"); make_link("$TEST_DIR/target/bin13", '../stow/pkg13/bin13'); @@ -364,7 +365,7 @@ ok( $stow = new_Stow(dir => canon_path("$TEST_DIR/stow"), target => "$TEST_DIR/target"); -make_dir("$TEST_DIR/stow/pkg14/bin14"); +make_path("$TEST_DIR/stow/pkg14/bin14"); make_file("$TEST_DIR/stow/pkg14/bin14/file14"); make_link("$TEST_DIR/target/bin14", '../stow/pkg14/bin14'); @@ -383,7 +384,7 @@ ok( $stow = new_Stow(dir => canon_path("$TEST_DIR/stow"), target => canon_path("$TEST_DIR/target")); -make_dir("$TEST_DIR/stow/pkg15/bin15"); +make_path("$TEST_DIR/stow/pkg15/bin15"); make_file("$TEST_DIR/stow/pkg15/bin15/file15"); make_link("$TEST_DIR/target/bin15", '../stow/pkg15/bin15'); From e4f6a6742b6803a2ea47af095a4bf8455d3821d5 Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Fri, 28 Jun 2019 10:32:18 +0100 Subject: [PATCH 294/482] Add examples of how to enable debugging in tests --- t/find_stowed_path.t | 6 ++++-- t/stow.t | 3 ++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/t/find_stowed_path.t b/t/find_stowed_path.t index 8111e66..968799a 100755 --- a/t/find_stowed_path.t +++ b/t/find_stowed_path.t @@ -22,13 +22,15 @@ use strict; use warnings; -use testutil; - use Test::More tests => 6; +use testutil; +use Stow::Util qw(set_debug_level); + init_test_dirs(); my $stow = new_Stow(dir => "$TEST_DIR/stow"); +#set_debug_level(4); is_deeply( [ $stow->find_stowed_path("$TEST_DIR/target/a/b/c", '../../../stow/a/b/c') ], diff --git a/t/stow.t b/t/stow.t index 1755e19..0563457 100755 --- a/t/stow.t +++ b/t/stow.t @@ -26,7 +26,7 @@ use Test::More tests => 118; use Test::Output; use English qw(-no_match_vars); -use Stow::Util qw(canon_path); +use Stow::Util qw(canon_path set_debug_level); use testutil; init_test_dirs(); @@ -228,6 +228,7 @@ is( # (can't unfold) # $stow = new_Stow(); +#set_debug_level(4); make_path('bin7'); make_path('../stow/pkg7a/bin7'); From 3270b145e12b507f972ddddc5b167c228bb0893b Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Fri, 28 Jun 2019 15:22:29 +0100 Subject: [PATCH 295/482] Improve comments on function parameters for clarity --- lib/Stow.pm.in | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/lib/Stow.pm.in b/lib/Stow.pm.in index fb454ab..643ed89 100755 --- a/lib/Stow.pm.in +++ b/lib/Stow.pm.in @@ -354,7 +354,9 @@ sub within_target_do { # Parameters: $stow_path => relative path from current (i.e. target) directory # : to the stow dir containing the package to be stowed # : $package => the package whose contents are being stowed -# : $target => subpath relative to package and target directories +# : $target => subpath relative to package directory which needs +# : stowing as a symlink at subpath relative to target +# : directory. # : $source => relative path from the (sub)dir of target # : to symlink source # Returns : n/a @@ -415,7 +417,9 @@ sub stow_contents { # Parameters: $stow_path => relative path from current (i.e. target) directory # : to the stow dir containing the node to be stowed # : $package => the package containing the node being stowed -# : $target => subpath relative to package and target directories +# : $target => subpath relative to package directory of node which +# : needs stowing as a symlink at subpath relative to +# : target directory. # : $source => relative path to symlink source from the dir of target # Returns : n/a # Throws : fatal exception if a conflict arises @@ -912,18 +916,20 @@ sub path_owned_by_package { # Name : find_stowed_path() # Purpose : determine whether the given link points to a member of a # : stowed package -# Parameters: $target => path to a symbolic link under current directory +# Parameters: $target => path to a symbolic link under current directory. +# : Must share a common prefix with $self->{stow_path} # : $source => where that link points to (needed because link # : might not exist yet due to two-phase approach, -# : so we can't just call readlink()) +# : so we can't just call readlink()). This must be +# : expressed relative to (the directory containing) +# : $target. # Returns : ($path, $stow_path, $package) where $path and $stow_path are # : relative from the current (i.e. target) directory. $path # : is the full relative path, $stow_path is the relative path # : to the stow directory, and $package is the name of the package. # : or ('', '', '') if link is not owned by stow # Throws : n/a -# Comments : Needs -# : Allow for stow dir not being under target dir. +# Comments : Allow for stow dir not being under target dir. # : We could put more logic under here for multiple stow dirs. #============================================================================ sub find_stowed_path { @@ -971,7 +977,7 @@ sub find_stowed_path { } my $package = shift @path; - + debug(4, " yes - by $package in " . join_paths(@path)); return ($path, $self->{stow_path}, $package); } From 40a0807185054a47cdd022fd36f0d44fc1bab9dd Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Fri, 28 Jun 2019 15:22:44 +0100 Subject: [PATCH 296/482] Check that find_stowed_path $path matches relative/absolute with target Watch out for a corner case probably only relevant in tests. --- lib/Stow.pm.in | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lib/Stow.pm.in b/lib/Stow.pm.in index 643ed89..77f67b3 100755 --- a/lib/Stow.pm.in +++ b/lib/Stow.pm.in @@ -961,6 +961,12 @@ sub find_stowed_path { # If no .stow file was found, we need to find out whether it's # owned by the current stow directory, in which case $path will be # a prefix of $self->{stow_path}. + if (substr($path, 0, 1) eq '/' xor substr($self->{stow_path}, 0, 1) eq '/') + { + warn "BUG in find_stowed_path? Absolute/relative mismatch between " . + "Stow dir $self->{stow_path} and path $path"; + } + my @stow_path = split m{/+}, $self->{stow_path}; # Strip off common prefixes until one is empty From ac74d75a983fc091210131e5919fe1b9461b03b0 Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Fri, 28 Jun 2019 15:23:52 +0100 Subject: [PATCH 297/482] Split up is_deeply() assertions in find_stowed_path.t This makes the tests and any failures more readable. --- t/find_stowed_path.t | 68 ++++++++++++++++++++++---------------------- 1 file changed, 34 insertions(+), 34 deletions(-) diff --git a/t/find_stowed_path.t b/t/find_stowed_path.t index 968799a..7b82520 100755 --- a/t/find_stowed_path.t +++ b/t/find_stowed_path.t @@ -22,7 +22,7 @@ use strict; use warnings; -use Test::More tests => 6; +use Test::More tests => 18; use testutil; use Stow::Util qw(set_debug_level); @@ -32,49 +32,49 @@ init_test_dirs(); my $stow = new_Stow(dir => "$TEST_DIR/stow"); #set_debug_level(4); -is_deeply( - [ $stow->find_stowed_path("$TEST_DIR/target/a/b/c", '../../../stow/a/b/c') ], - [ "$TEST_DIR/stow/a/b/c", "$TEST_DIR/stow", 'a' ] - => 'from root' -); +my ($path, $stow_path, $package) = + $stow->find_stowed_path("$TEST_DIR/target/a/b/c", "../../../stow/a/b/c"); +is($path, "$TEST_DIR/stow/a/b/c", "path"); +is($stow_path, "$TEST_DIR/stow", "stow path"); +is($package, "a", "package"); cd("$TEST_DIR/target"); -$stow->set_stow_dir('../stow'); -is_deeply( - [ $stow->find_stowed_path('a/b/c','../../../stow/a/b/c') ], - [ '../stow/a/b/c', '../stow', 'a' ] - => 'from target directory' -); +$stow->set_stow_dir("../stow"); +($path, $stow_path, $package) = + $stow->find_stowed_path("a/b/c", "../../../stow/a/b/c"); +is($path, "../stow/a/b/c", "path from target directory"); +is($stow_path, "../stow", "stow path from target directory"); +is($package, "a", "from target directory"); -make_path('stow'); -cd('../..'); +make_path("stow"); +cd("../.."); $stow->set_stow_dir("$TEST_DIR/target/stow"); -is_deeply( - [ $stow->find_stowed_path("$TEST_DIR/target/a/b/c", '../../stow/a/b/c') ], - [ "$TEST_DIR/target/stow/a/b/c", "$TEST_DIR/target/stow", 'a' ] - => 'stow is subdir of target directory' -); +($path, $stow_path, $package) = + $stow->find_stowed_path("$TEST_DIR/target/a/b/c", "../../stow/a/b/c"); +is($path, "$TEST_DIR/target/stow/a/b/c", "path"); +is($stow_path, "$TEST_DIR/target/stow", "stow path"); +is($package, "a", "stow is subdir of target directory"); -is_deeply( - [ $stow->find_stowed_path("$TEST_DIR/target/a/b/c",'../../empty') ], - [ '', '', '' ] - => 'target is not stowed' -); +($path, $stow_path, $package) = + $stow->find_stowed_path("$TEST_DIR/target/a/b/c", "../../empty"); +is($path, "", "empty path"); +is($stow_path, "", "empty stow path"); +is($package, "", "target is not stowed"); make_path("$TEST_DIR/target/stow2"); make_file("$TEST_DIR/target/stow2/.stow"); -is_deeply( - [ $stow->find_stowed_path("$TEST_DIR/target/a/b/c",'../../stow2/a/b/c') ], - [ "$TEST_DIR/target/stow2/a/b/c", "$TEST_DIR/target/stow2", 'a' ] - => q(detect alternate stow directory) -); +($path, $stow_path, $package) = + $stow->find_stowed_path("$TEST_DIR/target/a/b/c","../../stow2/a/b/c"); +is($path, "$TEST_DIR/target/stow2/a/b/c", "path"); +is($stow_path, "$TEST_DIR/target/stow2", "stow path"); +is($package, "a", "detect alternate stow directory"); # Possible corner case with rogue symlink pointing to ancestor of # stow dir. -is_deeply( - [ $stow->find_stowed_path("$TEST_DIR/target/a/b/c",'../../..') ], - [ '', '', '' ] - => q(corner case - link points to ancestor of stow dir) -); +($path, $stow_path, $package) = + $stow->find_stowed_path("$TEST_DIR/target/a/b/c","../../.."); +is($path, "", "path"); +is($stow_path, "", "stow path"); +is($package, "", "corner case - link points to ancestor of stow dir"); From 74f018283477b8953e43838353d596f595a6abb6 Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Fri, 28 Jun 2019 09:56:46 +0100 Subject: [PATCH 298/482] Add separate tests for .stowrc from $HOME and $PWD .stowrc can be obtained from $HOME and/or the current working directory; however only the $HOME case was tested before, because during tests Stow was being run from $HOME. So switch $TEST_DIR to an absolute path, create a new run_from/ subdirectory, and chdir to that before invoking any Stow code. This allows us to test the behaviour of .stowrc in $HOME and run_from/ separately. --- NEWS | 28 +++++---- bin/stow.in | 13 ++-- t/rc_options.t | 166 +++++++++++++++++++++++++++++++++++-------------- t/testutil.pm | 16 +++-- 4 files changed, 156 insertions(+), 67 deletions(-) diff --git a/NEWS b/NEWS index 51b7e38..4eae54d 100644 --- a/NEWS +++ b/NEWS @@ -98,12 +98,7 @@ News file for Stow. consistency. - INSTALL.md now also documents how to build directly from git. -** Fixes for bugs and technical debt -*** Fix for test suite on Cygwin - - Thanks to Lucas Theisen for this fix! - -*** aclocal.m4 was updated using aclocal 1.15.1. +** Fixes for bugs, tests, and other technical debt *** Add Docker files for convenient testing across multiple Perl versions @@ -118,17 +113,28 @@ News file for Stow. Thanks to Charles LeDoux for this! -*** Add Coveralls integration with GitHub - - This means that test coverage analysis will be automatically be run - on any pull requests submitted to GitHub. - *** Set up continuous testing via Travis CI This means that the test suite will be automatically run on any pull requests submitted to GitHub, as well as "make distcheck" and "./Build distcheck". +*** Add Coveralls integration with GitHub + + This means that test coverage analysis will be automatically be run + on any pull requests submitted to GitHub. + +*** Miscellaneous improvements to the test suite + + These include proper testing of the distinct impact of ~/.stowrc + and .stowrc in the directory from which Stow is invoked. + +*** Fix for test suite on Cygwin + + Thanks to Lucas Theisen for this fix! + +*** aclocal.m4 was updated using aclocal 1.15.1. + *** Miscellaneous fixes to the build and distribution process *** Improve handling of directories with unusual names diff --git a/bin/stow.in b/bin/stow.in index e33a4a6..1699bc0 100755 --- a/bin/stow.in +++ b/bin/stow.in @@ -515,14 +515,14 @@ sub main { #============================================================================ sub process_options { # Get cli options. - my ($cli_options, - $pkgs_to_unstow, + my ($cli_options, + $pkgs_to_unstow, $pkgs_to_stow) = parse_options(@ARGV); # Get the .stowrc options. # Note that rc_pkgs_to_unstow and rc_pkgs_to_stow are ignored. - my ($rc_options, - $rc_pkgs_to_unstow, + my ($rc_options, + $rc_pkgs_to_unstow, $rc_pkgs_to_stow) = get_config_file_options(); # Merge .stowrc and command line options. @@ -547,8 +547,8 @@ sub process_options { # Example: parse_options(@ARGV) # Returns : (\%options, \@pkgs_to_unstow, \@pkgs_to_stow) # Throws : a fatal error if a bad command line option is given -# Comments : Used for parsing both command line options and rc file. Used -# for parsing only. Sanity checks and post-processing belong in +# Comments : Used for parsing both command line options and rc file. Used +# for parsing only. Sanity checks and post-processing belong in # process_options(). #============================================================================ sub parse_options { @@ -614,6 +614,7 @@ sub parse_options { return (\%options, \@pkgs_to_unstow, \@pkgs_to_stow); } + sub sanitize_path_options { my ($options) = @_; diff --git a/t/rc_options.t b/t/rc_options.t index 419f8c3..593ff11 100755 --- a/t/rc_options.t +++ b/t/rc_options.t @@ -22,67 +22,144 @@ use strict; use warnings; -use Test::More tests => 23; +use Test::More tests => 33; use testutil; require 'stow'; -# stowrc file used for testing. -my $RC_FILE = "$TEST_DIR/.stowrc"; +# .stowrc files used for testing, relative to run_from/ +my $CWD_RC_FILE = ".stowrc"; +my $HOME_RC_FILE = "../.stowrc"; # Take the safe route and cowardly refuse to continue if there's -# already a file at $RC_FILE. -if (-e $RC_FILE) { - die "RC file location $RC_FILE already exists!\n"; +# already a file at $HOME_RC_FILE. +if (-e $HOME_RC_FILE) { + die "RC file location $HOME_RC_FILE already exists!\n"; } -# Define the variable that will be used to write stowrc. -my $rc_contents; +my ($options, $pkgs_to_delete, $pkgs_to_stow); # Init testing directory structure and overwrite ENV{HOME} to prevent -# squashing existing stowrc file. +# squashing existing .stowrc file. init_test_dirs(); # =========== RC Loading Tests =========== # Basic parsing and loading rc file tests. # ======================================== +my $orig_HOME = $ENV{HOME}; + # -# Test stowrc file with one options per line. +# Test no .stowrc file anywhere +# +delete $ENV{HOME}; +local @ARGV = ('dummy'); +cd("$TEST_DIR/run_from"); +($options, $pkgs_to_delete, $pkgs_to_stow) = process_options(); +is($options->{target}, "$ABS_TEST_DIR", "default --target with no .stowrc"); +is($options->{dir}, "$ABS_TEST_DIR/run_from", "default -d with no .stowrc"); + +# +# Test .stowrc file in cwd with relative paths, and $HOME not defined +# +make_file($CWD_RC_FILE, <{target}, "../target" + => "relative --target from \$PWD/.stowrc"); +is($options->{dir}, "../stow" + => "relative -d from \$PWD/.stowrc"); + +$ENV{HOME} = $orig_HOME; +remove_file($CWD_RC_FILE); + +# +# Test .stowrc file in cwd with absolute paths, and $HOME not defined +# +make_file($CWD_RC_FILE, <{target}, "$ABS_TEST_DIR/target" + => "absolute --target from \$PWD/.stowrc"); +is($options->{dir}, "$ABS_TEST_DIR/stow" + => "abs_test_dir -d from \$PWD/.stowrc"); + +$ENV{HOME} = $orig_HOME; +remove_file($CWD_RC_FILE); + +# +# Test ~/.stowrc file with one relative option per line. # local @ARGV = ('dummy'); -$rc_contents = <{target}, "$TEST_DIR/target", "rc options different lines"); -is($options->{dir}, "$TEST_DIR/stow", "rc options different lines"); + +($options, $pkgs_to_delete, $pkgs_to_stow) = process_options(); +is($options->{target}, "../target", "--target from \$HOME/.stowrc"); +is($options->{dir}, "../stow", "-d from \$HOME/.stowrc"); # -# Test that scalar cli option overwrites conflicting stowrc option. +# Test ~/.stowrc file with one absolute option per line. # -local @ARGV = ('-d', "$TEST_DIR/stow",'dummy'); -$rc_contents = <{target}, "$ABS_TEST_DIR/target" + => "--target from \$HOME/.stowrc"); +is($options->{dir}, "$ABS_TEST_DIR/stow" + => "-d from \$HOME/.stowrc"); + +# +# Test ~/.stowrc file is overridden by .stowrc in cwd. +# +local @ARGV = ('dummy'); +make_file($HOME_RC_FILE, <{target}, "$ABS_TEST_DIR/target" + => "--target overridden by \$PWD/.stowrc"); +is($options->{dir}, "$ABS_TEST_DIR/stow" + => "-d overridden \$PWD/.stowrc"); +unlink($CWD_RC_FILE) or die "Failed to unlink $CWD_RC_FILE"; + +# +# Test that scalar cli option overwrites conflicting ~/.stowrc option. +# +local @ARGV = ('-d', "$ABS_TEST_DIR/stow", 'dummy'); +make_file($HOME_RC_FILE, <{dir}, "$TEST_DIR/stow", "cli overwrite scalar rc option."); +is($options->{dir}, "$ABS_TEST_DIR/stow", "cli overwrite scalar rc option."); # -# Test that list cli option merges with conflicting stowrc option. -# Documentation states that stowrc options are prepended to cli options. +# Test that list cli option merges with conflicting .stowrc option. +# Documentation states that .stowrc options are prepended to cli options. # local @ARGV = ( '--defer=man', 'dummy' ); -$rc_contents = <{defer}, [qr(\Ainfo), qr(\Aman)], 'defer man and info'); @@ -98,8 +175,8 @@ is_deeply($options->{defer}, [qr(\Ainfo), qr(\Aman)], # Test environment variable expansion function. # # Basic expansion -is(expand_environment('$HOME/stow'), "$TEST_DIR/stow", 'expand $HOME'); -is(expand_environment('${HOME}/stow'), "$TEST_DIR/stow", 'expand ${HOME}'); +is(expand_environment('$HOME/stow'), "$ABS_TEST_DIR/stow", 'expand $HOME'); +is(expand_environment('${HOME}/stow'), "$ABS_TEST_DIR/stow", 'expand ${HOME}'); delete $ENV{UNDEFINED}; # just in case foreach my $var ('$UNDEFINED', '${UNDEFINED}') { @@ -135,19 +212,18 @@ is(expand_tilde('\~/path'), '~/path', 'escaped tilde'); # # Test that environment variable expansion is applied. # -$rc_contents = <<'HERE'; +make_file($HOME_RC_FILE, <<'HERE'); --dir=$HOME/stow --target=$HOME/stow --ignore=\$HOME --defer=\$HOME --override=\$HOME HERE -make_file($RC_FILE, $rc_contents); ($options, $pkgs_to_delete, $pkgs_to_stow) = get_config_file_options(); -is($options->{dir}, "$TEST_DIR/stow", - "apply environment expansion on stowrc --dir"); -is($options->{target}, "$TEST_DIR/stow", - "apply environment expansion on stowrc --target"); +is($options->{dir}, "$ABS_TEST_DIR/stow", + "apply environment expansion on \$HOME/.stowrc --dir"); +is($options->{target}, "$ABS_TEST_DIR/stow", + "apply environment expansion on \$HOME/.stowrc --target"); is_deeply($options->{ignore}, [qr(\$HOME\z)], "environment expansion not applied on --ignore"); is_deeply($options->{defer}, [qr(\A\$HOME)], @@ -158,28 +234,28 @@ is_deeply($options->{override}, [qr(\A\$HOME)], # # Test that tilde expansion is applied in correct places. # -$rc_contents = <<'HERE'; +make_file($HOME_RC_FILE, <<'HERE'); --dir=~/stow --target=~/stow --ignore=~/stow --defer=~/stow --override=~/stow HERE -make_file($RC_FILE, $rc_contents); ($options, $pkgs_to_delete, $pkgs_to_stow) = get_config_file_options(); -is($options->{dir}, "$TEST_DIR/stow", - "apply environment expansion on stowrc --dir"); -is($options->{target}, "$TEST_DIR/stow", - "apply environment expansion on stowrc --target"); +is($options->{dir}, "$ABS_TEST_DIR/stow", + "apply tilde expansion on \$HOME/.stowrc --dir"); +is($options->{target}, "$ABS_TEST_DIR/stow", + "apply tilde expansion on \$HOME/.stowrc --target"); is_deeply($options->{ignore}, [qr(~/stow\z)], - "environment expansion not applied on --ignore"); + "tilde expansion not applied on --ignore"); is_deeply($options->{defer}, [qr(\A~/stow)], - "environment expansion not applied on --defer"); + "tilde expansion not applied on --defer"); is_deeply($options->{override}, [qr(\A~/stow)], - "environment expansion not applied on --override"); + "tilde expansion not applied on --override"); +# # Clean up files used for testing. # -unlink $RC_FILE or die "Unable to clean up $RC_FILE.\n"; -remove_dir($TEST_DIR); +unlink $HOME_RC_FILE or die "Unable to clean up $HOME_RC_FILE.\n"; +remove_dir($ABS_TEST_DIR); diff --git a/t/testutil.pm b/t/testutil.pm index 3510ab5..ff1e6b4 100755 --- a/t/testutil.pm +++ b/t/testutil.pm @@ -36,19 +36,21 @@ use Stow::Util qw(parent canon_path); use base qw(Exporter); our @EXPORT = qw( + $ABS_TEST_DIR $TEST_DIR $stderr init_test_dirs cd new_Stow new_compat_Stow make_path make_link make_invalid_link make_file - remove_dir remove_link + remove_dir remove_file remove_link cat_file is_link is_dir_not_symlink is_nonexistent_path capture_stderr uncapture_stderr ); our $TEST_DIR = 'tmp-testing-trees'; +our $ABS_TEST_DIR = File::Spec->rel2abs('tmp-testing-trees'); our $stderr; my $tied_err; @@ -64,13 +66,17 @@ sub uncapture_stderr { } sub init_test_dirs { - for my $dir ("$TEST_DIR/target", "$TEST_DIR/stow") { - -d $dir and remove_tree($dir); - make_path($dir); + # Create a run_from/ subdirectory for tests which want to run + # from a separate directory outside the Stow directory or + # target directory. + for my $dir ("target", "stow", "run_from") { + my $path = "$TEST_DIR/$dir"; + -d $path and remove_tree($path); + make_path($path); } # Don't let user's ~/.stow-global-ignore affect test results - $ENV{HOME} = $TEST_DIR; + $ENV{HOME} = $ABS_TEST_DIR; } sub new_Stow { From e98fa1603aa690473c3874a8ce38a5914d8ab2ed Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Fri, 28 Jun 2019 17:04:40 +0100 Subject: [PATCH 299/482] rebuild META.* in preparation for 2.3.0 release --- META.json | 10 +++++----- META.yml | 8 ++++---- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/META.json b/META.json index dd806c9..d7cdd28 100644 --- a/META.json +++ b/META.json @@ -1,23 +1,22 @@ { - "abstract" : "manage the installation of multiple software packages", + "abstract" : "manage farms of symbolic links", "author" : [ "unknown" ], "dynamic_config" : 1, - "generated_by" : "Module::Build version 0.422", + "generated_by" : "Module::Build version 0.4224", "license" : [ "gpl_1" ], "meta-spec" : { "url" : "http://search.cpan.org/perldoc?CPAN::Meta::Spec", - "version" : "2" + "version" : 2 }, "name" : "Stow", "prereqs" : { "build" : { "requires" : { "IO::Scalar" : "0", - "Hash::Merge": "0", "Test::More" : "0", "Test::Output" : "0" } @@ -30,6 +29,7 @@ "runtime" : { "requires" : { "Carp" : "0", + "Hash::Merge" : "0", "IO::File" : "0", "perl" : "5.006" } @@ -57,5 +57,5 @@ } }, "version" : "v2.3.0", - "x_serialization_backend" : "JSON::PP version 2.27300" + "x_serialization_backend" : "JSON::PP version 4.00" } diff --git a/META.yml b/META.yml index 9bcbadb..ad00b1b 100644 --- a/META.yml +++ b/META.yml @@ -1,16 +1,15 @@ --- -abstract: 'manage the installation of multiple software packages' +abstract: 'manage farms of symbolic links' author: - unknown build_requires: IO::Scalar: '0' - Hash::Merge: '0' Test::More: '0' Test::Output: '0' configure_requires: Module::Build: '0' dynamic_config: 1 -generated_by: 'Module::Build version 0.422, CPAN::Meta::Converter version 2.150010' +generated_by: 'Module::Build version 0.4224, CPAN::Meta::Converter version 2.150010' license: gpl meta-spec: url: http://module-build.sourceforge.net/META-spec-v1.4.html @@ -25,6 +24,7 @@ provides: version: v2.3.0 requires: Carp: '0' + Hash::Merge: '0' IO::File: '0' perl: '5.006' resources: @@ -32,4 +32,4 @@ resources: license: http://www.gnu.org/licenses/gpl-2.0.html repository: git://git.savannah.gnu.org/stow.git version: v2.3.0 -x_serialization_backend: 'CPAN::Meta::YAML version 0.012' +x_serialization_backend: 'CPAN::Meta::YAML version 0.018' From ee57b1abc60844c1c5bacb8e92b5a28fdb189fc6 Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Fri, 28 Jun 2019 17:08:48 +0100 Subject: [PATCH 300/482] Make docker scripts use get-version --- build-docker.sh | 2 +- test-docker.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/build-docker.sh b/build-docker.sh index c8fab5e..59010ef 100755 --- a/build-docker.sh +++ b/build-docker.sh @@ -2,7 +2,7 @@ set -eu -version=$( git describe --match v* --abbrev=0 ) +version=$( tools/get-version ) imagename=stowtest image=$imagename:$version diff --git a/test-docker.sh b/test-docker.sh index 81e820e..f10456d 100755 --- a/test-docker.sh +++ b/test-docker.sh @@ -3,6 +3,6 @@ # Test Stow across multiple Perl versions, by executing the # Docker image built via build-docker.sh. -version=$( git describe --match v* --abbrev=0 ) +version=$( tools/get-version ) docker run --rm -it -v $(pwd):$(pwd) -w $(pwd) stowtest:$version From 71a8d5d42c7a6e5bba8d361355136831978f2520 Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Fri, 28 Jun 2019 17:12:18 +0100 Subject: [PATCH 301/482] Dockerfile: fix Debian jessie sources https://superuser.com/questions/1423486/issue-with-fetching-http-deb-debian-org-debian-dists-jessie-updates-inrelease --- docker/Dockerfile | 1 + 1 file changed, 1 insertion(+) diff --git a/docker/Dockerfile b/docker/Dockerfile index 1314a2d..137789a 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -17,6 +17,7 @@ # Run tests: (from stow src directory) # `docker run --rm -it -v $(pwd):$(pwd) -w $(pwd) stowtest` FROM debian:jessie +RUN printf "deb http://archive.debian.org/debian/ jessie main\ndeb-src http://archive.debian.org/debian/ jessie main\ndeb http://security.debian.org jessie/updates main\ndeb-src http://security.debian.org jessie/updates main" > /etc/apt/sources.list RUN DEBIAN_FRONTEND=noninteractive \ apt-get update -qq && \ apt-get install -y -q \ From ba243c0a610b5060ea5b20826cc643e1c5c97e0a Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Fri, 28 Jun 2019 20:21:41 +0100 Subject: [PATCH 302/482] Allow make to fail if missing modules for test dependencies e.g. make STRICT_TESTS=1 However we don't need this in .travis.yml as explained in the comments. --- .travis.yml | 2 ++ configure.ac | 5 ++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index f41c75f..cbd4ef6 100644 --- a/.travis.yml +++ b/.travis.yml @@ -15,7 +15,9 @@ before_install: install: - autoreconf --install - eval `perl -V:siteprefix` + # Note: this will complain Test::Output isn't yet installed: - ./configure --prefix=$siteprefix && make + # but that's OK because we install it here: - make cpanm script: - make distcheck diff --git a/configure.ac b/configure.ac index d22b1d4..699a88b 100644 --- a/configure.ac +++ b/configure.ac @@ -99,9 +99,12 @@ EOF ! ! Please (re-)read INSTALL, then install the missing modules ! and try again. -!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! +!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! EOF + if test -n "$STRICT_TESTS"; then + exit 1 + fi fi ]]) AC_SUBST([PMDIR]) From 5d667c3e71281068d7742f41cdfe13b53fd092d7 Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Fri, 28 Jun 2019 20:10:45 +0100 Subject: [PATCH 303/482] Make testing within Docker containers easier --- docker/run-stow-tests.sh | 38 +++++++++++++++++++++++++++++++++----- test-docker.sh | 31 ++++++++++++++++++++++++++++++- 2 files changed, 63 insertions(+), 6 deletions(-) diff --git a/docker/run-stow-tests.sh b/docker/run-stow-tests.sh index 416594c..121542c 100755 --- a/docker/run-stow-tests.sh +++ b/docker/run-stow-tests.sh @@ -22,11 +22,12 @@ . /usr/local/perlbrew/etc/bashrc # Standard safety protocol -set -euf -o pipefail +set -ef -o pipefail IFS=$'\n\t' -for p_version in $(perlbrew list | sed 's/ //g'); do - perlbrew use $p_version +test_perl_version () { + perl_version="$1" + perlbrew use $perl_version echo $(perl --version) @@ -40,6 +41,33 @@ for p_version in $(perlbrew list | sed 's/ //g'); do make distcheck perl Build.PL && ./Build build && cover -test ./Build distcheck -done +} -make distclean +if [[ -n "$LIST_PERL_VERSIONS" ]]; then + echo "Listing Perl versions available from perlbrew ..." + perlbrew list +elif [[ -z "$PERL_VERSION" ]]; then + echo "Testing all versions ..." + for perl_version in $(perlbrew list | sed 's/ //g'); do + test_perl_version $perl_version + done + make distclean +else + echo "Testing with Perl $PERL_VERSION" + # Test a specific version requested via $PERL_VERSION environment + # variable. Make sure set -e doesn't cause us to bail on failure + # before we start an interactive shell. + test_perl_version $PERL_VERSION || : + # N.B. Don't distclean since we probably want to debug this Perl + # version interactively. + cat < Date: Fri, 28 Jun 2019 21:20:22 +0100 Subject: [PATCH 304/482] make maintainer-clean remove cover_db/ --- Makefile.am | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile.am b/Makefile.am index 9917653..a6311d4 100644 --- a/Makefile.am +++ b/Makefile.am @@ -105,7 +105,7 @@ MAINTAINERCLEANFILES = $(dist_man_MANS) $(HTML) $(PDF) ChangeLog clean-local: -rm -rf $(TESTS_OUT) maintainer-clean-local: - -rm -rf doc/manual-split + -rm -rf doc/manual-split cover_db # this is more explicit and reliable than the config file trick edit = sed -e 's|[@]PERL[@]|$(PERL)|g' \ From 00c92076d906f9dab665ac547ed9fca6fd7dbc67 Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Fri, 28 Jun 2019 21:11:58 +0100 Subject: [PATCH 305/482] Use Clone backend for Hash::Merge, not Storable Need to avoid Storable backend, since it can't deal with regexps: https://rt.perl.org/Public/Bug/Display.html?id=50608 This should fix the Docker builds. --- Build.PL | 1 + META.json | 1 + META.yml | 1 + bin/stow.in | 5 ++++- 4 files changed, 7 insertions(+), 1 deletion(-) diff --git a/Build.PL b/Build.PL index 6e4c553..06e57ab 100644 --- a/Build.PL +++ b/Build.PL @@ -61,6 +61,7 @@ my $build = Module::Build->new( 'Carp' => 0, 'IO::File' => 0, 'Hash::Merge' => 0, + 'Clone' => 0, }, script_files => [ 'bin/stow', 'bin/chkstow' ], all_from => 'lib/Stow.pm.in', diff --git a/META.json b/META.json index d7cdd28..1a9e06f 100644 --- a/META.json +++ b/META.json @@ -29,6 +29,7 @@ "runtime" : { "requires" : { "Carp" : "0", + "Clone" : "0", "Hash::Merge" : "0", "IO::File" : "0", "perl" : "5.006" diff --git a/META.yml b/META.yml index ad00b1b..0215317 100644 --- a/META.yml +++ b/META.yml @@ -24,6 +24,7 @@ provides: version: v2.3.0 requires: Carp: '0' + Clone: '0' Hash::Merge: '0' IO::File: '0' perl: '5.006' diff --git a/bin/stow.in b/bin/stow.in index 1699bc0..355bbc9 100755 --- a/bin/stow.in +++ b/bin/stow.in @@ -462,7 +462,10 @@ use Getopt::Long qw(GetOptionsFromArray); use Stow; use Stow::Util qw(parent error); -use Hash::Merge qw( merge ); +# Need to avoid Storable backend, since it can't deal with regexps: +# https://rt.perl.org/Public/Bug/Display.html?id=50608 +use Clone::Choose qw(:Clone); +use Hash::Merge qw(merge); my $ProgramName = $0; $ProgramName =~ s{.*/}{}; From 8b2123847df7e48ed65d5f54283b2506b789da4c Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Fri, 28 Jun 2019 23:54:30 +0100 Subject: [PATCH 306/482] Split perlbrew install-multiple into separate RUN cmd This allows changing which Perls are used etc. without re-bootstrapping perlbrew. --- docker/Dockerfile | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docker/Dockerfile b/docker/Dockerfile index 137789a..ec8f089 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -43,9 +43,9 @@ ENV HOME=/root \ PERLBREW_PATH=/usr/local/perlbrew/bin RUN mkdir -p /usr/local/perlbrew /root \ && perlbrew init \ - && perlbrew install-cpanm \ - && perlbrew install-patchperl \ - && perlbrew install-multiple -j 4 --notest \ + && perlbrew install-cpanm \ + && perlbrew install-patchperl +RUN perlbrew install-multiple -j 4 --notest \ perl-5.22.2 \ perl-5.20.3 \ perl-5.18.4 \ From cef930852ce9c736367d90ef35c36839f5fd4d4c Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Sat, 29 Jun 2019 00:36:00 +0100 Subject: [PATCH 307/482] HOWTO-RELEASE: Fix git tag command --- doc/HOWTO-RELEASE | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/HOWTO-RELEASE b/doc/HOWTO-RELEASE index a5dd55f..616bea9 100644 --- a/doc/HOWTO-RELEASE +++ b/doc/HOWTO-RELEASE @@ -69,7 +69,7 @@ Release procedure - At this point we have a release candidate. Tag the current git HEAD with the new version number: - git tag -s $version -m "Release $version" + git tag -s v$version -m "Release $version" - Run ./Build dist From 872ec96350261ed3cadc713062842df851a21257 Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Sat, 29 Jun 2019 00:55:51 +0100 Subject: [PATCH 308/482] HOWTO-RELEASE: Fix cvs commit command for docs --- doc/HOWTO-RELEASE | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/HOWTO-RELEASE b/doc/HOWTO-RELEASE index 616bea9..0a21ace 100644 --- a/doc/HOWTO-RELEASE +++ b/doc/HOWTO-RELEASE @@ -111,7 +111,7 @@ Release procedure # Check that the changes look OK cvs diff # Then commit - cvs commit -m 'Update manual to v7.8.9' + cvs commit -m "Update manual to v$version" - Upload to ftp.gnu.org. This is easiest using gnupload: From 8d0a46cc88fbcc2eced3654a6af178cee517a325 Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Fri, 28 Jun 2019 23:48:37 +0100 Subject: [PATCH 309/482] Set DISTCLEANFILES to clean up more Docker generates a whole bunch of files as root. --- Makefile.am | 1 + 1 file changed, 1 insertion(+) diff --git a/Makefile.am b/Makefile.am index a6311d4..7748399 100644 --- a/Makefile.am +++ b/Makefile.am @@ -99,6 +99,7 @@ EXTRA_DIST = \ $(DEFAULT_IGNORE_LIST) \ $(CPAN_FILES) CLEANFILES = $(bin_SCRIPTS) $(pm_DATA) $(pmstow_DATA) +DISTCLEANFILES = Makefile.in configure Build MYMETA.* MAINTAINERCLEANFILES = $(dist_man_MANS) $(HTML) $(PDF) ChangeLog # clean up auto-generated files From 94175829b952847b6e73a33e6e523e4bd2587f98 Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Sat, 29 Jun 2019 01:12:36 +0100 Subject: [PATCH 310/482] Make NEWS export to text better Run org-convert-to-odd-levels on NEWS and set local variables so that sections can easily be exported for release announcements. --- NEWS | 652 +++++++++++++++++++++++----------------------- doc/HOWTO-RELEASE | 5 + 2 files changed, 332 insertions(+), 325 deletions(-) diff --git a/NEWS b/NEWS index 4eae54d..e587f72 100644 --- a/NEWS +++ b/NEWS @@ -2,545 +2,547 @@ News file for Stow. * Changes in version 2.3.0 -** New features / changes in behaviour +*** New features / changes in behaviour -*** New --dotfiles option +***** New --dotfiles option - Enable special handling for "dotfiles" (files or folders whose name - begins with a period) in the package directory. If this option is - enabled, Stow will add a preprocessing step for each file or folder - whose name begins with "dot-", and replace the "dot-" prefix in the - name by a period ("."). This is useful when Stow is used to manage - collections of dotfiles, to avoid having a package directory full - of hidden files. + Enable special handling for "dotfiles" (files or folders whose name + begins with a period) in the package directory. If this option is + enabled, Stow will add a preprocessing step for each file or folder + whose name begins with "dot-", and replace the "dot-" prefix in the + name by a period ("."). This is useful when Stow is used to manage + collections of dotfiles, to avoid having a package directory full + of hidden files. - For example, suppose we have a package containing two files, - stow/dot-bashrc and stow/dot-emacs.d/init.el. With this option, - Stow will create symlinks from .bashrc to stow/dot-bashrc and from - .emacs.d/init.el to stow/dot-emacs.d/init.el. Any other files, - whose name does not begin with "dot-", will be processed as usual. + For example, suppose we have a package containing two files, + stow/dot-bashrc and stow/dot-emacs.d/init.el. With this option, + Stow will create symlinks from .bashrc to stow/dot-bashrc and from + .emacs.d/init.el to stow/dot-emacs.d/init.el. Any other files, + whose name does not begin with "dot-", will be processed as usual. - Thanks to Joris Vankerschaver for this feature! + Thanks to Joris Vankerschaver for this feature! -*** Shell-like expansion in .stowrc files +***** Shell-like expansion in .stowrc files - For options within .stowrc files which describe file paths, "~" can - be included to expand to the current value of $HOME, and - environment variables can be referenced e.g. via "$FOO" or - "${FOO}". To prevent expansion, escape with a backslash. + For options within .stowrc files which describe file paths, "~" can + be included to expand to the current value of $HOME, and + environment variables can be referenced e.g. via "$FOO" or + "${FOO}". To prevent expansion, escape with a backslash. - Thanks a lot to Charles LeDoux for his diligent work on this - feature! + Thanks a lot to Charles LeDoux for his diligent work on this + feature! -*** chkstow now honours the $STOW_DIR environment variable +***** chkstow now honours the $STOW_DIR environment variable - The stow script already honoured the $STOW_DIR environment - variable. Now chkstow does too, for consistency. + The stow script already honoured the $STOW_DIR environment + variable. Now chkstow does too, for consistency. -*** Stow now has a non-zero exit code if option parsing failed +***** Stow now has a non-zero exit code if option parsing failed - Thanks to Brice Waegeneire for reporting this. + Thanks to Brice Waegeneire for reporting this. -** Documentation fixes and enhancements +*** Documentation fixes and enhancements -*** Remove dependency on unmaintained texi2html +***** Remove dependency on unmaintained texi2html - The dependency on the ancient and unmaintained texi2html for - building the single-page HTML version of the manual has been - removed, since it was difficult to get running on most distros - other than openSUSE. + The dependency on the ancient and unmaintained texi2html for + building the single-page HTML version of the manual has been + removed, since it was difficult to get running on most distros + other than openSUSE. - Instead use the more modern "makeinfo --html --no-split" approach. - Rules have been kept for posterity in the Makefile for the old - approach and also an "in-between" approach based on texi2any; - however these are not triggered by default. Run + Instead use the more modern "makeinfo --html --no-split" approach. + Rules have been kept for posterity in the Makefile for the old + approach and also an "in-between" approach based on texi2any; + however these are not triggered by default. Run - make manual-single-html-all + make manual-single-html-all - to compare the three versions. + to compare the three versions. -*** Fixed naming of man page +***** Fixed naming of man page - The title of the generated man page was previously ending up as - something like: + The title of the generated man page was previously ending up as + something like: - IO::FILE=IO(0XA719C0)(1) + IO::FILE=IO(0XA719C0)(1) - Thanks to @Corin-EU on GitHub highlighting this and proposing a - fix. + Thanks to @Corin-EU on GitHub highlighting this and proposing a + fix. -*** Convert README and INSTALL to Markdown +***** Convert README and INSTALL to Markdown - They are now named README.md and INSTALL.md, and render nicely - when viewed via git hosting services which support Markdown. + They are now named README.md and INSTALL.md, and render nicely + when viewed via git hosting services which support Markdown. -*** Update documentation to reflect more modern use cases +***** Update documentation to reflect more modern use cases - The README.md, stow(8) man page, and info manual have been updated - to de-emphasise the package management use, since these days almost - everyone prefers to use modern package managers such as rpm / dpkg - / Nix for (system-wide) package management. + The README.md, stow(8) man page, and info manual have been updated + to de-emphasise the package management use, since these days almost + everyone prefers to use modern package managers such as rpm / dpkg + / Nix for (system-wide) package management. - To compensate, more popular modern use cases for Stow have been - added, such as management of dotfiles and software compiled in the - user's $HOME directory. + To compensate, more popular modern use cases for Stow have been + added, such as management of dotfiles and software compiled in the + user's $HOME directory. -*** Miscellaneous documentation fixes +***** Miscellaneous documentation fixes - - Various typos were fixed. + - Various typos were fixed. - - The documentation for --verbose was updated to indicate that - verbosity levels now go up to 5. + - The documentation for --verbose was updated to indicate that + verbosity levels now go up to 5. - - Erroneous glob examples in the --ignore documentation were fixed. + - Erroneous glob examples in the --ignore documentation were fixed. - - The abbreviation "regex" was removed from the info manual for - consistency. + - The abbreviation "regex" was removed from the info manual for + consistency. - - INSTALL.md now also documents how to build directly from git. -** Fixes for bugs, tests, and other technical debt + - INSTALL.md now also documents how to build directly from git. +*** Fixes for bugs, tests, and other technical debt -*** Add Docker files for convenient testing across multiple Perl versions +***** Add Docker files for convenient testing across multiple Perl versions - This is the first release which has been tested across 5 different - versions of Perl prior to release! The versions are: + This is the first release which has been tested across 5 different + versions of Perl prior to release! The versions are: - perl-5.22.2 - perl-5.20.3 - perl-5.18.4 - perl-5.16.3 - perl-5.14.4 + perl-5.22.2 + perl-5.20.3 + perl-5.18.4 + perl-5.16.3 + perl-5.14.4 - Thanks to Charles LeDoux for this! + Thanks to Charles LeDoux for this! -*** Set up continuous testing via Travis CI +***** Set up continuous testing via Travis CI - This means that the test suite will be automatically run on any - pull requests submitted to GitHub, as well as "make distcheck" - and "./Build distcheck". + This means that the test suite will be automatically run on any + pull requests submitted to GitHub, as well as "make distcheck" + and "./Build distcheck". -*** Add Coveralls integration with GitHub +***** Add Coveralls integration with GitHub - This means that test coverage analysis will be automatically be run - on any pull requests submitted to GitHub. + This means that test coverage analysis will be automatically be run + on any pull requests submitted to GitHub. -*** Miscellaneous improvements to the test suite +***** Miscellaneous improvements to the test suite - These include proper testing of the distinct impact of ~/.stowrc - and .stowrc in the directory from which Stow is invoked. + These include proper testing of the distinct impact of ~/.stowrc + and .stowrc in the directory from which Stow is invoked. -*** Fix for test suite on Cygwin +***** Fix for test suite on Cygwin - Thanks to Lucas Theisen for this fix! + Thanks to Lucas Theisen for this fix! -*** aclocal.m4 was updated using aclocal 1.15.1. +***** aclocal.m4 was updated using aclocal 1.15.1. -*** Miscellaneous fixes to the build and distribution process +***** Miscellaneous fixes to the build and distribution process -*** Improve handling of directories with unusual names +***** Improve handling of directories with unusual names - Various fixes for corner cases where directories are named "0" - or begin with a space character, or where STOW_DIR is empty. + Various fixes for corner cases where directories are named "0" + or begin with a space character, or where STOW_DIR is empty. - Thanks to Cuong Manh Le for highlighting some of the issues and - proposing fixes! + Thanks to Cuong Manh Le for highlighting some of the issues and + proposing fixes! * Changes in version 2.2.2 -** @VERSION@ substitution was set up for the Stow::Util module. +*** @VERSION@ substitution was set up for the Stow::Util module. * Changes in version 2.2.1 Version 2.2.1 was not released since it was rejected by pause.perl.org due to Stow::Util missing $VERSION. -** Small improvements to documentation +*** Small improvements to documentation -*** The README has been revamped. +***** The README has been revamped. -*** Some index points have been added to the manual. +***** Some index points have been added to the manual. -*** Some typos were fixed. +***** Some typos were fixed. -*** @VERSION@ substitution was fixed in the stow(8) man page. +***** @VERSION@ substitution was fixed in the stow(8) man page. -** Fix Perl warnings +*** Fix Perl warnings - Stow no longer emits "v-string in use/require non-portable" and - "Possible precedence issue with control flow operator" warnings - with newer Perl versions. See https://savannah.gnu.org/bugs/?36478 - and http://lists.gnu.org/archive/html/bug-stow/2014-06/msg00000.html - for full details. + Stow no longer emits "v-string in use/require non-portable" and + "Possible precedence issue with control flow operator" warnings + with newer Perl versions. See https://savannah.gnu.org/bugs/?36478 + and http://lists.gnu.org/archive/html/bug-stow/2014-06/msg00000.html + for full details. -** Fix "Undefined subroutine &main::error" error +*** Fix "Undefined subroutine &main::error" error - See https://rt.cpan.org/Public/Bug/Display.html?id=75349 for details. + See https://rt.cpan.org/Public/Bug/Display.html?id=75349 for details. -** Failed system calls now include error description +*** Failed system calls now include error description - This should make errors easier to understand. + This should make errors easier to understand. -** Default ignore list now ignores top-level README.*, LICENSE.*, and COPYING +*** Default ignore list now ignores top-level README.*, LICENSE.*, and COPYING - These files are by definition specific to a given package, so if - they exist in the top-level directory, they should not be stowed. + These files are by definition specific to a given package, so if + they exist in the top-level directory, they should not be stowed. -** Correctly handle the stow/target directories as non-canonical paths +*** Correctly handle the stow/target directories as non-canonical paths - Fix the case discovered by Hiroyuki Iwatsuki where stowing fails if - the stow / target directories are non-canonical paths. For - example, on FreeBSD /home is a symlink pointing to 'usr/home', so - running with the stow directory as /home/user/local/stow and the - target directory as /home/user/local previously resulted in the - stow directory path being calculated as - ../../../usr/home/user/local/stow relative to the target. + Fix the case discovered by Hiroyuki Iwatsuki where stowing fails if + the stow / target directories are non-canonical paths. For + example, on FreeBSD /home is a symlink pointing to 'usr/home', so + running with the stow directory as /home/user/local/stow and the + target directory as /home/user/local previously resulted in the + stow directory path being calculated as + ../../../usr/home/user/local/stow relative to the target. - See http://article.gmane.org/gmane.comp.gnu.stow.bugs/8820 for details. + See http://article.gmane.org/gmane.comp.gnu.stow.bugs/8820 for details. -** Fix stowing of relative links when --no-folding is used. +*** Fix stowing of relative links when --no-folding is used. - With a tree like this: + With a tree like this: - . - |-- stow - | `-- pkg - | `-- lib - | |-- itk-current -> itk4.0.0 - | `-- itk4.0.0 - | `-- libitk4.0.0.so - `-- target - `-- lib - |-- itk4.0.0 -> ../../stow/pkg/lib/itk4.0.0 - `-- libfoo-1.2.3.so + . + |-- stow + | `-- pkg + | `-- lib + | |-- itk-current -> itk4.0.0 + | `-- itk4.0.0 + | `-- libitk4.0.0.so + `-- target + `-- lib + |-- itk4.0.0 -> ../../stow/pkg/lib/itk4.0.0 + `-- libfoo-1.2.3.so - stowing pkg with the --no-folding option resulted in itk-current - being "unpacked": + stowing pkg with the --no-folding option resulted in itk-current + being "unpacked": - . - `-- target - `-- lib - |-- itk-current - | `-- libitk4.0.0.so -> ../../../stow/pkg/lib/itk-current/libitk4.0.0.so - |-- itk4.0.0 - | `-- libitk4.0.0.so -> ../../../stow/pkg/lib/itk4.0.0/libitk4.0.0.so - `-- libfoo-1.2.3.so + . + `-- target + `-- lib + |-- itk-current + | `-- libitk4.0.0.so -> ../../../stow/pkg/lib/itk-current/libitk4.0.0.so + |-- itk4.0.0 + | `-- libitk4.0.0.so -> ../../../stow/pkg/lib/itk4.0.0/libitk4.0.0.so + `-- libfoo-1.2.3.so - This commit fixes it so that it gets stowed as a symlink: + This commit fixes it so that it gets stowed as a symlink: - . - `-- target - `-- lib - ... - |-- itk-current -> ../../stow/pkg/lib/itk-current - ... + . + `-- target + `-- lib + ... + |-- itk-current -> ../../stow/pkg/lib/itk-current + ... - Thanks to Gabriele Balducci for reporting this problem: + Thanks to Gabriele Balducci for reporting this problem: - http://thread.gmane.org/gmane.comp.gnu.stow.general/6676 + http://thread.gmane.org/gmane.comp.gnu.stow.general/6676 -** Internal code cleanups +*** Internal code cleanups -*** aclocal was updated. +***** aclocal was updated. -*** automake files were removed. +***** automake files were removed. -*** Trailing whitespace was removed. +***** Trailing whitespace was removed. -*** Comments were added. +***** Comments were added. -*** Debug messages were improved. +***** Debug messages were improved. * Changes in version 2.2.0 -** New --no-folding option +*** New --no-folding option - Disables folding of newly stowed directories when stowing, and - refolding of newly foldable directories when unstowing. + Disables folding of newly stowed directories when stowing, and + refolding of newly foldable directories when unstowing. -** Remove -a option (--adopt still available) +*** Remove -a option (--adopt still available) - As --adopt is the only option which allows stow to modify files, it - is considered potentially dangerous (especially for stow package - directories which are not managed by a version control system). - Therefore it seems prudent to require a bit more effort from the - user to enable this option, minimising the change of enabling it - via a typo. + As --adopt is the only option which allows stow to modify files, it + is considered potentially dangerous (especially for stow package + directories which are not managed by a version control system). + Therefore it seems prudent to require a bit more effort from the + user to enable this option, minimising the change of enabling it + via a typo. -** Improve error message when stow package is not found. +*** Improve error message when stow package is not found. - The error message displayed a path to the missing stow package - which was relative to the target directory rather than the cwd, - which was confusing for the user. + The error message displayed a path to the missing stow package + which was relative to the target directory rather than the cwd, + which was confusing for the user. -** Test suite improvements +*** Test suite improvements - The test suite has been tightened up slightly. + The test suite has been tightened up slightly. -** Documentation improvements +*** Documentation improvements - Various fixes and cosmetic improvements have been made in the manual. + Various fixes and cosmetic improvements have been made in the manual. -** Remove "There are no outstanding operations to perform" warning. +*** Remove "There are no outstanding operations to perform" warning. * Changes in version 2.1.3 -** New --adopt / -a option +*** New --adopt / -a option - This allows plain files in the target to be "adopted" into the - package being stowed. See the manual has more details. + This allows plain files in the target to be "adopted" into the + package being stowed. See the manual has more details. -** ./configure now checks for Perl modules required by the test suite. +*** ./configure now checks for Perl modules required by the test suite. * Changes in version 2.1.2 Many thanks to Stefano Lattarini for help with numerous autoconf and automake issues which are addressed in this release. -** Significantly improve the handling of --with-pmdir. +*** Significantly improve the handling of --with-pmdir. -*** Calculation of the default value for --with-pmdir is now done safely in Perl. +***** Calculation of the default value for --with-pmdir is now done safely in Perl. - Previously non-POSIX-compliant shells could cause issues. + Previously non-POSIX-compliant shells could cause issues. -*** The output of ./configure and make are now much more helpful. +***** The output of ./configure and make are now much more helpful. -*** The Makefile will now check whether pmdir is in Perl's built-in @INC. +***** The Makefile will now check whether pmdir is in Perl's built-in @INC. - If not, it will insert a + If not, it will insert a - use lib "..."; + use lib "..."; - line into the generated stow script to ensure that it can always - locate the Perl modules without needing to manually set PERL5LIB. + line into the generated stow script to ensure that it can always + locate the Perl modules without needing to manually set PERL5LIB. -*** Updated INSTALL and HOWTO-RELEASE accordingly. +***** Updated INSTALL and HOWTO-RELEASE accordingly. -** ./configure now aborts if Perl isn't found. +*** ./configure now aborts if Perl isn't found. -** Ensured the ChangeLog is up-to-date when making a new distribution. +*** Ensured the ChangeLog is up-to-date when making a new distribution. -** Fixed bug with `make clean' removing files which the user may not be able to rebuild. +*** Fixed bug with `make clean' removing files which the user may not be able to rebuild. * Changes in version 2.1.1 -** Fixed bug where ./configure --with-pmdir=X was ineffectual. +*** Fixed bug where ./configure --with-pmdir=X was ineffectual. -** Calculated the correct default value for pmdir based on the local Perl installation. +*** Calculated the correct default value for pmdir based on the local Perl installation. -** Fixed some automake issues (thanks to Stefano Lattarini for spotting these!) +*** Fixed some automake issues (thanks to Stefano Lattarini for spotting these!) -** Improved various bits of documentation. +*** Improved various bits of documentation. * Changes in version 2.1.0 -** Major refactoring of code into separate Stow and Stow::Util Perl modules. +*** Major refactoring of code into separate Stow and Stow::Util Perl modules. -** Added support for ignore list files. +*** Added support for ignore list files. -** Added support for CPAN-style installation and distribution via Module::Build. +*** Added support for CPAN-style installation and distribution via Module::Build. -** Introduced `make test' target and significantly tightened up test suite. +*** Introduced `make test' target and significantly tightened up test suite. -** Very large number of code and documentation fixes (over 80 commits since version 2.0.1). +*** Very large number of code and documentation fixes (over 80 commits since version 2.0.1). -** The '--conflicts' option has been removed. +*** The '--conflicts' option has been removed. - Stow will always show conflicts if they are found during the scanning - phase. + Stow will always show conflicts if they are found during the scanning + phase. -** Improved debugging output. +*** Improved debugging output. -** Converted man page to POD format. +*** Converted man page to POD format. -** Include PDF, and both split- and single-page HTML versions of manual in the distribution. +*** Include PDF, and both split- and single-page HTML versions of manual in the distribution. -** Fixed code style consistency issues. +*** Fixed code style consistency issues. -** Running configure from outside the source tree now works. +*** Running configure from outside the source tree now works. -** `make distcheck' now works. +*** `make distcheck' now works. * Changes in version 2.0.1 -** Defer operations until all potential conflicts have been assessed. +*** Defer operations until all potential conflicts have been assessed. - We do this by traversing the installation image(s) and recording the - actions that need to be performed. Redundant actions are factored out, - e.g., we don't want to create a link that we will later remove in order to - create a directory. Benefits of this approach: + We do this by traversing the installation image(s) and recording the + actions that need to be performed. Redundant actions are factored out, + e.g., we don't want to create a link that we will later remove in order to + create a directory. Benefits of this approach: - 1. Get to see _all_ the conflicts that are blocking an installation: - you don't have to deal with them one at a time. - 2. No operations are be performed if _any_ conflicts are detected: - a failed stow will not leave you with a partially installed - package. - 3. Minimises the set of operations that need to be performed. - 4. Operations are executed as a batch which is much faster - This can be an advantage when upgrading packages on a live system - where you want to minimise the amount of time when the package is - unavailable. + 1. Get to see _all_ the conflicts that are blocking an installation: + you don't have to deal with them one at a time. + 2. No operations are be performed if _any_ conflicts are detected: + a failed stow will not leave you with a partially installed + package. + 3. Minimises the set of operations that need to be performed. + 4. Operations are executed as a batch which is much faster + This can be an advantage when upgrading packages on a live system + where you want to minimise the amount of time when the package is + unavailable. -** The above fixes the false conflict problem mentioned in the info file. +*** The above fixes the false conflict problem mentioned in the info file. -** It also fixes the two bugs mentioned in the man page. +*** It also fixes the two bugs mentioned in the man page. -** Multiple stow directories will now cooperate in folding/unfolding. +*** Multiple stow directories will now cooperate in folding/unfolding. -** Conflict messages are more uniform and informative. +*** Conflict messages are more uniform and informative. -** Verbosity and tracing is more extensive and uniform. +*** Verbosity and tracing is more extensive and uniform. -** Implemented option parsing via Getopt::Long. +*** Implemented option parsing via Getopt::Long. -** Default command line arguments set via '.stowrc' and '~/.stowrc' files. +*** Default command line arguments set via '.stowrc' and '~/.stowrc' files. - Contents of these files are parsed as though they occurred first on - the command line. + Contents of these files are parsed as though they occurred first on + the command line. -** Support multiple actions per invocation. +*** Support multiple actions per invocation. - In order for this to work, we had to add a new (optional) command line arg - (-S) to specify packages to stow. For example, to update an installation - of emacs you can now do + In order for this to work, we had to add a new (optional) command line arg + (-S) to specify packages to stow. For example, to update an installation + of emacs you can now do - stow -D emacs-21.3 -S emacs-21.4a + stow -D emacs-21.3 -S emacs-21.4a - which will replace emacs-21.3 with emacs-21.4a. - You can mix and match any number of actions, e.g., + which will replace emacs-21.3 with emacs-21.4a. + You can mix and match any number of actions, e.g., - stow -S p1 p2 -D p3 p4 -S p5 -R p6 + stow -S p1 p2 -D p3 p4 -S p5 -R p6 - will unstow p3, p4 and p6, then stow p1, p2, p5 and p6. + will unstow p3, p4 and p6, then stow p1, p2, p5 and p6. -** New (repeatable) command line arg: --ignore='' +*** New (repeatable) command line arg: --ignore='' - This suppresses operating on a file matching the regex (suffix), - e.g. + This suppresses operating on a file matching the regex (suffix), + e.g. - --ignore='~' --ignore='\.#.*' + --ignore='~' --ignore='\.#.*' - will ignore emacs and CVS backup files (suitable for ~/.stowrc file). + will ignore emacs and CVS backup files (suitable for ~/.stowrc file). - (I opted for Perl regular expressions because they are more - powerful and easier to implement). + (I opted for Perl regular expressions because they are more + powerful and easier to implement). -** New (repeatable) command line arg: --defer='' +*** New (repeatable) command line arg: --defer='' - This defers stowing a file matching the regex (prefix) if that file - is already stowed to a different package, e.g., + This defers stowing a file matching the regex (prefix) if that file + is already stowed to a different package, e.g., - --defer='man' --defer='info' + --defer='man' --defer='info' - will cause stow to skip over pre-existing man and info pages. + will cause stow to skip over pre-existing man and info pages. - Equivalently, you could use --defer='man|info' since the argument - is just a Perl regex. + Equivalently, you could use --defer='man|info' since the argument + is just a Perl regex. -** New (repeatable) command line arg: --override='' +*** New (repeatable) command line arg: --override='' - This forces a file matching the regex (prefix) to be stowed even if - the file is already stowed to a different package, e.g. + This forces a file matching the regex (prefix) to be stowed even if + the file is already stowed to a different package, e.g. - --override='man' --override='info' + --override='man' --override='info' - will unstow any pre-existing man and info pages that would conflict - with the file we are trying to stow. + will unstow any pre-existing man and info pages that would conflict + with the file we are trying to stow. - Equivalently, you could use --override='man|info' since the - argument is just a Perl regex. + Equivalently, you could use --override='man|info' since the + argument is just a Perl regex. -** The above gives the ability to manage packages with common content. +*** The above gives the ability to manage packages with common content. - For example, man pages that are shared by a number of CPAN - packages. Using multiple stow directories and .stowrc files can - also simplify things. In our setup we use the standard - /usr/local/stow directory for packages to be installed in - /usr/local. Since we install a large number of extra Perl packages - (currently about 300) we use an additional stow directory: - /usr/local/stow/perl-5.8.8-extras. Both stow directories contain a - '.stow' file so that they collaborate appropriately. I then use - the following .stowrc file in /usr/local/stow/perl-5.8.8-extras + For example, man pages that are shared by a number of CPAN + packages. Using multiple stow directories and .stowrc files can + also simplify things. In our setup we use the standard + /usr/local/stow directory for packages to be installed in + /usr/local. Since we install a large number of extra Perl packages + (currently about 300) we use an additional stow directory: + /usr/local/stow/perl-5.8.8-extras. Both stow directories contain a + '.stow' file so that they collaborate appropriately. I then use + the following .stowrc file in /usr/local/stow/perl-5.8.8-extras - --dir=/usr/local/stow/perl-5.8.8-extras - --target=/usr/local - --override=bin - --override=man - --ignore='perllocal\.pod' - --ignore='\.packlist' - --ignore='\.bs' + --dir=/usr/local/stow/perl-5.8.8-extras + --target=/usr/local + --override=bin + --override=man + --ignore='perllocal\.pod' + --ignore='\.packlist' + --ignore='\.bs' - When I stow packages from there, they automatically override any - man pages and binaries that may already have been stowed by another - package or by the core perl-5.8.8 installation. For example, if - you want to upgrade the Test-Simple package, you need to override - all the man pages that would have been installed by the core - package. If you are upgrading CPAN, you will also have to override - the pre-existing cpan executable. + When I stow packages from there, they automatically override any + man pages and binaries that may already have been stowed by another + package or by the core perl-5.8.8 installation. For example, if + you want to upgrade the Test-Simple package, you need to override + all the man pages that would have been installed by the core + package. If you are upgrading CPAN, you will also have to override + the pre-existing cpan executable. -** By default, search less aggressively for invalid symlinks when unstowing. +*** By default, search less aggressively for invalid symlinks when unstowing. - That is, we only search for bad symlinks in the directories - explicitly mentioned in the installation image, and do not dig down - into other subdirs. Digging down into other directories can be - very time consuming if you have a really big tree (like with a - couple of Oracle installations lying around). In general the old - behaviour is only necessary when you have really stuffed up your - installation by deleting a directory that has already been stowed. - Doing that on a live system is somewhat crazy and hopefully rare. - We provide an option '-p|--compat' to enable the old behaviour for - those needing to patch up mistakes. + That is, we only search for bad symlinks in the directories + explicitly mentioned in the installation image, and do not dig down + into other subdirs. Digging down into other directories can be + very time consuming if you have a really big tree (like with a + couple of Oracle installations lying around). In general the old + behaviour is only necessary when you have really stuffed up your + installation by deleting a directory that has already been stowed. + Doing that on a live system is somewhat crazy and hopefully rare. + We provide an option '-p|--compat' to enable the old behaviour for + those needing to patch up mistakes. -** New chkstow utility for checking the integrity of the target directory. +*** New chkstow utility for checking the integrity of the target directory. -** Implement a test suite and support code. +*** Implement a test suite and support code. - This was built before implementing any of the extra features so I - could more easily check for equivalent functionality. The initial - code base had to be refactored substantially to allow for testing. - The test suite is not exhaustive, but it should provide enough to - check for regressions. + This was built before implementing any of the extra features so I + could more easily check for equivalent functionality. The initial + code base had to be refactored substantially to allow for testing. + The test suite is not exhaustive, but it should provide enough to + check for regressions. * Changes in version 1.3.3 -** Now requires Perl 5.005 or later +*** Now requires Perl 5.005 or later -** Initially empty directories are not removed anymore +*** Initially empty directories are not removed anymore -** Removed buggy fastcwd (we use POSIX::getcwd instead) +*** Removed buggy fastcwd (we use POSIX::getcwd instead) -** Fixed bug when the common Parent of Target dir and Stow dir was "/" +*** Fixed bug when the common Parent of Target dir and Stow dir was "/" -** Fixed bug when handling directories named "0" +*** Fixed bug when handling directories named "0" -** Stow now only warns the user if a directory is unreadable during unstowing. +*** Stow now only warns the user if a directory is unreadable during unstowing. * Changes in version 1.3: -** Added --restow option. +*** Added --restow option. -** Fixed handling of slashes in package names. +*** Fixed handling of slashes in package names. -** Expanded configure-time search for Perl binary. +*** Expanded configure-time search for Perl binary. * Changes in version 1.2: -** Dependency on `pwd' removed. +*** Dependency on `pwd' removed. -** Perl 4 compatibility fixes. +*** Perl 4 compatibility fixes. -** Manual expanded even more. +*** Manual expanded even more. * Changes in version 1.1: -** Long and short options now accepted. +*** Long and short options now accepted. -** Manual expanded. +*** Manual expanded. -** `make clean' removes stow (which is generated from stow.in). +*** `make clean' removes stow (which is generated from stow.in). * Initial public release (v1.0) of Stow. * emacs local variables Local Variables: mode: org + org-export-with-toc: t + org-toc-odd-levels-only: t End: diff --git a/doc/HOWTO-RELEASE b/doc/HOWTO-RELEASE index 0a21ace..0cff082 100644 --- a/doc/HOWTO-RELEASE +++ b/doc/HOWTO-RELEASE @@ -129,6 +129,11 @@ Release procedure See http://www.gnu.org/prep/maintain/html_node/Announcements.html for more on making release announcements. + Excerpts of NEWS can be formatted for inclusion in the email by + selecting the relevant version subtree via M-x org-mark-element, + minus the "* Changes in version x.y.z", running M-x + org-export-dispatch, and exporting as plain text. + - Update the git repositories to the next expected version, so that anyone who builds from git gets a version of Stow which is higher than the release which was just cut: From 583f0f01ea606fd87bcb34eeede28dbac1a59d13 Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Sat, 29 Jun 2019 01:30:36 +0100 Subject: [PATCH 311/482] Add GPL v3 upgrade to NEWS for 2.3.0 release Forgot to do this prior to the release :-( But at least it will be mentioned in the announcement on the mailing lists. --- NEWS | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/NEWS b/NEWS index e587f72..68047fc 100644 --- a/NEWS +++ b/NEWS @@ -41,6 +41,11 @@ News file for Stow. Thanks to Brice Waegeneire for reporting this. +*** License upgraded from GPL version 2 to version 3 + + Copyright and license notices were also added to the headers of + various files in accordance with GNU guidelines. + *** Documentation fixes and enhancements ***** Remove dependency on unmaintained texi2html From 4a9121eec90dd7876f44a96489d3357cc9983e78 Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Sat, 29 Jun 2019 13:40:45 +0100 Subject: [PATCH 312/482] Bump version to 2.3.1 for development of next release --- META.json | 6 +++--- META.yml | 6 +++--- NEWS | 2 ++ configure.ac | 2 +- doc/HOWTO-RELEASE | 6 +++++- 5 files changed, 14 insertions(+), 8 deletions(-) diff --git a/META.json b/META.json index 1a9e06f..a789f64 100644 --- a/META.json +++ b/META.json @@ -39,11 +39,11 @@ "provides" : { "Stow" : { "file" : "lib/Stow.pm", - "version" : "v2.3.0" + "version" : "v2.3.1" }, "Stow::Util" : { "file" : "lib/Stow/Util.pm", - "version" : "v2.3.0" + "version" : "v2.3.1" } }, "release_status" : "stable", @@ -57,6 +57,6 @@ "url" : "git://git.savannah.gnu.org/stow.git" } }, - "version" : "v2.3.0", + "version" : "v2.3.1", "x_serialization_backend" : "JSON::PP version 4.00" } diff --git a/META.yml b/META.yml index 0215317..a11b693 100644 --- a/META.yml +++ b/META.yml @@ -18,10 +18,10 @@ name: Stow provides: Stow: file: lib/Stow.pm - version: v2.3.0 + version: v2.3.1 Stow::Util: file: lib/Stow/Util.pm - version: v2.3.0 + version: v2.3.1 requires: Carp: '0' Clone: '0' @@ -32,5 +32,5 @@ resources: homepage: https://savannah.gnu.org/projects/stow license: http://www.gnu.org/licenses/gpl-2.0.html repository: git://git.savannah.gnu.org/stow.git -version: v2.3.0 +version: v2.3.1 x_serialization_backend: 'CPAN::Meta::YAML version 0.018' diff --git a/NEWS b/NEWS index 68047fc..6722a28 100644 --- a/NEWS +++ b/NEWS @@ -1,5 +1,7 @@ News file for Stow. +* Changes in version 2.3.1 + * Changes in version 2.3.0 *** New features / changes in behaviour diff --git a/configure.ac b/configure.ac index 699a88b..ecc3971 100644 --- a/configure.ac +++ b/configure.ac @@ -15,7 +15,7 @@ dnl along with this program. If not, see https://www.gnu.org/licenses/. dnl Process this file with Autoconf to produce configure dnl -AC_INIT([stow], [2.3.0], [bug-stow@gnu.org]) +AC_INIT([stow], [2.3.1], [bug-stow@gnu.org]) AC_PREREQ([2.61]) AC_CONFIG_AUX_DIR([automake]) # Unfortunately we have to disable warnings for overrides, because we diff --git a/doc/HOWTO-RELEASE b/doc/HOWTO-RELEASE index 0cff082..e2fcf55 100644 --- a/doc/HOWTO-RELEASE +++ b/doc/HOWTO-RELEASE @@ -140,10 +140,14 @@ Release procedure - Increment the patchlevel of the version number in configure.ac. + - Run this again: + + version=$( tools/get-version ) && echo $version + - Repeat the same procedure listed in the Module::Build section above, in order to update META.yaml and META.json. - - git commit -m "Bump version to X.Y.Z for development of next release" + - git commit -m "Bump version to $version for development of next release" - git push savannah From 9ce10eb3b1cee35906baf1daea8eccc43a4e6623 Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Sat, 29 Jun 2019 13:04:30 +0100 Subject: [PATCH 313/482] Remove dependencies on Hash::Merge and Clone::Choose stow 2.3.0 added external runtime dependencies on Hash::Merge and Clone::Choose. Historically stow hasn't had runtime dependencies other than Perl itself, which is a useful property if you're managing the installation of Perl using stow; the bootstrapping instructions in stow's manual would need updating to describe how to install these two modules (and any dependencies they have now or in the future) as well. However, Hash::Merge is much more general than stow actually needs, so replace the merge() call with a few lines of equivalent code -- this avoids the external dependencies, and is clearer than the merge() call. Many thanks to Adam Sampson for this patch: https://lists.gnu.org/archive/html/bug-stow/2019-06/msg00001.html --- Build.PL | 2 -- META.json | 2 -- META.yml | 2 -- NEWS | 19 +++++++++++++++++++ bin/stow.in | 28 +++++++++++++++++----------- t/rc_options.t | 9 +++++++-- 6 files changed, 43 insertions(+), 19 deletions(-) diff --git a/Build.PL b/Build.PL index 06e57ab..c21d767 100644 --- a/Build.PL +++ b/Build.PL @@ -60,8 +60,6 @@ my $build = Module::Build->new( 'perl' => '5.006', 'Carp' => 0, 'IO::File' => 0, - 'Hash::Merge' => 0, - 'Clone' => 0, }, script_files => [ 'bin/stow', 'bin/chkstow' ], all_from => 'lib/Stow.pm.in', diff --git a/META.json b/META.json index a789f64..7eb963b 100644 --- a/META.json +++ b/META.json @@ -29,8 +29,6 @@ "runtime" : { "requires" : { "Carp" : "0", - "Clone" : "0", - "Hash::Merge" : "0", "IO::File" : "0", "perl" : "5.006" } diff --git a/META.yml b/META.yml index a11b693..e7ae3a4 100644 --- a/META.yml +++ b/META.yml @@ -24,8 +24,6 @@ provides: version: v2.3.1 requires: Carp: '0' - Clone: '0' - Hash::Merge: '0' IO::File: '0' perl: '5.006' resources: diff --git a/NEWS b/NEWS index 6722a28..79ca76e 100644 --- a/NEWS +++ b/NEWS @@ -2,6 +2,25 @@ News file for Stow. * Changes in version 2.3.1 +*** Remove dependencies on Hash::Merge and Clone::Choose + + stow 2.3.0 added external runtime dependencies on Hash::Merge and + Clone::Choose. Historically stow hasn't had runtime dependencies + other than Perl itself, which is a useful property if you're + managing the installation of Perl using stow; the bootstrapping + instructions in stow's manual would need updating to describe how + to install these two modules (and any dependencies they have now + or in the future) as well. + + However, Hash::Merge is much more general than stow actually + needs, so replace the merge() call with a few lines of equivalent + code -- this avoids the external dependencies, and is clearer than + the merge() call. + + Many thanks to Adam Sampson for this patch! + + https://lists.gnu.org/archive/html/bug-stow/2019-06/msg00001.html + * Changes in version 2.3.0 *** New features / changes in behaviour diff --git a/bin/stow.in b/bin/stow.in index 355bbc9..4faa451 100755 --- a/bin/stow.in +++ b/bin/stow.in @@ -457,16 +457,12 @@ require 5.006_001; use POSIX qw(getcwd); use Getopt::Long qw(GetOptionsFromArray); +use Scalar::Util qw(reftype); @USE_LIB_PMDIR@ use Stow; use Stow::Util qw(parent error); -# Need to avoid Storable backend, since it can't deal with regexps: -# https://rt.perl.org/Public/Bug/Display.html?id=50608 -use Clone::Choose qw(:Clone); -use Hash::Merge qw(merge); - my $ProgramName = $0; $ProgramName =~ s{.*/}{}; @@ -530,17 +526,27 @@ sub process_options { # Merge .stowrc and command line options. # Preference is given to cli options. - # rc options come first in merged arrays. - # cli options overwrite conflicting rc options. - Hash::Merge::set_behavior('RIGHT_PRECEDENT'); - my $options = merge($rc_options, $cli_options); + my %options = %$rc_options; + foreach my $option (keys %$cli_options) { + my $rc_value = $rc_options->{$option}; + my $cli_value = $cli_options->{$option}; + my $type = reftype($cli_value); + + if (defined $type && $type eq 'ARRAY' && defined $rc_value) { + # rc options come first in merged arrays. + $options{$option} = [@{$rc_value}, @{$cli_value}]; + } else { + # cli options overwrite conflicting rc options. + $options{$option} = $cli_value; + } + } # Run checks on the merged options. - sanitize_path_options($options); + sanitize_path_options(\%options); check_packages($pkgs_to_unstow, $pkgs_to_stow); # Return merged and processed options. - return ($options, $pkgs_to_unstow, $pkgs_to_stow); + return (\%options, $pkgs_to_unstow, $pkgs_to_stow); } #===== SUBROUTINE =========================================================== diff --git a/t/rc_options.t b/t/rc_options.t index 593ff11..cbbbee2 100755 --- a/t/rc_options.t +++ b/t/rc_options.t @@ -22,7 +22,7 @@ use strict; use warnings; -use Test::More tests => 33; +use Test::More tests => 34; use testutil; @@ -120,16 +120,19 @@ is($options->{dir}, "$ABS_TEST_DIR/stow" => "-d from \$HOME/.stowrc"); # -# Test ~/.stowrc file is overridden by .stowrc in cwd. +# Test that some but not all options ~/.stowrc file are overridden by +# .stowrc in cwd. # local @ARGV = ('dummy'); make_file($HOME_RC_FILE, <{target}, "$ABS_TEST_DIR/target" => "--target overridden by \$PWD/.stowrc"); is($options->{dir}, "$ABS_TEST_DIR/stow" => "-d overridden \$PWD/.stowrc"); +is_deeply($options->{defer}, [qr(\Ainfo), qr(\Aman)], + 'defer man and info'); unlink($CWD_RC_FILE) or die "Failed to unlink $CWD_RC_FILE"; # From b6ee2d10d620955691b7448882323d2986ebb94e Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Mon, 15 Jul 2019 16:10:21 -0400 Subject: [PATCH 314/482] cli.t: test with the right Perl executable t/cli.t calls scripts which run with the first perl found in the user's PATH (usually the system perl), not with the perl used for the build, as reported here: https://rt.cpan.org/Ticket/Display.html?id=129944 Thanks to Slaven Rezic for spotting this and reporting it! --- THANKS | 1 + t/cli.t | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/THANKS b/THANKS index 64147fb..8fbdd43 100644 --- a/THANKS +++ b/THANKS @@ -36,6 +36,7 @@ Jean Louis Daniel Shahaf Matan Nassau Brice Waegeneire +Slaven Rezic Email addresses of new contributors are no longer being added by default for privacy reasons; however please contact the maintainer if you are diff --git a/t/cli.t b/t/cli.t index cf324ed..3bd3194 100755 --- a/t/cli.t +++ b/t/cli.t @@ -57,7 +57,7 @@ use testutil; # # or from the top of the source tree during development. This can be done # via the following, which also follows the KISS principle: -my $STOW = 'bin/stow'; +my $STOW = "$^X bin/stow"; `$STOW --help`; is($?, 0, "--help should return 0 exit code"); From cfb3ff7eff411d1878025178bd6f811c6e6d9fd7 Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Tue, 16 Jul 2019 19:21:04 +0100 Subject: [PATCH 315/482] HOWTO-RELEASE: update online docs *after* uploading release It doesn't make sense to have docs online relating to a release which isn't yet available; it's less confusing to have a small time window in which the online docs are out of date. --- doc/HOWTO-RELEASE | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/doc/HOWTO-RELEASE b/doc/HOWTO-RELEASE index e2fcf55..e88d241 100644 --- a/doc/HOWTO-RELEASE +++ b/doc/HOWTO-RELEASE @@ -86,6 +86,12 @@ Release procedure git push github git push --tags github +- Upload the new release to ftp.gnu.org. This is easiest using gnupload: + + - git clone git://git.savannah.gnu.org/gnulib.git + - Copy gnulib/build-aux/gnupload to somewhere on your $PATH + - Run gnupload --to ftp.gnu.org:stow --symlink-regex stow-7.8.9.tar.* + - Regenerate the documentation for the website: # First check out gnulib repository via: @@ -113,12 +119,6 @@ Release procedure # Then commit cvs commit -m "Update manual to v$version" -- Upload to ftp.gnu.org. This is easiest using gnupload: - - - git clone git://git.savannah.gnu.org/gnulib.git - - Copy gnulib/build-aux/gnupload to somewhere on your $PATH - - Run gnupload --to ftp.gnu.org:stow --symlink-regex stow-7.8.9.tar.* - - Send release announcements to - info-stow@gnu.org From 80d1472253334b074098302b363b4a776d1fa1e9 Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Tue, 16 Jul 2019 19:24:19 +0100 Subject: [PATCH 316/482] HOWTO-RELEASE: update news section of online home page --- doc/HOWTO-RELEASE | 3 +++ 1 file changed, 3 insertions(+) diff --git a/doc/HOWTO-RELEASE b/doc/HOWTO-RELEASE index e88d241..d6f0069 100644 --- a/doc/HOWTO-RELEASE +++ b/doc/HOWTO-RELEASE @@ -119,6 +119,9 @@ Release procedure # Then commit cvs commit -m "Update manual to v$version" +- Update the news section of stow.html in the stow-web CVS repository + to mention the new release. + - Send release announcements to - info-stow@gnu.org From ed2091e9a57ef6c200e7bdc4fb1bb107c49e4eba Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Sun, 28 Jul 2019 12:55:22 +0100 Subject: [PATCH 317/482] HOWTO-RELEASE: add suggested commands for updating home page --- doc/HOWTO-RELEASE | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/doc/HOWTO-RELEASE b/doc/HOWTO-RELEASE index d6f0069..045faad 100644 --- a/doc/HOWTO-RELEASE +++ b/doc/HOWTO-RELEASE @@ -122,6 +122,12 @@ Release procedure - Update the news section of stow.html in the stow-web CVS repository to mention the new release. + cd $stow_web_repo + # Check that the changes look OK + cvs diff + # Then commit + cvs commit -m "Update home page to v$version" + - Send release announcements to - info-stow@gnu.org From 3aa30ae1aaaa89944b8b974a6c2d2793db055ea3 Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Sun, 28 Jul 2019 12:57:27 +0100 Subject: [PATCH 318/482] fix cross-references under --no-folding section of manual Under emacs, this was previously rendered as '--no-folding' This disables any further *note tree folding:: or *note tree refolding::. If a new subdirectory is encountered whilst stowing a which looks awkward. Similarly under info(1): '--no-folding' This disables any further *note tree folding:: or *note tree refolding::. If a new subdirectory is encountered whilst stowing a The new way is undesirably repetitive, but at least grammatically correct. I don't think there's a better solution with texinfo :-/ --- doc/stow.texi | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/doc/stow.texi b/doc/stow.texi index b7ef78d..febc11c 100644 --- a/doc/stow.texi +++ b/doc/stow.texi @@ -360,13 +360,14 @@ the target directory, because this is what you will want to do most of the time. @item --no-folding -This disables any further @ref{tree folding} or @ref{tree refolding}. -If a new subdirectory is encountered whilst stowing a new package, the -subdirectory is created within the target, and its contents are -symlinked, rather than just creating a symlink for the directory. If -removal of symlinks whilst unstowing a package causes a subtree to be -foldable (i.e. only containing symlinks to a single package), that -subtree will not be removed and replaced with a symlink. +This disables any further tree folding (@pxref{tree folding}) or +refolding (@pxref{tree refolding}). If a new subdirectory is +encountered whilst stowing a new package, the subdirectory is created +within the target, and its contents are symlinked, rather than just +creating a symlink for the directory. If removal of symlinks whilst +unstowing a package causes a subtree to be foldable (i.e. only +containing symlinks to a single package), that subtree will not be +removed and replaced with a symlink. @cindex adopting existing files @item --adopt From bfe091f28e1d5b5e0974d3b2fa8a70566650ee8e Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Sun, 28 Jul 2019 13:10:49 +0100 Subject: [PATCH 319/482] Prepare NEWS for 2.3.1 release --- NEWS | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/NEWS b/NEWS index 79ca76e..7a3774e 100644 --- a/NEWS +++ b/NEWS @@ -21,6 +21,20 @@ News file for Stow. https://lists.gnu.org/archive/html/bug-stow/2019-06/msg00001.html +*** Fix an issue with the test suite + + t/cli.t was not testing with the right Perl executable, as + reported here: + + https://rt.cpan.org/Ticket/Display.html?id=129944 + + Thanks to Slaven Rezic for spotting this and reporting it! + +*** Various maintainer tweaks + + Improved the release process and its documentation in various + minor ways. + * Changes in version 2.3.0 *** New features / changes in behaviour From 5602166a57f774b24002e25b285b00f575182ef5 Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Sun, 28 Jul 2019 13:15:11 +0100 Subject: [PATCH 320/482] Make sure release process starts from a clean slate --- doc/HOWTO-RELEASE | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/doc/HOWTO-RELEASE b/doc/HOWTO-RELEASE index 045faad..bf83b55 100644 --- a/doc/HOWTO-RELEASE +++ b/doc/HOWTO-RELEASE @@ -29,6 +29,11 @@ Release procedure - Check CPAN distribution will work via Module::Build: + - Start from a clean slate: + + make distclean + autoreconf -iv + - Generate stow, chkstow, and lib/Stow.pm via: eval `perl -V:siteprefix` From 7fae30ecce213fd0a54d9e365e01afd06ea09f0d Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Sun, 28 Jul 2019 13:28:46 +0100 Subject: [PATCH 321/482] HOWTO-RELEASE: do ./Build dist earlier docker builds break ./Build dist, so do it earlier. --- doc/HOWTO-RELEASE | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/doc/HOWTO-RELEASE b/doc/HOWTO-RELEASE index bf83b55..5f1758d 100644 --- a/doc/HOWTO-RELEASE +++ b/doc/HOWTO-RELEASE @@ -50,6 +50,7 @@ Release procedure ./Build install ./Build distcheck ./Build distmeta + ./Build dist - Check META.yaml and META.json have the new version number. They already should if the final step of this document was @@ -76,8 +77,6 @@ Release procedure git tag -s v$version -m "Release $version" -- Run ./Build dist - - Upload the resulting Stow-v7.8.9.tar.gz to CPAN via https://pause.perl.org/ - Wait until PAUSE has accepted the upload as a valid module. From 71b9606ba44f7ae1fbbfcbe600922cd75214e117 Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Sun, 28 Jul 2019 13:58:00 +0100 Subject: [PATCH 322/482] HOWTO-RELEASE: explain how to confirm PAUSE acceptance of upload --- doc/HOWTO-RELEASE | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/doc/HOWTO-RELEASE b/doc/HOWTO-RELEASE index 5f1758d..2b07dca 100644 --- a/doc/HOWTO-RELEASE +++ b/doc/HOWTO-RELEASE @@ -79,9 +79,11 @@ Release procedure - Upload the resulting Stow-v7.8.9.tar.gz to CPAN via https://pause.perl.org/ -- Wait until PAUSE has accepted the upload as a valid module. - This provides some valuable final validation, as shown by the - non-release of 2.2.1. +- Wait until PAUSE has accepted the upload as a valid module. If you + are the maintainer of the module, you should receive two email + notifications: a CPAN upload confirmation, and a PAUSE indexer + report. This provides some valuable final validation, as learnt the + hard way during the non-release of 2.2.1. - Push HEAD and tag to savannah and GitHub: From 4f043bbd589e0ff1f5248050171dfeb8d88e04c5 Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Sun, 28 Jul 2019 14:28:41 +0100 Subject: [PATCH 323/482] NEWS: don't export with author name Avoid extra noise when exporting to text for a release announcement. --- NEWS | 1 + 1 file changed, 1 insertion(+) diff --git a/NEWS b/NEWS index 7a3774e..0372ff2 100644 --- a/NEWS +++ b/NEWS @@ -584,5 +584,6 @@ due to Stow::Util missing $VERSION. Local Variables: mode: org org-export-with-toc: t + org-export-with-author: nil org-toc-odd-levels-only: t End: From 59658a6c4edd910ca9a678037d3f2b129aedaebe Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Sun, 28 Jul 2019 14:29:06 +0100 Subject: [PATCH 324/482] NEWS: disable org-export-with-toc 2.3.0 was a big release with lots of stuff, but most releases will be smaller, so default to not having a ToC. --- NEWS | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/NEWS b/NEWS index 0372ff2..7a398ac 100644 --- a/NEWS +++ b/NEWS @@ -583,7 +583,7 @@ due to Stow::Util missing $VERSION. * emacs local variables Local Variables: mode: org - org-export-with-toc: t + org-export-with-toc: nil org-export-with-author: nil org-toc-odd-levels-only: t End: From c84a3b0f254a49cdcab897c61e14adf12eea7185 Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Sun, 28 Jul 2019 14:52:16 +0100 Subject: [PATCH 325/482] HOWTO-RELEASE: fix final step of bumping to next release version --- doc/HOWTO-RELEASE | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/doc/HOWTO-RELEASE b/doc/HOWTO-RELEASE index 2b07dca..b488744 100644 --- a/doc/HOWTO-RELEASE +++ b/doc/HOWTO-RELEASE @@ -52,9 +52,9 @@ Release procedure ./Build distmeta ./Build dist - - Check META.yaml and META.json have the new version number. + - Check META.yml and META.json have the new version number. They already should if the final step of this document was - carried out after the previous release was published, but + carried out after the previous release was publised, but if not: git commit -m "Bump version to $version" @@ -159,8 +159,13 @@ Release procedure version=$( tools/get-version ) && echo $version - - Repeat the same procedure listed in the Module::Build section - above, in order to update META.yaml and META.json. + - In order to update META.yml and META.json, repeat the same + procedure listed above, starting at "make distclean" and + finishing after "./Build distmeta". + + - Check META.yml and META.json now have the new versions. + + - git add configure.ac META.{yml,json} - git commit -m "Bump version to $version for development of next release" From d94f325e514f372a0839e121d33f62be9f8ed485 Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Sun, 28 Jul 2019 14:52:53 +0100 Subject: [PATCH 326/482] Bump version to 2.3.2 for development of next release --- META.json | 6 +++--- META.yml | 6 +++--- configure.ac | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/META.json b/META.json index 7eb963b..3509018 100644 --- a/META.json +++ b/META.json @@ -37,11 +37,11 @@ "provides" : { "Stow" : { "file" : "lib/Stow.pm", - "version" : "v2.3.1" + "version" : "v2.3.2" }, "Stow::Util" : { "file" : "lib/Stow/Util.pm", - "version" : "v2.3.1" + "version" : "v2.3.2" } }, "release_status" : "stable", @@ -55,6 +55,6 @@ "url" : "git://git.savannah.gnu.org/stow.git" } }, - "version" : "v2.3.1", + "version" : "v2.3.2", "x_serialization_backend" : "JSON::PP version 4.00" } diff --git a/META.yml b/META.yml index e7ae3a4..9385103 100644 --- a/META.yml +++ b/META.yml @@ -18,10 +18,10 @@ name: Stow provides: Stow: file: lib/Stow.pm - version: v2.3.1 + version: v2.3.2 Stow::Util: file: lib/Stow/Util.pm - version: v2.3.1 + version: v2.3.2 requires: Carp: '0' IO::File: '0' @@ -30,5 +30,5 @@ resources: homepage: https://savannah.gnu.org/projects/stow license: http://www.gnu.org/licenses/gpl-2.0.html repository: git://git.savannah.gnu.org/stow.git -version: v2.3.1 +version: v2.3.2 x_serialization_backend: 'CPAN::Meta::YAML version 0.018' diff --git a/configure.ac b/configure.ac index ecc3971..cd7dc4f 100644 --- a/configure.ac +++ b/configure.ac @@ -15,7 +15,7 @@ dnl along with this program. If not, see https://www.gnu.org/licenses/. dnl Process this file with Autoconf to produce configure dnl -AC_INIT([stow], [2.3.1], [bug-stow@gnu.org]) +AC_INIT([stow], [2.3.2], [bug-stow@gnu.org]) AC_PREREQ([2.61]) AC_CONFIG_AUX_DIR([automake]) # Unfortunately we have to disable warnings for overrides, because we From 9fd3624a755acee6c287c50f69497583db5998cd Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Sun, 28 Jul 2019 14:54:36 +0100 Subject: [PATCH 327/482] HOWTO-RELEASE: explicitly push to master This avoids errors like fatal: You are pushing to remote 'savannah', which is not the upstream of your current branch 'master', without telling me what to push to update which remote branch. --- doc/HOWTO-RELEASE | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/doc/HOWTO-RELEASE b/doc/HOWTO-RELEASE index b488744..2b0daab 100644 --- a/doc/HOWTO-RELEASE +++ b/doc/HOWTO-RELEASE @@ -87,9 +87,9 @@ Release procedure - Push HEAD and tag to savannah and GitHub: - git push savannah + git push savannah master git push --tags savannah - git push github + git push github master git push --tags github - Upload the new release to ftp.gnu.org. This is easiest using gnupload: @@ -169,6 +169,6 @@ Release procedure - git commit -m "Bump version to $version for development of next release" - - git push savannah + - git push savannah master - - git push github + - git push github master From d4e413536edfe64baddc48ea08aefe7b2e2d40db Mon Sep 17 00:00:00 2001 From: ATuinDev <1757663+AitorATuin@users.noreply.github.com> Date: Sun, 24 May 2020 18:12:49 +0200 Subject: [PATCH 328/482] Fixes Bug #56727 Problem was that when running stow_contents/unstow_contents recursively from stow_node/unstow_node the information for the source path (without the dot- to . transformation) was lost. In the case of stow_contents the solution is just to remove the leading dots (..) from the $source path (since the $source path is passed as an argument to the function) In the case of unstow_contents the solution is the same as for stow_contents but the arguments was now passed so I added it to the function. --- lib/Stow.pm.in | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/lib/Stow.pm.in b/lib/Stow.pm.in index 77f67b3..efe73c7 100755 --- a/lib/Stow.pm.in +++ b/lib/Stow.pm.in @@ -284,6 +284,7 @@ sub plan_unstow { $self->{stow_path}, $package, '.', + $path, ); } debug(2, "Planning unstow of package $package... done"); @@ -369,7 +370,8 @@ sub stow_contents { my $self = shift; my ($stow_path, $package, $target, $source) = @_; - my $path = join_paths($stow_path, $package, $target); + # Remove leading .. from $source + my $path = join '/', map { ($_ eq '..') ? ( ) : $_ } (split m{/+}, $source); return if $self->should_skip_target_which_is_stow_dir($target); @@ -740,9 +742,10 @@ sub unstow_node_orig { #============================================================================ sub unstow_contents { my $self = shift; - my ($stow_path, $package, $target) = @_; + my ($stow_path, $package, $target, $source) = @_; - my $path = join_paths($stow_path, $package, $target); + # Remove leading .. from $source + my $path = join '/', map { ($_ eq '..') ? ( ) : $_ } (split m{/+}, $source); return if $self->should_skip_target_which_is_stow_dir($target); @@ -778,7 +781,7 @@ sub unstow_contents { $node_target = $adj_node_target; } - $self->unstow_node($stow_path, $package, $node_target); + $self->unstow_node($stow_path, $package, $node_target, join_paths($source, $node)); } if (-d $target) { $self->cleanup_invalid_links($target); @@ -798,7 +801,7 @@ sub unstow_contents { #============================================================================ sub unstow_node { my $self = shift; - my ($stow_path, $package, $target) = @_; + my ($stow_path, $package, $target, $source) = @_; my $path = join_paths($stow_path, $package, $target); @@ -872,7 +875,7 @@ sub unstow_node { elsif (-e $target) { debug(4, " Evaluate existing node: $target"); if (-d $target) { - $self->unstow_contents($stow_path, $package, $target); + $self->unstow_contents($stow_path, $package, $target, $source); # This action may have made the parent directory foldable if (my $parent = $self->foldable($target)) { From a2db7a9c766cd953dfa2d4af3254a79f212204e5 Mon Sep 17 00:00:00 2001 From: ATuinDev <1757663+AitorATuin@users.noreply.github.com> Date: Mon, 25 May 2020 22:21:31 +0200 Subject: [PATCH 329/482] Add $level variable in stow_contents and stow_node This variables is used to keep track of the current level in the source. --- lib/Stow.pm.in | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/lib/Stow.pm.in b/lib/Stow.pm.in index efe73c7..a616a2b 100755 --- a/lib/Stow.pm.in +++ b/lib/Stow.pm.in @@ -317,6 +317,7 @@ sub plan_stow { $package, '.', $path, # source from target + 0, ); debug(2, "Planning stow of package $package... done"); $self->{action_count}++; @@ -368,11 +369,12 @@ sub within_target_do { #============================================================================ sub stow_contents { my $self = shift; - my ($stow_path, $package, $target, $source) = @_; - - # Remove leading .. from $source - my $path = join '/', map { ($_ eq '..') ? ( ) : $_ } (split m{/+}, $source); + my ($stow_path, $package, $target, $source, $level) = @_; + # Remove leading $level times .. from $source + my $n = 0; + my $path = join '/', map { (++$n <= $level) ? ( ) : $_ } (split m{/+}, $source); + return if $self->should_skip_target_which_is_stow_dir($target); my $cwd = getcwd(); @@ -409,6 +411,7 @@ sub stow_contents { $package, $node_target, # target join_paths($source, $node), # source + $level ); } } @@ -431,7 +434,7 @@ sub stow_contents { #============================================================================ sub stow_node { my $self = shift; - my ($stow_path, $package, $target, $source) = @_; + my ($stow_path, $package, $target, $source, $level) = @_; my $path = join_paths($stow_path, $package, $target); @@ -501,12 +504,14 @@ sub stow_node { $existing_package, $target, join_paths('..', $existing_source), + $level + 1, ); $self->stow_contents( $self->{stow_path}, $package, $target, join_paths('..', $source), + $level + 1, ); } else { @@ -533,6 +538,7 @@ sub stow_node { $package, $target, join_paths('..', $source), + $level + 1, ); } else { @@ -556,6 +562,7 @@ sub stow_node { $package, $target, join_paths('..', $source), + $level + 1, ); } else { @@ -742,10 +749,7 @@ sub unstow_node_orig { #============================================================================ sub unstow_contents { my $self = shift; - my ($stow_path, $package, $target, $source) = @_; - - # Remove leading .. from $source - my $path = join '/', map { ($_ eq '..') ? ( ) : $_ } (split m{/+}, $source); + my ($stow_path, $package, $target, $path) = @_; return if $self->should_skip_target_which_is_stow_dir($target); From 056d648d53949f173f91edf70a0eb8145da8b2c1 Mon Sep 17 00:00:00 2001 From: ATuinDev <1757663+AitorATuin@users.noreply.github.com> Date: Mon, 25 May 2020 22:23:23 +0200 Subject: [PATCH 330/482] Add more tests for testing directories in dotfiles.t --- t/dotfiles.t | 82 +++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 81 insertions(+), 1 deletion(-) diff --git a/t/dotfiles.t b/t/dotfiles.t index a4a45c8..9e70ad4 100755 --- a/t/dotfiles.t +++ b/t/dotfiles.t @@ -24,7 +24,7 @@ use warnings; use testutil; -use Test::More tests => 6; +use Test::More tests => 10; use English qw(-no_match_vars); use testutil; @@ -86,6 +86,64 @@ is( => 'processed dotfile folder' ); +# +# process folder marked with 'dot' prefix +# when directory exists is target +# + +$stow = new_Stow(dir => '../stow', dotfiles => 1); + +make_path('../stow/dotfiles/dot-emacs.d'); +make_file('../stow/dotfiles/dot-emacs.d/init.el'); +make_path('.emacs.d'); + +$stow->plan_stow('dotfiles'); +$stow->process_tasks(); +is( + readlink('.emacs.d/init.el'), + '../../stow/dotfiles/dot-emacs.d/init.el', + => 'processed dotfile folder when folder exists (1 level)' +); + +# +# process folder marked with 'dot' prefix +# when directory exists is target (2 levels) +# + +$stow = new_Stow(dir => '../stow', dotfiles => 1); + +make_path('../stow/dotfiles/dot-emacs.d/dot-emacs.d'); +make_file('../stow/dotfiles/dot-emacs.d/dot-emacs.d/init.el'); +make_path('.emacs.d'); + +$stow->plan_stow('dotfiles'); +$stow->process_tasks(); +is( + readlink('.emacs.d/.emacs.d'), + '../../stow/dotfiles/dot-emacs.d/dot-emacs.d', + => 'processed dotfile folder exists (2 levels)' +); + +# +# process folder marked with 'dot' prefix +# when directory exists is target +# + +$stow = new_Stow(dir => '../stow', dotfiles => 1); + +make_path('../stow/dotfiles/dot-one/dot-two'); +make_file('../stow/dotfiles/dot-one/dot-two/three'); +make_path('.one/.two'); + +$stow->plan_stow('dotfiles'); +$stow->process_tasks(); +is( + readlink('./.one/.two/three'), + '../../../stow/dotfiles/dot-one/dot-two/three', + => 'processed dotfile 2 folder exists (2 levels)' +); + + # # corner case: paths that have a part in them that's just "$DOT_PREFIX" or # "$DOT_PREFIX." should not have that part expanded. @@ -129,3 +187,25 @@ ok( -f '../stow/dotfiles/dot-bar' && ! -e '.bar' => 'unstow a simple dotfile' ); + +# +# unstow process folder marked with 'dot' prefix +# when directory exists is target +# + +$stow = new_Stow(dir => '../stow', dotfiles => 1); + +make_path('../stow/dotfiles/dot-emacs.d'); +make_file('../stow/dotfiles/dot-emacs.d/init.el'); +make_path('.emacs.d'); +make_link('.emacs.d/init.el', '../../stow/dotfiles/dot-emacs.d/init.el'); + +$stow->plan_unstow('dotfiles'); +$stow->process_tasks(); +ok( + $stow->get_conflict_count == 0 && + -f '../stow/dotfiles/dot-emacs.d/init.el' && + ! -e '.emacs.d/init.el' && + -d '.emacs.d/' + => 'unstow dotfile folder when folder already exists' +); From a41118d9277de701359543381c93d9fe168fd695 Mon Sep 17 00:00:00 2001 From: ATuinDev <1757663+AitorATuin@users.noreply.github.com> Date: Mon, 25 May 2020 22:26:31 +0200 Subject: [PATCH 331/482] Fix missing variable --- lib/Stow.pm.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Stow.pm.in b/lib/Stow.pm.in index a616a2b..87a25e1 100755 --- a/lib/Stow.pm.in +++ b/lib/Stow.pm.in @@ -785,7 +785,7 @@ sub unstow_contents { $node_target = $adj_node_target; } - $self->unstow_node($stow_path, $package, $node_target, join_paths($source, $node)); + $self->unstow_node($stow_path, $package, $node_target, join_paths($path, $node)); } if (-d $target) { $self->cleanup_invalid_links($target); From 74e0eab0c5ad04a0c8f218c11da421724465bc79 Mon Sep 17 00:00:00 2001 From: Christian Egli Date: Wed, 27 May 2020 17:51:37 +0200 Subject: [PATCH 332/482] Mention the dotfiles option in the manual This should have been part of 182acbbb64425bf95008cb6d42d266f6185032c9 when the option was first added. This commit basically just copies the help text from stow.in into the texinfo manual. --- doc/stow.texi | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/doc/stow.texi b/doc/stow.texi index febc11c..0b00860 100644 --- a/doc/stow.texi +++ b/doc/stow.texi @@ -358,6 +358,24 @@ pages that are owned by stow and would otherwise cause a conflict. The regular expression is anchored to the beginning of the path relative to the target directory, because this is what you will want to do most of the time. +@cindex dotfiles +@item --dotfiles + +Enable special handling for @emph{dotfiles} (files or folders whose +name begins with a period) in the package directory. If this option is +enabled, Stow will add a preprocessing step for each file or folder +whose name begins with @samp{dot-}, and replace the @samp{dot-} prefix +in the name by a period @samp{.}. This is useful when Stow is used to +manage collections of dotfiles, to avoid having a package directory +full of hidden files. + +For example, suppose we have a package containing two files, +@file{stow/dot-bashrc} and @file{stow/dot-emacs.d/init.el}. With this +option, Stow will create symlinks from @file{.bashrc} to +@file{stow/dot-bashrc} and from @file{.emacs.d/init.el} to +@file{stow/dot-emacs.d/init.el}. Any other files, whose name does not +begin with @samp{dot-}, will be processed as usual. + @item --no-folding This disables any further tree folding (@pxref{tree folding}) or From ca1e5e500fd0a248444996fc5c45dc9f85d569e2 Mon Sep 17 00:00:00 2001 From: Gutierri Barboza Date: Tue, 13 Apr 2021 22:09:38 -0300 Subject: [PATCH 333/482] add --dotfiles sub usage --- bin/stow.in | 2 ++ 1 file changed, 2 insertions(+) diff --git a/bin/stow.in b/bin/stow.in index 4faa451..84d9af6 100755 --- a/bin/stow.in +++ b/bin/stow.in @@ -821,6 +821,8 @@ OPTIONS: if the file is already stowed to another package --adopt (Use with care!) Import existing files into stow package from target. Please read docs before using. + --dotfiles Enables special handling for dotfiles that are + Stow packages that start with "dot-" and not "." -p, --compat Use legacy algorithm for unstowing -n, --no, --simulate Do not actually make any filesystem changes From 57d7b76bd3a988a7b840e99b54f9f62bfdf1c5e4 Mon Sep 17 00:00:00 2001 From: Gutierri Barboza Date: Wed, 14 Apr 2021 22:08:38 -0300 Subject: [PATCH 334/482] add option --simulate on manpage --- bin/stow.in | 2 ++ 1 file changed, 2 insertions(+) diff --git a/bin/stow.in b/bin/stow.in index 84d9af6..76b150c 100755 --- a/bin/stow.in +++ b/bin/stow.in @@ -135,6 +135,8 @@ C<-D>). =item --no +=item --simulate + Do not perform any operations that modify the filesystem; merely show what would happen. From 69614059a8644b798a16f0676fef62f2a88b0471 Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Sun, 1 Nov 2020 15:04:56 +0000 Subject: [PATCH 335/482] Ditch texinfo.tex from distribution --- MANIFEST | 2 +- Makefile.am | 2 - automake/.gitignore | 1 + doc/texinfo.tex | 7482 ------------------------------------------- 4 files changed, 2 insertions(+), 7485 deletions(-) delete mode 100644 doc/texinfo.tex diff --git a/MANIFEST b/MANIFEST index ae4a0cd..88255e6 100644 --- a/MANIFEST +++ b/MANIFEST @@ -3,6 +3,7 @@ aclocal.m4 automake/install-sh automake/mdate-sh automake/missing +automake/texinfo.tex bin/chkstow bin/chkstow.in bin/stow @@ -19,7 +20,6 @@ doc/manual.pdf doc/stow.8 doc/stow.info doc/stow.texi -doc/texinfo.tex doc/version.texi INSTALL.md lib/Stow.pm diff --git a/Makefile.am b/Makefile.am index 7748399..1ce2932 100644 --- a/Makefile.am +++ b/Makefile.am @@ -32,7 +32,6 @@ pmstowdir = $(pmdir)/Stow pm_DATA = lib/Stow.pm pmstow_DATA = lib/Stow/Util.pm -TEXINFO_TEX = doc/texinfo.tex export TEXI2DVI_BUILD_MODE = clean AM_MAKEINFOFLAGS = -I $(srcdir) @@ -95,7 +94,6 @@ EXTRA_DIST = \ bin/stow.in bin/chkstow.in lib/Stow.pm.in lib/Stow/Util.pm.in \ doc/manual-split \ $(TESTS) t/testutil.pm \ - $(TEXINFO_TEX) \ $(DEFAULT_IGNORE_LIST) \ $(CPAN_FILES) CLEANFILES = $(bin_SCRIPTS) $(pm_DATA) $(pmstow_DATA) diff --git a/automake/.gitignore b/automake/.gitignore index f23d52a..cfd5146 100644 --- a/automake/.gitignore +++ b/automake/.gitignore @@ -2,3 +2,4 @@ install-sh missing mdate-sh test-driver +texinfo.tex diff --git a/doc/texinfo.tex b/doc/texinfo.tex deleted file mode 100644 index f15767d..0000000 --- a/doc/texinfo.tex +++ /dev/null @@ -1,7482 +0,0 @@ -% texinfo.tex -- TeX macros to handle Texinfo files. -% -% Load plain if necessary, i.e., if running under initex. -\expandafter\ifx\csname fmtname\endcsname\relax\input plain\fi -% -\def\texinfoversion{2011-11-21.13} -% -% Copyright (C) 1985, 1986, 1988, 1990, 1991, 1992, 1993, 1994, 1995, -% 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006 Free -% Software Foundation, Inc. -% -% This texinfo.tex file is free software; you can redistribute it and/or -% modify it under the terms of the GNU General Public License as -% published by the Free Software Foundation; either version 2, or (at -% your option) any later version. -% -% This texinfo.tex file is distributed in the hope that it will be -% useful, but WITHOUT ANY WARRANTY; without even the implied warranty -% of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -% General Public License for more details. -% -% You should have received a copy of the GNU General Public License -% along with this texinfo.tex file; see the file COPYING. If not, write -% to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, -% Boston, MA 02110-1301, USA. -% -% As a special exception, when this file is read by TeX when processing -% a Texinfo source document, you may use the result without -% restriction. (This has been our intent since Texinfo was invented.) -% -% Please try the latest version of texinfo.tex before submitting bug -% reports; you can get the latest version from: -% http://www.gnu.org/software/texinfo/ (the Texinfo home page), or -% ftp://tug.org/tex/texinfo.tex -% (and all CTAN mirrors, see http://www.ctan.org). -% The texinfo.tex in any given distribution could well be out -% of date, so if that's what you're using, please check. -% -% Send bug reports to bug-texinfo@gnu.org. Please include including a -% complete document in each bug report with which we can reproduce the -% problem. Patches are, of course, greatly appreciated. -% -% To process a Texinfo manual with TeX, it's most reliable to use the -% texi2dvi shell script that comes with the distribution. For a simple -% manual foo.texi, however, you can get away with this: -% tex foo.texi -% texindex foo.?? -% tex foo.texi -% tex foo.texi -% dvips foo.dvi -o # or whatever; this makes foo.ps. -% The extra TeX runs get the cross-reference information correct. -% Sometimes one run after texindex suffices, and sometimes you need more -% than two; texi2dvi does it as many times as necessary. -% -% It is possible to adapt texinfo.tex for other languages, to some -% extent. You can get the existing language-specific files from the -% full Texinfo distribution. -% -% The GNU Texinfo home page is http://www.gnu.org/software/texinfo. - - -\message{Loading texinfo [version \texinfoversion]:} - -% If in a .fmt file, print the version number -% and turn on active characters that we couldn't do earlier because -% they might have appeared in the input file name. -\everyjob{\message{[Texinfo version \texinfoversion]}% - \catcode`+=\active \catcode`\_=\active} - -\message{Basics,} -\chardef\other=12 - -% We never want plain's \outer definition of \+ in Texinfo. -% For @tex, we can use \tabalign. -\let\+ = \relax - -% Save some plain tex macros whose names we will redefine. -\let\ptexb=\b -\let\ptexbullet=\bullet -\let\ptexc=\c -\let\ptexcomma=\, -\let\ptexdot=\. -\let\ptexdots=\dots -\let\ptexend=\end -\let\ptexequiv=\equiv -\let\ptexexclam=\! -\let\ptexfootnote=\footnote -\let\ptexgtr=> -\let\ptexhat=^ -\let\ptexi=\i -\let\ptexindent=\indent -\let\ptexinsert=\insert -\let\ptexlbrace=\{ -\let\ptexless=< -\let\ptexnewwrite\newwrite -\let\ptexnoindent=\noindent -\let\ptexplus=+ -\let\ptexrbrace=\} -\let\ptexslash=\/ -\let\ptexstar=\* -\let\ptext=\t - -% If this character appears in an error message or help string, it -% starts a new line in the output. -\newlinechar = `^^J - -% Use TeX 3.0's \inputlineno to get the line number, for better error -% messages, but if we're using an old version of TeX, don't do anything. -% -\ifx\inputlineno\thisisundefined - \let\linenumber = \empty % Pre-3.0. -\else - \def\linenumber{l.\the\inputlineno:\space} -\fi - -% Set up fixed words for English if not already set. -\ifx\putwordAppendix\undefined \gdef\putwordAppendix{Appendix}\fi -\ifx\putwordChapter\undefined \gdef\putwordChapter{Chapter}\fi -\ifx\putwordfile\undefined \gdef\putwordfile{file}\fi -\ifx\putwordin\undefined \gdef\putwordin{in}\fi -\ifx\putwordIndexIsEmpty\undefined \gdef\putwordIndexIsEmpty{(Index is empty)}\fi -\ifx\putwordIndexNonexistent\undefined \gdef\putwordIndexNonexistent{(Index is nonexistent)}\fi -\ifx\putwordInfo\undefined \gdef\putwordInfo{Info}\fi -\ifx\putwordInstanceVariableof\undefined \gdef\putwordInstanceVariableof{Instance Variable of}\fi -\ifx\putwordMethodon\undefined \gdef\putwordMethodon{Method on}\fi -\ifx\putwordNoTitle\undefined \gdef\putwordNoTitle{No Title}\fi -\ifx\putwordof\undefined \gdef\putwordof{of}\fi -\ifx\putwordon\undefined \gdef\putwordon{on}\fi -\ifx\putwordpage\undefined \gdef\putwordpage{page}\fi -\ifx\putwordsection\undefined \gdef\putwordsection{section}\fi -\ifx\putwordSection\undefined \gdef\putwordSection{Section}\fi -\ifx\putwordsee\undefined \gdef\putwordsee{see}\fi -\ifx\putwordSee\undefined \gdef\putwordSee{See}\fi -\ifx\putwordShortTOC\undefined \gdef\putwordShortTOC{Short Contents}\fi -\ifx\putwordTOC\undefined \gdef\putwordTOC{Table of Contents}\fi -% -\ifx\putwordMJan\undefined \gdef\putwordMJan{January}\fi -\ifx\putwordMFeb\undefined \gdef\putwordMFeb{February}\fi -\ifx\putwordMMar\undefined \gdef\putwordMMar{March}\fi -\ifx\putwordMApr\undefined \gdef\putwordMApr{April}\fi -\ifx\putwordMMay\undefined \gdef\putwordMMay{May}\fi -\ifx\putwordMJun\undefined \gdef\putwordMJun{June}\fi -\ifx\putwordMJul\undefined \gdef\putwordMJul{July}\fi -\ifx\putwordMAug\undefined \gdef\putwordMAug{August}\fi -\ifx\putwordMSep\undefined \gdef\putwordMSep{September}\fi -\ifx\putwordMOct\undefined \gdef\putwordMOct{October}\fi -\ifx\putwordMNov\undefined \gdef\putwordMNov{November}\fi -\ifx\putwordMDec\undefined \gdef\putwordMDec{December}\fi -% -\ifx\putwordDefmac\undefined \gdef\putwordDefmac{Macro}\fi -\ifx\putwordDefspec\undefined \gdef\putwordDefspec{Special Form}\fi -\ifx\putwordDefvar\undefined \gdef\putwordDefvar{Variable}\fi -\ifx\putwordDefopt\undefined \gdef\putwordDefopt{User Option}\fi -\ifx\putwordDeffunc\undefined \gdef\putwordDeffunc{Function}\fi - -% Since the category of space is not known, we have to be careful. -\chardef\spacecat = 10 -\def\spaceisspace{\catcode`\ =\spacecat} - -% sometimes characters are active, so we need control sequences. -\chardef\colonChar = `\: -\chardef\commaChar = `\, -\chardef\dashChar = `\- -\chardef\dotChar = `\. -\chardef\exclamChar= `\! -\chardef\lquoteChar= `\` -\chardef\questChar = `\? -\chardef\rquoteChar= `\' -\chardef\semiChar = `\; -\chardef\underChar = `\_ - -% Ignore a token. -% -\def\gobble#1{} - -% The following is used inside several \edef's. -\def\makecsname#1{\expandafter\noexpand\csname#1\endcsname} - -% Hyphenation fixes. -\hyphenation{ - Flor-i-da Ghost-script Ghost-view Mac-OS Post-Script - ap-pen-dix bit-map bit-maps - data-base data-bases eshell fall-ing half-way long-est man-u-script - man-u-scripts mini-buf-fer mini-buf-fers over-view par-a-digm - par-a-digms rath-er rec-tan-gu-lar ro-bot-ics se-vere-ly set-up spa-ces - spell-ing spell-ings - stand-alone strong-est time-stamp time-stamps which-ever white-space - wide-spread wrap-around -} - -% Margin to add to right of even pages, to left of odd pages. -\newdimen\bindingoffset -\newdimen\normaloffset -\newdimen\pagewidth \newdimen\pageheight - -% For a final copy, take out the rectangles -% that mark overfull boxes (in case you have decided -% that the text looks ok even though it passes the margin). -% -\def\finalout{\overfullrule=0pt} - -% @| inserts a changebar to the left of the current line. It should -% surround any changed text. This approach does *not* work if the -% change spans more than two lines of output. To handle that, we would -% have adopt a much more difficult approach (putting marks into the main -% vertical list for the beginning and end of each change). -% -\def\|{% - % \vadjust can only be used in horizontal mode. - \leavevmode - % - % Append this vertical mode material after the current line in the output. - \vadjust{% - % We want to insert a rule with the height and depth of the current - % leading; that is exactly what \strutbox is supposed to record. - \vskip-\baselineskip - % - % \vadjust-items are inserted at the left edge of the type. So - % the \llap here moves out into the left-hand margin. - \llap{% - % - % For a thicker or thinner bar, change the `1pt'. - \vrule height\baselineskip width1pt - % - % This is the space between the bar and the text. - \hskip 12pt - }% - }% -} - -% Sometimes it is convenient to have everything in the transcript file -% and nothing on the terminal. We don't just call \tracingall here, -% since that produces some useless output on the terminal. We also make -% some effort to order the tracing commands to reduce output in the log -% file; cf. trace.sty in LaTeX. -% -\def\gloggingall{\begingroup \globaldefs = 1 \loggingall \endgroup}% -\def\loggingall{% - \tracingstats2 - \tracingpages1 - \tracinglostchars2 % 2 gives us more in etex - \tracingparagraphs1 - \tracingoutput1 - \tracingmacros2 - \tracingrestores1 - \showboxbreadth\maxdimen \showboxdepth\maxdimen - \ifx\eTeXversion\undefined\else % etex gives us more logging - \tracingscantokens1 - \tracingifs1 - \tracinggroups1 - \tracingnesting2 - \tracingassigns1 - \fi - \tracingcommands3 % 3 gives us more in etex - \errorcontextlines16 -}% - -% add check for \lastpenalty to plain's definitions. If the last thing -% we did was a \nobreak, we don't want to insert more space. -% -\def\smallbreak{\ifnum\lastpenalty<10000\par\ifdim\lastskip<\smallskipamount - \removelastskip\penalty-50\smallskip\fi\fi} -\def\medbreak{\ifnum\lastpenalty<10000\par\ifdim\lastskip<\medskipamount - \removelastskip\penalty-100\medskip\fi\fi} -\def\bigbreak{\ifnum\lastpenalty<10000\par\ifdim\lastskip<\bigskipamount - \removelastskip\penalty-200\bigskip\fi\fi} - -% For @cropmarks command. -% Do @cropmarks to get crop marks. -% -\newif\ifcropmarks -\let\cropmarks = \cropmarkstrue -% -% Dimensions to add cropmarks at corners. -% Added by P. A. MacKay, 12 Nov. 1986 -% -\newdimen\outerhsize \newdimen\outervsize % set by the paper size routines -\newdimen\cornerlong \cornerlong=1pc -\newdimen\cornerthick \cornerthick=.3pt -\newdimen\topandbottommargin \topandbottommargin=.75in - -% Main output routine. -\chardef\PAGE = 255 -\output = {\onepageout{\pagecontents\PAGE}} - -\newbox\headlinebox -\newbox\footlinebox - -% \onepageout takes a vbox as an argument. Note that \pagecontents -% does insertions, but you have to call it yourself. -\def\onepageout#1{% - \ifcropmarks \hoffset=0pt \else \hoffset=\normaloffset \fi - % - \ifodd\pageno \advance\hoffset by \bindingoffset - \else \advance\hoffset by -\bindingoffset\fi - % - % Do this outside of the \shipout so @code etc. will be expanded in - % the headline as they should be, not taken literally (outputting ''code). - \setbox\headlinebox = \vbox{\let\hsize=\pagewidth \makeheadline}% - \setbox\footlinebox = \vbox{\let\hsize=\pagewidth \makefootline}% - % - {% - % Have to do this stuff outside the \shipout because we want it to - % take effect in \write's, yet the group defined by the \vbox ends - % before the \shipout runs. - % - \indexdummies % don't expand commands in the output. - \normalturnoffactive % \ in index entries must not stay \, e.g., if - % the page break happens to be in the middle of an example. - % We don't want .vr (or whatever) entries like this: - % \entry{{\tt \indexbackslash }acronym}{32}{\code {\acronym}} - % "\acronym" won't work when it's read back in; - % it needs to be - % {\code {{\tt \backslashcurfont }acronym} - \shipout\vbox{% - % Do this early so pdf references go to the beginning of the page. - \ifpdfmakepagedest \pdfdest name{\the\pageno} xyz\fi - % - \ifcropmarks \vbox to \outervsize\bgroup - \hsize = \outerhsize - \vskip-\topandbottommargin - \vtop to0pt{% - \line{\ewtop\hfil\ewtop}% - \nointerlineskip - \line{% - \vbox{\moveleft\cornerthick\nstop}% - \hfill - \vbox{\moveright\cornerthick\nstop}% - }% - \vss}% - \vskip\topandbottommargin - \line\bgroup - \hfil % center the page within the outer (page) hsize. - \ifodd\pageno\hskip\bindingoffset\fi - \vbox\bgroup - \fi - % - \unvbox\headlinebox - \pagebody{#1}% - \ifdim\ht\footlinebox > 0pt - % Only leave this space if the footline is nonempty. - % (We lessened \vsize for it in \oddfootingyyy.) - % The \baselineskip=24pt in plain's \makefootline has no effect. - \vskip 24pt - \unvbox\footlinebox - \fi - % - \ifcropmarks - \egroup % end of \vbox\bgroup - \hfil\egroup % end of (centering) \line\bgroup - \vskip\topandbottommargin plus1fill minus1fill - \boxmaxdepth = \cornerthick - \vbox to0pt{\vss - \line{% - \vbox{\moveleft\cornerthick\nsbot}% - \hfill - \vbox{\moveright\cornerthick\nsbot}% - }% - \nointerlineskip - \line{\ewbot\hfil\ewbot}% - }% - \egroup % \vbox from first cropmarks clause - \fi - }% end of \shipout\vbox - }% end of group with \indexdummies - \advancepageno - \ifnum\outputpenalty>-20000 \else\dosupereject\fi -} - -\newinsert\margin \dimen\margin=\maxdimen - -\def\pagebody#1{\vbox to\pageheight{\boxmaxdepth=\maxdepth #1}} -{\catcode`\@ =11 -\gdef\pagecontents#1{\ifvoid\topins\else\unvbox\topins\fi -% marginal hacks, juha@viisa.uucp (Juha Takala) -\ifvoid\margin\else % marginal info is present - \rlap{\kern\hsize\vbox to\z@{\kern1pt\box\margin \vss}}\fi -\dimen@=\dp#1 \unvbox#1 -\ifvoid\footins\else\vskip\skip\footins\footnoterule \unvbox\footins\fi -\ifr@ggedbottom \kern-\dimen@ \vfil \fi} -} - -% Here are the rules for the cropmarks. Note that they are -% offset so that the space between them is truly \outerhsize or \outervsize -% (P. A. MacKay, 12 November, 1986) -% -\def\ewtop{\vrule height\cornerthick depth0pt width\cornerlong} -\def\nstop{\vbox - {\hrule height\cornerthick depth\cornerlong width\cornerthick}} -\def\ewbot{\vrule height0pt depth\cornerthick width\cornerlong} -\def\nsbot{\vbox - {\hrule height\cornerlong depth\cornerthick width\cornerthick}} - -% Parse an argument, then pass it to #1. The argument is the rest of -% the input line (except we remove a trailing comment). #1 should be a -% macro which expects an ordinary undelimited TeX argument. -% -\def\parsearg{\parseargusing{}} -\def\parseargusing#1#2{% - \def\argtorun{#2}% - \begingroup - \obeylines - \spaceisspace - #1% - \parseargline\empty% Insert the \empty token, see \finishparsearg below. -} - -{\obeylines % - \gdef\parseargline#1^^M{% - \endgroup % End of the group started in \parsearg. - \argremovecomment #1\comment\ArgTerm% - }% -} - -% First remove any @comment, then any @c comment. -\def\argremovecomment#1\comment#2\ArgTerm{\argremovec #1\c\ArgTerm} -\def\argremovec#1\c#2\ArgTerm{\argcheckspaces#1\^^M\ArgTerm} - -% Each occurence of `\^^M' or `\^^M' is replaced by a single space. -% -% \argremovec might leave us with trailing space, e.g., -% @end itemize @c foo -% This space token undergoes the same procedure and is eventually removed -% by \finishparsearg. -% -\def\argcheckspaces#1\^^M{\argcheckspacesX#1\^^M \^^M} -\def\argcheckspacesX#1 \^^M{\argcheckspacesY#1\^^M} -\def\argcheckspacesY#1\^^M#2\^^M#3\ArgTerm{% - \def\temp{#3}% - \ifx\temp\empty - % Do not use \next, perhaps the caller of \parsearg uses it; reuse \temp: - \let\temp\finishparsearg - \else - \let\temp\argcheckspaces - \fi - % Put the space token in: - \temp#1 #3\ArgTerm -} - -% If a _delimited_ argument is enclosed in braces, they get stripped; so -% to get _exactly_ the rest of the line, we had to prevent such situation. -% We prepended an \empty token at the very beginning and we expand it now, -% just before passing the control to \argtorun. -% (Similarily, we have to think about #3 of \argcheckspacesY above: it is -% either the null string, or it ends with \^^M---thus there is no danger -% that a pair of braces would be stripped. -% -% But first, we have to remove the trailing space token. -% -\def\finishparsearg#1 \ArgTerm{\expandafter\argtorun\expandafter{#1}} - -% \parseargdef\foo{...} -% is roughly equivalent to -% \def\foo{\parsearg\Xfoo} -% \def\Xfoo#1{...} -% -% Actually, I use \csname\string\foo\endcsname, ie. \\foo, as it is my -% favourite TeX trick. --kasal, 16nov03 - -\def\parseargdef#1{% - \expandafter \doparseargdef \csname\string#1\endcsname #1% -} -\def\doparseargdef#1#2{% - \def#2{\parsearg#1}% - \def#1##1% -} - -% Several utility definitions with active space: -{ - \obeyspaces - \gdef\obeyedspace{ } - - % Make each space character in the input produce a normal interword - % space in the output. Don't allow a line break at this space, as this - % is used only in environments like @example, where each line of input - % should produce a line of output anyway. - % - \gdef\sepspaces{\obeyspaces\let =\tie} - - % If an index command is used in an @example environment, any spaces - % therein should become regular spaces in the raw index file, not the - % expansion of \tie (\leavevmode \penalty \@M \ ). - \gdef\unsepspaces{\let =\space} -} - - -\def\flushcr{\ifx\par\lisppar \def\next##1{}\else \let\next=\relax \fi \next} - -% Define the framework for environments in texinfo.tex. It's used like this: -% -% \envdef\foo{...} -% \def\Efoo{...} -% -% It's the responsibility of \envdef to insert \begingroup before the -% actual body; @end closes the group after calling \Efoo. \envdef also -% defines \thisenv, so the current environment is known; @end checks -% whether the environment name matches. The \checkenv macro can also be -% used to check whether the current environment is the one expected. -% -% Non-false conditionals (@iftex, @ifset) don't fit into this, so they -% are not treated as enviroments; they don't open a group. (The -% implementation of @end takes care not to call \endgroup in this -% special case.) - - -% At runtime, environments start with this: -\def\startenvironment#1{\begingroup\def\thisenv{#1}} -% initialize -\let\thisenv\empty - -% ... but they get defined via ``\envdef\foo{...}'': -\long\def\envdef#1#2{\def#1{\startenvironment#1#2}} -\def\envparseargdef#1#2{\parseargdef#1{\startenvironment#1#2}} - -% Check whether we're in the right environment: -\def\checkenv#1{% - \def\temp{#1}% - \ifx\thisenv\temp - \else - \badenverr - \fi -} - -% Evironment mismatch, #1 expected: -\def\badenverr{% - \errhelp = \EMsimple - \errmessage{This command can appear only \inenvironment\temp, - not \inenvironment\thisenv}% -} -\def\inenvironment#1{% - \ifx#1\empty - out of any environment% - \else - in environment \expandafter\string#1% - \fi -} - -% @end foo executes the definition of \Efoo. -% But first, it executes a specialized version of \checkenv -% -\parseargdef\end{% - \if 1\csname iscond.#1\endcsname - \else - % The general wording of \badenverr may not be ideal, but... --kasal, 06nov03 - \expandafter\checkenv\csname#1\endcsname - \csname E#1\endcsname - \endgroup - \fi -} - -\newhelp\EMsimple{Press RETURN to continue.} - - -%% Simple single-character @ commands - -% @@ prints an @ -% Kludge this until the fonts are right (grr). -\def\@{{\tt\char64}} - -% This is turned off because it was never documented -% and you can use @w{...} around a quote to suppress ligatures. -%% Define @` and @' to be the same as ` and ' -%% but suppressing ligatures. -%\def\`{{`}} -%\def\'{{'}} - -% Used to generate quoted braces. -\def\mylbrace {{\tt\char123}} -\def\myrbrace {{\tt\char125}} -\let\{=\mylbrace -\let\}=\myrbrace -\begingroup - % Definitions to produce \{ and \} commands for indices, - % and @{ and @} for the aux/toc files. - \catcode`\{ = \other \catcode`\} = \other - \catcode`\[ = 1 \catcode`\] = 2 - \catcode`\! = 0 \catcode`\\ = \other - !gdef!lbracecmd[\{]% - !gdef!rbracecmd[\}]% - !gdef!lbraceatcmd[@{]% - !gdef!rbraceatcmd[@}]% -!endgroup - -% @comma{} to avoid , parsing problems. -\let\comma = , - -% Accents: @, @dotaccent @ringaccent @ubaraccent @udotaccent -% Others are defined by plain TeX: @` @' @" @^ @~ @= @u @v @H. -\let\, = \c -\let\dotaccent = \. -\def\ringaccent#1{{\accent23 #1}} -\let\tieaccent = \t -\let\ubaraccent = \b -\let\udotaccent = \d - -% Other special characters: @questiondown @exclamdown @ordf @ordm -% Plain TeX defines: @AA @AE @O @OE @L (plus lowercase versions) @ss. -\def\questiondown{?`} -\def\exclamdown{!`} -\def\ordf{\leavevmode\raise1ex\hbox{\selectfonts\lllsize \underbar{a}}} -\def\ordm{\leavevmode\raise1ex\hbox{\selectfonts\lllsize \underbar{o}}} - -% Dotless i and dotless j, used for accents. -\def\imacro{i} -\def\jmacro{j} -\def\dotless#1{% - \def\temp{#1}% - \ifx\temp\imacro \ptexi - \else\ifx\temp\jmacro \j - \else \errmessage{@dotless can be used only with i or j}% - \fi\fi -} - -% The \TeX{} logo, as in plain, but resetting the spacing so that a -% period following counts as ending a sentence. (Idea found in latex.) -% -\edef\TeX{\TeX \spacefactor=1000 } - -% @LaTeX{} logo. Not quite the same results as the definition in -% latex.ltx, since we use a different font for the raised A; it's most -% convenient for us to use an explicitly smaller font, rather than using -% the \scriptstyle font (since we don't reset \scriptstyle and -% \scriptscriptstyle). -% -\def\LaTeX{% - L\kern-.36em - {\setbox0=\hbox{T}% - \vbox to \ht0{\hbox{\selectfonts\lllsize A}\vss}}% - \kern-.15em - \TeX -} - -% Be sure we're in horizontal mode when doing a tie, since we make space -% equivalent to this in @example-like environments. Otherwise, a space -% at the beginning of a line will start with \penalty -- and -% since \penalty is valid in vertical mode, we'd end up putting the -% penalty on the vertical list instead of in the new paragraph. -{\catcode`@ = 11 - % Avoid using \@M directly, because that causes trouble - % if the definition is written into an index file. - \global\let\tiepenalty = \@M - \gdef\tie{\leavevmode\penalty\tiepenalty\ } -} - -% @: forces normal size whitespace following. -\def\:{\spacefactor=1000 } - -% @* forces a line break. -\def\*{\hfil\break\hbox{}\ignorespaces} - -% @/ allows a line break. -\let\/=\allowbreak - -% @. is an end-of-sentence period. -\def\.{.\spacefactor=\endofsentencespacefactor\space} - -% @! is an end-of-sentence bang. -\def\!{!\spacefactor=\endofsentencespacefactor\space} - -% @? is an end-of-sentence query. -\def\?{?\spacefactor=\endofsentencespacefactor\space} - -% @frenchspacing on|off says whether to put extra space after punctuation. -% -\def\onword{on} -\def\offword{off} -% -\parseargdef\frenchspacing{% - \def\temp{#1}% - \ifx\temp\onword \plainfrenchspacing - \else\ifx\temp\offword \plainnonfrenchspacing - \else - \errhelp = \EMsimple - \errmessage{Unknown @frenchspacing option `\temp', must be on/off}% - \fi\fi -} - -% @w prevents a word break. Without the \leavevmode, @w at the -% beginning of a paragraph, when TeX is still in vertical mode, would -% produce a whole line of output instead of starting the paragraph. -\def\w#1{\leavevmode\hbox{#1}} - -% @group ... @end group forces ... to be all on one page, by enclosing -% it in a TeX vbox. We use \vtop instead of \vbox to construct the box -% to keep its height that of a normal line. According to the rules for -% \topskip (p.114 of the TeXbook), the glue inserted is -% max (\topskip - \ht (first item), 0). If that height is large, -% therefore, no glue is inserted, and the space between the headline and -% the text is small, which looks bad. -% -% Another complication is that the group might be very large. This can -% cause the glue on the previous page to be unduly stretched, because it -% does not have much material. In this case, it's better to add an -% explicit \vfill so that the extra space is at the bottom. The -% threshold for doing this is if the group is more than \vfilllimit -% percent of a page (\vfilllimit can be changed inside of @tex). -% -\newbox\groupbox -\def\vfilllimit{0.7} -% -\envdef\group{% - \ifnum\catcode`\^^M=\active \else - \errhelp = \groupinvalidhelp - \errmessage{@group invalid in context where filling is enabled}% - \fi - \startsavinginserts - % - \setbox\groupbox = \vtop\bgroup - % Do @comment since we are called inside an environment such as - % @example, where each end-of-line in the input causes an - % end-of-line in the output. We don't want the end-of-line after - % the `@group' to put extra space in the output. Since @group - % should appear on a line by itself (according to the Texinfo - % manual), we don't worry about eating any user text. - \comment -} -% -% The \vtop produces a box with normal height and large depth; thus, TeX puts -% \baselineskip glue before it, and (when the next line of text is done) -% \lineskip glue after it. Thus, space below is not quite equal to space -% above. But it's pretty close. -\def\Egroup{% - % To get correct interline space between the last line of the group - % and the first line afterwards, we have to propagate \prevdepth. - \endgraf % Not \par, as it may have been set to \lisppar. - \global\dimen1 = \prevdepth - \egroup % End the \vtop. - % \dimen0 is the vertical size of the group's box. - \dimen0 = \ht\groupbox \advance\dimen0 by \dp\groupbox - % \dimen2 is how much space is left on the page (more or less). - \dimen2 = \pageheight \advance\dimen2 by -\pagetotal - % if the group doesn't fit on the current page, and it's a big big - % group, force a page break. - \ifdim \dimen0 > \dimen2 - \ifdim \pagetotal < \vfilllimit\pageheight - \page - \fi - \fi - \box\groupbox - \prevdepth = \dimen1 - \checkinserts -} -% -% TeX puts in an \escapechar (i.e., `@') at the beginning of the help -% message, so this ends up printing `@group can only ...'. -% -\newhelp\groupinvalidhelp{% -group can only be used in environments such as @example,^^J% -where each line of input produces a line of output.} - -% @need space-in-mils -% forces a page break if there is not space-in-mils remaining. - -\newdimen\mil \mil=0.001in - -% Old definition--didn't work. -%\parseargdef\need{\par % -%% This method tries to make TeX break the page naturally -%% if the depth of the box does not fit. -%{\baselineskip=0pt% -%\vtop to #1\mil{\vfil}\kern -#1\mil\nobreak -%\prevdepth=-1000pt -%}} - -\parseargdef\need{% - % Ensure vertical mode, so we don't make a big box in the middle of a - % paragraph. - \par - % - % If the @need value is less than one line space, it's useless. - \dimen0 = #1\mil - \dimen2 = \ht\strutbox - \advance\dimen2 by \dp\strutbox - \ifdim\dimen0 > \dimen2 - % - % Do a \strut just to make the height of this box be normal, so the - % normal leading is inserted relative to the preceding line. - % And a page break here is fine. - \vtop to #1\mil{\strut\vfil}% - % - % TeX does not even consider page breaks if a penalty added to the - % main vertical list is 10000 or more. But in order to see if the - % empty box we just added fits on the page, we must make it consider - % page breaks. On the other hand, we don't want to actually break the - % page after the empty box. So we use a penalty of 9999. - % - % There is an extremely small chance that TeX will actually break the - % page at this \penalty, if there are no other feasible breakpoints in - % sight. (If the user is using lots of big @group commands, which - % almost-but-not-quite fill up a page, TeX will have a hard time doing - % good page breaking, for example.) However, I could not construct an - % example where a page broke at this \penalty; if it happens in a real - % document, then we can reconsider our strategy. - \penalty9999 - % - % Back up by the size of the box, whether we did a page break or not. - \kern -#1\mil - % - % Do not allow a page break right after this kern. - \nobreak - \fi -} - -% @br forces paragraph break (and is undocumented). - -\let\br = \par - -% @page forces the start of a new page. -% -\def\page{\par\vfill\supereject} - -% @exdent text.... -% outputs text on separate line in roman font, starting at standard page margin - -% This records the amount of indent in the innermost environment. -% That's how much \exdent should take out. -\newskip\exdentamount - -% This defn is used inside fill environments such as @defun. -\parseargdef\exdent{\hfil\break\hbox{\kern -\exdentamount{\rm#1}}\hfil\break} - -% This defn is used inside nofill environments such as @example. -\parseargdef\nofillexdent{{\advance \leftskip by -\exdentamount - \leftline{\hskip\leftskip{\rm#1}}}} - -% @inmargin{WHICH}{TEXT} puts TEXT in the WHICH margin next to the current -% paragraph. For more general purposes, use the \margin insertion -% class. WHICH is `l' or `r'. -% -\newskip\inmarginspacing \inmarginspacing=1cm -\def\strutdepth{\dp\strutbox} -% -\def\doinmargin#1#2{\strut\vadjust{% - \nobreak - \kern-\strutdepth - \vtop to \strutdepth{% - \baselineskip=\strutdepth - \vss - % if you have multiple lines of stuff to put here, you'll need to - % make the vbox yourself of the appropriate size. - \ifx#1l% - \llap{\ignorespaces #2\hskip\inmarginspacing}% - \else - \rlap{\hskip\hsize \hskip\inmarginspacing \ignorespaces #2}% - \fi - \null - }% -}} -\def\inleftmargin{\doinmargin l} -\def\inrightmargin{\doinmargin r} -% -% @inmargin{TEXT [, RIGHT-TEXT]} -% (if RIGHT-TEXT is given, use TEXT for left page, RIGHT-TEXT for right; -% else use TEXT for both). -% -\def\inmargin#1{\parseinmargin #1,,\finish} -\def\parseinmargin#1,#2,#3\finish{% not perfect, but better than nothing. - \setbox0 = \hbox{\ignorespaces #2}% - \ifdim\wd0 > 0pt - \def\lefttext{#1}% have both texts - \def\righttext{#2}% - \else - \def\lefttext{#1}% have only one text - \def\righttext{#1}% - \fi - % - \ifodd\pageno - \def\temp{\inrightmargin\righttext}% odd page -> outside is right margin - \else - \def\temp{\inleftmargin\lefttext}% - \fi - \temp -} - -% @include file insert text of that file as input. -% -\def\include{\parseargusing\filenamecatcodes\includezzz} -\def\includezzz#1{% - \pushthisfilestack - \def\thisfile{#1}% - {% - \makevalueexpandable - \def\temp{\input #1 }% - \expandafter - }\temp - \popthisfilestack -} -\def\filenamecatcodes{% - \catcode`\\=\other - \catcode`~=\other - \catcode`^=\other - \catcode`_=\other - \catcode`|=\other - \catcode`<=\other - \catcode`>=\other - \catcode`+=\other - \catcode`-=\other -} - -\def\pushthisfilestack{% - \expandafter\pushthisfilestackX\popthisfilestack\StackTerm -} -\def\pushthisfilestackX{% - \expandafter\pushthisfilestackY\thisfile\StackTerm -} -\def\pushthisfilestackY #1\StackTerm #2\StackTerm {% - \gdef\popthisfilestack{\gdef\thisfile{#1}\gdef\popthisfilestack{#2}}% -} - -\def\popthisfilestack{\errthisfilestackempty} -\def\errthisfilestackempty{\errmessage{Internal error: - the stack of filenames is empty.}} - -\def\thisfile{} - -% @center line -% outputs that line, centered. -% -\parseargdef\center{% - \ifhmode - \let\next\centerH - \else - \let\next\centerV - \fi - \next{\hfil \ignorespaces#1\unskip \hfil}% -} -\def\centerH#1{% - {% - \hfil\break - \advance\hsize by -\leftskip - \advance\hsize by -\rightskip - \line{#1}% - \break - }% -} -\def\centerV#1{\line{\kern\leftskip #1\kern\rightskip}} - -% @sp n outputs n lines of vertical space - -\parseargdef\sp{\vskip #1\baselineskip} - -% @comment ...line which is ignored... -% @c is the same as @comment -% @ignore ... @end ignore is another way to write a comment - -\def\comment{\begingroup \catcode`\^^M=\other% -\catcode`\@=\other \catcode`\{=\other \catcode`\}=\other% -\commentxxx} -{\catcode`\^^M=\other \gdef\commentxxx#1^^M{\endgroup}} - -\let\c=\comment - -% @paragraphindent NCHARS -% We'll use ems for NCHARS, close enough. -% NCHARS can also be the word `asis' or `none'. -% We cannot feasibly implement @paragraphindent asis, though. -% -\def\asisword{asis} % no translation, these are keywords -\def\noneword{none} -% -\parseargdef\paragraphindent{% - \def\temp{#1}% - \ifx\temp\asisword - \else - \ifx\temp\noneword - \defaultparindent = 0pt - \else - \defaultparindent = #1em - \fi - \fi - \parindent = \defaultparindent -} - -% @exampleindent NCHARS -% We'll use ems for NCHARS like @paragraphindent. -% It seems @exampleindent asis isn't necessary, but -% I preserve it to make it similar to @paragraphindent. -\parseargdef\exampleindent{% - \def\temp{#1}% - \ifx\temp\asisword - \else - \ifx\temp\noneword - \lispnarrowing = 0pt - \else - \lispnarrowing = #1em - \fi - \fi -} - -% @firstparagraphindent WORD -% If WORD is `none', then suppress indentation of the first paragraph -% after a section heading. If WORD is `insert', then do indent at such -% paragraphs. -% -% The paragraph indentation is suppressed or not by calling -% \suppressfirstparagraphindent, which the sectioning commands do. -% We switch the definition of this back and forth according to WORD. -% By default, we suppress indentation. -% -\def\suppressfirstparagraphindent{\dosuppressfirstparagraphindent} -\def\insertword{insert} -% -\parseargdef\firstparagraphindent{% - \def\temp{#1}% - \ifx\temp\noneword - \let\suppressfirstparagraphindent = \dosuppressfirstparagraphindent - \else\ifx\temp\insertword - \let\suppressfirstparagraphindent = \relax - \else - \errhelp = \EMsimple - \errmessage{Unknown @firstparagraphindent option `\temp'}% - \fi\fi -} - -% Here is how we actually suppress indentation. Redefine \everypar to -% \kern backwards by \parindent, and then reset itself to empty. -% -% We also make \indent itself not actually do anything until the next -% paragraph. -% -\gdef\dosuppressfirstparagraphindent{% - \gdef\indent{% - \restorefirstparagraphindent - \indent - }% - \gdef\noindent{% - \restorefirstparagraphindent - \noindent - }% - \global\everypar = {% - \kern -\parindent - \restorefirstparagraphindent - }% -} - -\gdef\restorefirstparagraphindent{% - \global \let \indent = \ptexindent - \global \let \noindent = \ptexnoindent - \global \everypar = {}% -} - - -% @asis just yields its argument. Used with @table, for example. -% -\def\asis#1{#1} - -% @math outputs its argument in math mode. -% -% One complication: _ usually means subscripts, but it could also mean -% an actual _ character, as in @math{@var{some_variable} + 1}. So make -% _ active, and distinguish by seeing if the current family is \slfam, -% which is what @var uses. -{ - \catcode`\_ = \active - \gdef\mathunderscore{% - \catcode`\_=\active - \def_{\ifnum\fam=\slfam \_\else\sb\fi}% - } -} -% Another complication: we want \\ (and @\) to output a \ character. -% FYI, plain.tex uses \\ as a temporary control sequence (why?), but -% this is not advertised and we don't care. Texinfo does not -% otherwise define @\. -% -% The \mathchar is class=0=ordinary, family=7=ttfam, position=5C=\. -\def\mathbackslash{\ifnum\fam=\ttfam \mathchar"075C \else\backslash \fi} -% -\def\math{% - \tex - \mathunderscore - \let\\ = \mathbackslash - \mathactive - $\finishmath -} -\def\finishmath#1{#1$\endgroup} % Close the group opened by \tex. - -% Some active characters (such as <) are spaced differently in math. -% We have to reset their definitions in case the @math was an argument -% to a command which sets the catcodes (such as @item or @section). -% -{ - \catcode`^ = \active - \catcode`< = \active - \catcode`> = \active - \catcode`+ = \active - \gdef\mathactive{% - \let^ = \ptexhat - \let< = \ptexless - \let> = \ptexgtr - \let+ = \ptexplus - } -} - -% @bullet and @minus need the same treatment as @math, just above. -\def\bullet{$\ptexbullet$} -\def\minus{$-$} - -% @dots{} outputs an ellipsis using the current font. -% We do .5em per period so that it has the same spacing in the cm -% typewriter fonts as three actual period characters; on the other hand, -% in other typewriter fonts three periods are wider than 1.5em. So do -% whichever is larger. -% -\def\dots{% - \leavevmode - \setbox0=\hbox{...}% get width of three periods - \ifdim\wd0 > 1.5em - \dimen0 = \wd0 - \else - \dimen0 = 1.5em - \fi - \hbox to \dimen0{% - \hskip 0pt plus.25fil - .\hskip 0pt plus1fil - .\hskip 0pt plus1fil - .\hskip 0pt plus.5fil - }% -} - -% @enddots{} is an end-of-sentence ellipsis. -% -\def\enddots{% - \dots - \spacefactor=\endofsentencespacefactor -} - -% @comma{} is so commas can be inserted into text without messing up -% Texinfo's parsing. -% -\let\comma = , - -% @refill is a no-op. -\let\refill=\relax - -% If working on a large document in chapters, it is convenient to -% be able to disable indexing, cross-referencing, and contents, for test runs. -% This is done with @novalidate (before @setfilename). -% -\newif\iflinks \linkstrue % by default we want the aux files. -\let\novalidate = \linksfalse - -% @setfilename is done at the beginning of every texinfo file. -% So open here the files we need to have open while reading the input. -% This makes it possible to make a .fmt file for texinfo. -\def\setfilename{% - \fixbackslash % Turn off hack to swallow `\input texinfo'. - \iflinks - \tryauxfile - % Open the new aux file. TeX will close it automatically at exit. - \immediate\openout\auxfile=\jobname.aux - \fi % \openindices needs to do some work in any case. - \openindices - \let\setfilename=\comment % Ignore extra @setfilename cmds. - % - % If texinfo.cnf is present on the system, read it. - % Useful for site-wide @afourpaper, etc. - \openin 1 texinfo.cnf - \ifeof 1 \else \input texinfo.cnf \fi - \closein 1 - % - \comment % Ignore the actual filename. -} - -% Called from \setfilename. -% -\def\openindices{% - \newindex{cp}% - \newcodeindex{fn}% - \newcodeindex{vr}% - \newcodeindex{tp}% - \newcodeindex{ky}% - \newcodeindex{pg}% -} - -% @bye. -\outer\def\bye{\pagealignmacro\tracingstats=1\ptexend} - - -\message{pdf,} -% adobe `portable' document format -\newcount\tempnum -\newcount\lnkcount -\newtoks\filename -\newcount\filenamelength -\newcount\pgn -\newtoks\toksA -\newtoks\toksB -\newtoks\toksC -\newtoks\toksD -\newbox\boxA -\newcount\countA -\newif\ifpdf -\newif\ifpdfmakepagedest - -% when pdftex is run in dvi mode, \pdfoutput is defined (so \pdfoutput=1 -% can be set). So we test for \relax and 0 as well as \undefined, -% borrowed from ifpdf.sty. -\ifx\pdfoutput\undefined -\else - \ifx\pdfoutput\relax - \else - \ifcase\pdfoutput - \else - \pdftrue - \fi - \fi -\fi - -% PDF uses PostScript string constants for the names of xref targets, -% for display in the outlines, and in other places. Thus, we have to -% double any backslashes. Otherwise, a name like "\node" will be -% interpreted as a newline (\n), followed by o, d, e. Not good. -% http://www.ntg.nl/pipermail/ntg-pdftex/2004-July/000654.html -% (and related messages, the final outcome is that it is up to the TeX -% user to double the backslashes and otherwise make the string valid, so -% that's what we do). - -% double active backslashes. -% -{\catcode`\@=0 \catcode`\\=\active - @gdef@activebackslashdouble{% - @catcode`@\=@active - @let\=@doublebackslash} -} - -% To handle parens, we must adopt a different approach, since parens are -% not active characters. hyperref.dtx (which has the same problem as -% us) handles it with this amazing macro to replace tokens. I've -% tinkered with it a little for texinfo, but it's definitely from there. -% -% #1 is the tokens to replace. -% #2 is the replacement. -% #3 is the control sequence with the string. -% -\def\HyPsdSubst#1#2#3{% - \def\HyPsdReplace##1#1##2\END{% - ##1% - \ifx\\##2\\% - \else - #2% - \HyReturnAfterFi{% - \HyPsdReplace##2\END - }% - \fi - }% - \xdef#3{\expandafter\HyPsdReplace#3#1\END}% -} -\long\def\HyReturnAfterFi#1\fi{\fi#1} - -% #1 is a control sequence in which to do the replacements. -\def\backslashparens#1{% - \xdef#1{#1}% redefine it as its expansion; the definition is simply - % \lastnode when called from \setref -> \pdfmkdest. - \HyPsdSubst{(}{\realbackslash(}{#1}% - \HyPsdSubst{)}{\realbackslash)}{#1}% -} - -\ifpdf - \input pdfcolor - \pdfcatalog{/PageMode /UseOutlines}% - % #1 is image name, #2 width (might be empty/whitespace), #3 height (ditto). - \def\dopdfimage#1#2#3{% - \def\imagewidth{#2}\setbox0 = \hbox{\ignorespaces #2}% - \def\imageheight{#3}\setbox2 = \hbox{\ignorespaces #3}% - % without \immediate, pdftex seg faults when the same image is - % included twice. (Version 3.14159-pre-1.0-unofficial-20010704.) - \ifnum\pdftexversion < 14 - \immediate\pdfimage - \else - \immediate\pdfximage - \fi - \ifdim \wd0 >0pt width \imagewidth \fi - \ifdim \wd2 >0pt height \imageheight \fi - \ifnum\pdftexversion<13 - #1.pdf% - \else - {#1.pdf}% - \fi - \ifnum\pdftexversion < 14 \else - \pdfrefximage \pdflastximage - \fi} - \def\pdfmkdest#1{{% - % We have to set dummies so commands such as @code, and characters - % such as \, aren't expanded when present in a section title. - \atdummies - \activebackslashdouble - \def\pdfdestname{#1}% - \backslashparens\pdfdestname - \pdfdest name{\pdfdestname} xyz% - }}% - % - % used to mark target names; must be expandable. - \def\pdfmkpgn#1{#1}% - % - \let\linkcolor = \Blue % was Cyan, but that seems light? - \def\endlink{\Black\pdfendlink} - % Adding outlines to PDF; macros for calculating structure of outlines - % come from Petr Olsak - \def\expnumber#1{\expandafter\ifx\csname#1\endcsname\relax 0% - \else \csname#1\endcsname \fi} - \def\advancenumber#1{\tempnum=\expnumber{#1}\relax - \advance\tempnum by 1 - \expandafter\xdef\csname#1\endcsname{\the\tempnum}} - % - % #1 is the section text, which is what will be displayed in the - % outline by the pdf viewer. #2 is the pdf expression for the number - % of subentries (or empty, for subsubsections). #3 is the node text, - % which might be empty if this toc entry had no corresponding node. - % #4 is the page number - % - \def\dopdfoutline#1#2#3#4{% - % Generate a link to the node text if that exists; else, use the - % page number. We could generate a destination for the section - % text in the case where a section has no node, but it doesn't - % seem worth the trouble, since most documents are normally structured. - \def\pdfoutlinedest{#3}% - \ifx\pdfoutlinedest\empty - \def\pdfoutlinedest{#4}% - \else - % Doubled backslashes in the name. - {\activebackslashdouble \xdef\pdfoutlinedest{#3}% - \backslashparens\pdfoutlinedest}% - \fi - % - % Also double the backslashes in the display string. - {\activebackslashdouble \xdef\pdfoutlinetext{#1}% - \backslashparens\pdfoutlinetext}% - % - \pdfoutline goto name{\pdfmkpgn{\pdfoutlinedest}}#2{\pdfoutlinetext}% - } - % - \def\pdfmakeoutlines{% - \begingroup - % Thanh's hack / proper braces in bookmarks - \edef\mylbrace{\iftrue \string{\else}\fi}\let\{=\mylbrace - \edef\myrbrace{\iffalse{\else\string}\fi}\let\}=\myrbrace - % - % Read toc silently, to get counts of subentries for \pdfoutline. - \def\numchapentry##1##2##3##4{% - \def\thischapnum{##2}% - \def\thissecnum{0}% - \def\thissubsecnum{0}% - }% - \def\numsecentry##1##2##3##4{% - \advancenumber{chap\thischapnum}% - \def\thissecnum{##2}% - \def\thissubsecnum{0}% - }% - \def\numsubsecentry##1##2##3##4{% - \advancenumber{sec\thissecnum}% - \def\thissubsecnum{##2}% - }% - \def\numsubsubsecentry##1##2##3##4{% - \advancenumber{subsec\thissubsecnum}% - }% - \def\thischapnum{0}% - \def\thissecnum{0}% - \def\thissubsecnum{0}% - % - % use \def rather than \let here because we redefine \chapentry et - % al. a second time, below. - \def\appentry{\numchapentry}% - \def\appsecentry{\numsecentry}% - \def\appsubsecentry{\numsubsecentry}% - \def\appsubsubsecentry{\numsubsubsecentry}% - \def\unnchapentry{\numchapentry}% - \def\unnsecentry{\numsecentry}% - \def\unnsubsecentry{\numsubsecentry}% - \def\unnsubsubsecentry{\numsubsubsecentry}% - \readdatafile{toc}% - % - % Read toc second time, this time actually producing the outlines. - % The `-' means take the \expnumber as the absolute number of - % subentries, which we calculated on our first read of the .toc above. - % - % We use the node names as the destinations. - \def\numchapentry##1##2##3##4{% - \dopdfoutline{##1}{count-\expnumber{chap##2}}{##3}{##4}}% - \def\numsecentry##1##2##3##4{% - \dopdfoutline{##1}{count-\expnumber{sec##2}}{##3}{##4}}% - \def\numsubsecentry##1##2##3##4{% - \dopdfoutline{##1}{count-\expnumber{subsec##2}}{##3}{##4}}% - \def\numsubsubsecentry##1##2##3##4{% count is always zero - \dopdfoutline{##1}{}{##3}{##4}}% - % - % PDF outlines are displayed using system fonts, instead of - % document fonts. Therefore we cannot use special characters, - % since the encoding is unknown. For example, the eogonek from - % Latin 2 (0xea) gets translated to a | character. Info from - % Staszek Wawrykiewicz, 19 Jan 2004 04:09:24 +0100. - % - % xx to do this right, we have to translate 8-bit characters to - % their "best" equivalent, based on the @documentencoding. Right - % now, I guess we'll just let the pdf reader have its way. - \indexnofonts - \setupdatafile - \catcode`\\=\active \otherbackslash - \input \jobname.toc - \endgroup - } - % - \def\skipspaces#1{\def\PP{#1}\def\D{|}% - \ifx\PP\D\let\nextsp\relax - \else\let\nextsp\skipspaces - \ifx\p\space\else\addtokens{\filename}{\PP}% - \advance\filenamelength by 1 - \fi - \fi - \nextsp} - \def\getfilename#1{\filenamelength=0\expandafter\skipspaces#1|\relax} - \ifnum\pdftexversion < 14 - \let \startlink \pdfannotlink - \else - \let \startlink \pdfstartlink - \fi - % make a live url in pdf output. - \def\pdfurl#1{% - \begingroup - % it seems we really need yet another set of dummies; have not - % tried to figure out what each command should do in the context - % of @url. for now, just make @/ a no-op, that's the only one - % people have actually reported a problem with. - % - \normalturnoffactive - \def\@{@}% - \let\/=\empty - \makevalueexpandable - \leavevmode\Red - \startlink attr{/Border [0 0 0]}% - user{/Subtype /Link /A << /S /URI /URI (#1) >>}% - \endgroup} - \def\pdfgettoks#1.{\setbox\boxA=\hbox{\toksA={#1.}\toksB={}\maketoks}} - \def\addtokens#1#2{\edef\addtoks{\noexpand#1={\the#1#2}}\addtoks} - \def\adn#1{\addtokens{\toksC}{#1}\global\countA=1\let\next=\maketoks} - \def\poptoks#1#2|ENDTOKS|{\let\first=#1\toksD={#1}\toksA={#2}} - \def\maketoks{% - \expandafter\poptoks\the\toksA|ENDTOKS|\relax - \ifx\first0\adn0 - \else\ifx\first1\adn1 \else\ifx\first2\adn2 \else\ifx\first3\adn3 - \else\ifx\first4\adn4 \else\ifx\first5\adn5 \else\ifx\first6\adn6 - \else\ifx\first7\adn7 \else\ifx\first8\adn8 \else\ifx\first9\adn9 - \else - \ifnum0=\countA\else\makelink\fi - \ifx\first.\let\next=\done\else - \let\next=\maketoks - \addtokens{\toksB}{\the\toksD} - \ifx\first,\addtokens{\toksB}{\space}\fi - \fi - \fi\fi\fi\fi\fi\fi\fi\fi\fi\fi - \next} - \def\makelink{\addtokens{\toksB}% - {\noexpand\pdflink{\the\toksC}}\toksC={}\global\countA=0} - \def\pdflink#1{% - \startlink attr{/Border [0 0 0]} goto name{\pdfmkpgn{#1}} - \linkcolor #1\endlink} - \def\done{\edef\st{\global\noexpand\toksA={\the\toksB}}\st} -\else - \let\pdfmkdest = \gobble - \let\pdfurl = \gobble - \let\endlink = \relax - \let\linkcolor = \relax - \let\pdfmakeoutlines = \relax -\fi % \ifx\pdfoutput - - -\message{fonts,} - -% Change the current font style to #1, remembering it in \curfontstyle. -% For now, we do not accumulate font styles: @b{@i{foo}} prints foo in -% italics, not bold italics. -% -\def\setfontstyle#1{% - \def\curfontstyle{#1}% not as a control sequence, because we are \edef'd. - \csname ten#1\endcsname % change the current font -} - -% Select #1 fonts with the current style. -% -\def\selectfonts#1{\csname #1fonts\endcsname \csname\curfontstyle\endcsname} - -\def\rm{\fam=0 \setfontstyle{rm}} -\def\it{\fam=\itfam \setfontstyle{it}} -\def\sl{\fam=\slfam \setfontstyle{sl}} -\def\bf{\fam=\bffam \setfontstyle{bf}}\def\bfstylename{bf} -\def\tt{\fam=\ttfam \setfontstyle{tt}} - -% Texinfo sort of supports the sans serif font style, which plain TeX does not. -% So we set up a \sf. -\newfam\sffam -\def\sf{\fam=\sffam \setfontstyle{sf}} -\let\li = \sf % Sometimes we call it \li, not \sf. - -% We don't need math for this font style. -\def\ttsl{\setfontstyle{ttsl}} - - -% Default leading. -\newdimen\textleading \textleading = 13.2pt - -% Set the baselineskip to #1, and the lineskip and strut size -% correspondingly. There is no deep meaning behind these magic numbers -% used as factors; they just match (closely enough) what Knuth defined. -% -\def\lineskipfactor{.08333} -\def\strutheightpercent{.70833} -\def\strutdepthpercent {.29167} -% -\def\setleading#1{% - \normalbaselineskip = #1\relax - \normallineskip = \lineskipfactor\normalbaselineskip - \normalbaselines - \setbox\strutbox =\hbox{% - \vrule width0pt height\strutheightpercent\baselineskip - depth \strutdepthpercent \baselineskip - }% -} - - -% Set the font macro #1 to the font named #2, adding on the -% specified font prefix (normally `cm'). -% #3 is the font's design size, #4 is a scale factor -\def\setfont#1#2#3#4{\font#1=\fontprefix#2#3 scaled #4} - - -% Use cm as the default font prefix. -% To specify the font prefix, you must define \fontprefix -% before you read in texinfo.tex. -\ifx\fontprefix\undefined -\def\fontprefix{cm} -\fi -% Support font families that don't use the same naming scheme as CM. -\def\rmshape{r} -\def\rmbshape{bx} %where the normal face is bold -\def\bfshape{b} -\def\bxshape{bx} -\def\ttshape{tt} -\def\ttbshape{tt} -\def\ttslshape{sltt} -\def\itshape{ti} -\def\itbshape{bxti} -\def\slshape{sl} -\def\slbshape{bxsl} -\def\sfshape{ss} -\def\sfbshape{ss} -\def\scshape{csc} -\def\scbshape{csc} - -% Definitions for a main text size of 11pt. This is the default in -% Texinfo. -% -\def\definetextfontsizexi{ -% Text fonts (11.2pt, magstep1). -\def\textnominalsize{11pt} -\edef\mainmagstep{\magstephalf} -\setfont\textrm\rmshape{10}{\mainmagstep} -\setfont\texttt\ttshape{10}{\mainmagstep} -\setfont\textbf\bfshape{10}{\mainmagstep} -\setfont\textit\itshape{10}{\mainmagstep} -\setfont\textsl\slshape{10}{\mainmagstep} -\setfont\textsf\sfshape{10}{\mainmagstep} -\setfont\textsc\scshape{10}{\mainmagstep} -\setfont\textttsl\ttslshape{10}{\mainmagstep} -\font\texti=cmmi10 scaled \mainmagstep -\font\textsy=cmsy10 scaled \mainmagstep - -% A few fonts for @defun names and args. -\setfont\defbf\bfshape{10}{\magstep1} -\setfont\deftt\ttshape{10}{\magstep1} -\setfont\defttsl\ttslshape{10}{\magstep1} -\def\df{\let\tentt=\deftt \let\tenbf = \defbf \let\tenttsl=\defttsl \bf} - -% Fonts for indices, footnotes, small examples (9pt). -\def\smallnominalsize{9pt} -\setfont\smallrm\rmshape{9}{1000} -\setfont\smalltt\ttshape{9}{1000} -\setfont\smallbf\bfshape{10}{900} -\setfont\smallit\itshape{9}{1000} -\setfont\smallsl\slshape{9}{1000} -\setfont\smallsf\sfshape{9}{1000} -\setfont\smallsc\scshape{10}{900} -\setfont\smallttsl\ttslshape{10}{900} -\font\smalli=cmmi9 -\font\smallsy=cmsy9 - -% Fonts for small examples (8pt). -\def\smallernominalsize{8pt} -\setfont\smallerrm\rmshape{8}{1000} -\setfont\smallertt\ttshape{8}{1000} -\setfont\smallerbf\bfshape{10}{800} -\setfont\smallerit\itshape{8}{1000} -\setfont\smallersl\slshape{8}{1000} -\setfont\smallersf\sfshape{8}{1000} -\setfont\smallersc\scshape{10}{800} -\setfont\smallerttsl\ttslshape{10}{800} -\font\smalleri=cmmi8 -\font\smallersy=cmsy8 - -% Fonts for title page (20.4pt): -\def\titlenominalsize{20pt} -\setfont\titlerm\rmbshape{12}{\magstep3} -\setfont\titleit\itbshape{10}{\magstep4} -\setfont\titlesl\slbshape{10}{\magstep4} -\setfont\titlett\ttbshape{12}{\magstep3} -\setfont\titlettsl\ttslshape{10}{\magstep4} -\setfont\titlesf\sfbshape{17}{\magstep1} -\let\titlebf=\titlerm -\setfont\titlesc\scbshape{10}{\magstep4} -\font\titlei=cmmi12 scaled \magstep3 -\font\titlesy=cmsy10 scaled \magstep4 -\def\authorrm{\secrm} -\def\authortt{\sectt} - -% Chapter (and unnumbered) fonts (17.28pt). -\def\chapnominalsize{17pt} -\setfont\chaprm\rmbshape{12}{\magstep2} -\setfont\chapit\itbshape{10}{\magstep3} -\setfont\chapsl\slbshape{10}{\magstep3} -\setfont\chaptt\ttbshape{12}{\magstep2} -\setfont\chapttsl\ttslshape{10}{\magstep3} -\setfont\chapsf\sfbshape{17}{1000} -\let\chapbf=\chaprm -\setfont\chapsc\scbshape{10}{\magstep3} -\font\chapi=cmmi12 scaled \magstep2 -\font\chapsy=cmsy10 scaled \magstep3 - -% Section fonts (14.4pt). -\def\secnominalsize{14pt} -\setfont\secrm\rmbshape{12}{\magstep1} -\setfont\secit\itbshape{10}{\magstep2} -\setfont\secsl\slbshape{10}{\magstep2} -\setfont\sectt\ttbshape{12}{\magstep1} -\setfont\secttsl\ttslshape{10}{\magstep2} -\setfont\secsf\sfbshape{12}{\magstep1} -\let\secbf\secrm -\setfont\secsc\scbshape{10}{\magstep2} -\font\seci=cmmi12 scaled \magstep1 -\font\secsy=cmsy10 scaled \magstep2 - -% Subsection fonts (13.15pt). -\def\ssecnominalsize{13pt} -\setfont\ssecrm\rmbshape{12}{\magstephalf} -\setfont\ssecit\itbshape{10}{1315} -\setfont\ssecsl\slbshape{10}{1315} -\setfont\ssectt\ttbshape{12}{\magstephalf} -\setfont\ssecttsl\ttslshape{10}{1315} -\setfont\ssecsf\sfbshape{12}{\magstephalf} -\let\ssecbf\ssecrm -\setfont\ssecsc\scbshape{10}{1315} -\font\sseci=cmmi12 scaled \magstephalf -\font\ssecsy=cmsy10 scaled 1315 - -% Reduced fonts for @acro in text (10pt). -\def\reducednominalsize{10pt} -\setfont\reducedrm\rmshape{10}{1000} -\setfont\reducedtt\ttshape{10}{1000} -\setfont\reducedbf\bfshape{10}{1000} -\setfont\reducedit\itshape{10}{1000} -\setfont\reducedsl\slshape{10}{1000} -\setfont\reducedsf\sfshape{10}{1000} -\setfont\reducedsc\scshape{10}{1000} -\setfont\reducedttsl\ttslshape{10}{1000} -\font\reducedi=cmmi10 -\font\reducedsy=cmsy10 - -% reset the current fonts -\textfonts -\rm -} % end of 11pt text font size definitions - - -% Definitions to make the main text be 10pt Computer Modern, with -% section, chapter, etc., sizes following suit. This is for the GNU -% Press printing of the Emacs 22 manual. Maybe other manuals in the -% future. Used with @smallbook, which sets the leading to 12pt. -% -\def\definetextfontsizex{% -% Text fonts (10pt). -\def\textnominalsize{10pt} -\edef\mainmagstep{1000} -\setfont\textrm\rmshape{10}{\mainmagstep} -\setfont\texttt\ttshape{10}{\mainmagstep} -\setfont\textbf\bfshape{10}{\mainmagstep} -\setfont\textit\itshape{10}{\mainmagstep} -\setfont\textsl\slshape{10}{\mainmagstep} -\setfont\textsf\sfshape{10}{\mainmagstep} -\setfont\textsc\scshape{10}{\mainmagstep} -\setfont\textttsl\ttslshape{10}{\mainmagstep} -\font\texti=cmmi10 scaled \mainmagstep -\font\textsy=cmsy10 scaled \mainmagstep - -% A few fonts for @defun names and args. -\setfont\defbf\bfshape{10}{\magstephalf} -\setfont\deftt\ttshape{10}{\magstephalf} -\setfont\defttsl\ttslshape{10}{\magstephalf} -\def\df{\let\tentt=\deftt \let\tenbf = \defbf \let\tenttsl=\defttsl \bf} - -% Fonts for indices, footnotes, small examples (9pt). -\def\smallnominalsize{9pt} -\setfont\smallrm\rmshape{9}{1000} -\setfont\smalltt\ttshape{9}{1000} -\setfont\smallbf\bfshape{10}{900} -\setfont\smallit\itshape{9}{1000} -\setfont\smallsl\slshape{9}{1000} -\setfont\smallsf\sfshape{9}{1000} -\setfont\smallsc\scshape{10}{900} -\setfont\smallttsl\ttslshape{10}{900} -\font\smalli=cmmi9 -\font\smallsy=cmsy9 - -% Fonts for small examples (8pt). -\def\smallernominalsize{8pt} -\setfont\smallerrm\rmshape{8}{1000} -\setfont\smallertt\ttshape{8}{1000} -\setfont\smallerbf\bfshape{10}{800} -\setfont\smallerit\itshape{8}{1000} -\setfont\smallersl\slshape{8}{1000} -\setfont\smallersf\sfshape{8}{1000} -\setfont\smallersc\scshape{10}{800} -\setfont\smallerttsl\ttslshape{10}{800} -\font\smalleri=cmmi8 -\font\smallersy=cmsy8 - -% Fonts for title page (20.4pt): -\def\titlenominalsize{20pt} -\setfont\titlerm\rmbshape{12}{\magstep3} -\setfont\titleit\itbshape{10}{\magstep4} -\setfont\titlesl\slbshape{10}{\magstep4} -\setfont\titlett\ttbshape{12}{\magstep3} -\setfont\titlettsl\ttslshape{10}{\magstep4} -\setfont\titlesf\sfbshape{17}{\magstep1} -\let\titlebf=\titlerm -\setfont\titlesc\scbshape{10}{\magstep4} -\font\titlei=cmmi12 scaled \magstep3 -\font\titlesy=cmsy10 scaled \magstep4 -\def\authorrm{\secrm} -\def\authortt{\sectt} - -% Chapter fonts (14.4pt). -\def\chapnominalsize{14pt} -\setfont\chaprm\rmbshape{12}{\magstep1} -\setfont\chapit\itbshape{10}{\magstep2} -\setfont\chapsl\slbshape{10}{\magstep2} -\setfont\chaptt\ttbshape{12}{\magstep1} -\setfont\chapttsl\ttslshape{10}{\magstep2} -\setfont\chapsf\sfbshape{12}{\magstep1} -\let\chapbf\chaprm -\setfont\chapsc\scbshape{10}{\magstep2} -\font\chapi=cmmi12 scaled \magstep1 -\font\chapsy=cmsy10 scaled \magstep2 - -% Section fonts (12pt). -\def\secnominalsize{12pt} -\setfont\secrm\rmbshape{12}{1000} -\setfont\secit\itbshape{10}{\magstep1} -\setfont\secsl\slbshape{10}{\magstep1} -\setfont\sectt\ttbshape{12}{1000} -\setfont\secttsl\ttslshape{10}{\magstep1} -\setfont\secsf\sfbshape{12}{1000} -\let\secbf\secrm -\setfont\secsc\scbshape{10}{\magstep1} -\font\seci=cmmi12 -\font\secsy=cmsy10 scaled \magstep1 - -% Subsection fonts (10pt). -\def\ssecnominalsize{10pt} -\setfont\ssecrm\rmbshape{10}{1000} -\setfont\ssecit\itbshape{10}{1000} -\setfont\ssecsl\slbshape{10}{1000} -\setfont\ssectt\ttbshape{10}{1000} -\setfont\ssecttsl\ttslshape{10}{1000} -\setfont\ssecsf\sfbshape{10}{1000} -\let\ssecbf\ssecrm -\setfont\ssecsc\scbshape{10}{1000} -\font\sseci=cmmi10 -\font\ssecsy=cmsy10 - -% Reduced fonts for @acro in text (9pt). -\def\reducednominalsize{9pt} -\setfont\reducedrm\rmshape{9}{1000} -\setfont\reducedtt\ttshape{9}{1000} -\setfont\reducedbf\bfshape{10}{900} -\setfont\reducedit\itshape{9}{1000} -\setfont\reducedsl\slshape{9}{1000} -\setfont\reducedsf\sfshape{9}{1000} -\setfont\reducedsc\scshape{10}{900} -\setfont\reducedttsl\ttslshape{10}{900} -\font\reducedi=cmmi9 -\font\reducedsy=cmsy9 - -% reduce space between paragraphs -\divide\parskip by 2 - -% reset the current fonts -\textfonts -\rm -} % end of 10pt text font size definitions - - -% We provide the user-level command -% @fonttextsize 10 -% (or 11) to redefine the text font size. pt is assumed. -% -\def\xword{10} -\def\xiword{11} -% -\parseargdef\fonttextsize{% - \def\textsizearg{#1}% - \wlog{doing @fonttextsize \textsizearg}% - % - % Set \globaldefs so that documents can use this inside @tex, since - % makeinfo 4.8 does not support it, but we need it nonetheless. - % - \begingroup \globaldefs=1 - \ifx\textsizearg\xword \definetextfontsizex - \else \ifx\textsizearg\xiword \definetextfontsizexi - \else - \errhelp=\EMsimple - \errmessage{@fonttextsize only supports `10' or `11', not `\textsizearg'} - \fi\fi - \endgroup -} - - -% In order for the font changes to affect most math symbols and letters, -% we have to define the \textfont of the standard families. Since -% texinfo doesn't allow for producing subscripts and superscripts except -% in the main text, we don't bother to reset \scriptfont and -% \scriptscriptfont (which would also require loading a lot more fonts). -% -\def\resetmathfonts{% - \textfont0=\tenrm \textfont1=\teni \textfont2=\tensy - \textfont\itfam=\tenit \textfont\slfam=\tensl \textfont\bffam=\tenbf - \textfont\ttfam=\tentt \textfont\sffam=\tensf -} - -% The font-changing commands redefine the meanings of \tenSTYLE, instead -% of just \STYLE. We do this because \STYLE needs to also set the -% current \fam for math mode. Our \STYLE (e.g., \rm) commands hardwire -% \tenSTYLE to set the current font. -% -% Each font-changing command also sets the names \lsize (one size lower) -% and \lllsize (three sizes lower). These relative commands are used in -% the LaTeX logo and acronyms. -% -% This all needs generalizing, badly. -% -\def\textfonts{% - \let\tenrm=\textrm \let\tenit=\textit \let\tensl=\textsl - \let\tenbf=\textbf \let\tentt=\texttt \let\smallcaps=\textsc - \let\tensf=\textsf \let\teni=\texti \let\tensy=\textsy - \let\tenttsl=\textttsl - \def\curfontsize{text}% - \def\lsize{reduced}\def\lllsize{smaller}% - \resetmathfonts \setleading{\textleading}} -\def\titlefonts{% - \let\tenrm=\titlerm \let\tenit=\titleit \let\tensl=\titlesl - \let\tenbf=\titlebf \let\tentt=\titlett \let\smallcaps=\titlesc - \let\tensf=\titlesf \let\teni=\titlei \let\tensy=\titlesy - \let\tenttsl=\titlettsl - \def\curfontsize{title}% - \def\lsize{chap}\def\lllsize{subsec}% - \resetmathfonts \setleading{25pt}} -\def\titlefont#1{{\titlefonts\rm #1}} -\def\chapfonts{% - \let\tenrm=\chaprm \let\tenit=\chapit \let\tensl=\chapsl - \let\tenbf=\chapbf \let\tentt=\chaptt \let\smallcaps=\chapsc - \let\tensf=\chapsf \let\teni=\chapi \let\tensy=\chapsy - \let\tenttsl=\chapttsl - \def\curfontsize{chap}% - \def\lsize{sec}\def\lllsize{text}% - \resetmathfonts \setleading{19pt}} -\def\secfonts{% - \let\tenrm=\secrm \let\tenit=\secit \let\tensl=\secsl - \let\tenbf=\secbf \let\tentt=\sectt \let\smallcaps=\secsc - \let\tensf=\secsf \let\teni=\seci \let\tensy=\secsy - \let\tenttsl=\secttsl - \def\curfontsize{sec}% - \def\lsize{subsec}\def\lllsize{reduced}% - \resetmathfonts \setleading{16pt}} -\def\subsecfonts{% - \let\tenrm=\ssecrm \let\tenit=\ssecit \let\tensl=\ssecsl - \let\tenbf=\ssecbf \let\tentt=\ssectt \let\smallcaps=\ssecsc - \let\tensf=\ssecsf \let\teni=\sseci \let\tensy=\ssecsy - \let\tenttsl=\ssecttsl - \def\curfontsize{ssec}% - \def\lsize{text}\def\lllsize{small}% - \resetmathfonts \setleading{15pt}} -\let\subsubsecfonts = \subsecfonts -\def\reducedfonts{% - \let\tenrm=\reducedrm \let\tenit=\reducedit \let\tensl=\reducedsl - \let\tenbf=\reducedbf \let\tentt=\reducedtt \let\reducedcaps=\reducedsc - \let\tensf=\reducedsf \let\teni=\reducedi \let\tensy=\reducedsy - \let\tenttsl=\reducedttsl - \def\curfontsize{reduced}% - \def\lsize{small}\def\lllsize{smaller}% - \resetmathfonts \setleading{10.5pt}} -\def\smallfonts{% - \let\tenrm=\smallrm \let\tenit=\smallit \let\tensl=\smallsl - \let\tenbf=\smallbf \let\tentt=\smalltt \let\smallcaps=\smallsc - \let\tensf=\smallsf \let\teni=\smalli \let\tensy=\smallsy - \let\tenttsl=\smallttsl - \def\curfontsize{small}% - \def\lsize{smaller}\def\lllsize{smaller}% - \resetmathfonts \setleading{10.5pt}} -\def\smallerfonts{% - \let\tenrm=\smallerrm \let\tenit=\smallerit \let\tensl=\smallersl - \let\tenbf=\smallerbf \let\tentt=\smallertt \let\smallcaps=\smallersc - \let\tensf=\smallersf \let\teni=\smalleri \let\tensy=\smallersy - \let\tenttsl=\smallerttsl - \def\curfontsize{smaller}% - \def\lsize{smaller}\def\lllsize{smaller}% - \resetmathfonts \setleading{9.5pt}} - -% Set the fonts to use with the @small... environments. -\let\smallexamplefonts = \smallfonts - -% About \smallexamplefonts. If we use \smallfonts (9pt), @smallexample -% can fit this many characters: -% 8.5x11=86 smallbook=72 a4=90 a5=69 -% If we use \scriptfonts (8pt), then we can fit this many characters: -% 8.5x11=90+ smallbook=80 a4=90+ a5=77 -% For me, subjectively, the few extra characters that fit aren't worth -% the additional smallness of 8pt. So I'm making the default 9pt. -% -% By the way, for comparison, here's what fits with @example (10pt): -% 8.5x11=71 smallbook=60 a4=75 a5=58 -% -% I wish the USA used A4 paper. -% --karl, 24jan03. - - -% Set up the default fonts, so we can use them for creating boxes. -% -\definetextfontsizexi - -% Define these so they can be easily changed for other fonts. -\def\angleleft{$\langle$} -\def\angleright{$\rangle$} - -% Count depth in font-changes, for error checks -\newcount\fontdepth \fontdepth=0 - -% Fonts for short table of contents. -\setfont\shortcontrm\rmshape{12}{1000} -\setfont\shortcontbf\bfshape{10}{\magstep1} % no cmb12 -\setfont\shortcontsl\slshape{12}{1000} -\setfont\shortconttt\ttshape{12}{1000} - -%% Add scribe-like font environments, plus @l for inline lisp (usually sans -%% serif) and @ii for TeX italic - -% \smartitalic{ARG} outputs arg in italics, followed by an italic correction -% unless the following character is such as not to need one. -\def\smartitalicx{\ifx\next,\else\ifx\next-\else\ifx\next.\else - \ptexslash\fi\fi\fi} -\def\smartslanted#1{{\ifusingtt\ttsl\sl #1}\futurelet\next\smartitalicx} -\def\smartitalic#1{{\ifusingtt\ttsl\it #1}\futurelet\next\smartitalicx} - -% like \smartslanted except unconditionally uses \ttsl. -% @var is set to this for defun arguments. -\def\ttslanted#1{{\ttsl #1}\futurelet\next\smartitalicx} - -% like \smartslanted except unconditionally use \sl. We never want -% ttsl for book titles, do we? -\def\cite#1{{\sl #1}\futurelet\next\smartitalicx} - -\let\i=\smartitalic -\let\slanted=\smartslanted -\let\var=\smartslanted -\let\dfn=\smartslanted -\let\emph=\smartitalic - -% @b, explicit bold. -\def\b#1{{\bf #1}} -\let\strong=\b - -% @sansserif, explicit sans. -\def\sansserif#1{{\sf #1}} - -% We can't just use \exhyphenpenalty, because that only has effect at -% the end of a paragraph. Restore normal hyphenation at the end of the -% group within which \nohyphenation is presumably called. -% -\def\nohyphenation{\hyphenchar\font = -1 \aftergroup\restorehyphenation} -\def\restorehyphenation{\hyphenchar\font = `- } - -% Set sfcode to normal for the chars that usually have another value. -% Can't use plain's \frenchspacing because it uses the `\x notation, and -% sometimes \x has an active definition that messes things up. -% -\catcode`@=11 - \def\plainfrenchspacing{% - \sfcode\dotChar =\@m \sfcode\questChar=\@m \sfcode\exclamChar=\@m - \sfcode\colonChar=\@m \sfcode\semiChar =\@m \sfcode\commaChar =\@m - \def\endofsentencespacefactor{1000}% for @. and friends - } - \def\plainnonfrenchspacing{% - \sfcode`\.3000\sfcode`\?3000\sfcode`\!3000 - \sfcode`\:2000\sfcode`\;1500\sfcode`\,1250 - \def\endofsentencespacefactor{3000}% for @. and friends - } -\catcode`@=\other -\def\endofsentencespacefactor{3000}% default - -\def\t#1{% - {\tt \rawbackslash \plainfrenchspacing #1}% - \null -} -\def\samp#1{`\tclose{#1}'\null} -\setfont\keyrm\rmshape{8}{1000} -\font\keysy=cmsy9 -\def\key#1{{\keyrm\textfont2=\keysy \leavevmode\hbox{% - \raise0.4pt\hbox{\angleleft}\kern-.08em\vtop{% - \vbox{\hrule\kern-0.4pt - \hbox{\raise0.4pt\hbox{\vphantom{\angleleft}}#1}}% - \kern-0.4pt\hrule}% - \kern-.06em\raise0.4pt\hbox{\angleright}}}} -% The old definition, with no lozenge: -%\def\key #1{{\ttsl \nohyphenation \uppercase{#1}}\null} -\def\ctrl #1{{\tt \rawbackslash \hat}#1} - -% @file, @option are the same as @samp. -\let\file=\samp -\let\option=\samp - -% @code is a modification of @t, -% which makes spaces the same size as normal in the surrounding text. -\def\tclose#1{% - {% - % Change normal interword space to be same as for the current font. - \spaceskip = \fontdimen2\font - % - % Switch to typewriter. - \tt - % - % But `\ ' produces the large typewriter interword space. - \def\ {{\spaceskip = 0pt{} }}% - % - % Turn off hyphenation. - \nohyphenation - % - \rawbackslash - \plainfrenchspacing - #1% - }% - \null -} - -% We *must* turn on hyphenation at `-' and `_' in @code. -% Otherwise, it is too hard to avoid overfull hboxes -% in the Emacs manual, the Library manual, etc. - -% Unfortunately, TeX uses one parameter (\hyphenchar) to control -% both hyphenation at - and hyphenation within words. -% We must therefore turn them both off (\tclose does that) -% and arrange explicitly to hyphenate at a dash. -% -- rms. -{ - \catcode`\-=\active \catcode`\_=\active - \catcode`\'=\active \catcode`\`=\active - % - \global\def\code{\begingroup - \catcode\rquoteChar=\active \catcode\lquoteChar=\active - \let'\codequoteright \let`\codequoteleft - % - \catcode\dashChar=\active \catcode\underChar=\active - \ifallowcodebreaks - \let-\codedash - \let_\codeunder - \else - \let-\realdash - \let_\realunder - \fi - \codex - } -} - -\def\realdash{-} -\def\codedash{-\discretionary{}{}{}} -\def\codeunder{% - % this is all so @math{@code{var_name}+1} can work. In math mode, _ - % is "active" (mathcode"8000) and \normalunderscore (or \char95, etc.) - % will therefore expand the active definition of _, which is us - % (inside @code that is), therefore an endless loop. - \ifusingtt{\ifmmode - \mathchar"075F % class 0=ordinary, family 7=ttfam, pos 0x5F=_. - \else\normalunderscore \fi - \discretionary{}{}{}}% - {\_}% -} -\def\codex #1{\tclose{#1}\endgroup} - -% An additional complication: the above will allow breaks after, e.g., -% each of the four underscores in __typeof__. This is undesirable in -% some manuals, especially if they don't have long identifiers in -% general. @allowcodebreaks provides a way to control this. -% -\newif\ifallowcodebreaks \allowcodebreakstrue - -\def\keywordtrue{true} -\def\keywordfalse{false} - -\parseargdef\allowcodebreaks{% - \def\txiarg{#1}% - \ifx\txiarg\keywordtrue - \allowcodebreakstrue - \else\ifx\txiarg\keywordfalse - \allowcodebreaksfalse - \else - \errhelp = \EMsimple - \errmessage{Unknown @allowcodebreaks option `\txiarg'}% - \fi\fi -} - -% @kbd is like @code, except that if the argument is just one @key command, -% then @kbd has no effect. - -% @kbdinputstyle -- arg is `distinct' (@kbd uses slanted tty font always), -% `example' (@kbd uses ttsl only inside of @example and friends), -% or `code' (@kbd uses normal tty font always). -\parseargdef\kbdinputstyle{% - \def\txiarg{#1}% - \ifx\txiarg\worddistinct - \gdef\kbdexamplefont{\ttsl}\gdef\kbdfont{\ttsl}% - \else\ifx\txiarg\wordexample - \gdef\kbdexamplefont{\ttsl}\gdef\kbdfont{\tt}% - \else\ifx\txiarg\wordcode - \gdef\kbdexamplefont{\tt}\gdef\kbdfont{\tt}% - \else - \errhelp = \EMsimple - \errmessage{Unknown @kbdinputstyle option `\txiarg'}% - \fi\fi\fi -} -\def\worddistinct{distinct} -\def\wordexample{example} -\def\wordcode{code} - -% Default is `distinct.' -\kbdinputstyle distinct - -\def\xkey{\key} -\def\kbdfoo#1#2#3\par{\def\one{#1}\def\three{#3}\def\threex{??}% -\ifx\one\xkey\ifx\threex\three \key{#2}% -\else{\tclose{\kbdfont\look}}\fi -\else{\tclose{\kbdfont\look}}\fi} - -% For @indicateurl, @env, @command quotes seem unnecessary, so use \code. -\let\indicateurl=\code -\let\env=\code -\let\command=\code - -% @uref (abbreviation for `urlref') takes an optional (comma-separated) -% second argument specifying the text to display and an optional third -% arg as text to display instead of (rather than in addition to) the url -% itself. First (mandatory) arg is the url. Perhaps eventually put in -% a hypertex \special here. -% -\def\uref#1{\douref #1,,,\finish} -\def\douref#1,#2,#3,#4\finish{\begingroup - \unsepspaces - \pdfurl{#1}% - \setbox0 = \hbox{\ignorespaces #3}% - \ifdim\wd0 > 0pt - \unhbox0 % third arg given, show only that - \else - \setbox0 = \hbox{\ignorespaces #2}% - \ifdim\wd0 > 0pt - \ifpdf - \unhbox0 % PDF: 2nd arg given, show only it - \else - \unhbox0\ (\code{#1})% DVI: 2nd arg given, show both it and url - \fi - \else - \code{#1}% only url given, so show it - \fi - \fi - \endlink -\endgroup} - -% @url synonym for @uref, since that's how everyone uses it. -% -\let\url=\uref - -% rms does not like angle brackets --karl, 17may97. -% So now @email is just like @uref, unless we are pdf. -% -%\def\email#1{\angleleft{\tt #1}\angleright} -\ifpdf - \def\email#1{\doemail#1,,\finish} - \def\doemail#1,#2,#3\finish{\begingroup - \unsepspaces - \pdfurl{mailto:#1}% - \setbox0 = \hbox{\ignorespaces #2}% - \ifdim\wd0>0pt\unhbox0\else\code{#1}\fi - \endlink - \endgroup} -\else - \let\email=\uref -\fi - -% Check if we are currently using a typewriter font. Since all the -% Computer Modern typewriter fonts have zero interword stretch (and -% shrink), and it is reasonable to expect all typewriter fonts to have -% this property, we can check that font parameter. -% -\def\ifmonospace{\ifdim\fontdimen3\font=0pt } - -% Typeset a dimension, e.g., `in' or `pt'. The only reason for the -% argument is to make the input look right: @dmn{pt} instead of @dmn{}pt. -% -\def\dmn#1{\thinspace #1} - -\def\kbd#1{\def\look{#1}\expandafter\kbdfoo\look??\par} - -% @l was never documented to mean ``switch to the Lisp font'', -% and it is not used as such in any manual I can find. We need it for -% Polish suppressed-l. --karl, 22sep96. -%\def\l#1{{\li #1}\null} - -% Explicit font changes: @r, @sc, undocumented @ii. -\def\r#1{{\rm #1}} % roman font -\def\sc#1{{\smallcaps#1}} % smallcaps font -\def\ii#1{{\it #1}} % italic font - -% @acronym for "FBI", "NATO", and the like. -% We print this one point size smaller, since it's intended for -% all-uppercase. -% -\def\acronym#1{\doacronym #1,,\finish} -\def\doacronym#1,#2,#3\finish{% - {\selectfonts\lsize #1}% - \def\temp{#2}% - \ifx\temp\empty \else - \space ({\unsepspaces \ignorespaces \temp \unskip})% - \fi -} - -% @abbr for "Comput. J." and the like. -% No font change, but don't do end-of-sentence spacing. -% -\def\abbr#1{\doabbr #1,,\finish} -\def\doabbr#1,#2,#3\finish{% - {\plainfrenchspacing #1}% - \def\temp{#2}% - \ifx\temp\empty \else - \space ({\unsepspaces \ignorespaces \temp \unskip})% - \fi -} - -% @pounds{} is a sterling sign, which Knuth put in the CM italic font. -% -\def\pounds{{\it\$}} - -% @euro{} comes from a separate font, depending on the current style. -% We use the free feym* fonts from the eurosym package by Henrik -% Theiling, which support regular, slanted, bold and bold slanted (and -% "outlined" (blackboard board, sort of) versions, which we don't need). -% It is available from http://www.ctan.org/tex-archive/fonts/eurosym. -% -% Although only regular is the truly official Euro symbol, we ignore -% that. The Euro is designed to be slightly taller than the regular -% font height. -% -% feymr - regular -% feymo - slanted -% feybr - bold -% feybo - bold slanted -% -% There is no good (free) typewriter version, to my knowledge. -% A feymr10 euro is ~7.3pt wide, while a normal cmtt10 char is ~5.25pt wide. -% Hmm. -% -% Also doesn't work in math. Do we need to do math with euro symbols? -% Hope not. -% -% -\def\euro{{\eurofont e}} -\def\eurofont{% - % We set the font at each command, rather than predefining it in - % \textfonts and the other font-switching commands, so that - % installations which never need the symbol don't have to have the - % font installed. - % - % There is only one designed size (nominal 10pt), so we always scale - % that to the current nominal size. - % - % By the way, simply using "at 1em" works for cmr10 and the like, but - % does not work for cmbx10 and other extended/shrunken fonts. - % - \def\eurosize{\csname\curfontsize nominalsize\endcsname}% - % - \ifx\curfontstyle\bfstylename - % bold: - \font\thiseurofont = \ifusingit{feybo10}{feybr10} at \eurosize - \else - % regular: - \font\thiseurofont = \ifusingit{feymo10}{feymr10} at \eurosize - \fi - \thiseurofont -} - -% @registeredsymbol - R in a circle. The font for the R should really -% be smaller yet, but lllsize is the best we can do for now. -% Adapted from the plain.tex definition of \copyright. -% -\def\registeredsymbol{% - $^{{\ooalign{\hfil\raise.07ex\hbox{\selectfonts\lllsize R}% - \hfil\crcr\Orb}}% - }$% -} - -% @textdegree - the normal degrees sign. -% -\def\textdegree{$^\circ$} - -% Laurent Siebenmann reports \Orb undefined with: -% Textures 1.7.7 (preloaded format=plain 93.10.14) (68K) 16 APR 2004 02:38 -% so we'll define it if necessary. -% -\ifx\Orb\undefined -\def\Orb{\mathhexbox20D} -\fi - - -\message{page headings,} - -\newskip\titlepagetopglue \titlepagetopglue = 1.5in -\newskip\titlepagebottomglue \titlepagebottomglue = 2pc - -% First the title page. Must do @settitle before @titlepage. -\newif\ifseenauthor -\newif\iffinishedtitlepage - -% Do an implicit @contents or @shortcontents after @end titlepage if the -% user says @setcontentsaftertitlepage or @setshortcontentsaftertitlepage. -% -\newif\ifsetcontentsaftertitlepage - \let\setcontentsaftertitlepage = \setcontentsaftertitlepagetrue -\newif\ifsetshortcontentsaftertitlepage - \let\setshortcontentsaftertitlepage = \setshortcontentsaftertitlepagetrue - -\parseargdef\shorttitlepage{\begingroup\hbox{}\vskip 1.5in \chaprm \centerline{#1}% - \endgroup\page\hbox{}\page} - -\envdef\titlepage{% - % Open one extra group, as we want to close it in the middle of \Etitlepage. - \begingroup - \parindent=0pt \textfonts - % Leave some space at the very top of the page. - \vglue\titlepagetopglue - % No rule at page bottom unless we print one at the top with @title. - \finishedtitlepagetrue - % - % Most title ``pages'' are actually two pages long, with space - % at the top of the second. We don't want the ragged left on the second. - \let\oldpage = \page - \def\page{% - \iffinishedtitlepage\else - \finishtitlepage - \fi - \let\page = \oldpage - \page - \null - }% -} - -\def\Etitlepage{% - \iffinishedtitlepage\else - \finishtitlepage - \fi - % It is important to do the page break before ending the group, - % because the headline and footline are only empty inside the group. - % If we use the new definition of \page, we always get a blank page - % after the title page, which we certainly don't want. - \oldpage - \endgroup - % - % Need this before the \...aftertitlepage checks so that if they are - % in effect the toc pages will come out with page numbers. - \HEADINGSon - % - % If they want short, they certainly want long too. - \ifsetshortcontentsaftertitlepage - \shortcontents - \contents - \global\let\shortcontents = \relax - \global\let\contents = \relax - \fi - % - \ifsetcontentsaftertitlepage - \contents - \global\let\contents = \relax - \global\let\shortcontents = \relax - \fi -} - -\def\finishtitlepage{% - \vskip4pt \hrule height 2pt width \hsize - \vskip\titlepagebottomglue - \finishedtitlepagetrue -} - -%%% Macros to be used within @titlepage: - -\let\subtitlerm=\tenrm -\def\subtitlefont{\subtitlerm \normalbaselineskip = 13pt \normalbaselines} - -\def\authorfont{\authorrm \normalbaselineskip = 16pt \normalbaselines - \let\tt=\authortt} - -\parseargdef\title{% - \checkenv\titlepage - \leftline{\titlefonts\rm #1} - % print a rule at the page bottom also. - \finishedtitlepagefalse - \vskip4pt \hrule height 4pt width \hsize \vskip4pt -} - -\parseargdef\subtitle{% - \checkenv\titlepage - {\subtitlefont \rightline{#1}}% -} - -% @author should come last, but may come many times. -% It can also be used inside @quotation. -% -\parseargdef\author{% - \def\temp{\quotation}% - \ifx\thisenv\temp - \def\quotationauthor{#1}% printed in \Equotation. - \else - \checkenv\titlepage - \ifseenauthor\else \vskip 0pt plus 1filll \seenauthortrue \fi - {\authorfont \leftline{#1}}% - \fi -} - - -%%% Set up page headings and footings. - -\let\thispage=\folio - -\newtoks\evenheadline % headline on even pages -\newtoks\oddheadline % headline on odd pages -\newtoks\evenfootline % footline on even pages -\newtoks\oddfootline % footline on odd pages - -% Now make TeX use those variables -\headline={{\textfonts\rm \ifodd\pageno \the\oddheadline - \else \the\evenheadline \fi}} -\footline={{\textfonts\rm \ifodd\pageno \the\oddfootline - \else \the\evenfootline \fi}\HEADINGShook} -\let\HEADINGShook=\relax - -% Commands to set those variables. -% For example, this is what @headings on does -% @evenheading @thistitle|@thispage|@thischapter -% @oddheading @thischapter|@thispage|@thistitle -% @evenfooting @thisfile|| -% @oddfooting ||@thisfile - - -\def\evenheading{\parsearg\evenheadingxxx} -\def\evenheadingxxx #1{\evenheadingyyy #1\|\|\|\|\finish} -\def\evenheadingyyy #1\|#2\|#3\|#4\finish{% -\global\evenheadline={\rlap{\centerline{#2}}\line{#1\hfil#3}}} - -\def\oddheading{\parsearg\oddheadingxxx} -\def\oddheadingxxx #1{\oddheadingyyy #1\|\|\|\|\finish} -\def\oddheadingyyy #1\|#2\|#3\|#4\finish{% -\global\oddheadline={\rlap{\centerline{#2}}\line{#1\hfil#3}}} - -\parseargdef\everyheading{\oddheadingxxx{#1}\evenheadingxxx{#1}}% - -\def\evenfooting{\parsearg\evenfootingxxx} -\def\evenfootingxxx #1{\evenfootingyyy #1\|\|\|\|\finish} -\def\evenfootingyyy #1\|#2\|#3\|#4\finish{% -\global\evenfootline={\rlap{\centerline{#2}}\line{#1\hfil#3}}} - -\def\oddfooting{\parsearg\oddfootingxxx} -\def\oddfootingxxx #1{\oddfootingyyy #1\|\|\|\|\finish} -\def\oddfootingyyy #1\|#2\|#3\|#4\finish{% - \global\oddfootline = {\rlap{\centerline{#2}}\line{#1\hfil#3}}% - % - % Leave some space for the footline. Hopefully ok to assume - % @evenfooting will not be used by itself. - \global\advance\pageheight by -12pt - \global\advance\vsize by -12pt -} - -\parseargdef\everyfooting{\oddfootingxxx{#1}\evenfootingxxx{#1}} - - -% @headings double turns headings on for double-sided printing. -% @headings single turns headings on for single-sided printing. -% @headings off turns them off. -% @headings on same as @headings double, retained for compatibility. -% @headings after turns on double-sided headings after this page. -% @headings doubleafter turns on double-sided headings after this page. -% @headings singleafter turns on single-sided headings after this page. -% By default, they are off at the start of a document, -% and turned `on' after @end titlepage. - -\def\headings #1 {\csname HEADINGS#1\endcsname} - -\def\HEADINGSoff{% -\global\evenheadline={\hfil} \global\evenfootline={\hfil} -\global\oddheadline={\hfil} \global\oddfootline={\hfil}} -\HEADINGSoff -% When we turn headings on, set the page number to 1. -% For double-sided printing, put current file name in lower left corner, -% chapter name on inside top of right hand pages, document -% title on inside top of left hand pages, and page numbers on outside top -% edge of all pages. -\def\HEADINGSdouble{% -\global\pageno=1 -\global\evenfootline={\hfil} -\global\oddfootline={\hfil} -\global\evenheadline={\line{\folio\hfil\thistitle}} -\global\oddheadline={\line{\thischapter\hfil\folio}} -\global\let\contentsalignmacro = \chapoddpage -} -\let\contentsalignmacro = \chappager - -% For single-sided printing, chapter title goes across top left of page, -% page number on top right. -\def\HEADINGSsingle{% -\global\pageno=1 -\global\evenfootline={\hfil} -\global\oddfootline={\hfil} -\global\evenheadline={\line{\thischapter\hfil\folio}} -\global\oddheadline={\line{\thischapter\hfil\folio}} -\global\let\contentsalignmacro = \chappager -} -\def\HEADINGSon{\HEADINGSdouble} - -\def\HEADINGSafter{\let\HEADINGShook=\HEADINGSdoublex} -\let\HEADINGSdoubleafter=\HEADINGSafter -\def\HEADINGSdoublex{% -\global\evenfootline={\hfil} -\global\oddfootline={\hfil} -\global\evenheadline={\line{\folio\hfil\thistitle}} -\global\oddheadline={\line{\thischapter\hfil\folio}} -\global\let\contentsalignmacro = \chapoddpage -} - -\def\HEADINGSsingleafter{\let\HEADINGShook=\HEADINGSsinglex} -\def\HEADINGSsinglex{% -\global\evenfootline={\hfil} -\global\oddfootline={\hfil} -\global\evenheadline={\line{\thischapter\hfil\folio}} -\global\oddheadline={\line{\thischapter\hfil\folio}} -\global\let\contentsalignmacro = \chappager -} - -% Subroutines used in generating headings -% This produces Day Month Year style of output. -% Only define if not already defined, in case a txi-??.tex file has set -% up a different format (e.g., txi-cs.tex does this). -\ifx\today\undefined -\def\today{% - \number\day\space - \ifcase\month - \or\putwordMJan\or\putwordMFeb\or\putwordMMar\or\putwordMApr - \or\putwordMMay\or\putwordMJun\or\putwordMJul\or\putwordMAug - \or\putwordMSep\or\putwordMOct\or\putwordMNov\or\putwordMDec - \fi - \space\number\year} -\fi - -% @settitle line... specifies the title of the document, for headings. -% It generates no output of its own. -\def\thistitle{\putwordNoTitle} -\def\settitle{\parsearg{\gdef\thistitle}} - - -\message{tables,} -% Tables -- @table, @ftable, @vtable, @item(x). - -% default indentation of table text -\newdimen\tableindent \tableindent=.8in -% default indentation of @itemize and @enumerate text -\newdimen\itemindent \itemindent=.3in -% margin between end of table item and start of table text. -\newdimen\itemmargin \itemmargin=.1in - -% used internally for \itemindent minus \itemmargin -\newdimen\itemmax - -% Note @table, @ftable, and @vtable define @item, @itemx, etc., with -% these defs. -% They also define \itemindex -% to index the item name in whatever manner is desired (perhaps none). - -\newif\ifitemxneedsnegativevskip - -\def\itemxpar{\par\ifitemxneedsnegativevskip\nobreak\vskip-\parskip\nobreak\fi} - -\def\internalBitem{\smallbreak \parsearg\itemzzz} -\def\internalBitemx{\itemxpar \parsearg\itemzzz} - -\def\itemzzz #1{\begingroup % - \advance\hsize by -\rightskip - \advance\hsize by -\tableindent - \setbox0=\hbox{\itemindicate{#1}}% - \itemindex{#1}% - \nobreak % This prevents a break before @itemx. - % - % If the item text does not fit in the space we have, put it on a line - % by itself, and do not allow a page break either before or after that - % line. We do not start a paragraph here because then if the next - % command is, e.g., @kindex, the whatsit would get put into the - % horizontal list on a line by itself, resulting in extra blank space. - \ifdim \wd0>\itemmax - % - % Make this a paragraph so we get the \parskip glue and wrapping, - % but leave it ragged-right. - \begingroup - \advance\leftskip by-\tableindent - \advance\hsize by\tableindent - \advance\rightskip by0pt plus1fil - \leavevmode\unhbox0\par - \endgroup - % - % We're going to be starting a paragraph, but we don't want the - % \parskip glue -- logically it's part of the @item we just started. - \nobreak \vskip-\parskip - % - % Stop a page break at the \parskip glue coming up. However, if - % what follows is an environment such as @example, there will be no - % \parskip glue; then the negative vskip we just inserted would - % cause the example and the item to crash together. So we use this - % bizarre value of 10001 as a signal to \aboveenvbreak to insert - % \parskip glue after all. Section titles are handled this way also. - % - \penalty 10001 - \endgroup - \itemxneedsnegativevskipfalse - \else - % The item text fits into the space. Start a paragraph, so that the - % following text (if any) will end up on the same line. - \noindent - % Do this with kerns and \unhbox so that if there is a footnote in - % the item text, it can migrate to the main vertical list and - % eventually be printed. - \nobreak\kern-\tableindent - \dimen0 = \itemmax \advance\dimen0 by \itemmargin \advance\dimen0 by -\wd0 - \unhbox0 - \nobreak\kern\dimen0 - \endgroup - \itemxneedsnegativevskiptrue - \fi -} - -\def\item{\errmessage{@item while not in a list environment}} -\def\itemx{\errmessage{@itemx while not in a list environment}} - -% @table, @ftable, @vtable. -\envdef\table{% - \let\itemindex\gobble - \tablecheck{table}% -} -\envdef\ftable{% - \def\itemindex ##1{\doind {fn}{\code{##1}}}% - \tablecheck{ftable}% -} -\envdef\vtable{% - \def\itemindex ##1{\doind {vr}{\code{##1}}}% - \tablecheck{vtable}% -} -\def\tablecheck#1{% - \ifnum \the\catcode`\^^M=\active - \endgroup - \errmessage{This command won't work in this context; perhaps the problem is - that we are \inenvironment\thisenv}% - \def\next{\doignore{#1}}% - \else - \let\next\tablex - \fi - \next -} -\def\tablex#1{% - \def\itemindicate{#1}% - \parsearg\tabley -} -\def\tabley#1{% - {% - \makevalueexpandable - \edef\temp{\noexpand\tablez #1\space\space\space}% - \expandafter - }\temp \endtablez -} -\def\tablez #1 #2 #3 #4\endtablez{% - \aboveenvbreak - \ifnum 0#1>0 \advance \leftskip by #1\mil \fi - \ifnum 0#2>0 \tableindent=#2\mil \fi - \ifnum 0#3>0 \advance \rightskip by #3\mil \fi - \itemmax=\tableindent - \advance \itemmax by -\itemmargin - \advance \leftskip by \tableindent - \exdentamount=\tableindent - \parindent = 0pt - \parskip = \smallskipamount - \ifdim \parskip=0pt \parskip=2pt \fi - \let\item = \internalBitem - \let\itemx = \internalBitemx -} -\def\Etable{\endgraf\afterenvbreak} -\let\Eftable\Etable -\let\Evtable\Etable -\let\Eitemize\Etable -\let\Eenumerate\Etable - -% This is the counter used by @enumerate, which is really @itemize - -\newcount \itemno - -\envdef\itemize{\parsearg\doitemize} - -\def\doitemize#1{% - \aboveenvbreak - \itemmax=\itemindent - \advance\itemmax by -\itemmargin - \advance\leftskip by \itemindent - \exdentamount=\itemindent - \parindent=0pt - \parskip=\smallskipamount - \ifdim\parskip=0pt \parskip=2pt \fi - \def\itemcontents{#1}% - % @itemize with no arg is equivalent to @itemize @bullet. - \ifx\itemcontents\empty\def\itemcontents{\bullet}\fi - \let\item=\itemizeitem -} - -% Definition of @item while inside @itemize and @enumerate. -% -\def\itemizeitem{% - \advance\itemno by 1 % for enumerations - {\let\par=\endgraf \smallbreak}% reasonable place to break - {% - % If the document has an @itemize directly after a section title, a - % \nobreak will be last on the list, and \sectionheading will have - % done a \vskip-\parskip. In that case, we don't want to zero - % parskip, or the item text will crash with the heading. On the - % other hand, when there is normal text preceding the item (as there - % usually is), we do want to zero parskip, or there would be too much - % space. In that case, we won't have a \nobreak before. At least - % that's the theory. - \ifnum\lastpenalty<10000 \parskip=0in \fi - \noindent - \hbox to 0pt{\hss \itemcontents \kern\itemmargin}% - \vadjust{\penalty 1200}}% not good to break after first line of item. - \flushcr -} - -% \splitoff TOKENS\endmark defines \first to be the first token in -% TOKENS, and \rest to be the remainder. -% -\def\splitoff#1#2\endmark{\def\first{#1}\def\rest{#2}}% - -% Allow an optional argument of an uppercase letter, lowercase letter, -% or number, to specify the first label in the enumerated list. No -% argument is the same as `1'. -% -\envparseargdef\enumerate{\enumeratey #1 \endenumeratey} -\def\enumeratey #1 #2\endenumeratey{% - % If we were given no argument, pretend we were given `1'. - \def\thearg{#1}% - \ifx\thearg\empty \def\thearg{1}\fi - % - % Detect if the argument is a single token. If so, it might be a - % letter. Otherwise, the only valid thing it can be is a number. - % (We will always have one token, because of the test we just made. - % This is a good thing, since \splitoff doesn't work given nothing at - % all -- the first parameter is undelimited.) - \expandafter\splitoff\thearg\endmark - \ifx\rest\empty - % Only one token in the argument. It could still be anything. - % A ``lowercase letter'' is one whose \lccode is nonzero. - % An ``uppercase letter'' is one whose \lccode is both nonzero, and - % not equal to itself. - % Otherwise, we assume it's a number. - % - % We need the \relax at the end of the \ifnum lines to stop TeX from - % continuing to look for a . - % - \ifnum\lccode\expandafter`\thearg=0\relax - \numericenumerate % a number (we hope) - \else - % It's a letter. - \ifnum\lccode\expandafter`\thearg=\expandafter`\thearg\relax - \lowercaseenumerate % lowercase letter - \else - \uppercaseenumerate % uppercase letter - \fi - \fi - \else - % Multiple tokens in the argument. We hope it's a number. - \numericenumerate - \fi -} - -% An @enumerate whose labels are integers. The starting integer is -% given in \thearg. -% -\def\numericenumerate{% - \itemno = \thearg - \startenumeration{\the\itemno}% -} - -% The starting (lowercase) letter is in \thearg. -\def\lowercaseenumerate{% - \itemno = \expandafter`\thearg - \startenumeration{% - % Be sure we're not beyond the end of the alphabet. - \ifnum\itemno=0 - \errmessage{No more lowercase letters in @enumerate; get a bigger - alphabet}% - \fi - \char\lccode\itemno - }% -} - -% The starting (uppercase) letter is in \thearg. -\def\uppercaseenumerate{% - \itemno = \expandafter`\thearg - \startenumeration{% - % Be sure we're not beyond the end of the alphabet. - \ifnum\itemno=0 - \errmessage{No more uppercase letters in @enumerate; get a bigger - alphabet} - \fi - \char\uccode\itemno - }% -} - -% Call \doitemize, adding a period to the first argument and supplying the -% common last two arguments. Also subtract one from the initial value in -% \itemno, since @item increments \itemno. -% -\def\startenumeration#1{% - \advance\itemno by -1 - \doitemize{#1.}\flushcr -} - -% @alphaenumerate and @capsenumerate are abbreviations for giving an arg -% to @enumerate. -% -\def\alphaenumerate{\enumerate{a}} -\def\capsenumerate{\enumerate{A}} -\def\Ealphaenumerate{\Eenumerate} -\def\Ecapsenumerate{\Eenumerate} - - -% @multitable macros -% Amy Hendrickson, 8/18/94, 3/6/96 -% -% @multitable ... @end multitable will make as many columns as desired. -% Contents of each column will wrap at width given in preamble. Width -% can be specified either with sample text given in a template line, -% or in percent of \hsize, the current width of text on page. - -% Table can continue over pages but will only break between lines. - -% To make preamble: -% -% Either define widths of columns in terms of percent of \hsize: -% @multitable @columnfractions .25 .3 .45 -% @item ... -% -% Numbers following @columnfractions are the percent of the total -% current hsize to be used for each column. You may use as many -% columns as desired. - - -% Or use a template: -% @multitable {Column 1 template} {Column 2 template} {Column 3 template} -% @item ... -% using the widest term desired in each column. - -% Each new table line starts with @item, each subsequent new column -% starts with @tab. Empty columns may be produced by supplying @tab's -% with nothing between them for as many times as empty columns are needed, -% ie, @tab@tab@tab will produce two empty columns. - -% @item, @tab do not need to be on their own lines, but it will not hurt -% if they are. - -% Sample multitable: - -% @multitable {Column 1 template} {Column 2 template} {Column 3 template} -% @item first col stuff @tab second col stuff @tab third col -% @item -% first col stuff -% @tab -% second col stuff -% @tab -% third col -% @item first col stuff @tab second col stuff -% @tab Many paragraphs of text may be used in any column. -% -% They will wrap at the width determined by the template. -% @item@tab@tab This will be in third column. -% @end multitable - -% Default dimensions may be reset by user. -% @multitableparskip is vertical space between paragraphs in table. -% @multitableparindent is paragraph indent in table. -% @multitablecolmargin is horizontal space to be left between columns. -% @multitablelinespace is space to leave between table items, baseline -% to baseline. -% 0pt means it depends on current normal line spacing. -% -\newskip\multitableparskip -\newskip\multitableparindent -\newdimen\multitablecolspace -\newskip\multitablelinespace -\multitableparskip=0pt -\multitableparindent=6pt -\multitablecolspace=12pt -\multitablelinespace=0pt - -% Macros used to set up halign preamble: -% -\let\endsetuptable\relax -\def\xendsetuptable{\endsetuptable} -\let\columnfractions\relax -\def\xcolumnfractions{\columnfractions} -\newif\ifsetpercent - -% #1 is the @columnfraction, usually a decimal number like .5, but might -% be just 1. We just use it, whatever it is. -% -\def\pickupwholefraction#1 {% - \global\advance\colcount by 1 - \expandafter\xdef\csname col\the\colcount\endcsname{#1\hsize}% - \setuptable -} - -\newcount\colcount -\def\setuptable#1{% - \def\firstarg{#1}% - \ifx\firstarg\xendsetuptable - \let\go = \relax - \else - \ifx\firstarg\xcolumnfractions - \global\setpercenttrue - \else - \ifsetpercent - \let\go\pickupwholefraction - \else - \global\advance\colcount by 1 - \setbox0=\hbox{#1\unskip\space}% Add a normal word space as a - % separator; typically that is always in the input, anyway. - \expandafter\xdef\csname col\the\colcount\endcsname{\the\wd0}% - \fi - \fi - \ifx\go\pickupwholefraction - % Put the argument back for the \pickupwholefraction call, so - % we'll always have a period there to be parsed. - \def\go{\pickupwholefraction#1}% - \else - \let\go = \setuptable - \fi% - \fi - \go -} - -% multitable-only commands. -% -% @headitem starts a heading row, which we typeset in bold. -% Assignments have to be global since we are inside the implicit group -% of an alignment entry. Note that \everycr resets \everytab. -\def\headitem{\checkenv\multitable \crcr \global\everytab={\bf}\the\everytab}% -% -% A \tab used to include \hskip1sp. But then the space in a template -% line is not enough. That is bad. So let's go back to just `&' until -% we encounter the problem it was intended to solve again. -% --karl, nathan@acm.org, 20apr99. -\def\tab{\checkenv\multitable &\the\everytab}% - -% @multitable ... @end multitable definitions: -% -\newtoks\everytab % insert after every tab. -% -\envdef\multitable{% - \vskip\parskip - \startsavinginserts - % - % @item within a multitable starts a normal row. - % We use \def instead of \let so that if one of the multitable entries - % contains an @itemize, we don't choke on the \item (seen as \crcr aka - % \endtemplate) expanding \doitemize. - \def\item{\crcr}% - % - \tolerance=9500 - \hbadness=9500 - \setmultitablespacing - \parskip=\multitableparskip - \parindent=\multitableparindent - \overfullrule=0pt - \global\colcount=0 - % - \everycr = {% - \noalign{% - \global\everytab={}% - \global\colcount=0 % Reset the column counter. - % Check for saved footnotes, etc. - \checkinserts - % Keeps underfull box messages off when table breaks over pages. - %\filbreak - % Maybe so, but it also creates really weird page breaks when the - % table breaks over pages. Wouldn't \vfil be better? Wait until the - % problem manifests itself, so it can be fixed for real --karl. - }% - }% - % - \parsearg\domultitable -} -\def\domultitable#1{% - % To parse everything between @multitable and @item: - \setuptable#1 \endsetuptable - % - % This preamble sets up a generic column definition, which will - % be used as many times as user calls for columns. - % \vtop will set a single line and will also let text wrap and - % continue for many paragraphs if desired. - \halign\bgroup &% - \global\advance\colcount by 1 - \multistrut - \vtop{% - % Use the current \colcount to find the correct column width: - \hsize=\expandafter\csname col\the\colcount\endcsname - % - % In order to keep entries from bumping into each other - % we will add a \leftskip of \multitablecolspace to all columns after - % the first one. - % - % If a template has been used, we will add \multitablecolspace - % to the width of each template entry. - % - % If the user has set preamble in terms of percent of \hsize we will - % use that dimension as the width of the column, and the \leftskip - % will keep entries from bumping into each other. Table will start at - % left margin and final column will justify at right margin. - % - % Make sure we don't inherit \rightskip from the outer environment. - \rightskip=0pt - \ifnum\colcount=1 - % The first column will be indented with the surrounding text. - \advance\hsize by\leftskip - \else - \ifsetpercent \else - % If user has not set preamble in terms of percent of \hsize - % we will advance \hsize by \multitablecolspace. - \advance\hsize by \multitablecolspace - \fi - % In either case we will make \leftskip=\multitablecolspace: - \leftskip=\multitablecolspace - \fi - % Ignoring space at the beginning and end avoids an occasional spurious - % blank line, when TeX decides to break the line at the space before the - % box from the multistrut, so the strut ends up on a line by itself. - % For example: - % @multitable @columnfractions .11 .89 - % @item @code{#} - % @tab Legal holiday which is valid in major parts of the whole country. - % Is automatically provided with highlighting sequences respectively - % marking characters. - \noindent\ignorespaces##\unskip\multistrut - }\cr -} -\def\Emultitable{% - \crcr - \egroup % end the \halign - \global\setpercentfalse -} - -\def\setmultitablespacing{% - \def\multistrut{\strut}% just use the standard line spacing - % - % Compute \multitablelinespace (if not defined by user) for use in - % \multitableparskip calculation. We used define \multistrut based on - % this, but (ironically) that caused the spacing to be off. - % See bug-texinfo report from Werner Lemberg, 31 Oct 2004 12:52:20 +0100. -\ifdim\multitablelinespace=0pt -\setbox0=\vbox{X}\global\multitablelinespace=\the\baselineskip -\global\advance\multitablelinespace by-\ht0 -\fi -%% Test to see if parskip is larger than space between lines of -%% table. If not, do nothing. -%% If so, set to same dimension as multitablelinespace. -\ifdim\multitableparskip>\multitablelinespace -\global\multitableparskip=\multitablelinespace -\global\advance\multitableparskip-7pt %% to keep parskip somewhat smaller - %% than skip between lines in the table. -\fi% -\ifdim\multitableparskip=0pt -\global\multitableparskip=\multitablelinespace -\global\advance\multitableparskip-7pt %% to keep parskip somewhat smaller - %% than skip between lines in the table. -\fi} - - -\message{conditionals,} - -% @iftex, @ifnotdocbook, @ifnothtml, @ifnotinfo, @ifnotplaintext, -% @ifnotxml always succeed. They currently do nothing; we don't -% attempt to check whether the conditionals are properly nested. But we -% have to remember that they are conditionals, so that @end doesn't -% attempt to close an environment group. -% -\def\makecond#1{% - \expandafter\let\csname #1\endcsname = \relax - \expandafter\let\csname iscond.#1\endcsname = 1 -} -\makecond{iftex} -\makecond{ifnotdocbook} -\makecond{ifnothtml} -\makecond{ifnotinfo} -\makecond{ifnotplaintext} -\makecond{ifnotxml} - -% Ignore @ignore, @ifhtml, @ifinfo, and the like. -% -\def\direntry{\doignore{direntry}} -\def\documentdescription{\doignore{documentdescription}} -\def\docbook{\doignore{docbook}} -\def\html{\doignore{html}} -\def\ifdocbook{\doignore{ifdocbook}} -\def\ifhtml{\doignore{ifhtml}} -\def\ifinfo{\doignore{ifinfo}} -\def\ifnottex{\doignore{ifnottex}} -\def\ifplaintext{\doignore{ifplaintext}} -\def\ifxml{\doignore{ifxml}} -\def\ignore{\doignore{ignore}} -\def\menu{\doignore{menu}} -\def\xml{\doignore{xml}} - -% Ignore text until a line `@end #1', keeping track of nested conditionals. -% -% A count to remember the depth of nesting. -\newcount\doignorecount - -\def\doignore#1{\begingroup - % Scan in ``verbatim'' mode: - \obeylines - \catcode`\@ = \other - \catcode`\{ = \other - \catcode`\} = \other - % - % Make sure that spaces turn into tokens that match what \doignoretext wants. - \spaceisspace - % - % Count number of #1's that we've seen. - \doignorecount = 0 - % - % Swallow text until we reach the matching `@end #1'. - \dodoignore{#1}% -} - -{ \catcode`_=11 % We want to use \_STOP_ which cannot appear in texinfo source. - \obeylines % - % - \gdef\dodoignore#1{% - % #1 contains the command name as a string, e.g., `ifinfo'. - % - % Define a command to find the next `@end #1'. - \long\def\doignoretext##1^^M@end #1{% - \doignoretextyyy##1^^M@#1\_STOP_}% - % - % And this command to find another #1 command, at the beginning of a - % line. (Otherwise, we would consider a line `@c @ifset', for - % example, to count as an @ifset for nesting.) - \long\def\doignoretextyyy##1^^M@#1##2\_STOP_{\doignoreyyy{##2}\_STOP_}% - % - % And now expand that command. - \doignoretext ^^M% - }% -} - -\def\doignoreyyy#1{% - \def\temp{#1}% - \ifx\temp\empty % Nothing found. - \let\next\doignoretextzzz - \else % Found a nested condition, ... - \advance\doignorecount by 1 - \let\next\doignoretextyyy % ..., look for another. - % If we're here, #1 ends with ^^M\ifinfo (for example). - \fi - \next #1% the token \_STOP_ is present just after this macro. -} - -% We have to swallow the remaining "\_STOP_". -% -\def\doignoretextzzz#1{% - \ifnum\doignorecount = 0 % We have just found the outermost @end. - \let\next\enddoignore - \else % Still inside a nested condition. - \advance\doignorecount by -1 - \let\next\doignoretext % Look for the next @end. - \fi - \next -} - -% Finish off ignored text. -{ \obeylines% - % Ignore anything after the last `@end #1'; this matters in verbatim - % environments, where otherwise the newline after an ignored conditional - % would result in a blank line in the output. - \gdef\enddoignore#1^^M{\endgroup\ignorespaces}% -} - - -% @set VAR sets the variable VAR to an empty value. -% @set VAR REST-OF-LINE sets VAR to the value REST-OF-LINE. -% -% Since we want to separate VAR from REST-OF-LINE (which might be -% empty), we can't just use \parsearg; we have to insert a space of our -% own to delimit the rest of the line, and then take it out again if we -% didn't need it. -% We rely on the fact that \parsearg sets \catcode`\ =10. -% -\parseargdef\set{\setyyy#1 \endsetyyy} -\def\setyyy#1 #2\endsetyyy{% - {% - \makevalueexpandable - \def\temp{#2}% - \edef\next{\gdef\makecsname{SET#1}}% - \ifx\temp\empty - \next{}% - \else - \setzzz#2\endsetzzz - \fi - }% -} -% Remove the trailing space \setxxx inserted. -\def\setzzz#1 \endsetzzz{\next{#1}} - -% @clear VAR clears (i.e., unsets) the variable VAR. -% -\parseargdef\clear{% - {% - \makevalueexpandable - \global\expandafter\let\csname SET#1\endcsname=\relax - }% -} - -% @value{foo} gets the text saved in variable foo. -\def\value{\begingroup\makevalueexpandable\valuexxx} -\def\valuexxx#1{\expandablevalue{#1}\endgroup} -{ - \catcode`\- = \active \catcode`\_ = \active - % - \gdef\makevalueexpandable{% - \let\value = \expandablevalue - % We don't want these characters active, ... - \catcode`\-=\other \catcode`\_=\other - % ..., but we might end up with active ones in the argument if - % we're called from @code, as @code{@value{foo-bar_}}, though. - % So \let them to their normal equivalents. - \let-\realdash \let_\normalunderscore - } -} - -% We have this subroutine so that we can handle at least some @value's -% properly in indexes (we call \makevalueexpandable in \indexdummies). -% The command has to be fully expandable (if the variable is set), since -% the result winds up in the index file. This means that if the -% variable's value contains other Texinfo commands, it's almost certain -% it will fail (although perhaps we could fix that with sufficient work -% to do a one-level expansion on the result, instead of complete). -% -\def\expandablevalue#1{% - \expandafter\ifx\csname SET#1\endcsname\relax - {[No value for ``#1'']}% - \message{Variable `#1', used in @value, is not set.}% - \else - \csname SET#1\endcsname - \fi -} - -% @ifset VAR ... @end ifset reads the `...' iff VAR has been defined -% with @set. -% -% To get special treatment of `@end ifset,' call \makeond and the redefine. -% -\makecond{ifset} -\def\ifset{\parsearg{\doifset{\let\next=\ifsetfail}}} -\def\doifset#1#2{% - {% - \makevalueexpandable - \let\next=\empty - \expandafter\ifx\csname SET#2\endcsname\relax - #1% If not set, redefine \next. - \fi - \expandafter - }\next -} -\def\ifsetfail{\doignore{ifset}} - -% @ifclear VAR ... @end ifclear reads the `...' iff VAR has never been -% defined with @set, or has been undefined with @clear. -% -% The `\else' inside the `\doifset' parameter is a trick to reuse the -% above code: if the variable is not set, do nothing, if it is set, -% then redefine \next to \ifclearfail. -% -\makecond{ifclear} -\def\ifclear{\parsearg{\doifset{\else \let\next=\ifclearfail}}} -\def\ifclearfail{\doignore{ifclear}} - -% @dircategory CATEGORY -- specify a category of the dir file -% which this file should belong to. Ignore this in TeX. -\let\dircategory=\comment - -% @defininfoenclose. -\let\definfoenclose=\comment - - -\message{indexing,} -% Index generation facilities - -% Define \newwrite to be identical to plain tex's \newwrite -% except not \outer, so it can be used within macros and \if's. -\edef\newwrite{\makecsname{ptexnewwrite}} - -% \newindex {foo} defines an index named foo. -% It automatically defines \fooindex such that -% \fooindex ...rest of line... puts an entry in the index foo. -% It also defines \fooindfile to be the number of the output channel for -% the file that accumulates this index. The file's extension is foo. -% The name of an index should be no more than 2 characters long -% for the sake of vms. -% -\def\newindex#1{% - \iflinks - \expandafter\newwrite \csname#1indfile\endcsname - \openout \csname#1indfile\endcsname \jobname.#1 % Open the file - \fi - \expandafter\xdef\csname#1index\endcsname{% % Define @#1index - \noexpand\doindex{#1}} -} - -% @defindex foo == \newindex{foo} -% -\def\defindex{\parsearg\newindex} - -% Define @defcodeindex, like @defindex except put all entries in @code. -% -\def\defcodeindex{\parsearg\newcodeindex} -% -\def\newcodeindex#1{% - \iflinks - \expandafter\newwrite \csname#1indfile\endcsname - \openout \csname#1indfile\endcsname \jobname.#1 - \fi - \expandafter\xdef\csname#1index\endcsname{% - \noexpand\docodeindex{#1}}% -} - - -% @synindex foo bar makes index foo feed into index bar. -% Do this instead of @defindex foo if you don't want it as a separate index. -% -% @syncodeindex foo bar similar, but put all entries made for index foo -% inside @code. -% -\def\synindex#1 #2 {\dosynindex\doindex{#1}{#2}} -\def\syncodeindex#1 #2 {\dosynindex\docodeindex{#1}{#2}} - -% #1 is \doindex or \docodeindex, #2 the index getting redefined (foo), -% #3 the target index (bar). -\def\dosynindex#1#2#3{% - % Only do \closeout if we haven't already done it, else we'll end up - % closing the target index. - \expandafter \ifx\csname donesynindex#2\endcsname \undefined - % The \closeout helps reduce unnecessary open files; the limit on the - % Acorn RISC OS is a mere 16 files. - \expandafter\closeout\csname#2indfile\endcsname - \expandafter\let\csname\donesynindex#2\endcsname = 1 - \fi - % redefine \fooindfile: - \expandafter\let\expandafter\temp\expandafter=\csname#3indfile\endcsname - \expandafter\let\csname#2indfile\endcsname=\temp - % redefine \fooindex: - \expandafter\xdef\csname#2index\endcsname{\noexpand#1{#3}}% -} - -% Define \doindex, the driver for all \fooindex macros. -% Argument #1 is generated by the calling \fooindex macro, -% and it is "foo", the name of the index. - -% \doindex just uses \parsearg; it calls \doind for the actual work. -% This is because \doind is more useful to call from other macros. - -% There is also \dosubind {index}{topic}{subtopic} -% which makes an entry in a two-level index such as the operation index. - -\def\doindex#1{\edef\indexname{#1}\parsearg\singleindexer} -\def\singleindexer #1{\doind{\indexname}{#1}} - -% like the previous two, but they put @code around the argument. -\def\docodeindex#1{\edef\indexname{#1}\parsearg\singlecodeindexer} -\def\singlecodeindexer #1{\doind{\indexname}{\code{#1}}} - -% Take care of Texinfo commands that can appear in an index entry. -% Since there are some commands we want to expand, and others we don't, -% we have to laboriously prevent expansion for those that we don't. -% -\def\indexdummies{% - \escapechar = `\\ % use backslash in output files. - \def\@{@}% change to @@ when we switch to @ as escape char in index files. - \def\ {\realbackslash\space }% - % - % Need these in case \tex is in effect and \{ is a \delimiter again. - % But can't use \lbracecmd and \rbracecmd because texindex assumes - % braces and backslashes are used only as delimiters. - \let\{ = \mylbrace - \let\} = \myrbrace - % - % I don't entirely understand this, but when an index entry is - % generated from a macro call, the \endinput which \scanmacro inserts - % causes processing to be prematurely terminated. This is, - % apparently, because \indexsorttmp is fully expanded, and \endinput - % is an expandable command. The redefinition below makes \endinput - % disappear altogether for that purpose -- although logging shows that - % processing continues to some further point. On the other hand, it - % seems \endinput does not hurt in the printed index arg, since that - % is still getting written without apparent harm. - % - % Sample source (mac-idx3.tex, reported by Graham Percival to - % help-texinfo, 22may06): - % @macro funindex {WORD} - % @findex xyz - % @end macro - % ... - % @funindex commtest - % - % The above is not enough to reproduce the bug, but it gives the flavor. - % - % Sample whatsit resulting: - % .@write3{\entry{xyz}{@folio }{@code {xyz@endinput }}} - % - % So: - \let\endinput = \empty - % - % Do the redefinitions. - \commondummies -} - -% For the aux and toc files, @ is the escape character. So we want to -% redefine everything using @ as the escape character (instead of -% \realbackslash, still used for index files). When everything uses @, -% this will be simpler. -% -\def\atdummies{% - \def\@{@@}% - \def\ {@ }% - \let\{ = \lbraceatcmd - \let\} = \rbraceatcmd - % - % Do the redefinitions. - \commondummies - \otherbackslash -} - -% Called from \indexdummies and \atdummies. -% -\def\commondummies{% - % - % \definedummyword defines \#1 as \string\#1\space, thus effectively - % preventing its expansion. This is used only for control% words, - % not control letters, because the \space would be incorrect for - % control characters, but is needed to separate the control word - % from whatever follows. - % - % For control letters, we have \definedummyletter, which omits the - % space. - % - % These can be used both for control words that take an argument and - % those that do not. If it is followed by {arg} in the input, then - % that will dutifully get written to the index (or wherever). - % - \def\definedummyword ##1{\def##1{\string##1\space}}% - \def\definedummyletter##1{\def##1{\string##1}}% - \let\definedummyaccent\definedummyletter - % - \commondummiesnofonts - % - \definedummyletter\_% - % - % Non-English letters. - \definedummyword\AA - \definedummyword\AE - \definedummyword\L - \definedummyword\OE - \definedummyword\O - \definedummyword\aa - \definedummyword\ae - \definedummyword\l - \definedummyword\oe - \definedummyword\o - \definedummyword\ss - \definedummyword\exclamdown - \definedummyword\questiondown - \definedummyword\ordf - \definedummyword\ordm - % - % Although these internal commands shouldn't show up, sometimes they do. - \definedummyword\bf - \definedummyword\gtr - \definedummyword\hat - \definedummyword\less - \definedummyword\sf - \definedummyword\sl - \definedummyword\tclose - \definedummyword\tt - % - \definedummyword\LaTeX - \definedummyword\TeX - % - % Assorted special characters. - \definedummyword\bullet - \definedummyword\comma - \definedummyword\copyright - \definedummyword\registeredsymbol - \definedummyword\dots - \definedummyword\enddots - \definedummyword\equiv - \definedummyword\error - \definedummyword\euro - \definedummyword\expansion - \definedummyword\minus - \definedummyword\pounds - \definedummyword\point - \definedummyword\print - \definedummyword\result - \definedummyword\textdegree - % - % We want to disable all macros so that they are not expanded by \write. - \macrolist - % - \normalturnoffactive - % - % Handle some cases of @value -- where it does not contain any - % (non-fully-expandable) commands. - \makevalueexpandable -} - -% \commondummiesnofonts: common to \commondummies and \indexnofonts. -% -\def\commondummiesnofonts{% - % Control letters and accents. - \definedummyletter\!% - \definedummyaccent\"% - \definedummyaccent\'% - \definedummyletter\*% - \definedummyaccent\,% - \definedummyletter\.% - \definedummyletter\/% - \definedummyletter\:% - \definedummyaccent\=% - \definedummyletter\?% - \definedummyaccent\^% - \definedummyaccent\`% - \definedummyaccent\~% - \definedummyword\u - \definedummyword\v - \definedummyword\H - \definedummyword\dotaccent - \definedummyword\ringaccent - \definedummyword\tieaccent - \definedummyword\ubaraccent - \definedummyword\udotaccent - \definedummyword\dotless - % - % Texinfo font commands. - \definedummyword\b - \definedummyword\i - \definedummyword\r - \definedummyword\sc - \definedummyword\t - % - % Commands that take arguments. - \definedummyword\acronym - \definedummyword\cite - \definedummyword\code - \definedummyword\command - \definedummyword\dfn - \definedummyword\emph - \definedummyword\env - \definedummyword\file - \definedummyword\kbd - \definedummyword\key - \definedummyword\math - \definedummyword\option - \definedummyword\pxref - \definedummyword\ref - \definedummyword\samp - \definedummyword\strong - \definedummyword\tie - \definedummyword\uref - \definedummyword\url - \definedummyword\var - \definedummyword\verb - \definedummyword\w - \definedummyword\xref -} - -% \indexnofonts is used when outputting the strings to sort the index -% by, and when constructing control sequence names. It eliminates all -% control sequences and just writes whatever the best ASCII sort string -% would be for a given command (usually its argument). -% -\def\indexnofonts{% - % Accent commands should become @asis. - \def\definedummyaccent##1{\let##1\asis}% - % We can just ignore other control letters. - \def\definedummyletter##1{\let##1\empty}% - % Hopefully, all control words can become @asis. - \let\definedummyword\definedummyaccent - % - \commondummiesnofonts - % - % Don't no-op \tt, since it isn't a user-level command - % and is used in the definitions of the active chars like <, >, |, etc. - % Likewise with the other plain tex font commands. - %\let\tt=\asis - % - \def\ { }% - \def\@{@}% - % how to handle braces? - \def\_{\normalunderscore}% - % - % Non-English letters. - \def\AA{AA}% - \def\AE{AE}% - \def\L{L}% - \def\OE{OE}% - \def\O{O}% - \def\aa{aa}% - \def\ae{ae}% - \def\l{l}% - \def\oe{oe}% - \def\o{o}% - \def\ss{ss}% - \def\exclamdown{!}% - \def\questiondown{?}% - \def\ordf{a}% - \def\ordm{o}% - % - \def\LaTeX{LaTeX}% - \def\TeX{TeX}% - % - % Assorted special characters. - % (The following {} will end up in the sort string, but that's ok.) - \def\bullet{bullet}% - \def\comma{,}% - \def\copyright{copyright}% - \def\registeredsymbol{R}% - \def\dots{...}% - \def\enddots{...}% - \def\equiv{==}% - \def\error{error}% - \def\euro{euro}% - \def\expansion{==>}% - \def\minus{-}% - \def\pounds{pounds}% - \def\point{.}% - \def\print{-|}% - \def\result{=>}% - \def\textdegree{degrees}% - % - % We need to get rid of all macros, leaving only the arguments (if present). - % Of course this is not nearly correct, but it is the best we can do for now. - % makeinfo does not expand macros in the argument to @deffn, which ends up - % writing an index entry, and texindex isn't prepared for an index sort entry - % that starts with \. - % - % Since macro invocations are followed by braces, we can just redefine them - % to take a single TeX argument. The case of a macro invocation that - % goes to end-of-line is not handled. - % - \macrolist -} - -\let\indexbackslash=0 %overridden during \printindex. -\let\SETmarginindex=\relax % put index entries in margin (undocumented)? - -% Most index entries go through here, but \dosubind is the general case. -% #1 is the index name, #2 is the entry text. -\def\doind#1#2{\dosubind{#1}{#2}{}} - -% Workhorse for all \fooindexes. -% #1 is name of index, #2 is stuff to put there, #3 is subentry -- -% empty if called from \doind, as we usually are (the main exception -% is with most defuns, which call us directly). -% -\def\dosubind#1#2#3{% - \iflinks - {% - % Store the main index entry text (including the third arg). - \toks0 = {#2}% - % If third arg is present, precede it with a space. - \def\thirdarg{#3}% - \ifx\thirdarg\empty \else - \toks0 = \expandafter{\the\toks0 \space #3}% - \fi - % - \edef\writeto{\csname#1indfile\endcsname}% - % - \ifvmode - \dosubindsanitize - \else - \dosubindwrite - \fi - }% - \fi -} - -% Write the entry in \toks0 to the index file: -% -\def\dosubindwrite{% - % Put the index entry in the margin if desired. - \ifx\SETmarginindex\relax\else - \insert\margin{\hbox{\vrule height8pt depth3pt width0pt \the\toks0}}% - \fi - % - % Remember, we are within a group. - \indexdummies % Must do this here, since \bf, etc expand at this stage - \def\backslashcurfont{\indexbackslash}% \indexbackslash isn't defined now - % so it will be output as is; and it will print as backslash. - % - % Process the index entry with all font commands turned off, to - % get the string to sort by. - {\indexnofonts - \edef\temp{\the\toks0}% need full expansion - \xdef\indexsorttmp{\temp}% - }% - % - % Set up the complete index entry, with both the sort key and - % the original text, including any font commands. We write - % three arguments to \entry to the .?? file (four in the - % subentry case), texindex reduces to two when writing the .??s - % sorted result. - \edef\temp{% - \write\writeto{% - \string\entry{\indexsorttmp}{\noexpand\folio}{\the\toks0}}% - }% - \temp -} - -% Take care of unwanted page breaks: -% -% If a skip is the last thing on the list now, preserve it -% by backing up by \lastskip, doing the \write, then inserting -% the skip again. Otherwise, the whatsit generated by the -% \write will make \lastskip zero. The result is that sequences -% like this: -% @end defun -% @tindex whatever -% @defun ... -% will have extra space inserted, because the \medbreak in the -% start of the @defun won't see the skip inserted by the @end of -% the previous defun. -% -% But don't do any of this if we're not in vertical mode. We -% don't want to do a \vskip and prematurely end a paragraph. -% -% Avoid page breaks due to these extra skips, too. -% -% But wait, there is a catch there: -% We'll have to check whether \lastskip is zero skip. \ifdim is not -% sufficient for this purpose, as it ignores stretch and shrink parts -% of the skip. The only way seems to be to check the textual -% representation of the skip. -% -% The following is almost like \def\zeroskipmacro{0.0pt} except that -% the ``p'' and ``t'' characters have catcode \other, not 11 (letter). -% -\edef\zeroskipmacro{\expandafter\the\csname z@skip\endcsname} -% -% ..., ready, GO: -% -\def\dosubindsanitize{% - % \lastskip and \lastpenalty cannot both be nonzero simultaneously. - \skip0 = \lastskip - \edef\lastskipmacro{\the\lastskip}% - \count255 = \lastpenalty - % - % If \lastskip is nonzero, that means the last item was a - % skip. And since a skip is discardable, that means this - % -\skip0 glue we're inserting is preceded by a - % non-discardable item, therefore it is not a potential - % breakpoint, therefore no \nobreak needed. - \ifx\lastskipmacro\zeroskipmacro - \else - \vskip-\skip0 - \fi - % - \dosubindwrite - % - \ifx\lastskipmacro\zeroskipmacro - % If \lastskip was zero, perhaps the last item was a penalty, and - % perhaps it was >=10000, e.g., a \nobreak. In that case, we want - % to re-insert the same penalty (values >10000 are used for various - % signals); since we just inserted a non-discardable item, any - % following glue (such as a \parskip) would be a breakpoint. For example: - % - % @deffn deffn-whatever - % @vindex index-whatever - % Description. - % would allow a break between the index-whatever whatsit - % and the "Description." paragraph. - \ifnum\count255>9999 \penalty\count255 \fi - \else - % On the other hand, if we had a nonzero \lastskip, - % this make-up glue would be preceded by a non-discardable item - % (the whatsit from the \write), so we must insert a \nobreak. - \nobreak\vskip\skip0 - \fi -} - -% The index entry written in the file actually looks like -% \entry {sortstring}{page}{topic} -% or -% \entry {sortstring}{page}{topic}{subtopic} -% The texindex program reads in these files and writes files -% containing these kinds of lines: -% \initial {c} -% before the first topic whose initial is c -% \entry {topic}{pagelist} -% for a topic that is used without subtopics -% \primary {topic} -% for the beginning of a topic that is used with subtopics -% \secondary {subtopic}{pagelist} -% for each subtopic. - -% Define the user-accessible indexing commands -% @findex, @vindex, @kindex, @cindex. - -\def\findex {\fnindex} -\def\kindex {\kyindex} -\def\cindex {\cpindex} -\def\vindex {\vrindex} -\def\tindex {\tpindex} -\def\pindex {\pgindex} - -\def\cindexsub {\begingroup\obeylines\cindexsub} -{\obeylines % -\gdef\cindexsub "#1" #2^^M{\endgroup % -\dosubind{cp}{#2}{#1}}} - -% Define the macros used in formatting output of the sorted index material. - -% @printindex causes a particular index (the ??s file) to get printed. -% It does not print any chapter heading (usually an @unnumbered). -% -\parseargdef\printindex{\begingroup - \dobreak \chapheadingskip{10000}% - % - \smallfonts \rm - \tolerance = 9500 - \everypar = {}% don't want the \kern\-parindent from indentation suppression. - % - % See if the index file exists and is nonempty. - % Change catcode of @ here so that if the index file contains - % \initial {@} - % as its first line, TeX doesn't complain about mismatched braces - % (because it thinks @} is a control sequence). - \catcode`\@ = 11 - \openin 1 \jobname.#1s - \ifeof 1 - % \enddoublecolumns gets confused if there is no text in the index, - % and it loses the chapter title and the aux file entries for the - % index. The easiest way to prevent this problem is to make sure - % there is some text. - \putwordIndexNonexistent - \else - % - % If the index file exists but is empty, then \openin leaves \ifeof - % false. We have to make TeX try to read something from the file, so - % it can discover if there is anything in it. - \read 1 to \temp - \ifeof 1 - \putwordIndexIsEmpty - \else - % Index files are almost Texinfo source, but we use \ as the escape - % character. It would be better to use @, but that's too big a change - % to make right now. - \def\indexbackslash{\backslashcurfont}% - \catcode`\\ = 0 - \escapechar = `\\ - \begindoublecolumns - \input \jobname.#1s - \enddoublecolumns - \fi - \fi - \closein 1 -\endgroup} - -% These macros are used by the sorted index file itself. -% Change them to control the appearance of the index. - -\def\initial#1{{% - % Some minor font changes for the special characters. - \let\tentt=\sectt \let\tt=\sectt \let\sf=\sectt - % - % Remove any glue we may have, we'll be inserting our own. - \removelastskip - % - % We like breaks before the index initials, so insert a bonus. - \nobreak - \vskip 0pt plus 3\baselineskip - \penalty 0 - \vskip 0pt plus -3\baselineskip - % - % Typeset the initial. Making this add up to a whole number of - % baselineskips increases the chance of the dots lining up from column - % to column. It still won't often be perfect, because of the stretch - % we need before each entry, but it's better. - % - % No shrink because it confuses \balancecolumns. - \vskip 1.67\baselineskip plus .5\baselineskip - \leftline{\secbf #1}% - % Do our best not to break after the initial. - \nobreak - \vskip .33\baselineskip plus .1\baselineskip -}} - -% \entry typesets a paragraph consisting of the text (#1), dot leaders, and -% then page number (#2) flushed to the right margin. It is used for index -% and table of contents entries. The paragraph is indented by \leftskip. -% -% A straightforward implementation would start like this: -% \def\entry#1#2{... -% But this frozes the catcodes in the argument, and can cause problems to -% @code, which sets - active. This problem was fixed by a kludge--- -% ``-'' was active throughout whole index, but this isn't really right. -% -% The right solution is to prevent \entry from swallowing the whole text. -% --kasal, 21nov03 -\def\entry{% - \begingroup - % - % Start a new paragraph if necessary, so our assignments below can't - % affect previous text. - \par - % - % Do not fill out the last line with white space. - \parfillskip = 0in - % - % No extra space above this paragraph. - \parskip = 0in - % - % Do not prefer a separate line ending with a hyphen to fewer lines. - \finalhyphendemerits = 0 - % - % \hangindent is only relevant when the entry text and page number - % don't both fit on one line. In that case, bob suggests starting the - % dots pretty far over on the line. Unfortunately, a large - % indentation looks wrong when the entry text itself is broken across - % lines. So we use a small indentation and put up with long leaders. - % - % \hangafter is reset to 1 (which is the value we want) at the start - % of each paragraph, so we need not do anything with that. - \hangindent = 2em - % - % When the entry text needs to be broken, just fill out the first line - % with blank space. - \rightskip = 0pt plus1fil - % - % A bit of stretch before each entry for the benefit of balancing - % columns. - \vskip 0pt plus1pt - % - % Swallow the left brace of the text (first parameter): - \afterassignment\doentry - \let\temp = -} -\def\doentry{% - \bgroup % Instead of the swallowed brace. - \noindent - \aftergroup\finishentry - % And now comes the text of the entry. -} -\def\finishentry#1{% - % #1 is the page number. - % - % The following is kludged to not output a line of dots in the index if - % there are no page numbers. The next person who breaks this will be - % cursed by a Unix daemon. - \def\tempa{{\rm }}% - \def\tempb{#1}% - \edef\tempc{\tempa}% - \edef\tempd{\tempb}% - \ifx\tempc\tempd - \ % - \else - % - % If we must, put the page number on a line of its own, and fill out - % this line with blank space. (The \hfil is overwhelmed with the - % fill leaders glue in \indexdotfill if the page number does fit.) - \hfil\penalty50 - \null\nobreak\indexdotfill % Have leaders before the page number. - % - % The `\ ' here is removed by the implicit \unskip that TeX does as - % part of (the primitive) \par. Without it, a spurious underfull - % \hbox ensues. - \ifpdf - \pdfgettoks#1.% - \ \the\toksA - \else - \ #1% - \fi - \fi - \par - \endgroup -} - -% Like plain.tex's \dotfill, except uses up at least 1 em. -\def\indexdotfill{\cleaders - \hbox{$\mathsurround=0pt \mkern1.5mu.\mkern1.5mu$}\hskip 1em plus 1fill} - -\def\primary #1{\line{#1\hfil}} - -\newskip\secondaryindent \secondaryindent=0.5cm -\def\secondary#1#2{{% - \parfillskip=0in - \parskip=0in - \hangindent=1in - \hangafter=1 - \noindent\hskip\secondaryindent\hbox{#1}\indexdotfill - \ifpdf - \pdfgettoks#2.\ \the\toksA % The page number ends the paragraph. - \else - #2 - \fi - \par -}} - -% Define two-column mode, which we use to typeset indexes. -% Adapted from the TeXbook, page 416, which is to say, -% the manmac.tex format used to print the TeXbook itself. -\catcode`\@=11 - -\newbox\partialpage -\newdimen\doublecolumnhsize - -\def\begindoublecolumns{\begingroup % ended by \enddoublecolumns - % Grab any single-column material above us. - \output = {% - % - % Here is a possibility not foreseen in manmac: if we accumulate a - % whole lot of material, we might end up calling this \output - % routine twice in a row (see the doublecol-lose test, which is - % essentially a couple of indexes with @setchapternewpage off). In - % that case we just ship out what is in \partialpage with the normal - % output routine. Generally, \partialpage will be empty when this - % runs and this will be a no-op. See the indexspread.tex test case. - \ifvoid\partialpage \else - \onepageout{\pagecontents\partialpage}% - \fi - % - \global\setbox\partialpage = \vbox{% - % Unvbox the main output page. - \unvbox\PAGE - \kern-\topskip \kern\baselineskip - }% - }% - \eject % run that output routine to set \partialpage - % - % Use the double-column output routine for subsequent pages. - \output = {\doublecolumnout}% - % - % Change the page size parameters. We could do this once outside this - % routine, in each of @smallbook, @afourpaper, and the default 8.5x11 - % format, but then we repeat the same computation. Repeating a couple - % of assignments once per index is clearly meaningless for the - % execution time, so we may as well do it in one place. - % - % First we halve the line length, less a little for the gutter between - % the columns. We compute the gutter based on the line length, so it - % changes automatically with the paper format. The magic constant - % below is chosen so that the gutter has the same value (well, +-<1pt) - % as it did when we hard-coded it. - % - % We put the result in a separate register, \doublecolumhsize, so we - % can restore it in \pagesofar, after \hsize itself has (potentially) - % been clobbered. - % - \doublecolumnhsize = \hsize - \advance\doublecolumnhsize by -.04154\hsize - \divide\doublecolumnhsize by 2 - \hsize = \doublecolumnhsize - % - % Double the \vsize as well. (We don't need a separate register here, - % since nobody clobbers \vsize.) - \vsize = 2\vsize -} - -% The double-column output routine for all double-column pages except -% the last. -% -\def\doublecolumnout{% - \splittopskip=\topskip \splitmaxdepth=\maxdepth - % Get the available space for the double columns -- the normal - % (undoubled) page height minus any material left over from the - % previous page. - \dimen@ = \vsize - \divide\dimen@ by 2 - \advance\dimen@ by -\ht\partialpage - % - % box0 will be the left-hand column, box2 the right. - \setbox0=\vsplit255 to\dimen@ \setbox2=\vsplit255 to\dimen@ - \onepageout\pagesofar - \unvbox255 - \penalty\outputpenalty -} -% -% Re-output the contents of the output page -- any previous material, -% followed by the two boxes we just split, in box0 and box2. -\def\pagesofar{% - \unvbox\partialpage - % - \hsize = \doublecolumnhsize - \wd0=\hsize \wd2=\hsize - \hbox to\pagewidth{\box0\hfil\box2}% -} -% -% All done with double columns. -\def\enddoublecolumns{% - \output = {% - % Split the last of the double-column material. Leave it on the - % current page, no automatic page break. - \balancecolumns - % - % If we end up splitting too much material for the current page, - % though, there will be another page break right after this \output - % invocation ends. Having called \balancecolumns once, we do not - % want to call it again. Therefore, reset \output to its normal - % definition right away. (We hope \balancecolumns will never be - % called on to balance too much material, but if it is, this makes - % the output somewhat more palatable.) - \global\output = {\onepageout{\pagecontents\PAGE}}% - }% - \eject - \endgroup % started in \begindoublecolumns - % - % \pagegoal was set to the doubled \vsize above, since we restarted - % the current page. We're now back to normal single-column - % typesetting, so reset \pagegoal to the normal \vsize (after the - % \endgroup where \vsize got restored). - \pagegoal = \vsize -} -% -% Called at the end of the double column material. -\def\balancecolumns{% - \setbox0 = \vbox{\unvbox255}% like \box255 but more efficient, see p.120. - \dimen@ = \ht0 - \advance\dimen@ by \topskip - \advance\dimen@ by-\baselineskip - \divide\dimen@ by 2 % target to split to - %debug\message{final 2-column material height=\the\ht0, target=\the\dimen@.}% - \splittopskip = \topskip - % Loop until we get a decent breakpoint. - {% - \vbadness = 10000 - \loop - \global\setbox3 = \copy0 - \global\setbox1 = \vsplit3 to \dimen@ - \ifdim\ht3>\dimen@ - \global\advance\dimen@ by 1pt - \repeat - }% - %debug\message{split to \the\dimen@, column heights: \the\ht1, \the\ht3.}% - \setbox0=\vbox to\dimen@{\unvbox1}% - \setbox2=\vbox to\dimen@{\unvbox3}% - % - \pagesofar -} -\catcode`\@ = \other - - -\message{sectioning,} -% Chapters, sections, etc. - -% \unnumberedno is an oxymoron, of course. But we count the unnumbered -% sections so that we can refer to them unambiguously in the pdf -% outlines by their "section number". We avoid collisions with chapter -% numbers by starting them at 10000. (If a document ever has 10000 -% chapters, we're in trouble anyway, I'm sure.) -\newcount\unnumberedno \unnumberedno = 10000 -\newcount\chapno -\newcount\secno \secno=0 -\newcount\subsecno \subsecno=0 -\newcount\subsubsecno \subsubsecno=0 - -% This counter is funny since it counts through charcodes of letters A, B, ... -\newcount\appendixno \appendixno = `\@ -% -% \def\appendixletter{\char\the\appendixno} -% We do the following ugly conditional instead of the above simple -% construct for the sake of pdftex, which needs the actual -% letter in the expansion, not just typeset. -% -\def\appendixletter{% - \ifnum\appendixno=`A A% - \else\ifnum\appendixno=`B B% - \else\ifnum\appendixno=`C C% - \else\ifnum\appendixno=`D D% - \else\ifnum\appendixno=`E E% - \else\ifnum\appendixno=`F F% - \else\ifnum\appendixno=`G G% - \else\ifnum\appendixno=`H H% - \else\ifnum\appendixno=`I I% - \else\ifnum\appendixno=`J J% - \else\ifnum\appendixno=`K K% - \else\ifnum\appendixno=`L L% - \else\ifnum\appendixno=`M M% - \else\ifnum\appendixno=`N N% - \else\ifnum\appendixno=`O O% - \else\ifnum\appendixno=`P P% - \else\ifnum\appendixno=`Q Q% - \else\ifnum\appendixno=`R R% - \else\ifnum\appendixno=`S S% - \else\ifnum\appendixno=`T T% - \else\ifnum\appendixno=`U U% - \else\ifnum\appendixno=`V V% - \else\ifnum\appendixno=`W W% - \else\ifnum\appendixno=`X X% - \else\ifnum\appendixno=`Y Y% - \else\ifnum\appendixno=`Z Z% - % The \the is necessary, despite appearances, because \appendixletter is - % expanded while writing the .toc file. \char\appendixno is not - % expandable, thus it is written literally, thus all appendixes come out - % with the same letter (or @) in the toc without it. - \else\char\the\appendixno - \fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi - \fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi} - -% Each @chapter defines this as the name of the chapter. -% page headings and footings can use it. @section does likewise. -% However, they are not reliable, because we don't use marks. -\def\thischapter{} -\def\thissection{} - -\newcount\absseclevel % used to calculate proper heading level -\newcount\secbase\secbase=0 % @raisesections/@lowersections modify this count - -% @raisesections: treat @section as chapter, @subsection as section, etc. -\def\raisesections{\global\advance\secbase by -1} -\let\up=\raisesections % original BFox name - -% @lowersections: treat @chapter as section, @section as subsection, etc. -\def\lowersections{\global\advance\secbase by 1} -\let\down=\lowersections % original BFox name - -% we only have subsub. -\chardef\maxseclevel = 3 -% -% A numbered section within an unnumbered changes to unnumbered too. -% To achive this, remember the "biggest" unnum. sec. we are currently in: -\chardef\unmlevel = \maxseclevel -% -% Trace whether the current chapter is an appendix or not: -% \chapheadtype is "N" or "A", unnumbered chapters are ignored. -\def\chapheadtype{N} - -% Choose a heading macro -% #1 is heading type -% #2 is heading level -% #3 is text for heading -\def\genhead#1#2#3{% - % Compute the abs. sec. level: - \absseclevel=#2 - \advance\absseclevel by \secbase - % Make sure \absseclevel doesn't fall outside the range: - \ifnum \absseclevel < 0 - \absseclevel = 0 - \else - \ifnum \absseclevel > 3 - \absseclevel = 3 - \fi - \fi - % The heading type: - \def\headtype{#1}% - \if \headtype U% - \ifnum \absseclevel < \unmlevel - \chardef\unmlevel = \absseclevel - \fi - \else - % Check for appendix sections: - \ifnum \absseclevel = 0 - \edef\chapheadtype{\headtype}% - \else - \if \headtype A\if \chapheadtype N% - \errmessage{@appendix... within a non-appendix chapter}% - \fi\fi - \fi - % Check for numbered within unnumbered: - \ifnum \absseclevel > \unmlevel - \def\headtype{U}% - \else - \chardef\unmlevel = 3 - \fi - \fi - % Now print the heading: - \if \headtype U% - \ifcase\absseclevel - \unnumberedzzz{#3}% - \or \unnumberedseczzz{#3}% - \or \unnumberedsubseczzz{#3}% - \or \unnumberedsubsubseczzz{#3}% - \fi - \else - \if \headtype A% - \ifcase\absseclevel - \appendixzzz{#3}% - \or \appendixsectionzzz{#3}% - \or \appendixsubseczzz{#3}% - \or \appendixsubsubseczzz{#3}% - \fi - \else - \ifcase\absseclevel - \chapterzzz{#3}% - \or \seczzz{#3}% - \or \numberedsubseczzz{#3}% - \or \numberedsubsubseczzz{#3}% - \fi - \fi - \fi - \suppressfirstparagraphindent -} - -% an interface: -\def\numhead{\genhead N} -\def\apphead{\genhead A} -\def\unnmhead{\genhead U} - -% @chapter, @appendix, @unnumbered. Increment top-level counter, reset -% all lower-level sectioning counters to zero. -% -% Also set \chaplevelprefix, which we prepend to @float sequence numbers -% (e.g., figures), q.v. By default (before any chapter), that is empty. -\let\chaplevelprefix = \empty -% -\outer\parseargdef\chapter{\numhead0{#1}} % normally numhead0 calls chapterzzz -\def\chapterzzz#1{% - % section resetting is \global in case the chapter is in a group, such - % as an @include file. - \global\secno=0 \global\subsecno=0 \global\subsubsecno=0 - \global\advance\chapno by 1 - % - % Used for \float. - \gdef\chaplevelprefix{\the\chapno.}% - \resetallfloatnos - % - \message{\putwordChapter\space \the\chapno}% - % - % Write the actual heading. - \chapmacro{#1}{Ynumbered}{\the\chapno}% - % - % So @section and the like are numbered underneath this chapter. - \global\let\section = \numberedsec - \global\let\subsection = \numberedsubsec - \global\let\subsubsection = \numberedsubsubsec -} - -\outer\parseargdef\appendix{\apphead0{#1}} % normally apphead0 calls appendixzzz -\def\appendixzzz#1{% - \global\secno=0 \global\subsecno=0 \global\subsubsecno=0 - \global\advance\appendixno by 1 - \gdef\chaplevelprefix{\appendixletter.}% - \resetallfloatnos - % - \def\appendixnum{\putwordAppendix\space \appendixletter}% - \message{\appendixnum}% - % - \chapmacro{#1}{Yappendix}{\appendixletter}% - % - \global\let\section = \appendixsec - \global\let\subsection = \appendixsubsec - \global\let\subsubsection = \appendixsubsubsec -} - -\outer\parseargdef\unnumbered{\unnmhead0{#1}} % normally unnmhead0 calls unnumberedzzz -\def\unnumberedzzz#1{% - \global\secno=0 \global\subsecno=0 \global\subsubsecno=0 - \global\advance\unnumberedno by 1 - % - % Since an unnumbered has no number, no prefix for figures. - \global\let\chaplevelprefix = \empty - \resetallfloatnos - % - % This used to be simply \message{#1}, but TeX fully expands the - % argument to \message. Therefore, if #1 contained @-commands, TeX - % expanded them. For example, in `@unnumbered The @cite{Book}', TeX - % expanded @cite (which turns out to cause errors because \cite is meant - % to be executed, not expanded). - % - % Anyway, we don't want the fully-expanded definition of @cite to appear - % as a result of the \message, we just want `@cite' itself. We use - % \the to achieve this: TeX expands \the only once, - % simply yielding the contents of . (We also do this for - % the toc entries.) - \toks0 = {#1}% - \message{(\the\toks0)}% - % - \chapmacro{#1}{Ynothing}{\the\unnumberedno}% - % - \global\let\section = \unnumberedsec - \global\let\subsection = \unnumberedsubsec - \global\let\subsubsection = \unnumberedsubsubsec -} - -% @centerchap is like @unnumbered, but the heading is centered. -\outer\parseargdef\centerchap{% - % Well, we could do the following in a group, but that would break - % an assumption that \chapmacro is called at the outermost level. - % Thus we are safer this way: --kasal, 24feb04 - \let\centerparametersmaybe = \centerparameters - \unnmhead0{#1}% - \let\centerparametersmaybe = \relax -} - -% @top is like @unnumbered. -\let\top\unnumbered - -% Sections. -\outer\parseargdef\numberedsec{\numhead1{#1}} % normally calls seczzz -\def\seczzz#1{% - \global\subsecno=0 \global\subsubsecno=0 \global\advance\secno by 1 - \sectionheading{#1}{sec}{Ynumbered}{\the\chapno.\the\secno}% -} - -\outer\parseargdef\appendixsection{\apphead1{#1}} % normally calls appendixsectionzzz -\def\appendixsectionzzz#1{% - \global\subsecno=0 \global\subsubsecno=0 \global\advance\secno by 1 - \sectionheading{#1}{sec}{Yappendix}{\appendixletter.\the\secno}% -} -\let\appendixsec\appendixsection - -\outer\parseargdef\unnumberedsec{\unnmhead1{#1}} % normally calls unnumberedseczzz -\def\unnumberedseczzz#1{% - \global\subsecno=0 \global\subsubsecno=0 \global\advance\secno by 1 - \sectionheading{#1}{sec}{Ynothing}{\the\unnumberedno.\the\secno}% -} - -% Subsections. -\outer\parseargdef\numberedsubsec{\numhead2{#1}} % normally calls numberedsubseczzz -\def\numberedsubseczzz#1{% - \global\subsubsecno=0 \global\advance\subsecno by 1 - \sectionheading{#1}{subsec}{Ynumbered}{\the\chapno.\the\secno.\the\subsecno}% -} - -\outer\parseargdef\appendixsubsec{\apphead2{#1}} % normally calls appendixsubseczzz -\def\appendixsubseczzz#1{% - \global\subsubsecno=0 \global\advance\subsecno by 1 - \sectionheading{#1}{subsec}{Yappendix}% - {\appendixletter.\the\secno.\the\subsecno}% -} - -\outer\parseargdef\unnumberedsubsec{\unnmhead2{#1}} %normally calls unnumberedsubseczzz -\def\unnumberedsubseczzz#1{% - \global\subsubsecno=0 \global\advance\subsecno by 1 - \sectionheading{#1}{subsec}{Ynothing}% - {\the\unnumberedno.\the\secno.\the\subsecno}% -} - -% Subsubsections. -\outer\parseargdef\numberedsubsubsec{\numhead3{#1}} % normally numberedsubsubseczzz -\def\numberedsubsubseczzz#1{% - \global\advance\subsubsecno by 1 - \sectionheading{#1}{subsubsec}{Ynumbered}% - {\the\chapno.\the\secno.\the\subsecno.\the\subsubsecno}% -} - -\outer\parseargdef\appendixsubsubsec{\apphead3{#1}} % normally appendixsubsubseczzz -\def\appendixsubsubseczzz#1{% - \global\advance\subsubsecno by 1 - \sectionheading{#1}{subsubsec}{Yappendix}% - {\appendixletter.\the\secno.\the\subsecno.\the\subsubsecno}% -} - -\outer\parseargdef\unnumberedsubsubsec{\unnmhead3{#1}} %normally unnumberedsubsubseczzz -\def\unnumberedsubsubseczzz#1{% - \global\advance\subsubsecno by 1 - \sectionheading{#1}{subsubsec}{Ynothing}% - {\the\unnumberedno.\the\secno.\the\subsecno.\the\subsubsecno}% -} - -% These macros control what the section commands do, according -% to what kind of chapter we are in (ordinary, appendix, or unnumbered). -% Define them by default for a numbered chapter. -\let\section = \numberedsec -\let\subsection = \numberedsubsec -\let\subsubsection = \numberedsubsubsec - -% Define @majorheading, @heading and @subheading - -% NOTE on use of \vbox for chapter headings, section headings, and such: -% 1) We use \vbox rather than the earlier \line to permit -% overlong headings to fold. -% 2) \hyphenpenalty is set to 10000 because hyphenation in a -% heading is obnoxious; this forbids it. -% 3) Likewise, headings look best if no \parindent is used, and -% if justification is not attempted. Hence \raggedright. - - -\def\majorheading{% - {\advance\chapheadingskip by 10pt \chapbreak }% - \parsearg\chapheadingzzz -} - -\def\chapheading{\chapbreak \parsearg\chapheadingzzz} -\def\chapheadingzzz#1{% - {\chapfonts \vbox{\hyphenpenalty=10000\tolerance=5000 - \parindent=0pt\raggedright - \rm #1\hfill}}% - \bigskip \par\penalty 200\relax - \suppressfirstparagraphindent -} - -% @heading, @subheading, @subsubheading. -\parseargdef\heading{\sectionheading{#1}{sec}{Yomitfromtoc}{} - \suppressfirstparagraphindent} -\parseargdef\subheading{\sectionheading{#1}{subsec}{Yomitfromtoc}{} - \suppressfirstparagraphindent} -\parseargdef\subsubheading{\sectionheading{#1}{subsubsec}{Yomitfromtoc}{} - \suppressfirstparagraphindent} - -% These macros generate a chapter, section, etc. heading only -% (including whitespace, linebreaking, etc. around it), -% given all the information in convenient, parsed form. - -%%% Args are the skip and penalty (usually negative) -\def\dobreak#1#2{\par\ifdim\lastskip<#1\removelastskip\penalty#2\vskip#1\fi} - -%%% Define plain chapter starts, and page on/off switching for it -% Parameter controlling skip before chapter headings (if needed) - -\newskip\chapheadingskip - -\def\chapbreak{\dobreak \chapheadingskip {-4000}} -\def\chappager{\par\vfill\supereject} -\def\chapoddpage{\chappager \ifodd\pageno \else \hbox to 0pt{} \chappager\fi} - -\def\setchapternewpage #1 {\csname CHAPPAG#1\endcsname} - -\def\CHAPPAGoff{% -\global\let\contentsalignmacro = \chappager -\global\let\pchapsepmacro=\chapbreak -\global\let\pagealignmacro=\chappager} - -\def\CHAPPAGon{% -\global\let\contentsalignmacro = \chappager -\global\let\pchapsepmacro=\chappager -\global\let\pagealignmacro=\chappager -\global\def\HEADINGSon{\HEADINGSsingle}} - -\def\CHAPPAGodd{% -\global\let\contentsalignmacro = \chapoddpage -\global\let\pchapsepmacro=\chapoddpage -\global\let\pagealignmacro=\chapoddpage -\global\def\HEADINGSon{\HEADINGSdouble}} - -\CHAPPAGon - -% Chapter opening. -% -% #1 is the text, #2 is the section type (Ynumbered, Ynothing, -% Yappendix, Yomitfromtoc), #3 the chapter number. -% -% To test against our argument. -\def\Ynothingkeyword{Ynothing} -\def\Yomitfromtockeyword{Yomitfromtoc} -\def\Yappendixkeyword{Yappendix} -% -\def\chapmacro#1#2#3{% - \pchapsepmacro - {% - \chapfonts \rm - % - % Have to define \thissection before calling \donoderef, because the - % xref code eventually uses it. On the other hand, it has to be called - % after \pchapsepmacro, or the headline will change too soon. - \gdef\thissection{#1}% - \gdef\thischaptername{#1}% - % - % Only insert the separating space if we have a chapter/appendix - % number, and don't print the unnumbered ``number''. - \def\temptype{#2}% - \ifx\temptype\Ynothingkeyword - \setbox0 = \hbox{}% - \def\toctype{unnchap}% - \gdef\thischapternum{}% - \gdef\thischapter{#1}% - \else\ifx\temptype\Yomitfromtockeyword - \setbox0 = \hbox{}% contents like unnumbered, but no toc entry - \def\toctype{omit}% - \gdef\thischapternum{}% - \gdef\thischapter{}% - \else\ifx\temptype\Yappendixkeyword - \setbox0 = \hbox{\putwordAppendix{} #3\enspace}% - \def\toctype{app}% - \xdef\thischapternum{\appendixletter}% - % We don't substitute the actual chapter name into \thischapter - % because we don't want its macros evaluated now. And we don't - % use \thissection because that changes with each section. - % - \xdef\thischapter{\putwordAppendix{} \appendixletter: - \noexpand\thischaptername}% - \else - \setbox0 = \hbox{#3\enspace}% - \def\toctype{numchap}% - \xdef\thischapternum{\the\chapno}% - \xdef\thischapter{\putwordChapter{} \the\chapno: - \noexpand\thischaptername}% - \fi\fi\fi - % - % Write the toc entry for this chapter. Must come before the - % \donoderef, because we include the current node name in the toc - % entry, and \donoderef resets it to empty. - \writetocentry{\toctype}{#1}{#3}% - % - % For pdftex, we have to write out the node definition (aka, make - % the pdfdest) after any page break, but before the actual text has - % been typeset. If the destination for the pdf outline is after the - % text, then jumping from the outline may wind up with the text not - % being visible, for instance under high magnification. - \donoderef{#2}% - % - % Typeset the actual heading. - \vbox{\hyphenpenalty=10000 \tolerance=5000 \parindent=0pt \raggedright - \hangindent=\wd0 \centerparametersmaybe - \unhbox0 #1\par}% - }% - \nobreak\bigskip % no page break after a chapter title - \nobreak -} - -% @centerchap -- centered and unnumbered. -\let\centerparametersmaybe = \relax -\def\centerparameters{% - \advance\rightskip by 3\rightskip - \leftskip = \rightskip - \parfillskip = 0pt -} - - -% I don't think this chapter style is supported any more, so I'm not -% updating it with the new noderef stuff. We'll see. --karl, 11aug03. -% -\def\setchapterstyle #1 {\csname CHAPF#1\endcsname} -% -\def\unnchfopen #1{% -\chapoddpage {\chapfonts \vbox{\hyphenpenalty=10000\tolerance=5000 - \parindent=0pt\raggedright - \rm #1\hfill}}\bigskip \par\nobreak -} -\def\chfopen #1#2{\chapoddpage {\chapfonts -\vbox to 3in{\vfil \hbox to\hsize{\hfil #2} \hbox to\hsize{\hfil #1} \vfil}}% -\par\penalty 5000 % -} -\def\centerchfopen #1{% -\chapoddpage {\chapfonts \vbox{\hyphenpenalty=10000\tolerance=5000 - \parindent=0pt - \hfill {\rm #1}\hfill}}\bigskip \par\nobreak -} -\def\CHAPFopen{% - \global\let\chapmacro=\chfopen - \global\let\centerchapmacro=\centerchfopen} - - -% Section titles. These macros combine the section number parts and -% call the generic \sectionheading to do the printing. -% -\newskip\secheadingskip -\def\secheadingbreak{\dobreak \secheadingskip{-1000}} - -% Subsection titles. -\newskip\subsecheadingskip -\def\subsecheadingbreak{\dobreak \subsecheadingskip{-500}} - -% Subsubsection titles. -\def\subsubsecheadingskip{\subsecheadingskip} -\def\subsubsecheadingbreak{\subsecheadingbreak} - - -% Print any size, any type, section title. -% -% #1 is the text, #2 is the section level (sec/subsec/subsubsec), #3 is -% the section type for xrefs (Ynumbered, Ynothing, Yappendix), #4 is the -% section number. -% -\def\sectionheading#1#2#3#4{% - {% - % Switch to the right set of fonts. - \csname #2fonts\endcsname \rm - % - % Insert space above the heading. - \csname #2headingbreak\endcsname - % - % Only insert the space after the number if we have a section number. - \def\sectionlevel{#2}% - \def\temptype{#3}% - % - \ifx\temptype\Ynothingkeyword - \setbox0 = \hbox{}% - \def\toctype{unn}% - \gdef\thissection{#1}% - \else\ifx\temptype\Yomitfromtockeyword - % for @headings -- no section number, don't include in toc, - % and don't redefine \thissection. - \setbox0 = \hbox{}% - \def\toctype{omit}% - \let\sectionlevel=\empty - \else\ifx\temptype\Yappendixkeyword - \setbox0 = \hbox{#4\enspace}% - \def\toctype{app}% - \gdef\thissection{#1}% - \else - \setbox0 = \hbox{#4\enspace}% - \def\toctype{num}% - \gdef\thissection{#1}% - \fi\fi\fi - % - % Write the toc entry (before \donoderef). See comments in \chapmacro. - \writetocentry{\toctype\sectionlevel}{#1}{#4}% - % - % Write the node reference (= pdf destination for pdftex). - % Again, see comments in \chapmacro. - \donoderef{#3}% - % - % Interline glue will be inserted when the vbox is completed. - % That glue will be a valid breakpoint for the page, since it'll be - % preceded by a whatsit (usually from the \donoderef, or from the - % \writetocentry if there was no node). We don't want to allow that - % break, since then the whatsits could end up on page n while the - % section is on page n+1, thus toc/etc. are wrong. Debian bug 276000. - \nobreak - % - % Output the actual section heading. - \vbox{\hyphenpenalty=10000 \tolerance=5000 \parindent=0pt \raggedright - \hangindent=\wd0 % zero if no section number - \unhbox0 #1}% - }% - % Add extra space after the heading -- half of whatever came above it. - % Don't allow stretch, though. - \kern .5 \csname #2headingskip\endcsname - % - % Do not let the kern be a potential breakpoint, as it would be if it - % was followed by glue. - \nobreak - % - % We'll almost certainly start a paragraph next, so don't let that - % glue accumulate. (Not a breakpoint because it's preceded by a - % discardable item.) - \vskip-\parskip - % - % This is purely so the last item on the list is a known \penalty > - % 10000. This is so \startdefun can avoid allowing breakpoints after - % section headings. Otherwise, it would insert a valid breakpoint between: - % - % @section sec-whatever - % @deffn def-whatever - \penalty 10001 -} - - -\message{toc,} -% Table of contents. -\newwrite\tocfile - -% Write an entry to the toc file, opening it if necessary. -% Called from @chapter, etc. -% -% Example usage: \writetocentry{sec}{Section Name}{\the\chapno.\the\secno} -% We append the current node name (if any) and page number as additional -% arguments for the \{chap,sec,...}entry macros which will eventually -% read this. The node name is used in the pdf outlines as the -% destination to jump to. -% -% We open the .toc file for writing here instead of at @setfilename (or -% any other fixed time) so that @contents can be anywhere in the document. -% But if #1 is `omit', then we don't do anything. This is used for the -% table of contents chapter openings themselves. -% -\newif\iftocfileopened -\def\omitkeyword{omit}% -% -\def\writetocentry#1#2#3{% - \edef\writetoctype{#1}% - \ifx\writetoctype\omitkeyword \else - \iftocfileopened\else - \immediate\openout\tocfile = \jobname.toc - \global\tocfileopenedtrue - \fi - % - \iflinks - {\atdummies - \edef\temp{% - \write\tocfile{@#1entry{#2}{#3}{\lastnode}{\noexpand\folio}}}% - \temp - }% - \fi - \fi - % - % Tell \shipout to create a pdf destination on each page, if we're - % writing pdf. These are used in the table of contents. We can't - % just write one on every page because the title pages are numbered - % 1 and 2 (the page numbers aren't printed), and so are the first - % two pages of the document. Thus, we'd have two destinations named - % `1', and two named `2'. - \ifpdf \global\pdfmakepagedesttrue \fi -} - - -% These characters do not print properly in the Computer Modern roman -% fonts, so we must take special care. This is more or less redundant -% with the Texinfo input format setup at the end of this file. -% -\def\activecatcodes{% - \catcode`\"=\active - \catcode`\$=\active - \catcode`\<=\active - \catcode`\>=\active - \catcode`\\=\active - \catcode`\^=\active - \catcode`\_=\active - \catcode`\|=\active - \catcode`\~=\active -} - - -% Read the toc file, which is essentially Texinfo input. -\def\readtocfile{% - \setupdatafile - \activecatcodes - \input \jobname.toc -} - -\newskip\contentsrightmargin \contentsrightmargin=1in -\newcount\savepageno -\newcount\lastnegativepageno \lastnegativepageno = -1 - -% Prepare to read what we've written to \tocfile. -% -\def\startcontents#1{% - % If @setchapternewpage on, and @headings double, the contents should - % start on an odd page, unlike chapters. Thus, we maintain - % \contentsalignmacro in parallel with \pagealignmacro. - % From: Torbjorn Granlund - \contentsalignmacro - \immediate\closeout\tocfile - % - % Don't need to put `Contents' or `Short Contents' in the headline. - % It is abundantly clear what they are. - \def\thischapter{}% - \chapmacro{#1}{Yomitfromtoc}{}% - % - \savepageno = \pageno - \begingroup % Set up to handle contents files properly. - \raggedbottom % Worry more about breakpoints than the bottom. - \advance\hsize by -\contentsrightmargin % Don't use the full line length. - % - % Roman numerals for page numbers. - \ifnum \pageno>0 \global\pageno = \lastnegativepageno \fi -} - - -% Normal (long) toc. -\def\contents{% - \startcontents{\putwordTOC}% - \openin 1 \jobname.toc - \ifeof 1 \else - \readtocfile - \fi - \vfill \eject - \contentsalignmacro % in case @setchapternewpage odd is in effect - \ifeof 1 \else - \pdfmakeoutlines - \fi - \closein 1 - \endgroup - \lastnegativepageno = \pageno - \global\pageno = \savepageno -} - -% And just the chapters. -\def\summarycontents{% - \startcontents{\putwordShortTOC}% - % - \let\numchapentry = \shortchapentry - \let\appentry = \shortchapentry - \let\unnchapentry = \shortunnchapentry - % We want a true roman here for the page numbers. - \secfonts - \let\rm=\shortcontrm \let\bf=\shortcontbf - \let\sl=\shortcontsl \let\tt=\shortconttt - \rm - \hyphenpenalty = 10000 - \advance\baselineskip by 1pt % Open it up a little. - \def\numsecentry##1##2##3##4{} - \let\appsecentry = \numsecentry - \let\unnsecentry = \numsecentry - \let\numsubsecentry = \numsecentry - \let\appsubsecentry = \numsecentry - \let\unnsubsecentry = \numsecentry - \let\numsubsubsecentry = \numsecentry - \let\appsubsubsecentry = \numsecentry - \let\unnsubsubsecentry = \numsecentry - \openin 1 \jobname.toc - \ifeof 1 \else - \readtocfile - \fi - \closein 1 - \vfill \eject - \contentsalignmacro % in case @setchapternewpage odd is in effect - \endgroup - \lastnegativepageno = \pageno - \global\pageno = \savepageno -} -\let\shortcontents = \summarycontents - -% Typeset the label for a chapter or appendix for the short contents. -% The arg is, e.g., `A' for an appendix, or `3' for a chapter. -% -\def\shortchaplabel#1{% - % This space should be enough, since a single number is .5em, and the - % widest letter (M) is 1em, at least in the Computer Modern fonts. - % But use \hss just in case. - % (This space doesn't include the extra space that gets added after - % the label; that gets put in by \shortchapentry above.) - % - % We'd like to right-justify chapter numbers, but that looks strange - % with appendix letters. And right-justifying numbers and - % left-justifying letters looks strange when there is less than 10 - % chapters. Have to read the whole toc once to know how many chapters - % there are before deciding ... - \hbox to 1em{#1\hss}% -} - -% These macros generate individual entries in the table of contents. -% The first argument is the chapter or section name. -% The last argument is the page number. -% The arguments in between are the chapter number, section number, ... - -% Chapters, in the main contents. -\def\numchapentry#1#2#3#4{\dochapentry{#2\labelspace#1}{#4}} -% -% Chapters, in the short toc. -% See comments in \dochapentry re vbox and related settings. -\def\shortchapentry#1#2#3#4{% - \tocentry{\shortchaplabel{#2}\labelspace #1}{\doshortpageno\bgroup#4\egroup}% -} - -% Appendices, in the main contents. -% Need the word Appendix, and a fixed-size box. -% -\def\appendixbox#1{% - % We use M since it's probably the widest letter. - \setbox0 = \hbox{\putwordAppendix{} M}% - \hbox to \wd0{\putwordAppendix{} #1\hss}} -% -\def\appentry#1#2#3#4{\dochapentry{\appendixbox{#2}\labelspace#1}{#4}} - -% Unnumbered chapters. -\def\unnchapentry#1#2#3#4{\dochapentry{#1}{#4}} -\def\shortunnchapentry#1#2#3#4{\tocentry{#1}{\doshortpageno\bgroup#4\egroup}} - -% Sections. -\def\numsecentry#1#2#3#4{\dosecentry{#2\labelspace#1}{#4}} -\let\appsecentry=\numsecentry -\def\unnsecentry#1#2#3#4{\dosecentry{#1}{#4}} - -% Subsections. -\def\numsubsecentry#1#2#3#4{\dosubsecentry{#2\labelspace#1}{#4}} -\let\appsubsecentry=\numsubsecentry -\def\unnsubsecentry#1#2#3#4{\dosubsecentry{#1}{#4}} - -% And subsubsections. -\def\numsubsubsecentry#1#2#3#4{\dosubsubsecentry{#2\labelspace#1}{#4}} -\let\appsubsubsecentry=\numsubsubsecentry -\def\unnsubsubsecentry#1#2#3#4{\dosubsubsecentry{#1}{#4}} - -% This parameter controls the indentation of the various levels. -% Same as \defaultparindent. -\newdimen\tocindent \tocindent = 15pt - -% Now for the actual typesetting. In all these, #1 is the text and #2 is the -% page number. -% -% If the toc has to be broken over pages, we want it to be at chapters -% if at all possible; hence the \penalty. -\def\dochapentry#1#2{% - \penalty-300 \vskip1\baselineskip plus.33\baselineskip minus.25\baselineskip - \begingroup - \chapentryfonts - \tocentry{#1}{\dopageno\bgroup#2\egroup}% - \endgroup - \nobreak\vskip .25\baselineskip plus.1\baselineskip -} - -\def\dosecentry#1#2{\begingroup - \secentryfonts \leftskip=\tocindent - \tocentry{#1}{\dopageno\bgroup#2\egroup}% -\endgroup} - -\def\dosubsecentry#1#2{\begingroup - \subsecentryfonts \leftskip=2\tocindent - \tocentry{#1}{\dopageno\bgroup#2\egroup}% -\endgroup} - -\def\dosubsubsecentry#1#2{\begingroup - \subsubsecentryfonts \leftskip=3\tocindent - \tocentry{#1}{\dopageno\bgroup#2\egroup}% -\endgroup} - -% We use the same \entry macro as for the index entries. -\let\tocentry = \entry - -% Space between chapter (or whatever) number and the title. -\def\labelspace{\hskip1em \relax} - -\def\dopageno#1{{\rm #1}} -\def\doshortpageno#1{{\rm #1}} - -\def\chapentryfonts{\secfonts \rm} -\def\secentryfonts{\textfonts} -\def\subsecentryfonts{\textfonts} -\def\subsubsecentryfonts{\textfonts} - - -\message{environments,} -% @foo ... @end foo. - -% @point{}, @result{}, @expansion{}, @print{}, @equiv{}. -% -% Since these characters are used in examples, it should be an even number of -% \tt widths. Each \tt character is 1en, so two makes it 1em. -% -\def\point{$\star$} -\def\result{\leavevmode\raise.15ex\hbox to 1em{\hfil$\Rightarrow$\hfil}} -\def\expansion{\leavevmode\raise.1ex\hbox to 1em{\hfil$\mapsto$\hfil}} -\def\print{\leavevmode\lower.1ex\hbox to 1em{\hfil$\dashv$\hfil}} -\def\equiv{\leavevmode\lower.1ex\hbox to 1em{\hfil$\ptexequiv$\hfil}} - -% The @error{} command. -% Adapted from the TeXbook's \boxit. -% -\newbox\errorbox -% -{\tentt \global\dimen0 = 3em}% Width of the box. -\dimen2 = .55pt % Thickness of rules -% The text. (`r' is open on the right, `e' somewhat less so on the left.) -\setbox0 = \hbox{\kern-.75pt \reducedsf error\kern-1.5pt} -% -\setbox\errorbox=\hbox to \dimen0{\hfil - \hsize = \dimen0 \advance\hsize by -5.8pt % Space to left+right. - \advance\hsize by -2\dimen2 % Rules. - \vbox{% - \hrule height\dimen2 - \hbox{\vrule width\dimen2 \kern3pt % Space to left of text. - \vtop{\kern2.4pt \box0 \kern2.4pt}% Space above/below. - \kern3pt\vrule width\dimen2}% Space to right. - \hrule height\dimen2} - \hfil} -% -\def\error{\leavevmode\lower.7ex\copy\errorbox} - -% @tex ... @end tex escapes into raw Tex temporarily. -% One exception: @ is still an escape character, so that @end tex works. -% But \@ or @@ will get a plain tex @ character. - -\envdef\tex{% - \catcode `\\=0 \catcode `\{=1 \catcode `\}=2 - \catcode `\$=3 \catcode `\&=4 \catcode `\#=6 - \catcode `\^=7 \catcode `\_=8 \catcode `\~=\active \let~=\tie - \catcode `\%=14 - \catcode `\+=\other - \catcode `\"=\other - \catcode `\|=\other - \catcode `\<=\other - \catcode `\>=\other - \escapechar=`\\ - % - \let\b=\ptexb - \let\bullet=\ptexbullet - \let\c=\ptexc - \let\,=\ptexcomma - \let\.=\ptexdot - \let\dots=\ptexdots - \let\equiv=\ptexequiv - \let\!=\ptexexclam - \let\i=\ptexi - \let\indent=\ptexindent - \let\noindent=\ptexnoindent - \let\{=\ptexlbrace - \let\+=\tabalign - \let\}=\ptexrbrace - \let\/=\ptexslash - \let\*=\ptexstar - \let\t=\ptext - \let\frenchspacing=\plainfrenchspacing - % - \def\endldots{\mathinner{\ldots\ldots\ldots\ldots}}% - \def\enddots{\relax\ifmmode\endldots\else$\mathsurround=0pt \endldots\,$\fi}% - \def\@{@}% -} -% There is no need to define \Etex. - -% Define @lisp ... @end lisp. -% @lisp environment forms a group so it can rebind things, -% including the definition of @end lisp (which normally is erroneous). - -% Amount to narrow the margins by for @lisp. -\newskip\lispnarrowing \lispnarrowing=0.4in - -% This is the definition that ^^M gets inside @lisp, @example, and other -% such environments. \null is better than a space, since it doesn't -% have any width. -\def\lisppar{\null\endgraf} - -% This space is always present above and below environments. -\newskip\envskipamount \envskipamount = 0pt - -% Make spacing and below environment symmetrical. We use \parskip here -% to help in doing that, since in @example-like environments \parskip -% is reset to zero; thus the \afterenvbreak inserts no space -- but the -% start of the next paragraph will insert \parskip. -% -\def\aboveenvbreak{{% - % =10000 instead of <10000 because of a special case in \itemzzz and - % \sectionheading, q.v. - \ifnum \lastpenalty=10000 \else - \advance\envskipamount by \parskip - \endgraf - \ifdim\lastskip<\envskipamount - \removelastskip - % it's not a good place to break if the last penalty was \nobreak - % or better ... - \ifnum\lastpenalty<10000 \penalty-50 \fi - \vskip\envskipamount - \fi - \fi -}} - -\let\afterenvbreak = \aboveenvbreak - -% \nonarrowing is a flag. If "set", @lisp etc don't narrow margins; it will -% also clear it, so that its embedded environments do the narrowing again. -\let\nonarrowing=\relax - -% @cartouche ... @end cartouche: draw rectangle w/rounded corners around -% environment contents. -\font\circle=lcircle10 -\newdimen\circthick -\newdimen\cartouter\newdimen\cartinner -\newskip\normbskip\newskip\normpskip\newskip\normlskip -\circthick=\fontdimen8\circle -% -\def\ctl{{\circle\char'013\hskip -6pt}}% 6pt from pl file: 1/2charwidth -\def\ctr{{\hskip 6pt\circle\char'010}} -\def\cbl{{\circle\char'012\hskip -6pt}} -\def\cbr{{\hskip 6pt\circle\char'011}} -\def\carttop{\hbox to \cartouter{\hskip\lskip - \ctl\leaders\hrule height\circthick\hfil\ctr - \hskip\rskip}} -\def\cartbot{\hbox to \cartouter{\hskip\lskip - \cbl\leaders\hrule height\circthick\hfil\cbr - \hskip\rskip}} -% -\newskip\lskip\newskip\rskip - -\envdef\cartouche{% - \ifhmode\par\fi % can't be in the midst of a paragraph. - \startsavinginserts - \lskip=\leftskip \rskip=\rightskip - \leftskip=0pt\rightskip=0pt % we want these *outside*. - \cartinner=\hsize \advance\cartinner by-\lskip - \advance\cartinner by-\rskip - \cartouter=\hsize - \advance\cartouter by 18.4pt % allow for 3pt kerns on either - % side, and for 6pt waste from - % each corner char, and rule thickness - \normbskip=\baselineskip \normpskip=\parskip \normlskip=\lineskip - % Flag to tell @lisp, etc., not to narrow margin. - \let\nonarrowing = t% - \vbox\bgroup - \baselineskip=0pt\parskip=0pt\lineskip=0pt - \carttop - \hbox\bgroup - \hskip\lskip - \vrule\kern3pt - \vbox\bgroup - \kern3pt - \hsize=\cartinner - \baselineskip=\normbskip - \lineskip=\normlskip - \parskip=\normpskip - \vskip -\parskip - \comment % For explanation, see the end of \def\group. -} -\def\Ecartouche{% - \ifhmode\par\fi - \kern3pt - \egroup - \kern3pt\vrule - \hskip\rskip - \egroup - \cartbot - \egroup - \checkinserts -} - - -% This macro is called at the beginning of all the @example variants, -% inside a group. -\def\nonfillstart{% - \aboveenvbreak - \hfuzz = 12pt % Don't be fussy - \sepspaces % Make spaces be word-separators rather than space tokens. - \let\par = \lisppar % don't ignore blank lines - \obeylines % each line of input is a line of output - \parskip = 0pt - \parindent = 0pt - \emergencystretch = 0pt % don't try to avoid overfull boxes - \ifx\nonarrowing\relax - \advance \leftskip by \lispnarrowing - \exdentamount=\lispnarrowing - \else - \let\nonarrowing = \relax - \fi - \let\exdent=\nofillexdent -} - -% If you want all examples etc. small: @set dispenvsize small. -% If you want even small examples the full size: @set dispenvsize nosmall. -% This affects the following displayed environments: -% @example, @display, @format, @lisp -% -\def\smallword{small} -\def\nosmallword{nosmall} -\let\SETdispenvsize\relax -\def\setnormaldispenv{% - \ifx\SETdispenvsize\smallword - \smallexamplefonts \rm - \fi -} -\def\setsmalldispenv{% - \ifx\SETdispenvsize\nosmallword - \else - \smallexamplefonts \rm - \fi -} - -% We often define two environments, @foo and @smallfoo. -% Let's do it by one command: -\def\makedispenv #1#2{ - \expandafter\envdef\csname#1\endcsname {\setnormaldispenv #2} - \expandafter\envdef\csname small#1\endcsname {\setsmalldispenv #2} - \expandafter\let\csname E#1\endcsname \afterenvbreak - \expandafter\let\csname Esmall#1\endcsname \afterenvbreak -} - -% Define two synonyms: -\def\maketwodispenvs #1#2#3{ - \makedispenv{#1}{#3} - \makedispenv{#2}{#3} -} - -% @lisp: indented, narrowed, typewriter font; @example: same as @lisp. -% -% @smallexample and @smalllisp: use smaller fonts. -% Originally contributed by Pavel@xerox. -% -\maketwodispenvs {lisp}{example}{% - \nonfillstart - \tt\quoteexpand - \let\kbdfont = \kbdexamplefont % Allow @kbd to do something special. - \gobble % eat return -} -% @display/@smalldisplay: same as @lisp except keep current font. -% -\makedispenv {display}{% - \nonfillstart - \gobble -} - -% @format/@smallformat: same as @display except don't narrow margins. -% -\makedispenv{format}{% - \let\nonarrowing = t% - \nonfillstart - \gobble -} - -% @flushleft: same as @format, but doesn't obey \SETdispenvsize. -\envdef\flushleft{% - \let\nonarrowing = t% - \nonfillstart - \gobble -} -\let\Eflushleft = \afterenvbreak - -% @flushright. -% -\envdef\flushright{% - \let\nonarrowing = t% - \nonfillstart - \advance\leftskip by 0pt plus 1fill - \gobble -} -\let\Eflushright = \afterenvbreak - - -% @quotation does normal linebreaking (hence we can't use \nonfillstart) -% and narrows the margins. We keep \parskip nonzero in general, since -% we're doing normal filling. So, when using \aboveenvbreak and -% \afterenvbreak, temporarily make \parskip 0. -% -\envdef\quotation{% - {\parskip=0pt \aboveenvbreak}% because \aboveenvbreak inserts \parskip - \parindent=0pt - % - % @cartouche defines \nonarrowing to inhibit narrowing at next level down. - \ifx\nonarrowing\relax - \advance\leftskip by \lispnarrowing - \advance\rightskip by \lispnarrowing - \exdentamount = \lispnarrowing - \else - \let\nonarrowing = \relax - \fi - \parsearg\quotationlabel -} - -% We have retained a nonzero parskip for the environment, since we're -% doing normal filling. -% -\def\Equotation{% - \par - \ifx\quotationauthor\undefined\else - % indent a bit. - \leftline{\kern 2\leftskip \sl ---\quotationauthor}% - \fi - {\parskip=0pt \afterenvbreak}% -} - -% If we're given an argument, typeset it in bold with a colon after. -\def\quotationlabel#1{% - \def\temp{#1}% - \ifx\temp\empty \else - {\bf #1: }% - \fi -} - - -% LaTeX-like @verbatim...@end verbatim and @verb{...} -% If we want to allow any as delimiter, -% we need the curly braces so that makeinfo sees the @verb command, eg: -% `@verbx...x' would look like the '@verbx' command. --janneke@gnu.org -% -% [Knuth]: Donald Ervin Knuth, 1996. The TeXbook. -% -% [Knuth] p.344; only we need to do the other characters Texinfo sets -% active too. Otherwise, they get lost as the first character on a -% verbatim line. -\def\dospecials{% - \do\ \do\\\do\{\do\}\do\$\do\&% - \do\#\do\^\do\^^K\do\_\do\^^A\do\%\do\~% - \do\<\do\>\do\|\do\@\do+\do\"% -} -% -% [Knuth] p. 380 -\def\uncatcodespecials{% - \def\do##1{\catcode`##1=\other}\dospecials} -% -% [Knuth] pp. 380,381,391 -% Disable Spanish ligatures ?` and !` of \tt font -\begingroup - \catcode`\`=\active\gdef`{\relax\lq} -\endgroup -% -% Setup for the @verb command. -% -% Eight spaces for a tab -\begingroup - \catcode`\^^I=\active - \gdef\tabeightspaces{\catcode`\^^I=\active\def^^I{\ \ \ \ \ \ \ \ }} -\endgroup -% -\def\setupverb{% - \tt % easiest (and conventionally used) font for verbatim - \def\par{\leavevmode\endgraf}% - \catcode`\`=\active - \tabeightspaces - % Respect line breaks, - % print special symbols as themselves, and - % make each space count - % must do in this order: - \obeylines \uncatcodespecials \sepspaces -} - -% Setup for the @verbatim environment -% -% Real tab expansion -\newdimen\tabw \setbox0=\hbox{\tt\space} \tabw=8\wd0 % tab amount -% -\def\starttabbox{\setbox0=\hbox\bgroup} - -% Allow an option to not replace quotes with a regular directed right -% quote/apostrophe (char 0x27), but instead use the undirected quote -% from cmtt (char 0x0d). The undirected quote is ugly, so don't make it -% the default, but it works for pasting with more pdf viewers (at least -% evince), the lilypond developers report. xpdf does work with the -% regular 0x27. -% -\def\codequoteright{% - \expandafter\ifx\csname SETcodequoteundirected\endcsname\relax - '% - \else - \char'15 - \fi -} -% -% and a similar option for the left quote char vs. a grave accent. -% Modern fonts display ASCII 0x60 as a grave accent, so some people like -% the code environments to do likewise. -% -\def\codequoteleft{% - \expandafter\ifx\csname SETcodequotebacktick\endcsname\relax - `% - \else - \char'22 - \fi -} -% -\begingroup - \catcode`\^^I=\active - \gdef\tabexpand{% - \catcode`\^^I=\active - \def^^I{\leavevmode\egroup - \dimen0=\wd0 % the width so far, or since the previous tab - \divide\dimen0 by\tabw - \multiply\dimen0 by\tabw % compute previous multiple of \tabw - \advance\dimen0 by\tabw % advance to next multiple of \tabw - \wd0=\dimen0 \box0 \starttabbox - }% - } - \catcode`\'=\active - \gdef\rquoteexpand{\catcode\rquoteChar=\active \def'{\codequoteright}}% - % - \catcode`\`=\active - \gdef\lquoteexpand{\catcode\lquoteChar=\active \def`{\codequoteleft}}% - % - \gdef\quoteexpand{\rquoteexpand \lquoteexpand}% -\endgroup - -% start the verbatim environment. -\def\setupverbatim{% - \let\nonarrowing = t% - \nonfillstart - % Easiest (and conventionally used) font for verbatim - \tt - \def\par{\leavevmode\egroup\box0\endgraf}% - \catcode`\`=\active - \tabexpand - \quoteexpand - % Respect line breaks, - % print special symbols as themselves, and - % make each space count - % must do in this order: - \obeylines \uncatcodespecials \sepspaces - \everypar{\starttabbox}% -} - -% Do the @verb magic: verbatim text is quoted by unique -% delimiter characters. Before first delimiter expect a -% right brace, after last delimiter expect closing brace: -% -% \def\doverb'{'#1'}'{#1} -% -% [Knuth] p. 382; only eat outer {} -\begingroup - \catcode`[=1\catcode`]=2\catcode`\{=\other\catcode`\}=\other - \gdef\doverb{#1[\def\next##1#1}[##1\endgroup]\next] -\endgroup -% -\def\verb{\begingroup\setupverb\doverb} -% -% -% Do the @verbatim magic: define the macro \doverbatim so that -% the (first) argument ends when '@end verbatim' is reached, ie: -% -% \def\doverbatim#1@end verbatim{#1} -% -% For Texinfo it's a lot easier than for LaTeX, -% because texinfo's \verbatim doesn't stop at '\end{verbatim}': -% we need not redefine '\', '{' and '}'. -% -% Inspired by LaTeX's verbatim command set [latex.ltx] -% -\begingroup - \catcode`\ =\active - \obeylines % - % ignore everything up to the first ^^M, that's the newline at the end - % of the @verbatim input line itself. Otherwise we get an extra blank - % line in the output. - \xdef\doverbatim#1^^M#2@end verbatim{#2\noexpand\end\gobble verbatim}% - % We really want {...\end verbatim} in the body of the macro, but - % without the active space; thus we have to use \xdef and \gobble. -\endgroup -% -\envdef\verbatim{% - \setupverbatim\doverbatim -} -\let\Everbatim = \afterenvbreak - - -% @verbatiminclude FILE - insert text of file in verbatim environment. -% -\def\verbatiminclude{\parseargusing\filenamecatcodes\doverbatiminclude} -% -\def\doverbatiminclude#1{% - {% - \makevalueexpandable - \setupverbatim - \input #1 - \afterenvbreak - }% -} - -% @copying ... @end copying. -% Save the text away for @insertcopying later. -% -% We save the uninterpreted tokens, rather than creating a box. -% Saving the text in a box would be much easier, but then all the -% typesetting commands (@smallbook, font changes, etc.) have to be done -% beforehand -- and a) we want @copying to be done first in the source -% file; b) letting users define the frontmatter in as flexible order as -% possible is very desirable. -% -\def\copying{\checkenv{}\begingroup\scanargctxt\docopying} -\def\docopying#1@end copying{\endgroup\def\copyingtext{#1}} -% -\def\insertcopying{% - \begingroup - \parindent = 0pt % paragraph indentation looks wrong on title page - \scanexp\copyingtext - \endgroup -} - -\message{defuns,} -% @defun etc. - -\newskip\defbodyindent \defbodyindent=.4in -\newskip\defargsindent \defargsindent=50pt -\newskip\deflastargmargin \deflastargmargin=18pt - -% Start the processing of @deffn: -\def\startdefun{% - \ifnum\lastpenalty<10000 - \medbreak - \else - % If there are two @def commands in a row, we'll have a \nobreak, - % which is there to keep the function description together with its - % header. But if there's nothing but headers, we need to allow a - % break somewhere. Check specifically for penalty 10002, inserted - % by \defargscommonending, instead of 10000, since the sectioning - % commands also insert a nobreak penalty, and we don't want to allow - % a break between a section heading and a defun. - % - \ifnum\lastpenalty=10002 \penalty2000 \fi - % - % Similarly, after a section heading, do not allow a break. - % But do insert the glue. - \medskip % preceded by discardable penalty, so not a breakpoint - \fi - % - \parindent=0in - \advance\leftskip by \defbodyindent - \exdentamount=\defbodyindent -} - -\def\dodefunx#1{% - % First, check whether we are in the right environment: - \checkenv#1% - % - % As above, allow line break if we have multiple x headers in a row. - % It's not a great place, though. - \ifnum\lastpenalty=10002 \penalty3000 \fi - % - % And now, it's time to reuse the body of the original defun: - \expandafter\gobbledefun#1% -} -\def\gobbledefun#1\startdefun{} - -% \printdefunline \deffnheader{text} -% -\def\printdefunline#1#2{% - \begingroup - % call \deffnheader: - #1#2 \endheader - % common ending: - \interlinepenalty = 10000 - \advance\rightskip by 0pt plus 1fil - \endgraf - \nobreak\vskip -\parskip - \penalty 10002 % signal to \startdefun and \dodefunx - % Some of the @defun-type tags do not enable magic parentheses, - % rendering the following check redundant. But we don't optimize. - \checkparencounts - \endgroup -} - -\def\Edefun{\endgraf\medbreak} - -% \makedefun{deffn} creates \deffn, \deffnx and \Edeffn; -% the only thing remainnig is to define \deffnheader. -% -\def\makedefun#1{% - \expandafter\let\csname E#1\endcsname = \Edefun - \edef\temp{\noexpand\domakedefun - \makecsname{#1}\makecsname{#1x}\makecsname{#1header}}% - \temp -} - -% \domakedefun \deffn \deffnx \deffnheader -% -% Define \deffn and \deffnx, without parameters. -% \deffnheader has to be defined explicitly. -% -\def\domakedefun#1#2#3{% - \envdef#1{% - \startdefun - \parseargusing\activeparens{\printdefunline#3}% - }% - \def#2{\dodefunx#1}% - \def#3% -} - -%%% Untyped functions: - -% @deffn category name args -\makedefun{deffn}{\deffngeneral{}} - -% @deffn category class name args -\makedefun{defop}#1 {\defopon{#1\ \putwordon}} - -% \defopon {category on}class name args -\def\defopon#1#2 {\deffngeneral{\putwordon\ \code{#2}}{#1\ \code{#2}} } - -% \deffngeneral {subind}category name args -% -\def\deffngeneral#1#2 #3 #4\endheader{% - % Remember that \dosubind{fn}{foo}{} is equivalent to \doind{fn}{foo}. - \dosubind{fn}{\code{#3}}{#1}% - \defname{#2}{}{#3}\magicamp\defunargs{#4\unskip}% -} - -%%% Typed functions: - -% @deftypefn category type name args -\makedefun{deftypefn}{\deftypefngeneral{}} - -% @deftypeop category class type name args -\makedefun{deftypeop}#1 {\deftypeopon{#1\ \putwordon}} - -% \deftypeopon {category on}class type name args -\def\deftypeopon#1#2 {\deftypefngeneral{\putwordon\ \code{#2}}{#1\ \code{#2}} } - -% \deftypefngeneral {subind}category type name args -% -\def\deftypefngeneral#1#2 #3 #4 #5\endheader{% - \dosubind{fn}{\code{#4}}{#1}% - \defname{#2}{#3}{#4}\defunargs{#5\unskip}% -} - -%%% Typed variables: - -% @deftypevr category type var args -\makedefun{deftypevr}{\deftypecvgeneral{}} - -% @deftypecv category class type var args -\makedefun{deftypecv}#1 {\deftypecvof{#1\ \putwordof}} - -% \deftypecvof {category of}class type var args -\def\deftypecvof#1#2 {\deftypecvgeneral{\putwordof\ \code{#2}}{#1\ \code{#2}} } - -% \deftypecvgeneral {subind}category type var args -% -\def\deftypecvgeneral#1#2 #3 #4 #5\endheader{% - \dosubind{vr}{\code{#4}}{#1}% - \defname{#2}{#3}{#4}\defunargs{#5\unskip}% -} - -%%% Untyped variables: - -% @defvr category var args -\makedefun{defvr}#1 {\deftypevrheader{#1} {} } - -% @defcv category class var args -\makedefun{defcv}#1 {\defcvof{#1\ \putwordof}} - -% \defcvof {category of}class var args -\def\defcvof#1#2 {\deftypecvof{#1}#2 {} } - -%%% Type: -% @deftp category name args -\makedefun{deftp}#1 #2 #3\endheader{% - \doind{tp}{\code{#2}}% - \defname{#1}{}{#2}\defunargs{#3\unskip}% -} - -% Remaining @defun-like shortcuts: -\makedefun{defun}{\deffnheader{\putwordDeffunc} } -\makedefun{defmac}{\deffnheader{\putwordDefmac} } -\makedefun{defspec}{\deffnheader{\putwordDefspec} } -\makedefun{deftypefun}{\deftypefnheader{\putwordDeffunc} } -\makedefun{defvar}{\defvrheader{\putwordDefvar} } -\makedefun{defopt}{\defvrheader{\putwordDefopt} } -\makedefun{deftypevar}{\deftypevrheader{\putwordDefvar} } -\makedefun{defmethod}{\defopon\putwordMethodon} -\makedefun{deftypemethod}{\deftypeopon\putwordMethodon} -\makedefun{defivar}{\defcvof\putwordInstanceVariableof} -\makedefun{deftypeivar}{\deftypecvof\putwordInstanceVariableof} - -% \defname, which formats the name of the @def (not the args). -% #1 is the category, such as "Function". -% #2 is the return type, if any. -% #3 is the function name. -% -% We are followed by (but not passed) the arguments, if any. -% -\def\defname#1#2#3{% - % Get the values of \leftskip and \rightskip as they were outside the @def... - \advance\leftskip by -\defbodyindent - % - % How we'll format the type name. Putting it in brackets helps - % distinguish it from the body text that may end up on the next line - % just below it. - \def\temp{#1}% - \setbox0=\hbox{\kern\deflastargmargin \ifx\temp\empty\else [\rm\temp]\fi} - % - % Figure out line sizes for the paragraph shape. - % The first line needs space for \box0; but if \rightskip is nonzero, - % we need only space for the part of \box0 which exceeds it: - \dimen0=\hsize \advance\dimen0 by -\wd0 \advance\dimen0 by \rightskip - % The continuations: - \dimen2=\hsize \advance\dimen2 by -\defargsindent - % (plain.tex says that \dimen1 should be used only as global.) - \parshape 2 0in \dimen0 \defargsindent \dimen2 - % - % Put the type name to the right margin. - \noindent - \hbox to 0pt{% - \hfil\box0 \kern-\hsize - % \hsize has to be shortened this way: - \kern\leftskip - % Intentionally do not respect \rightskip, since we need the space. - }% - % - % Allow all lines to be underfull without complaint: - \tolerance=10000 \hbadness=10000 - \exdentamount=\defbodyindent - {% - % defun fonts. We use typewriter by default (used to be bold) because: - % . we're printing identifiers, they should be in tt in principle. - % . in languages with many accents, such as Czech or French, it's - % common to leave accents off identifiers. The result looks ok in - % tt, but exceedingly strange in rm. - % . we don't want -- and --- to be treated as ligatures. - % . this still does not fix the ?` and !` ligatures, but so far no - % one has made identifiers using them :). - \df \tt - \def\temp{#2}% return value type - \ifx\temp\empty\else \tclose{\temp} \fi - #3% output function name - }% - {\rm\enskip}% hskip 0.5 em of \tenrm - % - \boldbrax - % arguments will be output next, if any. -} - -% Print arguments in slanted roman (not ttsl), inconsistently with using -% tt for the name. This is because literal text is sometimes needed in -% the argument list (groff manual), and ttsl and tt are not very -% distinguishable. Prevent hyphenation at `-' chars. -% -\def\defunargs#1{% - % use sl by default (not ttsl), - % tt for the names. - \df \sl \hyphenchar\font=0 - % - % On the other hand, if an argument has two dashes (for instance), we - % want a way to get ttsl. Let's try @var for that. - \let\var=\ttslanted - #1% - \sl\hyphenchar\font=45 -} - -% We want ()&[] to print specially on the defun line. -% -\def\activeparens{% - \catcode`\(=\active \catcode`\)=\active - \catcode`\[=\active \catcode`\]=\active - \catcode`\&=\active -} - -% Make control sequences which act like normal parenthesis chars. -\let\lparen = ( \let\rparen = ) - -% Be sure that we always have a definition for `(', etc. For example, -% if the fn name has parens in it, \boldbrax will not be in effect yet, -% so TeX would otherwise complain about undefined control sequence. -{ - \activeparens - \global\let(=\lparen \global\let)=\rparen - \global\let[=\lbrack \global\let]=\rbrack - \global\let& = \& - - \gdef\boldbrax{\let(=\opnr\let)=\clnr\let[=\lbrb\let]=\rbrb} - \gdef\magicamp{\let&=\amprm} -} - -\newcount\parencount - -% If we encounter &foo, then turn on ()-hacking afterwards -\newif\ifampseen -\def\amprm#1 {\ampseentrue{\bf\ }} - -\def\parenfont{% - \ifampseen - % At the first level, print parens in roman, - % otherwise use the default font. - \ifnum \parencount=1 \rm \fi - \else - % The \sf parens (in \boldbrax) actually are a little bolder than - % the contained text. This is especially needed for [ and ] . - \sf - \fi -} -\def\infirstlevel#1{% - \ifampseen - \ifnum\parencount=1 - #1% - \fi - \fi -} -\def\bfafterword#1 {#1 \bf} - -\def\opnr{% - \global\advance\parencount by 1 - {\parenfont(}% - \infirstlevel \bfafterword -} -\def\clnr{% - {\parenfont)}% - \infirstlevel \sl - \global\advance\parencount by -1 -} - -\newcount\brackcount -\def\lbrb{% - \global\advance\brackcount by 1 - {\bf[}% -} -\def\rbrb{% - {\bf]}% - \global\advance\brackcount by -1 -} - -\def\checkparencounts{% - \ifnum\parencount=0 \else \badparencount \fi - \ifnum\brackcount=0 \else \badbrackcount \fi -} -\def\badparencount{% - \errmessage{Unbalanced parentheses in @def}% - \global\parencount=0 -} -\def\badbrackcount{% - \errmessage{Unbalanced square braces in @def}% - \global\brackcount=0 -} - - -\message{macros,} -% @macro. - -% To do this right we need a feature of e-TeX, \scantokens, -% which we arrange to emulate with a temporary file in ordinary TeX. -\ifx\eTeXversion\undefined - \newwrite\macscribble - \def\scantokens#1{% - \toks0={#1}% - \immediate\openout\macscribble=\jobname.tmp - \immediate\write\macscribble{\the\toks0}% - \immediate\closeout\macscribble - \input \jobname.tmp - } -\fi - -\def\scanmacro#1{% - \begingroup - \newlinechar`\^^M - \let\xeatspaces\eatspaces - % Undo catcode changes of \startcontents and \doprintindex - % When called from @insertcopying or (short)caption, we need active - % backslash to get it printed correctly. Previously, we had - % \catcode`\\=\other instead. We'll see whether a problem appears - % with macro expansion. --kasal, 19aug04 - \catcode`\@=0 \catcode`\\=\active \escapechar=`\@ - % ... and \example - \spaceisspace - % - % Append \endinput to make sure that TeX does not see the ending newline. - % I've verified that it is necessary both for e-TeX and for ordinary TeX - % --kasal, 29nov03 - \scantokens{#1\endinput}% - \endgroup -} - -\def\scanexp#1{% - \edef\temp{\noexpand\scanmacro{#1}}% - \temp -} - -\newcount\paramno % Count of parameters -\newtoks\macname % Macro name -\newif\ifrecursive % Is it recursive? - -% List of all defined macros in the form -% \definedummyword\macro1\definedummyword\macro2... -% Currently is also contains all @aliases; the list can be split -% if there is a need. -\def\macrolist{} - -% Add the macro to \macrolist -\def\addtomacrolist#1{\expandafter \addtomacrolistxxx \csname#1\endcsname} -\def\addtomacrolistxxx#1{% - \toks0 = \expandafter{\macrolist\definedummyword#1}% - \xdef\macrolist{\the\toks0}% -} - -% Utility routines. -% This does \let #1 = #2, with \csnames; that is, -% \let \csname#1\endcsname = \csname#2\endcsname -% (except of course we have to play expansion games). -% -\def\cslet#1#2{% - \expandafter\let - \csname#1\expandafter\endcsname - \csname#2\endcsname -} - -% Trim leading and trailing spaces off a string. -% Concepts from aro-bend problem 15 (see CTAN). -{\catcode`\@=11 -\gdef\eatspaces #1{\expandafter\trim@\expandafter{#1 }} -\gdef\trim@ #1{\trim@@ @#1 @ #1 @ @@} -\gdef\trim@@ #1@ #2@ #3@@{\trim@@@\empty #2 @} -\def\unbrace#1{#1} -\unbrace{\gdef\trim@@@ #1 } #2@{#1} -} - -% Trim a single trailing ^^M off a string. -{\catcode`\^^M=\other \catcode`\Q=3% -\gdef\eatcr #1{\eatcra #1Q^^MQ}% -\gdef\eatcra#1^^MQ{\eatcrb#1Q}% -\gdef\eatcrb#1Q#2Q{#1}% -} - -% Macro bodies are absorbed as an argument in a context where -% all characters are catcode 10, 11 or 12, except \ which is active -% (as in normal texinfo). It is necessary to change the definition of \. - -% It's necessary to have hard CRs when the macro is executed. This is -% done by making ^^M (\endlinechar) catcode 12 when reading the macro -% body, and then making it the \newlinechar in \scanmacro. - -\def\scanctxt{% - \catcode`\"=\other - \catcode`\+=\other - \catcode`\<=\other - \catcode`\>=\other - \catcode`\@=\other - \catcode`\^=\other - \catcode`\_=\other - \catcode`\|=\other - \catcode`\~=\other -} - -\def\scanargctxt{% - \scanctxt - \catcode`\\=\other - \catcode`\^^M=\other -} - -\def\macrobodyctxt{% - \scanctxt - \catcode`\{=\other - \catcode`\}=\other - \catcode`\^^M=\other - \usembodybackslash -} - -\def\macroargctxt{% - \scanctxt - \catcode`\\=\other -} - -% \mbodybackslash is the definition of \ in @macro bodies. -% It maps \foo\ => \csname macarg.foo\endcsname => #N -% where N is the macro parameter number. -% We define \csname macarg.\endcsname to be \realbackslash, so -% \\ in macro replacement text gets you a backslash. - -{\catcode`@=0 @catcode`@\=@active - @gdef@usembodybackslash{@let\=@mbodybackslash} - @gdef@mbodybackslash#1\{@csname macarg.#1@endcsname} -} -\expandafter\def\csname macarg.\endcsname{\realbackslash} - -\def\macro{\recursivefalse\parsearg\macroxxx} -\def\rmacro{\recursivetrue\parsearg\macroxxx} - -\def\macroxxx#1{% - \getargs{#1}% now \macname is the macname and \argl the arglist - \ifx\argl\empty % no arguments - \paramno=0% - \else - \expandafter\parsemargdef \argl;% - \fi - \if1\csname ismacro.\the\macname\endcsname - \message{Warning: redefining \the\macname}% - \else - \expandafter\ifx\csname \the\macname\endcsname \relax - \else \errmessage{Macro name \the\macname\space already defined}\fi - \global\cslet{macsave.\the\macname}{\the\macname}% - \global\expandafter\let\csname ismacro.\the\macname\endcsname=1% - \addtomacrolist{\the\macname}% - \fi - \begingroup \macrobodyctxt - \ifrecursive \expandafter\parsermacbody - \else \expandafter\parsemacbody - \fi} - -\parseargdef\unmacro{% - \if1\csname ismacro.#1\endcsname - \global\cslet{#1}{macsave.#1}% - \global\expandafter\let \csname ismacro.#1\endcsname=0% - % Remove the macro name from \macrolist: - \begingroup - \expandafter\let\csname#1\endcsname \relax - \let\definedummyword\unmacrodo - \xdef\macrolist{\macrolist}% - \endgroup - \else - \errmessage{Macro #1 not defined}% - \fi -} - -% Called by \do from \dounmacro on each macro. The idea is to omit any -% macro definitions that have been changed to \relax. -% -\def\unmacrodo#1{% - \ifx #1\relax - % remove this - \else - \noexpand\definedummyword \noexpand#1% - \fi -} - -% This makes use of the obscure feature that if the last token of a -% is #, then the preceding argument is delimited by -% an opening brace, and that opening brace is not consumed. -\def\getargs#1{\getargsxxx#1{}} -\def\getargsxxx#1#{\getmacname #1 \relax\getmacargs} -\def\getmacname #1 #2\relax{\macname={#1}} -\def\getmacargs#1{\def\argl{#1}} - -% Parse the optional {params} list. Set up \paramno and \paramlist -% so \defmacro knows what to do. Define \macarg.blah for each blah -% in the params list, to be ##N where N is the position in that list. -% That gets used by \mbodybackslash (above). - -% We need to get `macro parameter char #' into several definitions. -% The technique used is stolen from LaTeX: let \hash be something -% unexpandable, insert that wherever you need a #, and then redefine -% it to # just before using the token list produced. -% -% The same technique is used to protect \eatspaces till just before -% the macro is used. - -\def\parsemargdef#1;{\paramno=0\def\paramlist{}% - \let\hash\relax\let\xeatspaces\relax\parsemargdefxxx#1,;,} -\def\parsemargdefxxx#1,{% - \if#1;\let\next=\relax - \else \let\next=\parsemargdefxxx - \advance\paramno by 1% - \expandafter\edef\csname macarg.\eatspaces{#1}\endcsname - {\xeatspaces{\hash\the\paramno}}% - \edef\paramlist{\paramlist\hash\the\paramno,}% - \fi\next} - -% These two commands read recursive and nonrecursive macro bodies. -% (They're different since rec and nonrec macros end differently.) - -\long\def\parsemacbody#1@end macro% -{\xdef\temp{\eatcr{#1}}\endgroup\defmacro}% -\long\def\parsermacbody#1@end rmacro% -{\xdef\temp{\eatcr{#1}}\endgroup\defmacro}% - -% This defines the macro itself. There are six cases: recursive and -% nonrecursive macros of zero, one, and many arguments. -% Much magic with \expandafter here. -% \xdef is used so that macro definitions will survive the file -% they're defined in; @include reads the file inside a group. -\def\defmacro{% - \let\hash=##% convert placeholders to macro parameter chars - \ifrecursive - \ifcase\paramno - % 0 - \expandafter\xdef\csname\the\macname\endcsname{% - \noexpand\scanmacro{\temp}}% - \or % 1 - \expandafter\xdef\csname\the\macname\endcsname{% - \bgroup\noexpand\macroargctxt - \noexpand\braceorline - \expandafter\noexpand\csname\the\macname xxx\endcsname}% - \expandafter\xdef\csname\the\macname xxx\endcsname##1{% - \egroup\noexpand\scanmacro{\temp}}% - \else % many - \expandafter\xdef\csname\the\macname\endcsname{% - \bgroup\noexpand\macroargctxt - \noexpand\csname\the\macname xx\endcsname}% - \expandafter\xdef\csname\the\macname xx\endcsname##1{% - \expandafter\noexpand\csname\the\macname xxx\endcsname ##1,}% - \expandafter\expandafter - \expandafter\xdef - \expandafter\expandafter - \csname\the\macname xxx\endcsname - \paramlist{\egroup\noexpand\scanmacro{\temp}}% - \fi - \else - \ifcase\paramno - % 0 - \expandafter\xdef\csname\the\macname\endcsname{% - \noexpand\norecurse{\the\macname}% - \noexpand\scanmacro{\temp}\egroup}% - \or % 1 - \expandafter\xdef\csname\the\macname\endcsname{% - \bgroup\noexpand\macroargctxt - \noexpand\braceorline - \expandafter\noexpand\csname\the\macname xxx\endcsname}% - \expandafter\xdef\csname\the\macname xxx\endcsname##1{% - \egroup - \noexpand\norecurse{\the\macname}% - \noexpand\scanmacro{\temp}\egroup}% - \else % many - \expandafter\xdef\csname\the\macname\endcsname{% - \bgroup\noexpand\macroargctxt - \expandafter\noexpand\csname\the\macname xx\endcsname}% - \expandafter\xdef\csname\the\macname xx\endcsname##1{% - \expandafter\noexpand\csname\the\macname xxx\endcsname ##1,}% - \expandafter\expandafter - \expandafter\xdef - \expandafter\expandafter - \csname\the\macname xxx\endcsname - \paramlist{% - \egroup - \noexpand\norecurse{\the\macname}% - \noexpand\scanmacro{\temp}\egroup}% - \fi - \fi} - -\def\norecurse#1{\bgroup\cslet{#1}{macsave.#1}} - -% \braceorline decides whether the next nonwhitespace character is a -% {. If so it reads up to the closing }, if not, it reads the whole -% line. Whatever was read is then fed to the next control sequence -% as an argument (by \parsebrace or \parsearg) -\def\braceorline#1{\let\macnamexxx=#1\futurelet\nchar\braceorlinexxx} -\def\braceorlinexxx{% - \ifx\nchar\bgroup\else - \expandafter\parsearg - \fi \macnamexxx} - - -% @alias. -% We need some trickery to remove the optional spaces around the equal -% sign. Just make them active and then expand them all to nothing. -\def\alias{\parseargusing\obeyspaces\aliasxxx} -\def\aliasxxx #1{\aliasyyy#1\relax} -\def\aliasyyy #1=#2\relax{% - {% - \expandafter\let\obeyedspace=\empty - \addtomacrolist{#1}% - \xdef\next{\global\let\makecsname{#1}=\makecsname{#2}}% - }% - \next -} - - -\message{cross references,} - -\newwrite\auxfile - -\newif\ifhavexrefs % True if xref values are known. -\newif\ifwarnedxrefs % True if we warned once that they aren't known. - -% @inforef is relatively simple. -\def\inforef #1{\inforefzzz #1,,,,**} -\def\inforefzzz #1,#2,#3,#4**{\putwordSee{} \putwordInfo{} \putwordfile{} \file{\ignorespaces #3{}}, - node \samp{\ignorespaces#1{}}} - -% @node's only job in TeX is to define \lastnode, which is used in -% cross-references. The @node line might or might not have commas, and -% might or might not have spaces before the first comma, like: -% @node foo , bar , ... -% We don't want such trailing spaces in the node name. -% -\parseargdef\node{\checkenv{}\donode #1 ,\finishnodeparse} -% -% also remove a trailing comma, in case of something like this: -% @node Help-Cross, , , Cross-refs -\def\donode#1 ,#2\finishnodeparse{\dodonode #1,\finishnodeparse} -\def\dodonode#1,#2\finishnodeparse{\gdef\lastnode{#1}} - -\let\nwnode=\node -\let\lastnode=\empty - -% Write a cross-reference definition for the current node. #1 is the -% type (Ynumbered, Yappendix, Ynothing). -% -\def\donoderef#1{% - \ifx\lastnode\empty\else - \setref{\lastnode}{#1}% - \global\let\lastnode=\empty - \fi -} - -% @anchor{NAME} -- define xref target at arbitrary point. -% -\newcount\savesfregister -% -\def\savesf{\relax \ifhmode \savesfregister=\spacefactor \fi} -\def\restoresf{\relax \ifhmode \spacefactor=\savesfregister \fi} -\def\anchor#1{\savesf \setref{#1}{Ynothing}\restoresf \ignorespaces} - -% \setref{NAME}{SNT} defines a cross-reference point NAME (a node or an -% anchor), which consists of three parts: -% 1) NAME-title - the current sectioning name taken from \thissection, -% or the anchor name. -% 2) NAME-snt - section number and type, passed as the SNT arg, or -% empty for anchors. -% 3) NAME-pg - the page number. -% -% This is called from \donoderef, \anchor, and \dofloat. In the case of -% floats, there is an additional part, which is not written here: -% 4) NAME-lof - the text as it should appear in a @listoffloats. -% -\def\setref#1#2{% - \pdfmkdest{#1}% - \iflinks - {% - \atdummies % preserve commands, but don't expand them - \edef\writexrdef##1##2{% - \write\auxfile{@xrdef{#1-% #1 of \setref, expanded by the \edef - ##1}{##2}}% these are parameters of \writexrdef - }% - \toks0 = \expandafter{\thissection}% - \immediate \writexrdef{title}{\the\toks0 }% - \immediate \writexrdef{snt}{\csname #2\endcsname}% \Ynumbered etc. - \writexrdef{pg}{\folio}% will be written later, during \shipout - }% - \fi -} - -% @xref, @pxref, and @ref generate cross-references. For \xrefX, #1 is -% the node name, #2 the name of the Info cross-reference, #3 the printed -% node name, #4 the name of the Info file, #5 the name of the printed -% manual. All but the node name can be omitted. -% -\def\pxref#1{\putwordsee{} \xrefX[#1,,,,,,,]} -\def\xref#1{\putwordSee{} \xrefX[#1,,,,,,,]} -\def\ref#1{\xrefX[#1,,,,,,,]} -\def\xrefX[#1,#2,#3,#4,#5,#6]{\begingroup - \unsepspaces - \def\printedmanual{\ignorespaces #5}% - \def\printedrefname{\ignorespaces #3}% - \setbox1=\hbox{\printedmanual\unskip}% - \setbox0=\hbox{\printedrefname\unskip}% - \ifdim \wd0 = 0pt - % No printed node name was explicitly given. - \expandafter\ifx\csname SETxref-automatic-section-title\endcsname\relax - % Use the node name inside the square brackets. - \def\printedrefname{\ignorespaces #1}% - \else - % Use the actual chapter/section title appear inside - % the square brackets. Use the real section title if we have it. - \ifdim \wd1 > 0pt - % It is in another manual, so we don't have it. - \def\printedrefname{\ignorespaces #1}% - \else - \ifhavexrefs - % We know the real title if we have the xref values. - \def\printedrefname{\refx{#1-title}{}}% - \else - % Otherwise just copy the Info node name. - \def\printedrefname{\ignorespaces #1}% - \fi% - \fi - \fi - \fi - % - % Make link in pdf output. - \ifpdf - \leavevmode - \getfilename{#4}% - {\turnoffactive - % See comments at \activebackslashdouble. - {\activebackslashdouble \xdef\pdfxrefdest{#1}% - \backslashparens\pdfxrefdest}% - % - \ifnum\filenamelength>0 - \startlink attr{/Border [0 0 0]}% - goto file{\the\filename.pdf} name{\pdfxrefdest}% - \else - \startlink attr{/Border [0 0 0]}% - goto name{\pdfmkpgn{\pdfxrefdest}}% - \fi - }% - \linkcolor - \fi - % - % Float references are printed completely differently: "Figure 1.2" - % instead of "[somenode], p.3". We distinguish them by the - % LABEL-title being set to a magic string. - {% - % Have to otherify everything special to allow the \csname to - % include an _ in the xref name, etc. - \indexnofonts - \turnoffactive - \expandafter\global\expandafter\let\expandafter\Xthisreftitle - \csname XR#1-title\endcsname - }% - \iffloat\Xthisreftitle - % If the user specified the print name (third arg) to the ref, - % print it instead of our usual "Figure 1.2". - \ifdim\wd0 = 0pt - \refx{#1-snt}{}% - \else - \printedrefname - \fi - % - % if the user also gave the printed manual name (fifth arg), append - % "in MANUALNAME". - \ifdim \wd1 > 0pt - \space \putwordin{} \cite{\printedmanual}% - \fi - \else - % node/anchor (non-float) references. - % - % If we use \unhbox0 and \unhbox1 to print the node names, TeX does not - % insert empty discretionaries after hyphens, which means that it will - % not find a line break at a hyphen in a node names. Since some manuals - % are best written with fairly long node names, containing hyphens, this - % is a loss. Therefore, we give the text of the node name again, so it - % is as if TeX is seeing it for the first time. - \ifdim \wd1 > 0pt - \putwordsection{} ``\printedrefname'' \putwordin{} \cite{\printedmanual}% - \else - % _ (for example) has to be the character _ for the purposes of the - % control sequence corresponding to the node, but it has to expand - % into the usual \leavevmode...\vrule stuff for purposes of - % printing. So we \turnoffactive for the \refx-snt, back on for the - % printing, back off for the \refx-pg. - {\turnoffactive - % Only output a following space if the -snt ref is nonempty; for - % @unnumbered and @anchor, it won't be. - \setbox2 = \hbox{\ignorespaces \refx{#1-snt}{}}% - \ifdim \wd2 > 0pt \refx{#1-snt}\space\fi - }% - % output the `[mynode]' via a macro so it can be overridden. - \xrefprintnodename\printedrefname - % - % But we always want a comma and a space: - ,\space - % - % output the `page 3'. - \turnoffactive \putwordpage\tie\refx{#1-pg}{}% - \fi - \fi - \endlink -\endgroup} - -% This macro is called from \xrefX for the `[nodename]' part of xref -% output. It's a separate macro only so it can be changed more easily, -% since square brackets don't work well in some documents. Particularly -% one that Bob is working on :). -% -\def\xrefprintnodename#1{[#1]} - -% Things referred to by \setref. -% -\def\Ynothing{} -\def\Yomitfromtoc{} -\def\Ynumbered{% - \ifnum\secno=0 - \putwordChapter@tie \the\chapno - \else \ifnum\subsecno=0 - \putwordSection@tie \the\chapno.\the\secno - \else \ifnum\subsubsecno=0 - \putwordSection@tie \the\chapno.\the\secno.\the\subsecno - \else - \putwordSection@tie \the\chapno.\the\secno.\the\subsecno.\the\subsubsecno - \fi\fi\fi -} -\def\Yappendix{% - \ifnum\secno=0 - \putwordAppendix@tie @char\the\appendixno{}% - \else \ifnum\subsecno=0 - \putwordSection@tie @char\the\appendixno.\the\secno - \else \ifnum\subsubsecno=0 - \putwordSection@tie @char\the\appendixno.\the\secno.\the\subsecno - \else - \putwordSection@tie - @char\the\appendixno.\the\secno.\the\subsecno.\the\subsubsecno - \fi\fi\fi -} - -% Define \refx{NAME}{SUFFIX} to reference a cross-reference string named NAME. -% If its value is nonempty, SUFFIX is output afterward. -% -\def\refx#1#2{% - {% - \indexnofonts - \otherbackslash - \expandafter\global\expandafter\let\expandafter\thisrefX - \csname XR#1\endcsname - }% - \ifx\thisrefX\relax - % If not defined, say something at least. - \angleleft un\-de\-fined\angleright - \iflinks - \ifhavexrefs - \message{\linenumber Undefined cross reference `#1'.}% - \else - \ifwarnedxrefs\else - \global\warnedxrefstrue - \message{Cross reference values unknown; you must run TeX again.}% - \fi - \fi - \fi - \else - % It's defined, so just use it. - \thisrefX - \fi - #2% Output the suffix in any case. -} - -% This is the macro invoked by entries in the aux file. Usually it's -% just a \def (we prepend XR to the control sequence name to avoid -% collisions). But if this is a float type, we have more work to do. -% -\def\xrdef#1#2{% - \expandafter\gdef\csname XR#1\endcsname{#2}% remember this xref value. - % - % Was that xref control sequence that we just defined for a float? - \expandafter\iffloat\csname XR#1\endcsname - % it was a float, and we have the (safe) float type in \iffloattype. - \expandafter\let\expandafter\floatlist - \csname floatlist\iffloattype\endcsname - % - % Is this the first time we've seen this float type? - \expandafter\ifx\floatlist\relax - \toks0 = {\do}% yes, so just \do - \else - % had it before, so preserve previous elements in list. - \toks0 = \expandafter{\floatlist\do}% - \fi - % - % Remember this xref in the control sequence \floatlistFLOATTYPE, - % for later use in \listoffloats. - \expandafter\xdef\csname floatlist\iffloattype\endcsname{\the\toks0{#1}}% - \fi -} - -% Read the last existing aux file, if any. No error if none exists. -% -\def\tryauxfile{% - \openin 1 \jobname.aux - \ifeof 1 \else - \readdatafile{aux}% - \global\havexrefstrue - \fi - \closein 1 -} - -\def\setupdatafile{% - \catcode`\^^@=\other - \catcode`\^^A=\other - \catcode`\^^B=\other - \catcode`\^^C=\other - \catcode`\^^D=\other - \catcode`\^^E=\other - \catcode`\^^F=\other - \catcode`\^^G=\other - \catcode`\^^H=\other - \catcode`\^^K=\other - \catcode`\^^L=\other - \catcode`\^^N=\other - \catcode`\^^P=\other - \catcode`\^^Q=\other - \catcode`\^^R=\other - \catcode`\^^S=\other - \catcode`\^^T=\other - \catcode`\^^U=\other - \catcode`\^^V=\other - \catcode`\^^W=\other - \catcode`\^^X=\other - \catcode`\^^Z=\other - \catcode`\^^[=\other - \catcode`\^^\=\other - \catcode`\^^]=\other - \catcode`\^^^=\other - \catcode`\^^_=\other - % It was suggested to set the catcode of ^ to 7, which would allow ^^e4 etc. - % in xref tags, i.e., node names. But since ^^e4 notation isn't - % supported in the main text, it doesn't seem desirable. Furthermore, - % that is not enough: for node names that actually contain a ^ - % character, we would end up writing a line like this: 'xrdef {'hat - % b-title}{'hat b} and \xrdef does a \csname...\endcsname on the first - % argument, and \hat is not an expandable control sequence. It could - % all be worked out, but why? Either we support ^^ or we don't. - % - % The other change necessary for this was to define \auxhat: - % \def\auxhat{\def^{'hat }}% extra space so ok if followed by letter - % and then to call \auxhat in \setq. - % - \catcode`\^=\other - % - % Special characters. Should be turned off anyway, but... - \catcode`\~=\other - \catcode`\[=\other - \catcode`\]=\other - \catcode`\"=\other - \catcode`\_=\other - \catcode`\|=\other - \catcode`\<=\other - \catcode`\>=\other - \catcode`\$=\other - \catcode`\#=\other - \catcode`\&=\other - \catcode`\%=\other - \catcode`+=\other % avoid \+ for paranoia even though we've turned it off - % - % This is to support \ in node names and titles, since the \ - % characters end up in a \csname. It's easier than - % leaving it active and making its active definition an actual \ - % character. What I don't understand is why it works in the *value* - % of the xrdef. Seems like it should be a catcode12 \, and that - % should not typeset properly. But it works, so I'm moving on for - % now. --karl, 15jan04. - \catcode`\\=\other - % - % Make the characters 128-255 be printing characters. - {% - \count1=128 - \def\loop{% - \catcode\count1=\other - \advance\count1 by 1 - \ifnum \count1<256 \loop \fi - }% - }% - % - % @ is our escape character in .aux files, and we need braces. - \catcode`\{=1 - \catcode`\}=2 - \catcode`\@=0 -} - -\def\readdatafile#1{% -\begingroup - \setupdatafile - \input\jobname.#1 -\endgroup} - -\message{insertions,} -% including footnotes. - -\newcount \footnoteno - -% The trailing space in the following definition for supereject is -% vital for proper filling; pages come out unaligned when you do a -% pagealignmacro call if that space before the closing brace is -% removed. (Generally, numeric constants should always be followed by a -% space to prevent strange expansion errors.) -\def\supereject{\par\penalty -20000\footnoteno =0 } - -% @footnotestyle is meaningful for info output only. -\let\footnotestyle=\comment - -{\catcode `\@=11 -% -% Auto-number footnotes. Otherwise like plain. -\gdef\footnote{% - \let\indent=\ptexindent - \let\noindent=\ptexnoindent - \global\advance\footnoteno by \@ne - \edef\thisfootno{$^{\the\footnoteno}$}% - % - % In case the footnote comes at the end of a sentence, preserve the - % extra spacing after we do the footnote number. - \let\@sf\empty - \ifhmode\edef\@sf{\spacefactor\the\spacefactor}\ptexslash\fi - % - % Remove inadvertent blank space before typesetting the footnote number. - \unskip - \thisfootno\@sf - \dofootnote -}% - -% Don't bother with the trickery in plain.tex to not require the -% footnote text as a parameter. Our footnotes don't need to be so general. -% -% Oh yes, they do; otherwise, @ifset (and anything else that uses -% \parseargline) fails inside footnotes because the tokens are fixed when -% the footnote is read. --karl, 16nov96. -% -\gdef\dofootnote{% - \insert\footins\bgroup - % We want to typeset this text as a normal paragraph, even if the - % footnote reference occurs in (for example) a display environment. - % So reset some parameters. - \hsize=\pagewidth - \interlinepenalty\interfootnotelinepenalty - \splittopskip\ht\strutbox % top baseline for broken footnotes - \splitmaxdepth\dp\strutbox - \floatingpenalty\@MM - \leftskip\z@skip - \rightskip\z@skip - \spaceskip\z@skip - \xspaceskip\z@skip - \parindent\defaultparindent - % - \smallfonts \rm - % - % Because we use hanging indentation in footnotes, a @noindent appears - % to exdent this text, so make it be a no-op. makeinfo does not use - % hanging indentation so @noindent can still be needed within footnote - % text after an @example or the like (not that this is good style). - \let\noindent = \relax - % - % Hang the footnote text off the number. Use \everypar in case the - % footnote extends for more than one paragraph. - \everypar = {\hang}% - \textindent{\thisfootno}% - % - % Don't crash into the line above the footnote text. Since this - % expands into a box, it must come within the paragraph, lest it - % provide a place where TeX can split the footnote. - \footstrut - \futurelet\next\fo@t -} -}%end \catcode `\@=11 - -% In case a @footnote appears in a vbox, save the footnote text and create -% the real \insert just after the vbox finished. Otherwise, the insertion -% would be lost. -% Similarily, if a @footnote appears inside an alignment, save the footnote -% text to a box and make the \insert when a row of the table is finished. -% And the same can be done for other insert classes. --kasal, 16nov03. - -% Replace the \insert primitive by a cheating macro. -% Deeper inside, just make sure that the saved insertions are not spilled -% out prematurely. -% -\def\startsavinginserts{% - \ifx \insert\ptexinsert - \let\insert\saveinsert - \else - \let\checkinserts\relax - \fi -} - -% This \insert replacement works for both \insert\footins{foo} and -% \insert\footins\bgroup foo\egroup, but it doesn't work for \insert27{foo}. -% -\def\saveinsert#1{% - \edef\next{\noexpand\savetobox \makeSAVEname#1}% - \afterassignment\next - % swallow the left brace - \let\temp = -} -\def\makeSAVEname#1{\makecsname{SAVE\expandafter\gobble\string#1}} -\def\savetobox#1{\global\setbox#1 = \vbox\bgroup \unvbox#1} - -\def\checksaveins#1{\ifvoid#1\else \placesaveins#1\fi} - -\def\placesaveins#1{% - \ptexinsert \csname\expandafter\gobblesave\string#1\endcsname - {\box#1}% -} - -% eat @SAVE -- beware, all of them have catcode \other: -{ - \def\dospecials{\do S\do A\do V\do E} \uncatcodespecials % ;-) - \gdef\gobblesave @SAVE{} -} - -% initialization: -\def\newsaveins #1{% - \edef\next{\noexpand\newsaveinsX \makeSAVEname#1}% - \next -} -\def\newsaveinsX #1{% - \csname newbox\endcsname #1% - \expandafter\def\expandafter\checkinserts\expandafter{\checkinserts - \checksaveins #1}% -} - -% initialize: -\let\checkinserts\empty -\newsaveins\footins -\newsaveins\margin - - -% @image. We use the macros from epsf.tex to support this. -% If epsf.tex is not installed and @image is used, we complain. -% -% Check for and read epsf.tex up front. If we read it only at @image -% time, we might be inside a group, and then its definitions would get -% undone and the next image would fail. -\openin 1 = epsf.tex -\ifeof 1 \else - % Do not bother showing banner with epsf.tex v2.7k (available in - % doc/epsf.tex and on ctan). - \def\epsfannounce{\toks0 = }% - \input epsf.tex -\fi -\closein 1 -% -% We will only complain once about lack of epsf.tex. -\newif\ifwarnednoepsf -\newhelp\noepsfhelp{epsf.tex must be installed for images to - work. It is also included in the Texinfo distribution, or you can get - it from ftp://tug.org/tex/epsf.tex.} -% -\def\image#1{% - \ifx\epsfbox\undefined - \ifwarnednoepsf \else - \errhelp = \noepsfhelp - \errmessage{epsf.tex not found, images will be ignored}% - \global\warnednoepsftrue - \fi - \else - \imagexxx #1,,,,,\finish - \fi -} -% -% Arguments to @image: -% #1 is (mandatory) image filename; we tack on .eps extension. -% #2 is (optional) width, #3 is (optional) height. -% #4 is (ignored optional) html alt text. -% #5 is (ignored optional) extension. -% #6 is just the usual extra ignored arg for parsing this stuff. -\newif\ifimagevmode -\def\imagexxx#1,#2,#3,#4,#5,#6\finish{\begingroup - \catcode`\^^M = 5 % in case we're inside an example - \normalturnoffactive % allow _ et al. in names - % If the image is by itself, center it. - \ifvmode - \imagevmodetrue - \nobreak\bigskip - % Usually we'll have text after the image which will insert - % \parskip glue, so insert it here too to equalize the space - % above and below. - \nobreak\vskip\parskip - \nobreak - \line\bgroup - \fi - % - % Output the image. - \ifpdf - \dopdfimage{#1}{#2}{#3}% - \else - % \epsfbox itself resets \epsf?size at each figure. - \setbox0 = \hbox{\ignorespaces #2}\ifdim\wd0 > 0pt \epsfxsize=#2\relax \fi - \setbox0 = \hbox{\ignorespaces #3}\ifdim\wd0 > 0pt \epsfysize=#3\relax \fi - \epsfbox{#1.eps}% - \fi - % - \ifimagevmode \egroup \bigbreak \fi % space after the image -\endgroup} - - -% @float FLOATTYPE,LABEL,LOC ... @end float for displayed figures, tables, -% etc. We don't actually implement floating yet, we always include the -% float "here". But it seemed the best name for the future. -% -\envparseargdef\float{\eatcommaspace\eatcommaspace\dofloat#1, , ,\finish} - -% There may be a space before second and/or third parameter; delete it. -\def\eatcommaspace#1, {#1,} - -% #1 is the optional FLOATTYPE, the text label for this float, typically -% "Figure", "Table", "Example", etc. Can't contain commas. If omitted, -% this float will not be numbered and cannot be referred to. -% -% #2 is the optional xref label. Also must be present for the float to -% be referable. -% -% #3 is the optional positioning argument; for now, it is ignored. It -% will somehow specify the positions allowed to float to (here, top, bottom). -% -% We keep a separate counter for each FLOATTYPE, which we reset at each -% chapter-level command. -\let\resetallfloatnos=\empty -% -\def\dofloat#1,#2,#3,#4\finish{% - \let\thiscaption=\empty - \let\thisshortcaption=\empty - % - % don't lose footnotes inside @float. - % - % BEWARE: when the floats start float, we have to issue warning whenever an - % insert appears inside a float which could possibly float. --kasal, 26may04 - % - \startsavinginserts - % - % We can't be used inside a paragraph. - \par - % - \vtop\bgroup - \def\floattype{#1}% - \def\floatlabel{#2}% - \def\floatloc{#3}% we do nothing with this yet. - % - \ifx\floattype\empty - \let\safefloattype=\empty - \else - {% - % the floattype might have accents or other special characters, - % but we need to use it in a control sequence name. - \indexnofonts - \turnoffactive - \xdef\safefloattype{\floattype}% - }% - \fi - % - % If label is given but no type, we handle that as the empty type. - \ifx\floatlabel\empty \else - % We want each FLOATTYPE to be numbered separately (Figure 1, - % Table 1, Figure 2, ...). (And if no label, no number.) - % - \expandafter\getfloatno\csname\safefloattype floatno\endcsname - \global\advance\floatno by 1 - % - {% - % This magic value for \thissection is output by \setref as the - % XREFLABEL-title value. \xrefX uses it to distinguish float - % labels (which have a completely different output format) from - % node and anchor labels. And \xrdef uses it to construct the - % lists of floats. - % - \edef\thissection{\floatmagic=\safefloattype}% - \setref{\floatlabel}{Yfloat}% - }% - \fi - % - % start with \parskip glue, I guess. - \vskip\parskip - % - % Don't suppress indentation if a float happens to start a section. - \restorefirstparagraphindent -} - -% we have these possibilities: -% @float Foo,lbl & @caption{Cap}: Foo 1.1: Cap -% @float Foo,lbl & no caption: Foo 1.1 -% @float Foo & @caption{Cap}: Foo: Cap -% @float Foo & no caption: Foo -% @float ,lbl & Caption{Cap}: 1.1: Cap -% @float ,lbl & no caption: 1.1 -% @float & @caption{Cap}: Cap -% @float & no caption: -% -\def\Efloat{% - \let\floatident = \empty - % - % In all cases, if we have a float type, it comes first. - \ifx\floattype\empty \else \def\floatident{\floattype}\fi - % - % If we have an xref label, the number comes next. - \ifx\floatlabel\empty \else - \ifx\floattype\empty \else % if also had float type, need tie first. - \appendtomacro\floatident{\tie}% - \fi - % the number. - \appendtomacro\floatident{\chaplevelprefix\the\floatno}% - \fi - % - % Start the printed caption with what we've constructed in - % \floatident, but keep it separate; we need \floatident again. - \let\captionline = \floatident - % - \ifx\thiscaption\empty \else - \ifx\floatident\empty \else - \appendtomacro\captionline{: }% had ident, so need a colon between - \fi - % - % caption text. - \appendtomacro\captionline{\scanexp\thiscaption}% - \fi - % - % If we have anything to print, print it, with space before. - % Eventually this needs to become an \insert. - \ifx\captionline\empty \else - \vskip.5\parskip - \captionline - % - % Space below caption. - \vskip\parskip - \fi - % - % If have an xref label, write the list of floats info. Do this - % after the caption, to avoid chance of it being a breakpoint. - \ifx\floatlabel\empty \else - % Write the text that goes in the lof to the aux file as - % \floatlabel-lof. Besides \floatident, we include the short - % caption if specified, else the full caption if specified, else nothing. - {% - \atdummies - % - % since we read the caption text in the macro world, where ^^M - % is turned into a normal character, we have to scan it back, so - % we don't write the literal three characters "^^M" into the aux file. - \scanexp{% - \xdef\noexpand\gtemp{% - \ifx\thisshortcaption\empty - \thiscaption - \else - \thisshortcaption - \fi - }% - }% - \immediate\write\auxfile{@xrdef{\floatlabel-lof}{\floatident - \ifx\gtemp\empty \else : \gtemp \fi}}% - }% - \fi - \egroup % end of \vtop - % - % place the captured inserts - % - % BEWARE: when the floats start floating, we have to issue warning - % whenever an insert appears inside a float which could possibly - % float. --kasal, 26may04 - % - \checkinserts -} - -% Append the tokens #2 to the definition of macro #1, not expanding either. -% -\def\appendtomacro#1#2{% - \expandafter\def\expandafter#1\expandafter{#1#2}% -} - -% @caption, @shortcaption -% -\def\caption{\docaption\thiscaption} -\def\shortcaption{\docaption\thisshortcaption} -\def\docaption{\checkenv\float \bgroup\scanargctxt\defcaption} -\def\defcaption#1#2{\egroup \def#1{#2}} - -% The parameter is the control sequence identifying the counter we are -% going to use. Create it if it doesn't exist and assign it to \floatno. -\def\getfloatno#1{% - \ifx#1\relax - % Haven't seen this figure type before. - \csname newcount\endcsname #1% - % - % Remember to reset this floatno at the next chap. - \expandafter\gdef\expandafter\resetallfloatnos - \expandafter{\resetallfloatnos #1=0 }% - \fi - \let\floatno#1% -} - -% \setref calls this to get the XREFLABEL-snt value. We want an @xref -% to the FLOATLABEL to expand to "Figure 3.1". We call \setref when we -% first read the @float command. -% -\def\Yfloat{\floattype@tie \chaplevelprefix\the\floatno}% - -% Magic string used for the XREFLABEL-title value, so \xrefX can -% distinguish floats from other xref types. -\def\floatmagic{!!float!!} - -% #1 is the control sequence we are passed; we expand into a conditional -% which is true if #1 represents a float ref. That is, the magic -% \thissection value which we \setref above. -% -\def\iffloat#1{\expandafter\doiffloat#1==\finish} -% -% #1 is (maybe) the \floatmagic string. If so, #2 will be the -% (safe) float type for this float. We set \iffloattype to #2. -% -\def\doiffloat#1=#2=#3\finish{% - \def\temp{#1}% - \def\iffloattype{#2}% - \ifx\temp\floatmagic -} - -% @listoffloats FLOATTYPE - print a list of floats like a table of contents. -% -\parseargdef\listoffloats{% - \def\floattype{#1}% floattype - {% - % the floattype might have accents or other special characters, - % but we need to use it in a control sequence name. - \indexnofonts - \turnoffactive - \xdef\safefloattype{\floattype}% - }% - % - % \xrdef saves the floats as a \do-list in \floatlistSAFEFLOATTYPE. - \expandafter\ifx\csname floatlist\safefloattype\endcsname \relax - \ifhavexrefs - % if the user said @listoffloats foo but never @float foo. - \message{\linenumber No `\safefloattype' floats to list.}% - \fi - \else - \begingroup - \leftskip=\tocindent % indent these entries like a toc - \let\do=\listoffloatsdo - \csname floatlist\safefloattype\endcsname - \endgroup - \fi -} - -% This is called on each entry in a list of floats. We're passed the -% xref label, in the form LABEL-title, which is how we save it in the -% aux file. We strip off the -title and look up \XRLABEL-lof, which -% has the text we're supposed to typeset here. -% -% Figures without xref labels will not be included in the list (since -% they won't appear in the aux file). -% -\def\listoffloatsdo#1{\listoffloatsdoentry#1\finish} -\def\listoffloatsdoentry#1-title\finish{{% - % Can't fully expand XR#1-lof because it can contain anything. Just - % pass the control sequence. On the other hand, XR#1-pg is just the - % page number, and we want to fully expand that so we can get a link - % in pdf output. - \toksA = \expandafter{\csname XR#1-lof\endcsname}% - % - % use the same \entry macro we use to generate the TOC and index. - \edef\writeentry{\noexpand\entry{\the\toksA}{\csname XR#1-pg\endcsname}}% - \writeentry -}} - -\message{localization,} -% and i18n. - -% @documentlanguage is usually given very early, just after -% @setfilename. If done too late, it may not override everything -% properly. Single argument is the language abbreviation. -% It would be nice if we could set up a hyphenation file here. -% -\parseargdef\documentlanguage{% - \tex % read txi-??.tex file in plain TeX. - % Read the file if it exists. - \openin 1 txi-#1.tex - \ifeof 1 - \errhelp = \nolanghelp - \errmessage{Cannot read language file txi-#1.tex}% - \else - \input txi-#1.tex - \fi - \closein 1 - \endgroup -} -\newhelp\nolanghelp{The given language definition file cannot be found or -is empty. Maybe you need to install it? In the current directory -should work if nowhere else does.} - - -% @documentencoding should change something in TeX eventually, most -% likely, but for now just recognize it. -\let\documentencoding = \comment - - -% Page size parameters. -% -\newdimen\defaultparindent \defaultparindent = 15pt - -\chapheadingskip = 15pt plus 4pt minus 2pt -\secheadingskip = 12pt plus 3pt minus 2pt -\subsecheadingskip = 9pt plus 2pt minus 2pt - -% Prevent underfull vbox error messages. -\vbadness = 10000 - -% Don't be so finicky about underfull hboxes, either. -\hbadness = 2000 - -% Following George Bush, just get rid of widows and orphans. -\widowpenalty=10000 -\clubpenalty=10000 - -% Use TeX 3.0's \emergencystretch to help line breaking, but if we're -% using an old version of TeX, don't do anything. We want the amount of -% stretch added to depend on the line length, hence the dependence on -% \hsize. We call this whenever the paper size is set. -% -\def\setemergencystretch{% - \ifx\emergencystretch\thisisundefined - % Allow us to assign to \emergencystretch anyway. - \def\emergencystretch{\dimen0}% - \else - \emergencystretch = .15\hsize - \fi -} - -% Parameters in order: 1) textheight; 2) textwidth; -% 3) voffset; 4) hoffset; 5) binding offset; 6) topskip; -% 7) physical page height; 8) physical page width. -% -% We also call \setleading{\textleading}, so the caller should define -% \textleading. The caller should also set \parskip. -% -\def\internalpagesizes#1#2#3#4#5#6#7#8{% - \voffset = #3\relax - \topskip = #6\relax - \splittopskip = \topskip - % - \vsize = #1\relax - \advance\vsize by \topskip - \outervsize = \vsize - \advance\outervsize by 2\topandbottommargin - \pageheight = \vsize - % - \hsize = #2\relax - \outerhsize = \hsize - \advance\outerhsize by 0.5in - \pagewidth = \hsize - % - \normaloffset = #4\relax - \bindingoffset = #5\relax - % - \ifpdf - \pdfpageheight #7\relax - \pdfpagewidth #8\relax - \fi - % - \setleading{\textleading} - % - \parindent = \defaultparindent - \setemergencystretch -} - -% @letterpaper (the default). -\def\letterpaper{{\globaldefs = 1 - \parskip = 3pt plus 2pt minus 1pt - \textleading = 13.2pt - % - % If page is nothing but text, make it come out even. - \internalpagesizes{46\baselineskip}{6in}% - {\voffset}{.25in}% - {\bindingoffset}{36pt}% - {11in}{8.5in}% -}} - -% Use @smallbook to reset parameters for 7x9.25 trim size. -\def\smallbook{{\globaldefs = 1 - \parskip = 2pt plus 1pt - \textleading = 12pt - % - \internalpagesizes{7.5in}{5in}% - {\voffset}{.25in}% - {\bindingoffset}{16pt}% - {9.25in}{7in}% - % - \lispnarrowing = 0.3in - \tolerance = 700 - \hfuzz = 1pt - \contentsrightmargin = 0pt - \defbodyindent = .5cm -}} - -% Use @smallerbook to reset parameters for 6x9 trim size. -% (Just testing, parameters still in flux.) -\def\smallerbook{{\globaldefs = 1 - \parskip = 1.5pt plus 1pt - \textleading = 12pt - % - \internalpagesizes{7.4in}{4.8in}% - {-.2in}{-.4in}% - {0pt}{14pt}% - {9in}{6in}% - % - \lispnarrowing = 0.25in - \tolerance = 700 - \hfuzz = 1pt - \contentsrightmargin = 0pt - \defbodyindent = .4cm -}} - -% Use @afourpaper to print on European A4 paper. -\def\afourpaper{{\globaldefs = 1 - \parskip = 3pt plus 2pt minus 1pt - \textleading = 13.2pt - % - % Double-side printing via postscript on Laserjet 4050 - % prints double-sided nicely when \bindingoffset=10mm and \hoffset=-6mm. - % To change the settings for a different printer or situation, adjust - % \normaloffset until the front-side and back-side texts align. Then - % do the same for \bindingoffset. You can set these for testing in - % your texinfo source file like this: - % @tex - % \global\normaloffset = -6mm - % \global\bindingoffset = 10mm - % @end tex - \internalpagesizes{51\baselineskip}{160mm} - {\voffset}{\hoffset}% - {\bindingoffset}{44pt}% - {297mm}{210mm}% - % - \tolerance = 700 - \hfuzz = 1pt - \contentsrightmargin = 0pt - \defbodyindent = 5mm -}} - -% Use @afivepaper to print on European A5 paper. -% From romildo@urano.iceb.ufop.br, 2 July 2000. -% He also recommends making @example and @lisp be small. -\def\afivepaper{{\globaldefs = 1 - \parskip = 2pt plus 1pt minus 0.1pt - \textleading = 12.5pt - % - \internalpagesizes{160mm}{120mm}% - {\voffset}{\hoffset}% - {\bindingoffset}{8pt}% - {210mm}{148mm}% - % - \lispnarrowing = 0.2in - \tolerance = 800 - \hfuzz = 1.2pt - \contentsrightmargin = 0pt - \defbodyindent = 2mm - \tableindent = 12mm -}} - -% A specific text layout, 24x15cm overall, intended for A4 paper. -\def\afourlatex{{\globaldefs = 1 - \afourpaper - \internalpagesizes{237mm}{150mm}% - {\voffset}{4.6mm}% - {\bindingoffset}{7mm}% - {297mm}{210mm}% - % - % Must explicitly reset to 0 because we call \afourpaper. - \globaldefs = 0 -}} - -% Use @afourwide to print on A4 paper in landscape format. -\def\afourwide{{\globaldefs = 1 - \afourpaper - \internalpagesizes{241mm}{165mm}% - {\voffset}{-2.95mm}% - {\bindingoffset}{7mm}% - {297mm}{210mm}% - \globaldefs = 0 -}} - -% @pagesizes TEXTHEIGHT[,TEXTWIDTH] -% Perhaps we should allow setting the margins, \topskip, \parskip, -% and/or leading, also. Or perhaps we should compute them somehow. -% -\parseargdef\pagesizes{\pagesizesyyy #1,,\finish} -\def\pagesizesyyy#1,#2,#3\finish{{% - \setbox0 = \hbox{\ignorespaces #2}\ifdim\wd0 > 0pt \hsize=#2\relax \fi - \globaldefs = 1 - % - \parskip = 3pt plus 2pt minus 1pt - \setleading{\textleading}% - % - \dimen0 = #1 - \advance\dimen0 by \voffset - % - \dimen2 = \hsize - \advance\dimen2 by \normaloffset - % - \internalpagesizes{#1}{\hsize}% - {\voffset}{\normaloffset}% - {\bindingoffset}{44pt}% - {\dimen0}{\dimen2}% -}} - -% Set default to letter. -% -\letterpaper - - -\message{and turning on texinfo input format.} - -% Define macros to output various characters with catcode for normal text. -\catcode`\"=\other -\catcode`\~=\other -\catcode`\^=\other -\catcode`\_=\other -\catcode`\|=\other -\catcode`\<=\other -\catcode`\>=\other -\catcode`\+=\other -\catcode`\$=\other -\def\normaldoublequote{"} -\def\normaltilde{~} -\def\normalcaret{^} -\def\normalunderscore{_} -\def\normalverticalbar{|} -\def\normalless{<} -\def\normalgreater{>} -\def\normalplus{+} -\def\normaldollar{$}%$ font-lock fix - -% This macro is used to make a character print one way in \tt -% (where it can probably be output as-is), and another way in other fonts, -% where something hairier probably needs to be done. -% -% #1 is what to print if we are indeed using \tt; #2 is what to print -% otherwise. Since all the Computer Modern typewriter fonts have zero -% interword stretch (and shrink), and it is reasonable to expect all -% typewriter fonts to have this, we can check that font parameter. -% -\def\ifusingtt#1#2{\ifdim \fontdimen3\font=0pt #1\else #2\fi} - -% Same as above, but check for italic font. Actually this also catches -% non-italic slanted fonts since it is impossible to distinguish them from -% italic fonts. But since this is only used by $ and it uses \sl anyway -% this is not a problem. -\def\ifusingit#1#2{\ifdim \fontdimen1\font>0pt #1\else #2\fi} - -% Turn off all special characters except @ -% (and those which the user can use as if they were ordinary). -% Most of these we simply print from the \tt font, but for some, we can -% use math or other variants that look better in normal text. - -\catcode`\"=\active -\def\activedoublequote{{\tt\char34}} -\let"=\activedoublequote -\catcode`\~=\active -\def~{{\tt\char126}} -\chardef\hat=`\^ -\catcode`\^=\active -\def^{{\tt \hat}} - -\catcode`\_=\active -\def_{\ifusingtt\normalunderscore\_} -\let\realunder=_ -% Subroutine for the previous macro. -\def\_{\leavevmode \kern.07em \vbox{\hrule width.3em height.1ex}\kern .07em } - -\catcode`\|=\active -\def|{{\tt\char124}} -\chardef \less=`\< -\catcode`\<=\active -\def<{{\tt \less}} -\chardef \gtr=`\> -\catcode`\>=\active -\def>{{\tt \gtr}} -\catcode`\+=\active -\def+{{\tt \char 43}} -\catcode`\$=\active -\def${\ifusingit{{\sl\$}}\normaldollar}%$ font-lock fix - -% If a .fmt file is being used, characters that might appear in a file -% name cannot be active until we have parsed the command line. -% So turn them off again, and have \everyjob (or @setfilename) turn them on. -% \otherifyactive is called near the end of this file. -\def\otherifyactive{\catcode`+=\other \catcode`\_=\other} - -% Used sometimes to turn off (effectively) the active characters even after -% parsing them. -\def\turnoffactive{% - \normalturnoffactive - \otherbackslash -} - -\catcode`\@=0 - -% \backslashcurfont outputs one backslash character in current font, -% as in \char`\\. -\global\chardef\backslashcurfont=`\\ -\global\let\rawbackslashxx=\backslashcurfont % let existing .??s files work - -% \realbackslash is an actual character `\' with catcode other, and -% \doublebackslash is two of them (for the pdf outlines). -{\catcode`\\=\other @gdef@realbackslash{\} @gdef@doublebackslash{\\}} - -% In texinfo, backslash is an active character; it prints the backslash -% in fixed width font. -\catcode`\\=\active -@def@normalbackslash{{@tt@backslashcurfont}} -% On startup, @fixbackslash assigns: -% @let \ = @normalbackslash - -% \rawbackslash defines an active \ to do \backslashcurfont. -% \otherbackslash defines an active \ to be a literal `\' character with -% catcode other. -@gdef@rawbackslash{@let\=@backslashcurfont} -@gdef@otherbackslash{@let\=@realbackslash} - -% Same as @turnoffactive except outputs \ as {\tt\char`\\} instead of -% the literal character `\'. -% -@def@normalturnoffactive{% - @let\=@normalbackslash - @let"=@normaldoublequote - @let~=@normaltilde - @let^=@normalcaret - @let_=@normalunderscore - @let|=@normalverticalbar - @let<=@normalless - @let>=@normalgreater - @let+=@normalplus - @let$=@normaldollar %$ font-lock fix - @unsepspaces -} - -% Make _ and + \other characters, temporarily. -% This is canceled by @fixbackslash. -@otherifyactive - -% If a .fmt file is being used, we don't want the `\input texinfo' to show up. -% That is what \eatinput is for; after that, the `\' should revert to printing -% a backslash. -% -@gdef@eatinput input texinfo{@fixbackslash} -@global@let\ = @eatinput - -% On the other hand, perhaps the file did not have a `\input texinfo'. Then -% the first `\' in the file would cause an error. This macro tries to fix -% that, assuming it is called before the first `\' could plausibly occur. -% Also turn back on active characters that might appear in the input -% file name, in case not using a pre-dumped format. -% -@gdef@fixbackslash{% - @ifx\@eatinput @let\ = @normalbackslash @fi - @catcode`+=@active - @catcode`@_=@active -} - -% Say @foo, not \foo, in error messages. -@escapechar = `@@ - -% These look ok in all fonts, so just make them not special. -@catcode`@& = @other -@catcode`@# = @other -@catcode`@% = @other - - -@c Local variables: -@c eval: (add-hook 'write-file-hooks 'time-stamp) -@c page-delimiter: "^\\\\message" -@c time-stamp-start: "def\\\\texinfoversion{" -@c time-stamp-format: "%:y-%02m-%02d.%02H" -@c time-stamp-end: "}" -@c End: - -@c vim:sw=2: - -@ignore - arch-tag: e1b36e32-c96e-4135-a41a-0b2efa2ea115 -@end ignore From d18b5e99a0efeb8eb093b9d3002293e012235d83 Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Sun, 1 Nov 2020 15:05:31 +0000 Subject: [PATCH 336/482] aclocal.m4: update to 1.16.2 This only updates copyright notices to 2020, and URLs to https. --- aclocal.m4 | 40 ++++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/aclocal.m4 b/aclocal.m4 index 9ad3397..a5dbd09 100644 --- a/aclocal.m4 +++ b/aclocal.m4 @@ -1,6 +1,6 @@ -# generated automatically by aclocal 1.15.1 -*- Autoconf -*- +# generated automatically by aclocal 1.16.2 -*- Autoconf -*- -# Copyright (C) 1996-2017 Free Software Foundation, Inc. +# Copyright (C) 1996-2020 Free Software Foundation, Inc. # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -20,7 +20,7 @@ You have another version of autoconf. It may work, but is not guaranteed to. If you have problems, you may need to regenerate the build system entirely. To do so, use the procedure documented by the package, typically 'autoreconf'.])]) -# Copyright (C) 2002-2017 Free Software Foundation, Inc. +# Copyright (C) 2002-2020 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -32,10 +32,10 @@ To do so, use the procedure documented by the package, typically 'autoreconf'.]) # generated from the m4 files accompanying Automake X.Y. # (This private macro should not be called outside this file.) AC_DEFUN([AM_AUTOMAKE_VERSION], -[am__api_version='1.15' +[am__api_version='1.16' dnl Some users find AM_AUTOMAKE_VERSION and mistake it for a way to dnl require some minimum version. Point them to the right macro. -m4_if([$1], [1.15.1], [], +m4_if([$1], [1.16.2], [], [AC_FATAL([Do not call $0, use AM_INIT_AUTOMAKE([$1]).])])dnl ]) @@ -51,14 +51,14 @@ m4_define([_AM_AUTOCONF_VERSION], []) # Call AM_AUTOMAKE_VERSION and AM_AUTOMAKE_VERSION so they can be traced. # This function is AC_REQUIREd by AM_INIT_AUTOMAKE. AC_DEFUN([AM_SET_CURRENT_AUTOMAKE_VERSION], -[AM_AUTOMAKE_VERSION([1.15.1])dnl +[AM_AUTOMAKE_VERSION([1.16.2])dnl m4_ifndef([AC_AUTOCONF_VERSION], [m4_copy([m4_PACKAGE_VERSION], [AC_AUTOCONF_VERSION])])dnl _AM_AUTOCONF_VERSION(m4_defn([AC_AUTOCONF_VERSION]))]) # AM_AUX_DIR_EXPAND -*- Autoconf -*- -# Copyright (C) 2001-2017 Free Software Foundation, Inc. +# Copyright (C) 2001-2020 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -110,7 +110,7 @@ am_aux_dir=`cd "$ac_aux_dir" && pwd` # Do all the work for Automake. -*- Autoconf -*- -# Copyright (C) 1996-2017 Free Software Foundation, Inc. +# Copyright (C) 1996-2020 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -197,8 +197,8 @@ AC_REQUIRE([AM_PROG_INSTALL_STRIP])dnl AC_REQUIRE([AC_PROG_MKDIR_P])dnl # For better backward compatibility. To be removed once Automake 1.9.x # dies out for good. For more background, see: -# -# +# +# AC_SUBST([mkdir_p], ['$(MKDIR_P)']) # We need awk for the "check" target (and possibly the TAP driver). The # system "awk" is bad on some platforms. @@ -265,7 +265,7 @@ END Aborting the configuration process, to ensure you take notice of the issue. You can download and install GNU coreutils to get an 'rm' implementation -that behaves properly: . +that behaves properly: . If you want to complete the configuration process using your problematic 'rm' anyway, export the environment variable ACCEPT_INFERIOR_RM_PROGRAM @@ -307,7 +307,7 @@ for _am_header in $config_headers :; do done echo "timestamp for $_am_arg" >`AS_DIRNAME(["$_am_arg"])`/stamp-h[]$_am_stamp_count]) -# Copyright (C) 2001-2017 Free Software Foundation, Inc. +# Copyright (C) 2001-2020 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -328,7 +328,7 @@ if test x"${install_sh+set}" != xset; then fi AC_SUBST([install_sh])]) -# Copyright (C) 2003-2017 Free Software Foundation, Inc. +# Copyright (C) 2003-2020 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -349,7 +349,7 @@ AC_SUBST([am__leading_dot])]) # Fake the existence of programs that GNU maintainers use. -*- Autoconf -*- -# Copyright (C) 1997-2017 Free Software Foundation, Inc. +# Copyright (C) 1997-2020 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -388,7 +388,7 @@ fi # Helper functions for option handling. -*- Autoconf -*- -# Copyright (C) 2001-2017 Free Software Foundation, Inc. +# Copyright (C) 2001-2020 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -419,7 +419,7 @@ AC_DEFUN([_AM_IF_OPTION], # Check to make sure that the build environment is sane. -*- Autoconf -*- -# Copyright (C) 1996-2017 Free Software Foundation, Inc. +# Copyright (C) 1996-2020 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -500,7 +500,7 @@ AC_CONFIG_COMMANDS_PRE( rm -f conftest.file ]) -# Copyright (C) 2009-2017 Free Software Foundation, Inc. +# Copyright (C) 2009-2020 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -560,7 +560,7 @@ AC_SUBST([AM_BACKSLASH])dnl _AM_SUBST_NOTMAKE([AM_BACKSLASH])dnl ]) -# Copyright (C) 2001-2017 Free Software Foundation, Inc. +# Copyright (C) 2001-2020 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -588,7 +588,7 @@ fi INSTALL_STRIP_PROGRAM="\$(install_sh) -c -s" AC_SUBST([INSTALL_STRIP_PROGRAM])]) -# Copyright (C) 2006-2017 Free Software Foundation, Inc. +# Copyright (C) 2006-2020 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -607,7 +607,7 @@ AC_DEFUN([AM_SUBST_NOTMAKE], [_AM_SUBST_NOTMAKE($@)]) # Check how to create a tarball. -*- Autoconf -*- -# Copyright (C) 2004-2017 Free Software Foundation, Inc. +# Copyright (C) 2004-2020 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, From 8cd6cadd3dccc7129d818f573b286bf78025f973 Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Sun, 1 Nov 2020 16:06:36 +0000 Subject: [PATCH 337/482] Replace broken gmane links with links to lists.gnu.org gmane has been dead for quite a while: https://lars.ingebrigtsen.no/2020/01/06/whatever-happened-to-news-gmane-org/ --- Makefile.am | 6 +++--- NEWS | 4 ++-- TODO | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Makefile.am b/Makefile.am index 1ce2932..dbf234e 100644 --- a/Makefile.am +++ b/Makefile.am @@ -39,7 +39,7 @@ AM_MAKEINFOFLAGS = -I $(srcdir) # default ignore list in the manual works. Unfortunately this is # the only way to do it: # -# http://article.gmane.org/gmane.comp.sysutils.automake.bugs/4334/match=passing+parameters +# https://lists.gnu.org/archive/html/bug-automake/2008-09/msg00040.html # # even though it annoyingly produces a warning with the -Wall option # to AM_INIT_AUTOMAKE which has to be silenced via -Wno-override. @@ -76,7 +76,7 @@ check_DATA = $(TESTS_OUT) # Note that automake's `check' rule cannot be overridden # for some weird reason: # -# http://thread.gmane.org/gmane.comp.sysutils.automake.general/13040/focus=13041 +# https://lists.gnu.org/archive/html/automake/2011-09/msg00029.html # # so we override check-TESTS instead which is where the real work is # done anyway. Unfortunately this produces a warning with the -Wall @@ -188,7 +188,7 @@ doc/stow.8: bin/stow.in Makefile.am # # If it were not for a troublesome dependency on doc/$(am__dirstamp): # -# http://article.gmane.org/gmane.comp.sysutils.automake.general/13192 +# https://lists.gnu.org/archive/html/automake/2011-11/msg00107.html # # we could have achieved this using the built-in rules combined with # install-data-hook to rename from stow.pdf to manual.pdf etc. on diff --git a/NEWS b/NEWS index 7a398ac..8d85cd2 100644 --- a/NEWS +++ b/NEWS @@ -235,7 +235,7 @@ due to Stow::Util missing $VERSION. stow directory path being calculated as ../../../usr/home/user/local/stow relative to the target. - See http://article.gmane.org/gmane.comp.gnu.stow.bugs/8820 for details. + See https://lists.gnu.org/archive/html/bug-stow/2013-04/msg00000.html for details. *** Fix stowing of relative links when --no-folding is used. @@ -276,7 +276,7 @@ due to Stow::Util missing $VERSION. Thanks to Gabriele Balducci for reporting this problem: - http://thread.gmane.org/gmane.comp.gnu.stow.general/6676 + https://lists.gnu.org/archive/html/help-stow/2014-09/msg00000.html *** Internal code cleanups diff --git a/TODO b/TODO index a42d4cb..c2da1f4 100644 --- a/TODO +++ b/TODO @@ -4,7 +4,7 @@ install-info, amongst other things: *** http://unix.stackexchange.com/questions/73426/dealing-with-gnu-stow-conflicts -*** http://article.gmane.org/gmane.comp.gnu.stow.general/6661 +*** https://lists.gnu.org/archive/html/help-stow/2013-04/msg00016.html * Get permission for next documentation release to be under FDL 1.3 From 1a20a3f7eec823820b5cd01d566244e4fa968b73 Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Sun, 1 Nov 2020 16:34:46 +0000 Subject: [PATCH 338/482] Remove unnecessary AM_MAKEINFOFLAGS tweak We no longer need to ensure that texi2any (a.k.a. makeinfo) is called with -I $(srcdir) in order to make the @verbatiminclude default-ignore-list in the manual work, because texi2any includes the current working directory by default anyway. Presumably this behaviour was introduced after this AM_MAKEINFOFLAGS was previously added, because it was needed at some point in the past. --- Makefile.am | 11 ----------- configure.ac | 3 +-- 2 files changed, 1 insertion(+), 13 deletions(-) diff --git a/Makefile.am b/Makefile.am index dbf234e..ec1a2bd 100644 --- a/Makefile.am +++ b/Makefile.am @@ -33,17 +33,6 @@ pm_DATA = lib/Stow.pm pmstow_DATA = lib/Stow/Util.pm export TEXI2DVI_BUILD_MODE = clean -AM_MAKEINFOFLAGS = -I $(srcdir) - -# We require this -I parameter to ensure that the include of the -# default ignore list in the manual works. Unfortunately this is -# the only way to do it: -# -# https://lists.gnu.org/archive/html/bug-automake/2008-09/msg00040.html -# -# even though it annoyingly produces a warning with the -Wall option -# to AM_INIT_AUTOMAKE which has to be silenced via -Wno-override. -TEXI2DVI = texi2dvi $(AM_MAKEINFOFLAGS) doc_deps = $(info_TEXINFOS) doc/version.texi diff --git a/configure.ac b/configure.ac index cd7dc4f..1af78e8 100644 --- a/configure.ac +++ b/configure.ac @@ -19,8 +19,7 @@ AC_INIT([stow], [2.3.2], [bug-stow@gnu.org]) AC_PREREQ([2.61]) AC_CONFIG_AUX_DIR([automake]) # Unfortunately we have to disable warnings for overrides, because we -# need to override the built-in `check' rule and also the TEXI2DVI -# variable. +# need to override the built-in `check' rule. AM_INIT_AUTOMAKE([-Wall -Werror -Wno-override dist-bzip2 foreign]) AC_PROG_INSTALL From 0b727240668f384f8b0a6312204797fb0a36462b Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Sun, 1 Nov 2020 16:52:50 +0000 Subject: [PATCH 339/482] Correct comment about overriding the check rule We actually override check-TESTS. --- configure.ac | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index 1af78e8..4b74c67 100644 --- a/configure.ac +++ b/configure.ac @@ -19,7 +19,7 @@ AC_INIT([stow], [2.3.2], [bug-stow@gnu.org]) AC_PREREQ([2.61]) AC_CONFIG_AUX_DIR([automake]) # Unfortunately we have to disable warnings for overrides, because we -# need to override the built-in `check' rule. +# need to override the built-in `check-TESTS' rule. AM_INIT_AUTOMAKE([-Wall -Werror -Wno-override dist-bzip2 foreign]) AC_PROG_INSTALL From 3aae830e560966b68b959ac34e68431d31c5eba9 Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Sun, 1 Nov 2020 17:19:18 +0000 Subject: [PATCH 340/482] HOWTO-RELEASE: maintainer-clean is better than distclean --- doc/HOWTO-RELEASE | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/HOWTO-RELEASE b/doc/HOWTO-RELEASE index 2b0daab..e4a23af 100644 --- a/doc/HOWTO-RELEASE +++ b/doc/HOWTO-RELEASE @@ -31,7 +31,7 @@ Release procedure - Start from a clean slate: - make distclean + make maintainer-clean autoreconf -iv - Generate stow, chkstow, and lib/Stow.pm via: From 9f4f8185ac3a861cd0725bc2139752a407427e07 Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Sun, 1 Nov 2020 17:43:17 +0000 Subject: [PATCH 341/482] should_skip_target_which_is_stow_dir(): fix debug indentation --- lib/Stow.pm.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Stow.pm.in b/lib/Stow.pm.in index 77f67b3..8a24ae6 100755 --- a/lib/Stow.pm.in +++ b/lib/Stow.pm.in @@ -586,7 +586,7 @@ sub should_skip_target_which_is_stow_dir { return 1; } - debug(4, "$target not protected"); + debug(4, " $target not protected"); return 0; } From 8d7b7a73107cf51eeca0449784b72bbdac35c992 Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Sun, 1 Nov 2020 17:46:01 +0000 Subject: [PATCH 342/482] foldable(): fix debug indentation --- lib/Stow.pm.in | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/Stow.pm.in b/lib/Stow.pm.in index 8a24ae6..e8f5e9d 100755 --- a/lib/Stow.pm.in +++ b/lib/Stow.pm.in @@ -1055,9 +1055,9 @@ sub foldable { my $self = shift; my ($target) = @_; - debug(3, "--- Is $target foldable?"); + debug(3, " Is $target foldable?"); if ($self->{'no-folding'}) { - debug(3, "--- no because --no-folding enabled"); + debug(3, " no because --no-folding enabled"); return ''; } @@ -1104,7 +1104,7 @@ sub foldable { # If the resulting path is owned by stow, we can fold it if ($self->path_owned_by_package($target, $parent)) { - debug(3, "--- $target is foldable"); + debug(3, " $target is foldable"); return $parent; } else { From 90278f854c2d49f509759cb7bd1cc21365532376 Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Sun, 1 Nov 2020 21:04:22 +0000 Subject: [PATCH 343/482] Move to explicit debug indentation levels --- lib/Stow.pm.in | 202 ++++++++++++++++++++++---------------------- lib/Stow/Util.pm.in | 13 ++- 2 files changed, 110 insertions(+), 105 deletions(-) diff --git a/lib/Stow.pm.in b/lib/Stow.pm.in index e8f5e9d..206c147 100755 --- a/lib/Stow.pm.in +++ b/lib/Stow.pm.in @@ -204,8 +204,8 @@ sub set_stow_dir { my $target = canon_path($self->{target}); $self->{stow_path} = File::Spec->abs2rel($stow_dir, $target); - debug(2, "stow dir is $stow_dir"); - debug(2, "stow dir path relative to target $target is $self->{stow_path}"); + debug(2, 0, "stow dir is $stow_dir"); + debug(2, 0, "stow dir path relative to target $target is $self->{stow_path}"); } sub init_state { @@ -271,7 +271,7 @@ sub plan_unstow { if (not -d $path) { error("The stow directory $self->{stow_path} does not contain package $package"); } - debug(2, "Planning unstow of package $package..."); + debug(2, 0, "Planning unstow of package $package..."); if ($self->{compat}) { $self->unstow_contents_orig( $self->{stow_path}, @@ -286,7 +286,7 @@ sub plan_unstow { '.', ); } - debug(2, "Planning unstow of package $package... done"); + debug(2, 0, "Planning unstow of package $package... done"); $self->{action_count}++; } }); @@ -310,14 +310,14 @@ sub plan_stow { if (not -d $path) { error("The stow directory $self->{stow_path} does not contain package $package"); } - debug(2, "Planning stow of package $package..."); + debug(2, 0, "Planning stow of package $package..."); $self->stow_contents( $self->{stow_path}, $package, '.', $path, # source from target ); - debug(2, "Planning stow of package $package... done"); + debug(2, 0, "Planning stow of package $package... done"); $self->{action_count}++; } }); @@ -340,12 +340,12 @@ sub within_target_do { my $cwd = getcwd(); chdir($self->{target}) or error("Cannot chdir to target tree: $self->{target} ($!)"); - debug(3, "cwd now $self->{target}"); + debug(3, 0, "cwd now $self->{target}"); $self->$code(); restore_cwd($cwd); - debug(3, "cwd restored to $cwd"); + debug(3, 0, "cwd restored to $cwd"); } #===== METHOD =============================================================== @@ -376,8 +376,8 @@ sub stow_contents { my $cwd = getcwd(); my $msg = "Stowing contents of $path (cwd=$cwd)"; $msg =~ s!$ENV{HOME}(/|$)!~$1!g; - debug(3, $msg); - debug(4, " => $source"); + debug(3, 0, $msg); + debug(4, 1, "=> $source"); error("stow_contents() called with non-directory path: $path") unless -d $path; @@ -398,7 +398,7 @@ sub stow_contents { if ($self->{dotfiles}) { my $adj_node_target = adjust_dotfile($node_target); - debug(4, " Adjusting: $node_target => $adj_node_target"); + debug(4, 1, "Adjusting: $node_target => $adj_node_target"); $node_target = $adj_node_target; } @@ -433,8 +433,8 @@ sub stow_node { my $path = join_paths($stow_path, $package, $target); - debug(3, "Stowing $stow_path / $package / $target"); - debug(4, " => $source"); + debug(3, 0, "Stowing $stow_path / $package / $target"); + debug(4, 1, "=> $source"); # Don't try to stow absolute symlinks (they can't be unstowed) if (-l $source) { @@ -445,7 +445,7 @@ sub stow_node { $package, "source is an absolute symlink $source => $second_source" ); - debug(3, "Absolute symlinks cannot be unstowed"); + debug(3, 0, "Absolute symlinks cannot be unstowed"); return; } } @@ -457,7 +457,7 @@ sub stow_node { if (not $existing_source) { error("Could not read link: $target"); } - debug(4, " Evaluate existing link: $target => $existing_source"); + debug(4, 1, "Evaluate existing link: $target => $existing_source"); # Does it point to a node under any stow directory? my ($existing_path, $existing_stow_path, $existing_package) = @@ -474,13 +474,13 @@ sub stow_node { # Does the existing $target actually point to anything? if ($self->is_a_node($existing_path)) { if ($existing_source eq $source) { - debug(2, "--- Skipping $target as it already points to $source"); + debug(2, 0, "--- Skipping $target as it already points to $source"); } elsif ($self->defer($target)) { - debug(2, "--- Deferring installation of: $target"); + debug(2, 0, "--- Deferring installation of: $target"); } elsif ($self->override($target)) { - debug(2, "--- Overriding installation of: $target"); + debug(2, 0, "--- Overriding installation of: $target"); $self->do_unlink($target); $self->do_link($source, $target); } @@ -491,7 +491,7 @@ sub stow_node { # and the proposed new link points to a directory, # then we can unfold (split open) the tree at that point - debug(2, "--- Unfolding $target which was already owned by $existing_package"); + debug(2, 0, "--- Unfolding $target which was already owned by $existing_package"); $self->do_unlink($target); $self->do_mkdir($target); $self->stow_contents( @@ -518,13 +518,13 @@ sub stow_node { } else { # The existing link is invalid, so replace it with a good link - debug(2, "--- replacing invalid link: $path"); + debug(2, 0, "--- replacing invalid link: $path"); $self->do_unlink($target); $self->do_link($source, $target); } } elsif ($self->is_a_node($target)) { - debug(4, " Evaluate existing node: $target"); + debug(4, 1, "Evaluate existing node: $target"); if ($self->is_a_dir($target)) { $self->stow_contents( $self->{stow_path}, @@ -586,7 +586,7 @@ sub should_skip_target_which_is_stow_dir { return 1; } - debug(4, " $target not protected"); + debug(4, 1, "$target not protected"); return 0; } @@ -595,7 +595,7 @@ sub marked_stow_dir { my ($target) = @_; for my $f (".stow", ".nonstow") { if (-e join_paths($target, $f)) { - debug(4, "$target contained $f"); + debug(4, 0, "$target contained $f"); return 1; } } @@ -625,8 +625,8 @@ sub unstow_contents_orig { my $cwd = getcwd(); my $msg = "Unstowing from $target (compat mode, cwd=$cwd, stow dir=$self->{stow_path})"; $msg =~ s!$ENV{HOME}(/|$)!~$1!g; - debug(3, $msg); - debug(4, " source path is $path"); + debug(3, 0, $msg); + debug(4, 1, "source path is $path"); # In compat mode we traverse the target tree not the source tree, # so we're unstowing the contents of /target/foo, there's no # guarantee that the corresponding /stow/mypkg/foo exists. @@ -665,12 +665,12 @@ sub unstow_node_orig { my $path = join_paths($stow_path, $package, $target); - debug(3, "Unstowing $target (compat mode)"); - debug(4, " source path is $path"); + debug(3, 0, "Unstowing $target (compat mode)"); + debug(4, 1, "source path is $path"); # Does the target exist? if ($self->is_a_link($target)) { - debug(4, " Evaluate existing link: $target"); + debug(4, 1, "Evaluate existing link: $target"); # Where is the link pointing? my $existing_source = $self->read_a_link($target); @@ -695,13 +695,13 @@ sub unstow_node_orig { $self->do_unlink($target); } elsif ($self->override($target)) { - debug(2, "--- overriding installation of: $target"); + debug(2, 0, "--- overriding installation of: $target"); $self->do_unlink($target); } # else leave it alone } else { - debug(2, "--- removing invalid link into a stow directory: $path"); + debug(2, 0, "--- removing invalid link into a stow directory: $path"); $self->do_unlink($target); } } @@ -721,7 +721,7 @@ sub unstow_node_orig { ); } else { - debug(2, "$target did not exist to be unstowed"); + debug(2, 0, "$target did not exist to be unstowed"); } return; } @@ -749,8 +749,8 @@ sub unstow_contents { my $cwd = getcwd(); my $msg = "Unstowing from $target (cwd=$cwd, stow dir=$self->{stow_path})"; $msg =~ s!$ENV{HOME}/!~/!g; - debug(3, $msg); - debug(4, " source path is $path"); + debug(3, 0, $msg); + debug(4, 1, "source path is $path"); # We traverse the source tree not the target tree, so $path must exist. error("unstow_contents() called with non-directory path: $path") unless -d $path; @@ -774,7 +774,7 @@ sub unstow_contents { if ($self->{dotfiles}) { my $adj_node_target = adjust_dotfile($node_target); - debug(4, " Adjusting: $node_target => $adj_node_target"); + debug(4, 1, "Adjusting: $node_target => $adj_node_target"); $node_target = $adj_node_target; } @@ -802,12 +802,12 @@ sub unstow_node { my $path = join_paths($stow_path, $package, $target); - debug(3, "Unstowing $path"); - debug(4, " target is $target"); + debug(3, 0, "Unstowing $path"); + debug(4, 1, "target is $target"); # Does the target exist? if ($self->is_a_link($target)) { - debug(4, " Evaluate existing link: $target"); + debug(4, 1, "Evaluate existing link: $target"); # Where is the link pointing? my $existing_source = $self->read_a_link($target); @@ -849,10 +849,10 @@ sub unstow_node { # package. #elsif (defer($target)) { - # debug(2, "--- deferring to installation of: $target"); + # debug(2, 0, "--- deferring to installation of: $target"); #} #elsif ($self->override($target)) { - # debug(2, "--- overriding installation of: $target"); + # debug(2, 0, "--- overriding installation of: $target"); # $self->do_unlink($target); #} #else { @@ -865,12 +865,12 @@ sub unstow_node { #} } else { - debug(2, "--- removing invalid link into a stow directory: $path"); + debug(2, 0, "--- removing invalid link into a stow directory: $path"); $self->do_unlink($target); } } elsif (-e $target) { - debug(4, " Evaluate existing node: $target"); + debug(4, 1, "Evaluate existing node: $target"); if (-d $target) { $self->unstow_contents($stow_path, $package, $target); @@ -888,7 +888,7 @@ sub unstow_node { } } else { - debug(2, "$target did not exist to be unstowed"); + debug(2, 0, "$target did not exist to be unstowed"); } return; } @@ -938,7 +938,7 @@ sub find_stowed_path { # Evaluate softlink relative to its target my $path = join_paths(parent($target), $source); - debug(4, " is path $path owned by stow?"); + debug(4, 1, "is path $path owned by stow?"); # Search for .stow files - this allows us to detect links # owned by stow directories other than the current one. @@ -952,7 +952,7 @@ sub find_stowed_path { internal_error("find_stowed_path() called directly on stow dir") if $i == $#path; - debug(4, " yes - $dir was marked as a stow dir"); + debug(4, 2, "yes - $dir was marked as a stow dir"); my $package = $path[$i + 1]; return ($path, $dir, $package); } @@ -972,19 +972,19 @@ sub find_stowed_path { # Strip off common prefixes until one is empty while (@path && @stow_path) { if ((shift @path) ne (shift @stow_path)) { - debug(4, " no - either $path not under $self->{stow_path} or vice-versa"); + debug(4, 2, "no - either $path not under $self->{stow_path} or vice-versa"); return ('', '', ''); } } if (@stow_path) { # @path must be empty - debug(4, " no - $path is not under $self->{stow_path}"); + debug(4, 2, "no - $path is not under $self->{stow_path}"); return ('', '', ''); } my $package = shift @path; - debug(4, " yes - by $package in " . join_paths(@path)); + debug(4, 2, "yes - by $package in " . join_paths(@path)); return ($path, $self->{stow_path}, $package); } @@ -1032,7 +1032,7 @@ sub cleanup_invalid_links { not -e join_paths($dir, $source) and # bad link $self->path_owned_by_package($node_path, $source) # owned by stow ){ - debug(2, "--- removing stale link: $node_path => " . + debug(2, 0, "--- removing stale link: $node_path => " . join_paths($dir, $source)); $self->do_unlink($node_path); } @@ -1055,9 +1055,9 @@ sub foldable { my $self = shift; my ($target) = @_; - debug(3, " Is $target foldable?"); + debug(3, 2, "Is $target foldable?"); if ($self->{'no-folding'}) { - debug(3, " no because --no-folding enabled"); + debug(3, 3, "no because --no-folding enabled"); return ''; } @@ -1104,7 +1104,7 @@ sub foldable { # If the resulting path is owned by stow, we can fold it if ($self->path_owned_by_package($target, $parent)) { - debug(3, " $target is foldable"); + debug(3, 3, "$target is foldable"); return $parent; } else { @@ -1125,7 +1125,7 @@ sub fold_tree { my $self = shift; my ($target, $source) = @_; - debug(3, "--- Folding tree: $target => $source"); + debug(3, 0, "--- Folding tree: $target => $source"); opendir my $DIR, $target or error(qq{Cannot read directory "$target" ($!)\n}); @@ -1158,7 +1158,7 @@ sub conflict { my $self = shift; my ($action, $package, $message) = @_; - debug(2, "CONFLICT when ${action}ing $package: $message"); + debug(2, 0, "CONFLICT when ${action}ing $package: $message"); $self->{conflicts}{$action}{$package} ||= []; push @{ $self->{conflicts}{$action}{$package} }, $message; $self->{conflict_count}++; @@ -1242,7 +1242,7 @@ sub ignore { for my $suffix (@{ $self->{ignore} }) { if ($target =~ m/$suffix/) { - debug(4, " Ignoring path $target due to --ignore=$suffix"); + debug(4, 1, "Ignoring path $target due to --ignore=$suffix"); return 1; } } @@ -1250,23 +1250,23 @@ sub ignore { my $package_dir = join_paths($stow_path, $package); my ($path_regexp, $segment_regexp) = $self->get_ignore_regexps($package_dir); - debug(5, " Ignore list regexp for paths: " . + debug(5, 2, "Ignore list regexp for paths: " . (defined $path_regexp ? "/$path_regexp/" : "none")); - debug(5, " Ignore list regexp for segments: " . + debug(5, 2, "Ignore list regexp for segments: " . (defined $segment_regexp ? "/$segment_regexp/" : "none")); if (defined $path_regexp and "/$target" =~ $path_regexp) { - debug(4, " Ignoring path /$target"); + debug(4, 1, "Ignoring path /$target"); return 1; } (my $basename = $target) =~ s!.+/!!; if (defined $segment_regexp and $basename =~ $segment_regexp) { - debug(4, " Ignoring path segment $basename"); + debug(4, 1, "Ignoring path segment $basename"); return 1; } - debug(5, " Not ignoring $target"); + debug(5, 1, "Not ignoring $target"); return 0; } @@ -1286,15 +1286,15 @@ sub get_ignore_regexps { for my $file ($local_stow_ignore, $global_stow_ignore) { if (-e $file) { - debug(5, " Using ignore file: $file"); + debug(5, 1, "Using ignore file: $file"); return $self->get_ignore_regexps_from_file($file); } else { - debug(5, " $file didn't exist"); + debug(5, 1, "$file didn't exist"); } } - debug(4, " Using built-in ignore list"); + debug(4, 1, "Using built-in ignore list"); return @default_global_ignore_regexps; } @@ -1305,12 +1305,12 @@ sub get_ignore_regexps_from_file { my ($file) = @_; if (exists $ignore_file_regexps{$file}) { - debug(4, " Using memoized regexps from $file"); + debug(4, 2, "Using memoized regexps from $file"); return @{ $ignore_file_regexps{$file} }; } if (! open(REGEXPS, $file)) { - debug(4, " Failed to open $file: $!"); + debug(4, 2, "Failed to open $file: $!"); return undef; } @@ -1335,11 +1335,11 @@ sub invalidate_memoized_regexp { my $self = shift; my ($file) = @_; if (exists $ignore_file_regexps{$file}) { - debug(4, " Invalidated memoized regexp for $file"); + debug(4, 2, "Invalidated memoized regexp for $file"); delete $ignore_file_regexps{$file}; } else { - debug(2, " WARNING: no memoized regexp for $file to invalidate"); + debug(2, 1, "WARNING: no memoized regexp for $file to invalidate"); } } @@ -1462,7 +1462,7 @@ sub override { sub process_tasks { my $self = shift; - debug(2, "Processing tasks..."); + debug(2, 0, "Processing tasks..."); # Strip out all tasks with a skip action $self->{tasks} = [ grep { $_->{action} ne 'skip' } @{ $self->{tasks} } ]; @@ -1477,7 +1477,7 @@ sub process_tasks { } }); - debug(2, "Processing tasks... done"); + debug(2, 0, "Processing tasks... done"); } #===== METHOD =============================================================== @@ -1549,7 +1549,7 @@ sub link_task_action { my ($path) = @_; if (! exists $self->{link_task_for}{$path}) { - debug(4, " link_task_action($path): no task"); + debug(4, 1, "link_task_action($path): no task"); return ''; } @@ -1557,7 +1557,7 @@ sub link_task_action { internal_error("bad task action: $action") unless $action eq 'remove' or $action eq 'create'; - debug(4, " link_task_action($path): link task exists with action $action"); + debug(4, 1, "link_task_action($path): link task exists with action $action"); return $action; } @@ -1574,7 +1574,7 @@ sub dir_task_action { my ($path) = @_; if (! exists $self->{dir_task_for}{$path}) { - debug(4, " dir_task_action($path): no task"); + debug(4, 1, "dir_task_action($path): no task"); return ''; } @@ -1582,7 +1582,7 @@ sub dir_task_action { internal_error("bad task action: $action") unless $action eq 'remove' or $action eq 'create'; - debug(4, " dir_task_action($path): dir task exists with action $action"); + debug(4, 1, "dir_task_action($path): dir task exists with action $action"); return $action; } @@ -1602,15 +1602,15 @@ sub parent_link_scheduled_for_removal { my $prefix = ''; for my $part (split m{/+}, $path) { $prefix = join_paths($prefix, $part); - debug(4, " parent_link_scheduled_for_removal($path): prefix $prefix"); + debug(4, 2, "parent_link_scheduled_for_removal($path): prefix $prefix"); if (exists $self->{link_task_for}{$prefix} and $self->{link_task_for}{$prefix}->{action} eq 'remove') { - debug(4, " parent_link_scheduled_for_removal($path): link scheduled for removal"); + debug(4, 2, "parent_link_scheduled_for_removal($path): link scheduled for removal"); return 1; } } - debug(4, " parent_link_scheduled_for_removal($path): returning false"); + debug(4, 2, "parent_link_scheduled_for_removal($path): returning false"); return 0; } @@ -1626,15 +1626,15 @@ sub parent_link_scheduled_for_removal { sub is_a_link { my $self = shift; my ($path) = @_; - debug(4, " is_a_link($path)"); + debug(4, 1, "is_a_link($path)"); if (my $action = $self->link_task_action($path)) { if ($action eq 'remove') { - debug(4, " is_a_link($path): returning 0 (remove action found)"); + debug(4, 1, "is_a_link($path): returning 0 (remove action found)"); return 0; } elsif ($action eq 'create') { - debug(4, " is_a_link($path): returning 1 (create action found)"); + debug(4, 1, "is_a_link($path): returning 1 (create action found)"); return 1; } } @@ -1642,11 +1642,11 @@ sub is_a_link { if (-l $path) { # Check if any of its parent are links scheduled for removal # (need this for edge case during unfolding) - debug(4, " is_a_link($path): is a real link"); + debug(4, 1, "is_a_link($path): is a real link"); return $self->parent_link_scheduled_for_removal($path) ? 0 : 1; } - debug(4, " is_a_link($path): returning 0"); + debug(4, 1, "is_a_link($path): returning 0"); return 0; } @@ -1663,7 +1663,7 @@ sub is_a_link { sub is_a_dir { my $self = shift; my ($path) = @_; - debug(4, " is_a_dir($path)"); + debug(4, 1, "is_a_dir($path)"); if (my $action = $self->dir_task_action($path)) { if ($action eq 'remove') { @@ -1677,11 +1677,11 @@ sub is_a_dir { return 0 if $self->parent_link_scheduled_for_removal($path); if (-d $path) { - debug(4, " is_a_dir($path): real dir"); + debug(4, 1, "is_a_dir($path): real dir"); return 1; } - debug(4, " is_a_dir($path): returning false"); + debug(4, 1, "is_a_dir($path): returning false"); return 0; } @@ -1698,7 +1698,7 @@ sub is_a_dir { sub is_a_node { my $self = shift; my ($path) = @_; - debug(4, " is_a_node($path)"); + debug(4, 1, "is_a_node($path)"); my $laction = $self->link_task_action($path); my $daction = $self->dir_task_action($path); @@ -1749,11 +1749,11 @@ sub is_a_node { return 0 if $self->parent_link_scheduled_for_removal($path); if (-e $path) { - debug(4, " is_a_node($path): really exists"); + debug(4, 1, "is_a_node($path): really exists"); return 1; } - debug(4, " is_a_node($path): returning false"); + debug(4, 1, "is_a_node($path): returning false"); return 0; } @@ -1771,7 +1771,7 @@ sub read_a_link { my ($path) = @_; if (my $action = $self->link_task_action($path)) { - debug(4, " read_a_link($path): task exists with action $action"); + debug(4, 1, "read_a_link($path): task exists with action $action"); if ($action eq 'create') { return $self->{link_task_for}{$path}->{source}; @@ -1783,7 +1783,7 @@ sub read_a_link { } } elsif (-l $path) { - debug(4, " read_a_link($path): real link"); + debug(4, 1, "read_a_link($path): real link"); my $target = readlink $path or error("Could not read link: $path ($!)"); return $target; } @@ -1835,14 +1835,14 @@ sub do_link { ) } else { - debug(1, "LINK: $newfile => $oldfile (duplicates previous action)"); + debug(1, 0, "LINK: $newfile => $oldfile (duplicates previous action)"); return; } } elsif ($task_ref->{action} eq 'remove') { if ($task_ref->{source} eq $oldfile) { # No need to remove a link we are going to recreate - debug(1, "LINK: $newfile => $oldfile (reverts previous action)"); + debug(1, 0, "LINK: $newfile => $oldfile (reverts previous action)"); $self->{link_task_for}{$newfile}->{action} = 'skip'; delete $self->{link_task_for}{$newfile}; return; @@ -1855,7 +1855,7 @@ sub do_link { } # Creating a new link - debug(1, "LINK: $newfile => $oldfile"); + debug(1, 0, "LINK: $newfile => $oldfile"); my $task = { action => 'create', type => 'link', @@ -1883,12 +1883,12 @@ sub do_unlink { if (exists $self->{link_task_for}{$file}) { my $task_ref = $self->{link_task_for}{$file}; if ($task_ref->{action} eq 'remove') { - debug(1, "UNLINK: $file (duplicates previous action)"); + debug(1, 0, "UNLINK: $file (duplicates previous action)"); return; } elsif ($task_ref->{action} eq 'create') { # Do need to create a link then remove it - debug(1, "UNLINK: $file (reverts previous action)"); + debug(1, 0, "UNLINK: $file (reverts previous action)"); $self->{link_task_for}{$file}->{action} = 'skip'; delete $self->{link_task_for}{$file}; return; @@ -1907,7 +1907,7 @@ sub do_unlink { } # Remove the link - debug(1, "UNLINK: $file"); + debug(1, 0, "UNLINK: $file"); my $source = readlink $file or error("could not readlink $file ($!)"); @@ -1959,11 +1959,11 @@ sub do_mkdir { my $task_ref = $self->{dir_task_for}{$dir}; if ($task_ref->{action} eq 'create') { - debug(1, "MKDIR: $dir (duplicates previous action)"); + debug(1, 0, "MKDIR: $dir (duplicates previous action)"); return; } elsif ($task_ref->{action} eq 'remove') { - debug(1, "MKDIR: $dir (reverts previous action)"); + debug(1, 0, "MKDIR: $dir (reverts previous action)"); $self->{dir_task_for}{$dir}->{action} = 'skip'; delete $self->{dir_task_for}{$dir}; return; @@ -1973,7 +1973,7 @@ sub do_mkdir { } } - debug(1, "MKDIR: $dir"); + debug(1, 0, "MKDIR: $dir"); my $task = { action => 'create', type => 'dir', @@ -2013,11 +2013,11 @@ sub do_rmdir { my $task_ref = $self->{link_task_for}{$dir}; if ($task_ref->{action} eq 'remove') { - debug(1, "RMDIR $dir (duplicates previous action)"); + debug(1, 0, "RMDIR $dir (duplicates previous action)"); return; } elsif ($task_ref->{action} eq 'create') { - debug(1, "MKDIR $dir (reverts previous action)"); + debug(1, 0, "MKDIR $dir (reverts previous action)"); $self->{link_task_for}{$dir}->{action} = 'skip'; delete $self->{link_task_for}{$dir}; return; @@ -2027,7 +2027,7 @@ sub do_rmdir { } } - debug(1, "RMDIR $dir"); + debug(1, 0, "RMDIR $dir"); my $task = { action => 'remove', type => 'dir', @@ -2071,7 +2071,7 @@ sub do_mv { } # Remove the link - debug(1, "MV: $src -> $dst"); + debug(1, 0, "MV: $src -> $dst"); my $task = { action => 'move', diff --git a/lib/Stow/Util.pm.in b/lib/Stow/Util.pm.in index e3e932b..497e7a3 100644 --- a/lib/Stow/Util.pm.in +++ b/lib/Stow/Util.pm.in @@ -93,7 +93,7 @@ sub set_test_mode { } } -=head2 debug($level, $msg) +=head2 debug($level[, $indent_level], $msg) Logs to STDERR based on C<$debug_level> setting. C<$level> is the minimum verbosity level required to output C<$msg>. All output is to @@ -125,13 +125,18 @@ overriding, fixing invalid links =cut sub debug { - my ($level, $msg) = @_; + my $level = shift; + my $indent_level; + # Maintain backwards-compatibility in case anyone's relying on this. + $indent_level = $_[0] =~ /^\d+$/ ? shift : 0; + my $msg = shift; if ($debug_level >= $level) { + my $indent = ' ' x $indent_level; if ($test_mode) { - print "# $msg\n"; + print "# $indent$msg\n"; } else { - warn "$msg\n"; + warn "$indent$msg\n"; } } } From c872baba2d548fe369c5740b03ff7535e0c83a2e Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Mon, 2 Nov 2020 00:19:21 +0000 Subject: [PATCH 344/482] Add support for emacs dumb-jump Allow easy navigation to function definitions in emacs. The rg (ripgrep) search is needed because as the dumb-jump README says: [...] the default searcher (git-grep) won't be able to search outside of the project root. This edge case will be fixed in a future release. See: https://github.com/jacktasia/dumb-jump --- .dir-locals.el | 1 + .dumbjump | 2 ++ 2 files changed, 3 insertions(+) create mode 100644 .dir-locals.el create mode 100644 .dumbjump diff --git a/.dir-locals.el b/.dir-locals.el new file mode 100644 index 0000000..97211a4 --- /dev/null +++ b/.dir-locals.el @@ -0,0 +1 @@ +((cperl-mode . ((dumb-jump-force-searcher . rg)))) diff --git a/.dumbjump b/.dumbjump new file mode 100644 index 0000000..060cbbd --- /dev/null +++ b/.dumbjump @@ -0,0 +1,2 @@ ++bin/*.in ++lib/*.pm.in From 86f4694d960c3440ff63e56dc22d7c3cf70c2840 Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Mon, 2 Nov 2020 00:53:19 +0000 Subject: [PATCH 345/482] Improve debug indent levels --- lib/Stow.pm.in | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/Stow.pm.in b/lib/Stow.pm.in index 206c147..b343f26 100755 --- a/lib/Stow.pm.in +++ b/lib/Stow.pm.in @@ -938,7 +938,7 @@ sub find_stowed_path { # Evaluate softlink relative to its target my $path = join_paths(parent($target), $source); - debug(4, 1, "is path $path owned by stow?"); + debug(4, 2, "is path $path owned by stow?"); # Search for .stow files - this allows us to detect links # owned by stow directories other than the current one. @@ -952,7 +952,7 @@ sub find_stowed_path { internal_error("find_stowed_path() called directly on stow dir") if $i == $#path; - debug(4, 2, "yes - $dir was marked as a stow dir"); + debug(4, 3, "yes - $dir was marked as a stow dir"); my $package = $path[$i + 1]; return ($path, $dir, $package); } @@ -972,19 +972,19 @@ sub find_stowed_path { # Strip off common prefixes until one is empty while (@path && @stow_path) { if ((shift @path) ne (shift @stow_path)) { - debug(4, 2, "no - either $path not under $self->{stow_path} or vice-versa"); + debug(4, 3, "no - either $path not under $self->{stow_path} or vice-versa"); return ('', '', ''); } } if (@stow_path) { # @path must be empty - debug(4, 2, "no - $path is not under $self->{stow_path}"); + debug(4, 3, "no - $path is not under $self->{stow_path}"); return ('', '', ''); } my $package = shift @path; - debug(4, 2, "yes - by $package in " . join_paths(@path)); + debug(4, 3, "yes - by $package in " . join_paths(@path)); return ($path, $self->{stow_path}, $package); } From 832135e269be36ac4c4ab54a7095a912f4c0d46b Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Mon, 2 Nov 2020 00:54:15 +0000 Subject: [PATCH 346/482] Make cleanup_invalid_links() more explicit And add some debug. --- lib/Stow.pm.in | 45 ++++++++++++++++++++++++++++++--------------- 1 file changed, 30 insertions(+), 15 deletions(-) diff --git a/lib/Stow.pm.in b/lib/Stow.pm.in index b343f26..3c4f7b2 100755 --- a/lib/Stow.pm.in +++ b/lib/Stow.pm.in @@ -1003,6 +1003,9 @@ sub cleanup_invalid_links { my $self = shift; my ($dir) = @_; + my $cwd = getcwd(); + debug(2, 1, "cleanup_invalid_links for $dir (pwd=$cwd)"); + if (not -d $dir) { error("cleanup_invalid_links() called with a non-directory: $dir"); } @@ -1019,23 +1022,35 @@ sub cleanup_invalid_links { my $node_path = join_paths($dir, $node); - if (-l $node_path and not exists $self->{link_task_for}{$node_path}) { + next unless -l $node_path; - # Where is the link pointing? - # (don't use read_a_link() here) - my $source = readlink($node_path); - if (not $source) { - error("Could not read link $node_path"); - } + debug(2, 2, "checking validity of link $node_path"); - if ( - not -e join_paths($dir, $source) and # bad link - $self->path_owned_by_package($node_path, $source) # owned by stow - ){ - debug(2, 0, "--- removing stale link: $node_path => " . - join_paths($dir, $source)); - $self->do_unlink($node_path); - } + if (exists $self->{link_task_for}{$node_path}) { + die "huh? link_task_for $node_path"; + } + + # Where is the link pointing? + # (don't use read_a_link() here) + my $source = readlink($node_path); + if (not $source) { + error("Could not read link $node_path"); + } + + if (-e join_paths($dir, $source)) { + debug(4, 3, "link target $source exists; skipping clean up"); + next; + } + + debug(2, 2, + "checking whether valid link $node_path -> $source is " . + "owned by stow"); + + if ($self->path_owned_by_package($node_path, $source)) { + # owned by stow + debug(2, 0, "--- removing stale link: $node_path => " . + join_paths($dir, $source)); + $self->do_unlink($node_path); } } return; From 396357dc67932a8d7c66fac3354d0b992f5ba14d Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Mon, 2 Nov 2020 00:52:41 +0000 Subject: [PATCH 347/482] Rename path_owned_by_package() to link_owned_by_package() --- lib/Stow.pm.in | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/Stow.pm.in b/lib/Stow.pm.in index 3c4f7b2..df62bf3 100755 --- a/lib/Stow.pm.in +++ b/lib/Stow.pm.in @@ -894,7 +894,7 @@ sub unstow_node { } #===== METHOD =============================================================== -# Name : path_owned_by_package() +# Name : link_owned_by_package() # Purpose : determine whether the given link points to a member of a # : stowed package # Parameters: $target => path to a symbolic link under current directory @@ -903,7 +903,7 @@ sub unstow_node { # Throws : n/a # Comments : lossy wrapper around find_stowed_path() #============================================================================ -sub path_owned_by_package { +sub link_owned_by_package { my $self = shift; my ($target, $source) = @_; @@ -1046,7 +1046,7 @@ sub cleanup_invalid_links { "checking whether valid link $node_path -> $source is " . "owned by stow"); - if ($self->path_owned_by_package($node_path, $source)) { + if ($self->link_owned_by_package($node_path, $source)) { # owned by stow debug(2, 0, "--- removing stale link: $node_path => " . join_paths($dir, $source)); @@ -1118,7 +1118,7 @@ sub foldable { $parent =~ s{\A\.\./}{}; # If the resulting path is owned by stow, we can fold it - if ($self->path_owned_by_package($target, $parent)) { + if ($self->link_owned_by_package($target, $parent)) { debug(3, 3, "$target is foldable"); return $parent; } From 208f3835801bde2f0e9577c8f2b5459106736731 Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Wed, 11 Nov 2020 17:13:47 +0000 Subject: [PATCH 348/482] Further improve debug output --- lib/Stow.pm.in | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/lib/Stow.pm.in b/lib/Stow.pm.in index df62bf3..f7c4d60 100755 --- a/lib/Stow.pm.in +++ b/lib/Stow.pm.in @@ -595,7 +595,7 @@ sub marked_stow_dir { my ($target) = @_; for my $f (".stow", ".nonstow") { if (-e join_paths($target, $f)) { - debug(4, 0, "$target contained $f"); + debug(4, 2, "$target contained $f"); return 1; } } @@ -802,12 +802,12 @@ sub unstow_node { my $path = join_paths($stow_path, $package, $target); - debug(3, 0, "Unstowing $path"); - debug(4, 1, "target is $target"); + debug(3, 1, "Unstowing $path"); + debug(4, 2, "target is $target"); # Does the target exist? if ($self->is_a_link($target)) { - debug(4, 1, "Evaluate existing link: $target"); + debug(4, 2, "Evaluate existing link: $target"); # Where is the link pointing? my $existing_source = $self->read_a_link($target); @@ -870,7 +870,7 @@ sub unstow_node { } } elsif (-e $target) { - debug(4, 1, "Evaluate existing node: $target"); + debug(4, 2, "Evaluate existing node: $target"); if (-d $target) { $self->unstow_contents($stow_path, $package, $target); @@ -888,7 +888,7 @@ sub unstow_node { } } else { - debug(2, 0, "$target did not exist to be unstowed"); + debug(2, 1, "$target did not exist to be unstowed"); } return; } @@ -1004,7 +1004,7 @@ sub cleanup_invalid_links { my ($dir) = @_; my $cwd = getcwd(); - debug(2, 1, "cleanup_invalid_links for $dir (pwd=$cwd)"); + debug(2, 0, "Cleaning up any invalid links in $dir (pwd=$cwd)"); if (not -d $dir) { error("cleanup_invalid_links() called with a non-directory: $dir"); @@ -1024,7 +1024,7 @@ sub cleanup_invalid_links { next unless -l $node_path; - debug(2, 2, "checking validity of link $node_path"); + debug(4, 1, "Checking validity of link $node_path"); if (exists $self->{link_task_for}{$node_path}) { die "huh? link_task_for $node_path"; @@ -1038,12 +1038,12 @@ sub cleanup_invalid_links { } if (-e join_paths($dir, $source)) { - debug(4, 3, "link target $source exists; skipping clean up"); + debug(4, 2, "Link target $source exists; skipping clean up"); next; } - debug(2, 2, - "checking whether valid link $node_path -> $source is " . + debug(3, 1, + "Checking whether valid link $node_path -> $source is " . "owned by stow"); if ($self->link_owned_by_package($node_path, $source)) { @@ -1713,7 +1713,7 @@ sub is_a_dir { sub is_a_node { my $self = shift; my ($path) = @_; - debug(4, 1, "is_a_node($path)"); + debug(4, 1, "Checking whether $path is a current/planned node"); my $laction = $self->link_task_action($path); my $daction = $self->dir_task_action($path); From c0c01a6c61befd0036e5abaec220c57916f9b698 Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Wed, 11 Nov 2020 17:13:57 +0000 Subject: [PATCH 349/482] cleanup_invalid_links: improve handling of scheduled actions --- lib/Stow.pm.in | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/lib/Stow.pm.in b/lib/Stow.pm.in index f7c4d60..2553546 100755 --- a/lib/Stow.pm.in +++ b/lib/Stow.pm.in @@ -1027,7 +1027,14 @@ sub cleanup_invalid_links { debug(4, 1, "Checking validity of link $node_path"); if (exists $self->{link_task_for}{$node_path}) { - die "huh? link_task_for $node_path"; + my $action = $self->{link_task_for}{$node_path}{action}; + if ($action ne 'remove') { + warn "Unexpected action $action scheduled for $node_path; skipping clean-up\n"; + } + else { + debug(4, 2, "$node_path scheduled for removal; skipping clean-up"); + } + next; } # Where is the link pointing? From e76dda400af08a5dc8ab6982abf71660904018ba Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Wed, 11 Nov 2020 18:19:43 +0000 Subject: [PATCH 350/482] Skip unnecessary planning --- lib/Stow.pm.in | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/lib/Stow.pm.in b/lib/Stow.pm.in index 2553546..16d6bc0 100755 --- a/lib/Stow.pm.in +++ b/lib/Stow.pm.in @@ -265,6 +265,10 @@ sub plan_unstow { my $self = shift; my @packages = @_; + return unless @packages; + + debug(2, 0, "Planning unstow of: @packages ..."); + $self->within_target_do(sub { for my $package (@packages) { my $path = join_paths($self->{stow_path}, $package); @@ -304,6 +308,10 @@ sub plan_stow { my $self = shift; my @packages = @_; + return unless @packages; + + debug(2, 0, "Planning stow of: @packages ..."); + $self->within_target_do(sub { for my $package (@packages) { my $path = join_paths($self->{stow_path}, $package); From 134e448aec28c64498bf77e8c0655d28e0d91b2a Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Wed, 11 Nov 2020 18:42:21 +0000 Subject: [PATCH 351/482] NEWS: set org-blank-before-new-entry --- NEWS | 1 + 1 file changed, 1 insertion(+) diff --git a/NEWS b/NEWS index 8d85cd2..37adbef 100644 --- a/NEWS +++ b/NEWS @@ -586,4 +586,5 @@ due to Stow::Util missing $VERSION. org-export-with-toc: nil org-export-with-author: nil org-toc-odd-levels-only: t + org-blank-before-new-entry: ((heading . auto) (plain-list-item . auto)) End: From a3f526edc2e6eda39b5893f7535835d1070d1ce1 Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Wed, 11 Nov 2020 18:51:22 +0000 Subject: [PATCH 352/482] NEWS: update for 2.3.2 --- NEWS | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/NEWS b/NEWS index 37adbef..398d2ab 100644 --- a/NEWS +++ b/NEWS @@ -1,5 +1,36 @@ News file for Stow. +* Changes in version 2.3.2 + +*** Improved debug output + + Extra output resulting from use of the -v / --verbose flag + now appears in a more logical and understandable way. + +*** Minor janitorial tasks + + Users are not substantially affected by these behind-the-scenes + changes. + +***** Removed texinfo.tex from the distribution + + This eliminates existing and future bit-rot. + +***** Updated aclocal.m4 from 1.15.1 to 1.16.2 + + This only updates copyright notices to 2020, and URLs to https. + +***** Replace broken gmane links with links to lists.gnu.org + + [[https://lars.ingebrigtsen.no/2020/01/06/whatever-happened-to-news-gmane-org/][gmane has been dead for quite a while.]] + +***** Add support for source navigation in emacs via [[https://github.com/jacktasia/dumb-jump][dumb-jump]]. + +*** Various maintainer tweaks + + Further improved the release process and its documentation in + various minor ways. + * Changes in version 2.3.1 *** Remove dependencies on Hash::Merge and Clone::Choose @@ -138,6 +169,7 @@ News file for Stow. consistency. - INSTALL.md now also documents how to build directly from git. + *** Fixes for bugs, tests, and other technical debt ***** Add Docker files for convenient testing across multiple Perl versions From 5b0efb3757205b8ad6cf3d9f0a9eaaca50b60142 Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Wed, 11 Nov 2020 19:24:09 +0000 Subject: [PATCH 353/482] AUTHORS: mention THANKS file --- AUTHORS | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/AUTHORS b/AUTHORS index 58d7ad1..1e98122 100644 --- a/AUTHORS +++ b/AUTHORS @@ -1,3 +1,7 @@ +This file documents the high-level history of Stow, and some of its +major contributors. See also the THANKS file for a more complete list +of contributors. + Stow was originally written by Bob Glickstein , Zanshin Software, Inc. From 205158a528109ed178eb10949b915aca7b07b337 Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Wed, 11 Nov 2020 19:24:59 +0000 Subject: [PATCH 354/482] manual: request --verbose=5 for bug reports --- doc/stow.texi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/stow.texi b/doc/stow.texi index 0b00860..015d37b 100644 --- a/doc/stow.texi +++ b/doc/stow.texi @@ -1287,7 +1287,7 @@ the precise command you gave; @item the output from the command (preferably verbose output, obtained by -adding @samp{--verbose=3} to the Stow command line). +adding @samp{--verbose=5} to the Stow command line). @end itemize If you are really keen, consider developing a minimal test case and From 64e0dc8793d657ebf96f8105aa3b9fef46664a76 Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Wed, 11 Nov 2020 19:36:38 +0000 Subject: [PATCH 355/482] Beef up README.md and add CONTRIBUTING.md --- CONTRIBUTING.md | 46 ++++++++++++++++++++++++++++++++++++ NEWS | 7 ++++-- README.md | 62 +++++++++++++++++++++++++++++++++++++++---------- doc/stow.texi | 5 ++-- 4 files changed, 104 insertions(+), 16 deletions(-) create mode 100644 CONTRIBUTING.md diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 0000000..983f7b9 --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,46 @@ +Contributing to GNU Stow +======================== + +Development of Stow, and GNU in general, is a volunteer effort, and +you can contribute. If you'd like to get involved, it's a good idea to join +the [stow-devel](https://lists.gnu.org/mailman/listinfo/stow-devel) +mailing list. + +Bug reporting +------------- + +Please follow the procedure described in [the "Reporting Bugs" +section](https://www.gnu.org/software/stow/manual/html_node/Reporting-Bugs.html#Reporting-Bugs) +of [the manual](README.md#documentation). + +Development +----------- + +For [development sources](https://savannah.gnu.org/git/?group=stow) +and other information, please see the [Stow project +page](http://savannah.gnu.org/projects/stow/) at +[savannah.gnu.org](http://savannah.gnu.org). + +There is also a +[stow-devel](https://lists.gnu.org/mailman/listinfo/stow-devel) +mailing list (see [Mailing lists](README.md#mailing-lists)). + +Translating Stow +---------------- + +Stow is not currently multi-lingual, but patches would be very +gratefully accepted. Please e-mail +[stow-devel](https://lists.gnu.org/mailman/listinfo/stow-devel) if you +intend to work on this. + +Maintainers +----------- + +Stow is currently being maintained by Adam Spiers. Please use [the +mailing lists](README.md#mailing-lists). + +Helping the GNU project +----------------------- + +For more general information, please read [How to help +GNU](https://www.gnu.org/help/). diff --git a/NEWS b/NEWS index 398d2ab..0aa80f1 100644 --- a/NEWS +++ b/NEWS @@ -9,8 +9,11 @@ News file for Stow. *** Minor janitorial tasks - Users are not substantially affected by these behind-the-scenes - changes. + Users are not substantially affected by these changes. + +***** Added some more information from the web page to the README + +***** Added a CONTRIBUTING.md file ***** Removed texinfo.tex from the distribution diff --git a/README.md b/README.md index 525a573..d91c9a4 100644 --- a/README.md +++ b/README.md @@ -60,6 +60,56 @@ You can get the latest information about Stow from the home page: http://www.gnu.org/software/stow/ +Installation +------------ + +See [`INSTALL.md`](INSTALL.md) for installation instructions. + +Documentation +------------- + +Documentation for Stow is available +[online](https://www.gnu.org/software/stow/manual/), as is +[documentation for most GNU +software](https://www.gnu.org/software/manual/). Once you have Stow +installed, you may also find more information about Stow by running +`info stow` or `man stow`, or by looking at `/usr/share/doc/stow/`, +`/usr/local/doc/stow/`, or similar directories on your system. A +brief summary is available by running `stow --help`. + +Mailing lists +------------- + +Stow has the following mailing lists: + +- [help-stow](https://lists.gnu.org/mailman/listinfo/help-stow) is for + general user help and discussion. +- [stow-devel](https://lists.gnu.org/mailman/listinfo/stow-devel) is + used to discuss most aspects of Stow, including development and + enhancement requests. +- [bug-stow](https://lists.gnu.org/mailman/listinfo/bug-stow) is for + bug reports. + +Announcements about Stow are posted to +[info-stow](http://lists.gnu.org/mailman/listinfo/info-stow) and also, +as with most other GNU software, to +[info-gnu](http://lists.gnu.org/mailman/listinfo/info-gnu) +([archive](http://lists.gnu.org/archive/html/info-gnu/)). + +Security reports that should not be made immediately public can be +sent directly to the maintainer. If there is no response to an urgent +issue, you can escalate to the general +[security](http://lists.gnu.org/mailman/listinfo/security) mailing +list for advice. + +The Savannah project also has a [mailing +lists](https://savannah.gnu.org/mail/?group=stow) page. + +Getting involved +---------------- + +Please see the [`CONTRIBUTING.md` file](CONTRIBUTING.md). + License ------- @@ -71,18 +121,6 @@ are permitted in any medium without royalty provided the copyright notice and this notice are preserved. This file is offered as-is, without any warranty. -Installation ------------- - -See [`INSTALL.md`](INSTALL.md) for installation instructions. - -Feedback --------- - -Please do send comments, questions, and constructive criticism. The -mailing lists and any other communication channels are detailed on the -above home page. - Brief history and authorship ---------------------------- diff --git a/doc/stow.texi b/doc/stow.texi index 015d37b..3b840a1 100644 --- a/doc/stow.texi +++ b/doc/stow.texi @@ -1291,8 +1291,9 @@ adding @samp{--verbose=5} to the Stow command line). @end itemize If you are really keen, consider developing a minimal test case and -creating a new test. See the @file{t/} directory in the source for -lots of examples. +creating a new test. See the @file{t/} directory in the source for lots +of examples, and the @file{CONTRIBUTING.md} file for a guide on how to +contribute. Before reporting a bug, please read the manual carefully, especially @ref{Known Bugs}, to see whether you're encountering From 6870e96873452b19b9b76b85d028d9c6d4740395 Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Wed, 11 Nov 2020 19:41:38 +0000 Subject: [PATCH 356/482] CONTRIBUTING: Add a section on how to run the tests --- CONTRIBUTING.md | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 983f7b9..d8c82dd 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -25,6 +25,23 @@ There is also a [stow-devel](https://lists.gnu.org/mailman/listinfo/stow-devel) mailing list (see [Mailing lists](README.md#mailing-lists)). +Testing +~~~~~~~ + +The test suite can be found in the [`t/`](t/) subdirectory. You can +run the test suite via: + + make check + +Individual tests can be run as follows: + + perl -It t/stow.t + +or with a given debugging verbosity corresponding to the `-v` / `--verbose` +command-line option: + + TEST_VERBOSE=4 perl -It t/stow.t + Translating Stow ---------------- From ee240c5bf20deb5a246b7b05a69adfb882c75549 Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Wed, 11 Nov 2020 19:42:28 +0000 Subject: [PATCH 357/482] cleanup_invalid_links: it's a bug if called with a non-directory --- lib/Stow.pm.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Stow.pm.in b/lib/Stow.pm.in index 16d6bc0..fe34f1c 100755 --- a/lib/Stow.pm.in +++ b/lib/Stow.pm.in @@ -1015,7 +1015,7 @@ sub cleanup_invalid_links { debug(2, 0, "Cleaning up any invalid links in $dir (pwd=$cwd)"); if (not -d $dir) { - error("cleanup_invalid_links() called with a non-directory: $dir"); + internal_error("cleanup_invalid_links() called with a non-directory: $dir"); } opendir my $DIR, $dir From a829eeb4a01e2f39c1804c99133597d385bffa7e Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Sun, 4 Apr 2021 17:34:46 +0100 Subject: [PATCH 358/482] Upgrade aclocal to 1.16.3 --- NEWS | 4 ++-- aclocal.m4 | 15 +++++---------- 2 files changed, 7 insertions(+), 12 deletions(-) diff --git a/NEWS b/NEWS index 0aa80f1..c53efd6 100644 --- a/NEWS +++ b/NEWS @@ -19,9 +19,9 @@ News file for Stow. This eliminates existing and future bit-rot. -***** Updated aclocal.m4 from 1.15.1 to 1.16.2 +***** Updated aclocal.m4 from 1.15.1 to 1.16.3 - This only updates copyright notices to 2020, and URLs to https. + This mostly just updates copyright notices to 2020, and URLs to https. ***** Replace broken gmane links with links to lists.gnu.org diff --git a/aclocal.m4 b/aclocal.m4 index a5dbd09..489e952 100644 --- a/aclocal.m4 +++ b/aclocal.m4 @@ -1,4 +1,4 @@ -# generated automatically by aclocal 1.16.2 -*- Autoconf -*- +# generated automatically by aclocal 1.16.3 -*- Autoconf -*- # Copyright (C) 1996-2020 Free Software Foundation, Inc. @@ -35,7 +35,7 @@ AC_DEFUN([AM_AUTOMAKE_VERSION], [am__api_version='1.16' dnl Some users find AM_AUTOMAKE_VERSION and mistake it for a way to dnl require some minimum version. Point them to the right macro. -m4_if([$1], [1.16.2], [], +m4_if([$1], [1.16.3], [], [AC_FATAL([Do not call $0, use AM_INIT_AUTOMAKE([$1]).])])dnl ]) @@ -51,7 +51,7 @@ m4_define([_AM_AUTOCONF_VERSION], []) # Call AM_AUTOMAKE_VERSION and AM_AUTOMAKE_VERSION so they can be traced. # This function is AC_REQUIREd by AM_INIT_AUTOMAKE. AC_DEFUN([AM_SET_CURRENT_AUTOMAKE_VERSION], -[AM_AUTOMAKE_VERSION([1.16.2])dnl +[AM_AUTOMAKE_VERSION([1.16.3])dnl m4_ifndef([AC_AUTOCONF_VERSION], [m4_copy([m4_PACKAGE_VERSION], [AC_AUTOCONF_VERSION])])dnl _AM_AUTOCONF_VERSION(m4_defn([AC_AUTOCONF_VERSION]))]) @@ -174,7 +174,7 @@ m4_ifval([$3], [_AM_SET_OPTION([no-define])])dnl [_AM_SET_OPTIONS([$1])dnl dnl Diagnose old-style AC_INIT with new-style AM_AUTOMAKE_INIT. m4_if( - m4_ifdef([AC_PACKAGE_NAME], [ok]):m4_ifdef([AC_PACKAGE_VERSION], [ok]), + m4_ifset([AC_PACKAGE_NAME], [ok]):m4_ifset([AC_PACKAGE_VERSION], [ok]), [ok:ok],, [m4_fatal([AC_INIT should be called with package and version arguments])])dnl AC_SUBST([PACKAGE], ['AC_PACKAGE_TARNAME'])dnl @@ -370,12 +370,7 @@ AC_DEFUN([AM_MISSING_HAS_RUN], [AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl AC_REQUIRE_AUX_FILE([missing])dnl if test x"${MISSING+set}" != xset; then - case $am_aux_dir in - *\ * | *\ *) - MISSING="\${SHELL} \"$am_aux_dir/missing\"" ;; - *) - MISSING="\${SHELL} $am_aux_dir/missing" ;; - esac + MISSING="\${SHELL} '$am_aux_dir/missing'" fi # Use eval to expand $SHELL if eval "$MISSING --is-lightweight"; then From 6f76606390886a6b24dbc183ead21271cc68bb31 Mon Sep 17 00:00:00 2001 From: Ilya Grigoriev Date: Fri, 12 Aug 2022 20:43:56 -0700 Subject: [PATCH 359/482] Add .gitmodules to the default ignore list --- default-ignore-list | 1 + 1 file changed, 1 insertion(+) diff --git a/default-ignore-list b/default-ignore-list index 17bf13d..0ebf4fb 100644 --- a/default-ignore-list +++ b/default-ignore-list @@ -13,6 +13,7 @@ _darcs \.git \.gitignore +\.gitmodules .+~ # emacs backup files \#.*\# # emacs autosave files From a6391cd291b5b1933d71dea8497970ed050adb9b Mon Sep 17 00:00:00 2001 From: Danielle McLean Date: Mon, 23 Oct 2023 14:02:03 +1100 Subject: [PATCH 360/482] Save upgraded aclocal.m4 produced by autoreconf -vi --- aclocal.m4 | 71 ++++++++++++++++++++++++++++++++---------------------- 1 file changed, 42 insertions(+), 29 deletions(-) diff --git a/aclocal.m4 b/aclocal.m4 index 9ad3397..6d04fca 100644 --- a/aclocal.m4 +++ b/aclocal.m4 @@ -1,6 +1,6 @@ -# generated automatically by aclocal 1.15.1 -*- Autoconf -*- +# generated automatically by aclocal 1.16.5 -*- Autoconf -*- -# Copyright (C) 1996-2017 Free Software Foundation, Inc. +# Copyright (C) 1996-2021 Free Software Foundation, Inc. # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -14,13 +14,13 @@ m4_ifndef([AC_CONFIG_MACRO_DIRS], [m4_defun([_AM_CONFIG_MACRO_DIRS], [])m4_defun([AC_CONFIG_MACRO_DIRS], [_AM_CONFIG_MACRO_DIRS($@)])]) m4_ifndef([AC_AUTOCONF_VERSION], [m4_copy([m4_PACKAGE_VERSION], [AC_AUTOCONF_VERSION])])dnl -m4_if(m4_defn([AC_AUTOCONF_VERSION]), [2.69],, -[m4_warning([this file was generated for autoconf 2.69. +m4_if(m4_defn([AC_AUTOCONF_VERSION]), [2.71],, +[m4_warning([this file was generated for autoconf 2.71. You have another version of autoconf. It may work, but is not guaranteed to. If you have problems, you may need to regenerate the build system entirely. To do so, use the procedure documented by the package, typically 'autoreconf'.])]) -# Copyright (C) 2002-2017 Free Software Foundation, Inc. +# Copyright (C) 2002-2021 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -32,10 +32,10 @@ To do so, use the procedure documented by the package, typically 'autoreconf'.]) # generated from the m4 files accompanying Automake X.Y. # (This private macro should not be called outside this file.) AC_DEFUN([AM_AUTOMAKE_VERSION], -[am__api_version='1.15' +[am__api_version='1.16' dnl Some users find AM_AUTOMAKE_VERSION and mistake it for a way to dnl require some minimum version. Point them to the right macro. -m4_if([$1], [1.15.1], [], +m4_if([$1], [1.16.5], [], [AC_FATAL([Do not call $0, use AM_INIT_AUTOMAKE([$1]).])])dnl ]) @@ -51,14 +51,14 @@ m4_define([_AM_AUTOCONF_VERSION], []) # Call AM_AUTOMAKE_VERSION and AM_AUTOMAKE_VERSION so they can be traced. # This function is AC_REQUIREd by AM_INIT_AUTOMAKE. AC_DEFUN([AM_SET_CURRENT_AUTOMAKE_VERSION], -[AM_AUTOMAKE_VERSION([1.15.1])dnl +[AM_AUTOMAKE_VERSION([1.16.5])dnl m4_ifndef([AC_AUTOCONF_VERSION], [m4_copy([m4_PACKAGE_VERSION], [AC_AUTOCONF_VERSION])])dnl _AM_AUTOCONF_VERSION(m4_defn([AC_AUTOCONF_VERSION]))]) # AM_AUX_DIR_EXPAND -*- Autoconf -*- -# Copyright (C) 2001-2017 Free Software Foundation, Inc. +# Copyright (C) 2001-2021 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -110,7 +110,7 @@ am_aux_dir=`cd "$ac_aux_dir" && pwd` # Do all the work for Automake. -*- Autoconf -*- -# Copyright (C) 1996-2017 Free Software Foundation, Inc. +# Copyright (C) 1996-2021 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -138,6 +138,10 @@ m4_defn([AC_PROG_CC]) # release and drop the old call support. AC_DEFUN([AM_INIT_AUTOMAKE], [AC_PREREQ([2.65])dnl +m4_ifdef([_$0_ALREADY_INIT], + [m4_fatal([$0 expanded multiple times +]m4_defn([_$0_ALREADY_INIT]))], + [m4_define([_$0_ALREADY_INIT], m4_expansion_stack)])dnl dnl Autoconf wants to disallow AM_ names. We explicitly allow dnl the ones we care about. m4_pattern_allow([^AM_[A-Z]+FLAGS$])dnl @@ -174,7 +178,7 @@ m4_ifval([$3], [_AM_SET_OPTION([no-define])])dnl [_AM_SET_OPTIONS([$1])dnl dnl Diagnose old-style AC_INIT with new-style AM_AUTOMAKE_INIT. m4_if( - m4_ifdef([AC_PACKAGE_NAME], [ok]):m4_ifdef([AC_PACKAGE_VERSION], [ok]), + m4_ifset([AC_PACKAGE_NAME], [ok]):m4_ifset([AC_PACKAGE_VERSION], [ok]), [ok:ok],, [m4_fatal([AC_INIT should be called with package and version arguments])])dnl AC_SUBST([PACKAGE], ['AC_PACKAGE_TARNAME'])dnl @@ -197,8 +201,8 @@ AC_REQUIRE([AM_PROG_INSTALL_STRIP])dnl AC_REQUIRE([AC_PROG_MKDIR_P])dnl # For better backward compatibility. To be removed once Automake 1.9.x # dies out for good. For more background, see: -# -# +# +# AC_SUBST([mkdir_p], ['$(MKDIR_P)']) # We need awk for the "check" target (and possibly the TAP driver). The # system "awk" is bad on some platforms. @@ -226,6 +230,20 @@ AC_PROVIDE_IFELSE([AC_PROG_OBJCXX], [m4_define([AC_PROG_OBJCXX], m4_defn([AC_PROG_OBJCXX])[_AM_DEPENDENCIES([OBJCXX])])])dnl ]) +# Variables for tags utilities; see am/tags.am +if test -z "$CTAGS"; then + CTAGS=ctags +fi +AC_SUBST([CTAGS]) +if test -z "$ETAGS"; then + ETAGS=etags +fi +AC_SUBST([ETAGS]) +if test -z "$CSCOPE"; then + CSCOPE=cscope +fi +AC_SUBST([CSCOPE]) + AC_REQUIRE([AM_SILENT_RULES])dnl dnl The testsuite driver may need to know about EXEEXT, so add the dnl 'am__EXEEXT' conditional if _AM_COMPILER_EXEEXT was seen. This @@ -265,7 +283,7 @@ END Aborting the configuration process, to ensure you take notice of the issue. You can download and install GNU coreutils to get an 'rm' implementation -that behaves properly: . +that behaves properly: . If you want to complete the configuration process using your problematic 'rm' anyway, export the environment variable ACCEPT_INFERIOR_RM_PROGRAM @@ -307,7 +325,7 @@ for _am_header in $config_headers :; do done echo "timestamp for $_am_arg" >`AS_DIRNAME(["$_am_arg"])`/stamp-h[]$_am_stamp_count]) -# Copyright (C) 2001-2017 Free Software Foundation, Inc. +# Copyright (C) 2001-2021 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -328,7 +346,7 @@ if test x"${install_sh+set}" != xset; then fi AC_SUBST([install_sh])]) -# Copyright (C) 2003-2017 Free Software Foundation, Inc. +# Copyright (C) 2003-2021 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -349,7 +367,7 @@ AC_SUBST([am__leading_dot])]) # Fake the existence of programs that GNU maintainers use. -*- Autoconf -*- -# Copyright (C) 1997-2017 Free Software Foundation, Inc. +# Copyright (C) 1997-2021 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -370,12 +388,7 @@ AC_DEFUN([AM_MISSING_HAS_RUN], [AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl AC_REQUIRE_AUX_FILE([missing])dnl if test x"${MISSING+set}" != xset; then - case $am_aux_dir in - *\ * | *\ *) - MISSING="\${SHELL} \"$am_aux_dir/missing\"" ;; - *) - MISSING="\${SHELL} $am_aux_dir/missing" ;; - esac + MISSING="\${SHELL} '$am_aux_dir/missing'" fi # Use eval to expand $SHELL if eval "$MISSING --is-lightweight"; then @@ -388,7 +401,7 @@ fi # Helper functions for option handling. -*- Autoconf -*- -# Copyright (C) 2001-2017 Free Software Foundation, Inc. +# Copyright (C) 2001-2021 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -419,7 +432,7 @@ AC_DEFUN([_AM_IF_OPTION], # Check to make sure that the build environment is sane. -*- Autoconf -*- -# Copyright (C) 1996-2017 Free Software Foundation, Inc. +# Copyright (C) 1996-2021 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -500,7 +513,7 @@ AC_CONFIG_COMMANDS_PRE( rm -f conftest.file ]) -# Copyright (C) 2009-2017 Free Software Foundation, Inc. +# Copyright (C) 2009-2021 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -560,7 +573,7 @@ AC_SUBST([AM_BACKSLASH])dnl _AM_SUBST_NOTMAKE([AM_BACKSLASH])dnl ]) -# Copyright (C) 2001-2017 Free Software Foundation, Inc. +# Copyright (C) 2001-2021 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -588,7 +601,7 @@ fi INSTALL_STRIP_PROGRAM="\$(install_sh) -c -s" AC_SUBST([INSTALL_STRIP_PROGRAM])]) -# Copyright (C) 2006-2017 Free Software Foundation, Inc. +# Copyright (C) 2006-2021 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -607,7 +620,7 @@ AC_DEFUN([AM_SUBST_NOTMAKE], [_AM_SUBST_NOTMAKE($@)]) # Check how to create a tarball. -*- Autoconf -*- -# Copyright (C) 2004-2017 Free Software Foundation, Inc. +# Copyright (C) 2004-2021 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, From 47634b9cf1f80a200e080c417719c7367fdff4be Mon Sep 17 00:00:00 2001 From: Danielle McLean Date: Mon, 23 Oct 2023 14:38:27 +1100 Subject: [PATCH 361/482] Support relative --with-pmdir by using FindBin --- Makefile.am | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Makefile.am b/Makefile.am index 7748399..22cd470 100644 --- a/Makefile.am +++ b/Makefile.am @@ -116,11 +116,14 @@ edit = sed -e 's|[@]PERL[@]|$(PERL)|g' \ pmdir_in_INC = \ PERL5LIB= $(PERL) -V | \ awk '/@INC/ {p=1; next} p==1 {print $$1}' | \ - grep -q "$(pmdir)" + grep -F -q "$(pmdir)" calc_use_lib_pmdir = \ + pmdir="$(pmdir)"; \ if $(pmdir_in_INC); then \ use_lib_pmdir=""; \ + elif [ "$${pmdir\#../}" != "$$pmdir" ]; then \ + use_lib_pmdir="use FindBin; use lib \"\$$FindBin::Bin/$$pmdir\";"; \ else \ use_lib_pmdir="use lib \"$(pmdir)\";"; \ fi From 70b6c6cd9eeda4a4330bc7373d542baf45f293a0 Mon Sep 17 00:00:00 2001 From: Danielle McLean Date: Mon, 23 Oct 2023 14:54:38 +1100 Subject: [PATCH 362/482] Prerelease v2.3.2-fixbug56727 --- META.json | 6 +++--- META.yml | 6 +++--- configure.ac | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/META.json b/META.json index 3509018..7c582ce 100644 --- a/META.json +++ b/META.json @@ -37,11 +37,11 @@ "provides" : { "Stow" : { "file" : "lib/Stow.pm", - "version" : "v2.3.2" + "version" : "v2.3.2-fixbug56727" }, "Stow::Util" : { "file" : "lib/Stow/Util.pm", - "version" : "v2.3.2" + "version" : "v2.3.2-fixbug56727" } }, "release_status" : "stable", @@ -55,6 +55,6 @@ "url" : "git://git.savannah.gnu.org/stow.git" } }, - "version" : "v2.3.2", + "version" : "v2.3.2-fixbug56727", "x_serialization_backend" : "JSON::PP version 4.00" } diff --git a/META.yml b/META.yml index 9385103..f7da35a 100644 --- a/META.yml +++ b/META.yml @@ -18,10 +18,10 @@ name: Stow provides: Stow: file: lib/Stow.pm - version: v2.3.2 + version: v2.3.2-fixbug56727 Stow::Util: file: lib/Stow/Util.pm - version: v2.3.2 + version: v2.3.2-fixbug56727 requires: Carp: '0' IO::File: '0' @@ -30,5 +30,5 @@ resources: homepage: https://savannah.gnu.org/projects/stow license: http://www.gnu.org/licenses/gpl-2.0.html repository: git://git.savannah.gnu.org/stow.git -version: v2.3.2 +version: v2.3.2-fixbug56727 x_serialization_backend: 'CPAN::Meta::YAML version 0.018' diff --git a/configure.ac b/configure.ac index cd7dc4f..bcd66eb 100644 --- a/configure.ac +++ b/configure.ac @@ -15,7 +15,7 @@ dnl along with this program. If not, see https://www.gnu.org/licenses/. dnl Process this file with Autoconf to produce configure dnl -AC_INIT([stow], [2.3.2], [bug-stow@gnu.org]) +AC_INIT([stow], [2.3.2-fixbug56727], [bug-stow@gnu.org]) AC_PREREQ([2.61]) AC_CONFIG_AUX_DIR([automake]) # Unfortunately we have to disable warnings for overrides, because we From 51e303a7980ee863cd2e2bb169fd8cfbc1903571 Mon Sep 17 00:00:00 2001 From: Danielle McLean Date: Mon, 23 Oct 2023 16:13:57 +1100 Subject: [PATCH 363/482] Add explict --enable-relative ./configure flag for using FindBin --- Makefile.am | 8 ++++---- configure.ac | 10 ++++++++++ 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/Makefile.am b/Makefile.am index 22cd470..ab99056 100644 --- a/Makefile.am +++ b/Makefile.am @@ -116,14 +116,14 @@ edit = sed -e 's|[@]PERL[@]|$(PERL)|g' \ pmdir_in_INC = \ PERL5LIB= $(PERL) -V | \ awk '/@INC/ {p=1; next} p==1 {print $$1}' | \ - grep -F -q "$(pmdir)" + grep -F -x -q "$(pmdir)" calc_use_lib_pmdir = \ pmdir="$(pmdir)"; \ - if $(pmdir_in_INC); then \ + if [ $(FINDBIN) = yes ]; then \ + use_lib_pmdir="use FindBin; use lib \"\$$FindBin::Bin/../$${pmdir\#$(prefix)/}\";"; \ + elif $(pmdir_in_INC); then \ use_lib_pmdir=""; \ - elif [ "$${pmdir\#../}" != "$$pmdir" ]; then \ - use_lib_pmdir="use FindBin; use lib \"\$$FindBin::Bin/$$pmdir\";"; \ else \ use_lib_pmdir="use lib \"$(pmdir)\";"; \ fi diff --git a/configure.ac b/configure.ac index bcd66eb..0869e17 100644 --- a/configure.ac +++ b/configure.ac @@ -70,6 +70,15 @@ AC_ARG_WITH( [Install Perl modules in DIR]), [PMDIR=${withval}], [PMDIR='${prefix}'/"$pmdir_relative_path"]) + +AC_ARG_ENABLE( + [relative], + AS_HELP_STRING( + [--enable-relative], + [Load Stow modules relative to the main script]), + [FINDBIN="$enable_relative"], + [FINDBIN=no]) + AC_CONFIG_COMMANDS_POST([[ eval pmdir="$PMDIR" cat < Date: Sun, 4 Apr 2021 18:10:17 +0100 Subject: [PATCH 364/482] CONTRIBUTING: document how to test using prove(1) --- CONTRIBUTING.md | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index d8c82dd..0f73c83 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -33,14 +33,34 @@ run the test suite via: make check -Individual tests can be run as follows: +Tests can be run individually as follows. First you have to ensure +that the `t/`, `bin/`, and `lib/` directories are on Perl's search path. +Assuming that you run all tests from the root of the repository tree, +this will do the job: - perl -It t/stow.t + export PERL5LIB=t:bin:lib + +(Not all tests require all of these, but it's safer to include all of +them.) + +Now running an individual test is as simple as: + + perl t/chkstow.t or with a given debugging verbosity corresponding to the `-v` / `--verbose` command-line option: - TEST_VERBOSE=4 perl -It t/stow.t + TEST_VERBOSE=4 perl t/chkstow.t + +The [`prove(1)` test runner](https://perldoc.perl.org/prove) is another +good alternative which provides several handy extra features. Invocation +is very similar, e.g.: + + prove t/stow.t + +or to run the whole suite: + + prove Translating Stow ---------------- From 478c7b921de2d59aad513b8149b987733903a78e Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Sun, 4 Apr 2021 19:08:15 +0100 Subject: [PATCH 365/482] Add `watch` target to Makefile for easier hacking --- CONTRIBUTING.md | 20 ++++++++++++++++++++ Makefile.am | 25 +++++++++++++++++++++++++ NEWS | 5 +++++ 3 files changed, 50 insertions(+) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 0f73c83..39c4052 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -25,6 +25,22 @@ There is also a [stow-devel](https://lists.gnu.org/mailman/listinfo/stow-devel) mailing list (see [Mailing lists](README.md#mailing-lists)). +Please be aware that all program source files (excluding the test +suite) end in `.in`, and are pre-processed by `Makefile` into +corresponding files with that prefix stripped before execution. So if +you want to test any modifications to the source, make sure that you +change the `.in` files and then run `make` to regenerate the +pre-processed versions before doing any testing. To avoid forgetting +(which can potentially waste a lot of time debugging the wrong code), +you can automatically run `make` in an infinite loop every second via: + + make watch + +(You could even use fancier approaches like +[`inotifywait(1)`](https://www.man7.org/linux/man-pages/man1/inotifywait.1.html) +or [Guard](https://guardgem.org/). But those are probably overkill in +this case where the simple `while` loop is plenty good enough.) + Testing ~~~~~~~ @@ -43,6 +59,10 @@ this will do the job: (Not all tests require all of these, but it's safer to include all of them.) +Secondly, be aware that if you want to test modifications to the +source files, you will need to run `make watch`, or `make` before each +test run as explained above. + Now running an individual test is as simple as: perl t/chkstow.t diff --git a/Makefile.am b/Makefile.am index ec1a2bd..d5218eb 100644 --- a/Makefile.am +++ b/Makefile.am @@ -286,3 +286,28 @@ ChangeLog: doc/ChangeLog.OLD else \ echo "Not in a git repository; can't update ChangeLog."; \ fi + +# Watch for changes, and if any rebuilds are required, also do a +# make install. +# +# If we solved https://github.com/aspiers/stow/issues/84, we could +# probably ditch this: +watch: + @echo "Watching for changes to program source files ..." + @while true; do \ + if $(MAKE) 2>&1 | \ + grep -vE 'make\[[1-9]\]: (Entering|Leaving) directory ' | \ + grep -v 'Nothing to be done'; \ + then \ + echo; \ + echo "-----------------------------------------------------"; \ + echo "make found things to rebuild; doing $(MAKE) install ..."; \ + echo; \ + $(MAKE) install; \ + echo; \ + echo ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>"; \ + echo; \ + fi; \ + sleep 1; \ + done 2>&1 | \ + grep -vE 'make\[[1-9]\]: (Entering|Leaving) directory ' diff --git a/NEWS b/NEWS index c53efd6..40d433a 100644 --- a/NEWS +++ b/NEWS @@ -15,6 +15,11 @@ News file for Stow. ***** Added a CONTRIBUTING.md file +***** Add a =watch= target to =Makefile= + + =make watch= provides easy continual pre-processing during + development, which reduces the risk of debugging the wrong code. + ***** Removed texinfo.tex from the distribution This eliminates existing and future bit-rot. From 72140071ad486040d96b6365affad602a144224a Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Sun, 4 Apr 2021 22:52:22 +0100 Subject: [PATCH 366/482] manual: improve explanation of target directory definition Bring this more up to date by mentioning the dotfiles use case. --- NEWS | 2 ++ doc/stow.texi | 9 ++++++--- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/NEWS b/NEWS index 40d433a..72f53e9 100644 --- a/NEWS +++ b/NEWS @@ -13,6 +13,8 @@ News file for Stow. ***** Added some more information from the web page to the README +***** Made some small improvements to the documentation + ***** Added a CONTRIBUTING.md file ***** Add a =watch= target to =Makefile= diff --git a/doc/stow.texi b/doc/stow.texi index 3b840a1..a191d9e 100644 --- a/doc/stow.texi +++ b/doc/stow.texi @@ -220,9 +220,12 @@ to be installed in a particular directory structure --- e.g., with @cindex target directory A @dfn{target directory} is the root of a tree in which one or more -packages wish to @emph{appear} to be installed. A common, but by no -means the only such location is @file{/usr/local}. The examples in this -manual will use @file{/usr/local} as the target directory. +packages wish to @emph{appear} to be installed. @file{/usr/local} is a +common choice for this, but by no means the only such location. Another +common choice is @file{~} (i.e. the user's @code{$HOME} directory) in +the case where Stow is being used to manage the user's configuration +(``dotfiles'') and other files in their @code{$HOME}. The examples in +this manual will use @file{/usr/local} as the target directory. @cindex stow directory A @dfn{stow directory} is the root of a tree containing separate From a426a5979d0ec5be17b27ba1870e23b62a6bf87a Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Sun, 4 Apr 2021 23:31:35 +0100 Subject: [PATCH 367/482] testutil: clarify reason for default paths in new_Stow() --- t/testutil.pm | 2 ++ 1 file changed, 2 insertions(+) diff --git a/t/testutil.pm b/t/testutil.pm index ff1e6b4..a700bd5 100755 --- a/t/testutil.pm +++ b/t/testutil.pm @@ -81,6 +81,8 @@ sub init_test_dirs { sub new_Stow { my %opts = @_; + # These default paths assume that execution will be triggered from + # within the target directory. $opts{dir} ||= '../stow'; $opts{target} ||= '.'; $opts{test_mode} = 1; From cb4b0c6a9a966ddce4b96405066c78d50c6cf2b9 Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Sun, 4 Apr 2021 23:37:24 +0100 Subject: [PATCH 368/482] Remove trailing whitespace --- lib/Stow/Util.pm.in | 2 +- t/unstow_orig.t | 20 ++++++++++---------- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/lib/Stow/Util.pm.in b/lib/Stow/Util.pm.in index 497e7a3..f8f0cd4 100644 --- a/lib/Stow/Util.pm.in +++ b/lib/Stow/Util.pm.in @@ -186,7 +186,7 @@ sub parent { my $path = join '/', @_; my @elts = split m{/+}, $path; pop @elts; - return join '/', @elts; + return join '/', @elts; } #===== METHOD =============================================================== diff --git a/t/unstow_orig.t b/t/unstow_orig.t index 6d5ff8d..e0f595c 100755 --- a/t/unstow_orig.t +++ b/t/unstow_orig.t @@ -40,7 +40,7 @@ my %conflicts; # # unstow a simple tree minimally -# +# $stow = new_compat_Stow(); @@ -53,7 +53,7 @@ $stow->process_tasks(); ok( $stow->get_conflict_count == 0 && -f '../stow/pkg1/bin1/file1' && ! -e 'bin1' - => 'unstow a simple tree' + => 'unstow a simple tree' ); # @@ -70,7 +70,7 @@ $stow->process_tasks(); ok( $stow->get_conflict_count == 0 && -f '../stow/pkg2/lib2/file2' && -d 'lib2' - => 'unstow simple tree from a pre-existing directory' + => 'unstow simple tree from a pre-existing directory' ); # @@ -89,10 +89,10 @@ make_file('../stow/pkg3b/bin3/file3b'); make_link('bin3/file3b' => '../../stow/pkg3b/bin3/file3b'); # emulate stow $stow->plan_unstow('pkg3b'); $stow->process_tasks(); -ok( +ok( $stow->get_conflict_count == 0 && -l 'bin3' && - readlink('bin3') eq '../stow/pkg3a/bin3' + readlink('bin3') eq '../stow/pkg3a/bin3' => 'fold tree after unstowing' ); @@ -235,7 +235,7 @@ make_file('../stow/pkg9b/man9/man1/file9.1'); capture_stderr(); $stow->plan_unstow('pkg9b'); $stow->process_tasks(); -ok( +ok( $stow->get_conflict_count == 0 && !-l 'man9/man1/file9.1' => 'overriding existing documentation files' @@ -263,9 +263,9 @@ make_file('../stow/pkg10c/man10/man1/file10a.1'); capture_stderr(); $stow->plan_unstow('pkg10c'); is($stow->get_tasks, 0, 'no tasks to process when unstowing pkg10c'); -ok( +ok( $stow->get_conflict_count == 0 && - readlink('man10/man1/file10a.1') eq '../../../stow/pkg10a/man10/man1/file10a.1' + readlink('man10/man1/file10a.1') eq '../../../stow/pkg10a/man10/man1/file10a.1' => 'defer to existing documentation files' ); check_protected_dirs_skipped(); @@ -285,7 +285,7 @@ make_link('man12/man1/file12.1' => '../../../stow/pkg12/man12/man1/file12.1'); capture_stderr(); $stow->plan_unstow('pkg12'); $stow->process_tasks(); -ok( +ok( $stow->get_conflict_count == 0 && !-e 'man12/man1/file12.1' => 'ignore temp files' @@ -355,7 +355,7 @@ $stow->process_tasks(); ok( $stow->get_conflict_count == 0 && -f "$TEST_DIR/stow/pkg13/bin13/file13" && ! -e "$TEST_DIR/target/bin13" - => 'unstow a simple tree' + => 'unstow a simple tree' ); # From c30792270e452da82e380572a5b0de5d9bf904c7 Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Mon, 5 Apr 2021 15:33:44 +0100 Subject: [PATCH 369/482] manual: use @email{} for email addresses --- doc/stow.texi | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/doc/stow.texi b/doc/stow.texi index a191d9e..60364a8 100644 --- a/doc/stow.texi +++ b/doc/stow.texi @@ -19,13 +19,13 @@ This manual describes GNU Stow version @value{VERSION} Software and documentation is copyrighted by the following: -@copyright{} 1993, 1994, 1995, 1996 Bob Glickstein +@copyright{} 1993, 1994, 1995, 1996 Bob Glickstein @email{bobg+stow@@zanshin.com} @* -@copyright{} 2000, 2001 Guillaume Morin +@copyright{} 2000, 2001 Guillaume Morin @email{gmorin@@gnu.org} @* -@copyright{} 2007 Kahlil (Kal) Hodgson +@copyright{} 2007 Kahlil (Kal) Hodgson @email{kahlil@@internode.on.net} @* -@copyright{} 2011 Adam Spiers +@copyright{} 2011 Adam Spiers @email{stow@@adamspiers.org} @quotation Permission is granted to make and distribute verbatim copies of this From 2c7d3d47628e8799216f9f078f83a942e0d1029e Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Mon, 5 Apr 2021 15:35:13 +0100 Subject: [PATCH 370/482] manual: update the Reporting Bugs / Known Bugs sections --- doc/stow.texi | 50 +++++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 41 insertions(+), 9 deletions(-) diff --git a/doc/stow.texi b/doc/stow.texi index 60364a8..d57c7f6 100644 --- a/doc/stow.texi +++ b/doc/stow.texi @@ -1267,9 +1267,32 @@ perl/bin/perl stow/bin/stow -vv * @node Reporting Bugs, Known Bugs, Bootstrapping, Top @chapter Reporting Bugs -Please send bug reports to the current maintainers by electronic -mail. The address to use is @samp{}. Please -include: +You can report bugs to the current maintainers in one of three ways: + +@enumerate +@item +Send e-mail to @email{bug-stow@@gnu.org}. + +@item +File an issue in @uref{https://savannah.gnu.org/bugs/?group=stow, +the Savannah bug tracker}. + +@item +File an issue in +@uref{https://github.com/aspiers/stow/issues/, the GitHub project}. +@end enumerate + +While GitHub is arguably the most convenient of these three options, it +@uref{https://www.gnu.org/software/repo-criteria-evaluation.html#GitHub, +is not the most ethical or freedom-preserving way to host software +projects}. Therefore the GitHub project may be +@uref{https://github.com/aspiers/stow/issues/43, moved to a more ethical +hosting service} in the future. + +Before reporting a bug, it is recommended to check whether it is already +known, so please first @pxref{Known Bugs}. + +When reporting a new bug, please include: @itemize @bullet @item @@ -1307,13 +1330,22 @@ something that doesn't need reporting. @node Known Bugs, GNU General Public License, Reporting Bugs, Top @chapter Known Bugs -There are no known bugs in Stow version @value{VERSION}! -If you think you have found one, please @pxref{Reporting Bugs}. +Known bugs can be found in the following locations: -@c @itemize @bullet -@c @item -@c Put known bugs here -@c @end itemize +@itemize +@item +@uref{https://github.com/aspiers/stow/issues/, the GitHub issue tracker} + +@item +@uref{https://savannah.gnu.org/bugs/?group=stow, the Savannah bug +tracker} + +@item +the @uref{https://lists.gnu.org/archive/html/bug-stow/, bug-stow list +archives} +@end itemize + +If you think you have found a new bug, please @pxref{Reporting Bugs}. @c =========================================================================== @node GNU General Public License, Index, Known Bugs, Top From 5d4e68291e24558a51376cf218cca9a1142dfff1 Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Mon, 5 Apr 2021 15:36:36 +0100 Subject: [PATCH 371/482] testutil: Add sanity check for cwd --- t/testutil.pm | 2 ++ 1 file changed, 2 insertions(+) diff --git a/t/testutil.pm b/t/testutil.pm index a700bd5..3913cfc 100755 --- a/t/testutil.pm +++ b/t/testutil.pm @@ -66,6 +66,8 @@ sub uncapture_stderr { } sub init_test_dirs { + -d "t" or die "Was expecting tests to be run from root of repo\n"; + # Create a run_from/ subdirectory for tests which want to run # from a separate directory outside the Stow directory or # target directory. From 6519ee842659fc05c0d6a16f9130a92ed3f1547c Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Sun, 3 Mar 2024 18:29:53 +0000 Subject: [PATCH 372/482] aclocal.m4: update to 1.16.5 --- NEWS | 4 ++-- aclocal.m4 | 54 ++++++++++++++++++++++++++++++++++++------------------ 2 files changed, 38 insertions(+), 20 deletions(-) diff --git a/NEWS b/NEWS index 72f53e9..f14d101 100644 --- a/NEWS +++ b/NEWS @@ -26,9 +26,9 @@ News file for Stow. This eliminates existing and future bit-rot. -***** Updated aclocal.m4 from 1.15.1 to 1.16.3 +***** Updated aclocal.m4 from 1.15.1 to 1.16.5 - This mostly just updates copyright notices to 2020, and URLs to https. + This mostly just updates copyright notices to 2021, and URLs to https. ***** Replace broken gmane links with links to lists.gnu.org diff --git a/aclocal.m4 b/aclocal.m4 index 489e952..6d04fca 100644 --- a/aclocal.m4 +++ b/aclocal.m4 @@ -1,6 +1,6 @@ -# generated automatically by aclocal 1.16.3 -*- Autoconf -*- +# generated automatically by aclocal 1.16.5 -*- Autoconf -*- -# Copyright (C) 1996-2020 Free Software Foundation, Inc. +# Copyright (C) 1996-2021 Free Software Foundation, Inc. # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -14,13 +14,13 @@ m4_ifndef([AC_CONFIG_MACRO_DIRS], [m4_defun([_AM_CONFIG_MACRO_DIRS], [])m4_defun([AC_CONFIG_MACRO_DIRS], [_AM_CONFIG_MACRO_DIRS($@)])]) m4_ifndef([AC_AUTOCONF_VERSION], [m4_copy([m4_PACKAGE_VERSION], [AC_AUTOCONF_VERSION])])dnl -m4_if(m4_defn([AC_AUTOCONF_VERSION]), [2.69],, -[m4_warning([this file was generated for autoconf 2.69. +m4_if(m4_defn([AC_AUTOCONF_VERSION]), [2.71],, +[m4_warning([this file was generated for autoconf 2.71. You have another version of autoconf. It may work, but is not guaranteed to. If you have problems, you may need to regenerate the build system entirely. To do so, use the procedure documented by the package, typically 'autoreconf'.])]) -# Copyright (C) 2002-2020 Free Software Foundation, Inc. +# Copyright (C) 2002-2021 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -35,7 +35,7 @@ AC_DEFUN([AM_AUTOMAKE_VERSION], [am__api_version='1.16' dnl Some users find AM_AUTOMAKE_VERSION and mistake it for a way to dnl require some minimum version. Point them to the right macro. -m4_if([$1], [1.16.3], [], +m4_if([$1], [1.16.5], [], [AC_FATAL([Do not call $0, use AM_INIT_AUTOMAKE([$1]).])])dnl ]) @@ -51,14 +51,14 @@ m4_define([_AM_AUTOCONF_VERSION], []) # Call AM_AUTOMAKE_VERSION and AM_AUTOMAKE_VERSION so they can be traced. # This function is AC_REQUIREd by AM_INIT_AUTOMAKE. AC_DEFUN([AM_SET_CURRENT_AUTOMAKE_VERSION], -[AM_AUTOMAKE_VERSION([1.16.3])dnl +[AM_AUTOMAKE_VERSION([1.16.5])dnl m4_ifndef([AC_AUTOCONF_VERSION], [m4_copy([m4_PACKAGE_VERSION], [AC_AUTOCONF_VERSION])])dnl _AM_AUTOCONF_VERSION(m4_defn([AC_AUTOCONF_VERSION]))]) # AM_AUX_DIR_EXPAND -*- Autoconf -*- -# Copyright (C) 2001-2020 Free Software Foundation, Inc. +# Copyright (C) 2001-2021 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -110,7 +110,7 @@ am_aux_dir=`cd "$ac_aux_dir" && pwd` # Do all the work for Automake. -*- Autoconf -*- -# Copyright (C) 1996-2020 Free Software Foundation, Inc. +# Copyright (C) 1996-2021 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -138,6 +138,10 @@ m4_defn([AC_PROG_CC]) # release and drop the old call support. AC_DEFUN([AM_INIT_AUTOMAKE], [AC_PREREQ([2.65])dnl +m4_ifdef([_$0_ALREADY_INIT], + [m4_fatal([$0 expanded multiple times +]m4_defn([_$0_ALREADY_INIT]))], + [m4_define([_$0_ALREADY_INIT], m4_expansion_stack)])dnl dnl Autoconf wants to disallow AM_ names. We explicitly allow dnl the ones we care about. m4_pattern_allow([^AM_[A-Z]+FLAGS$])dnl @@ -226,6 +230,20 @@ AC_PROVIDE_IFELSE([AC_PROG_OBJCXX], [m4_define([AC_PROG_OBJCXX], m4_defn([AC_PROG_OBJCXX])[_AM_DEPENDENCIES([OBJCXX])])])dnl ]) +# Variables for tags utilities; see am/tags.am +if test -z "$CTAGS"; then + CTAGS=ctags +fi +AC_SUBST([CTAGS]) +if test -z "$ETAGS"; then + ETAGS=etags +fi +AC_SUBST([ETAGS]) +if test -z "$CSCOPE"; then + CSCOPE=cscope +fi +AC_SUBST([CSCOPE]) + AC_REQUIRE([AM_SILENT_RULES])dnl dnl The testsuite driver may need to know about EXEEXT, so add the dnl 'am__EXEEXT' conditional if _AM_COMPILER_EXEEXT was seen. This @@ -307,7 +325,7 @@ for _am_header in $config_headers :; do done echo "timestamp for $_am_arg" >`AS_DIRNAME(["$_am_arg"])`/stamp-h[]$_am_stamp_count]) -# Copyright (C) 2001-2020 Free Software Foundation, Inc. +# Copyright (C) 2001-2021 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -328,7 +346,7 @@ if test x"${install_sh+set}" != xset; then fi AC_SUBST([install_sh])]) -# Copyright (C) 2003-2020 Free Software Foundation, Inc. +# Copyright (C) 2003-2021 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -349,7 +367,7 @@ AC_SUBST([am__leading_dot])]) # Fake the existence of programs that GNU maintainers use. -*- Autoconf -*- -# Copyright (C) 1997-2020 Free Software Foundation, Inc. +# Copyright (C) 1997-2021 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -383,7 +401,7 @@ fi # Helper functions for option handling. -*- Autoconf -*- -# Copyright (C) 2001-2020 Free Software Foundation, Inc. +# Copyright (C) 2001-2021 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -414,7 +432,7 @@ AC_DEFUN([_AM_IF_OPTION], # Check to make sure that the build environment is sane. -*- Autoconf -*- -# Copyright (C) 1996-2020 Free Software Foundation, Inc. +# Copyright (C) 1996-2021 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -495,7 +513,7 @@ AC_CONFIG_COMMANDS_PRE( rm -f conftest.file ]) -# Copyright (C) 2009-2020 Free Software Foundation, Inc. +# Copyright (C) 2009-2021 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -555,7 +573,7 @@ AC_SUBST([AM_BACKSLASH])dnl _AM_SUBST_NOTMAKE([AM_BACKSLASH])dnl ]) -# Copyright (C) 2001-2020 Free Software Foundation, Inc. +# Copyright (C) 2001-2021 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -583,7 +601,7 @@ fi INSTALL_STRIP_PROGRAM="\$(install_sh) -c -s" AC_SUBST([INSTALL_STRIP_PROGRAM])]) -# Copyright (C) 2006-2020 Free Software Foundation, Inc. +# Copyright (C) 2006-2021 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -602,7 +620,7 @@ AC_DEFUN([AM_SUBST_NOTMAKE], [_AM_SUBST_NOTMAKE($@)]) # Check how to create a tarball. -*- Autoconf -*- -# Copyright (C) 2004-2020 Free Software Foundation, Inc. +# Copyright (C) 2004-2021 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, From 457fa98527ed7bc87517d8d0027a0299d80401cf Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Sun, 3 Mar 2024 18:30:21 +0000 Subject: [PATCH 373/482] dotfiles.t: improve comment descriptions --- t/dotfiles.t | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/t/dotfiles.t b/t/dotfiles.t index a4a45c8..9659dd7 100755 --- a/t/dotfiles.t +++ b/t/dotfiles.t @@ -35,7 +35,7 @@ cd("$TEST_DIR/target"); my $stow; # -# process a dotfile marked with 'dot' prefix +# stow a dotfile marked with 'dot' prefix # $stow = new_Stow(dir => '../stow', dotfiles => 1); @@ -70,7 +70,7 @@ is( # -# process folder marked with 'dot' prefix +# stow folder marked with 'dot' prefix # $stow = new_Stow(dir => '../stow', dotfiles => 1); @@ -87,7 +87,7 @@ is( ); # -# corner case: paths that have a part in them that's just "$DOT_PREFIX" or +# corner case: paths with a part in them that's just "$DOT_PREFIX" or # "$DOT_PREFIX." should not have that part expanded. # From f51fc1248c5a3c4f3777125204052c6ea45d3a78 Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Mon, 4 Mar 2024 00:53:51 +0000 Subject: [PATCH 374/482] plan_*: rename $path to $pkg_path for clarity $path is a vague variable name. --- lib/Stow.pm.in | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/Stow.pm.in b/lib/Stow.pm.in index fe34f1c..b603455 100755 --- a/lib/Stow.pm.in +++ b/lib/Stow.pm.in @@ -271,8 +271,8 @@ sub plan_unstow { $self->within_target_do(sub { for my $package (@packages) { - my $path = join_paths($self->{stow_path}, $package); - if (not -d $path) { + my $pkg_path = join_paths($self->{stow_path}, $package); + if (not -d $pkg_path) { error("The stow directory $self->{stow_path} does not contain package $package"); } debug(2, 0, "Planning unstow of package $package..."); @@ -314,8 +314,8 @@ sub plan_stow { $self->within_target_do(sub { for my $package (@packages) { - my $path = join_paths($self->{stow_path}, $package); - if (not -d $path) { + my $pkg_path = join_paths($self->{stow_path}, $package); + if (not -d $pkg_path) { error("The stow directory $self->{stow_path} does not contain package $package"); } debug(2, 0, "Planning stow of package $package..."); @@ -323,7 +323,7 @@ sub plan_stow { $self->{stow_path}, $package, '.', - $path, # source from target + $pkg_path, # source from target ); debug(2, 0, "Planning stow of package $package... done"); $self->{action_count}++; From 20bee7428ea0856d31bc9d0e56f98ed3ebcfd1e6 Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Sat, 9 Mar 2024 17:33:25 +0000 Subject: [PATCH 375/482] Add a comment explaining $stow_path parameter of stow_contents() At first sight this parameter looks redundant since we have $self->{stow_path}, but in one case the value can differ from that, so mention that explicitly. --- lib/Stow.pm.in | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/Stow.pm.in b/lib/Stow.pm.in index b603455..ea34e66 100755 --- a/lib/Stow.pm.in +++ b/lib/Stow.pm.in @@ -360,7 +360,11 @@ sub within_target_do { # Name : stow_contents() # Purpose : stow the contents of the given directory # Parameters: $stow_path => relative path from current (i.e. target) directory -# : to the stow dir containing the package to be stowed +# : to the stow dir containing the package to be stowed. +# : This can differ from $self->{stow_path} when unfolding +# : a (sub)tree which is already stowed from a package +# : in a different stow directory (see the "Multiple Stow +# : Directories" section of the manual). # : $package => the package whose contents are being stowed # : $target => subpath relative to package directory which needs # : stowing as a symlink at subpath relative to target From a3700e7171c3d65c80dddd2e63b5dd0559e4ef12 Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Sat, 9 Mar 2024 17:34:46 +0000 Subject: [PATCH 376/482] Add a comment explaining path in stow_contents() --- lib/Stow.pm.in | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/lib/Stow.pm.in b/lib/Stow.pm.in index ea34e66..a64233e 100755 --- a/lib/Stow.pm.in +++ b/lib/Stow.pm.in @@ -381,6 +381,15 @@ sub stow_contents { my $self = shift; my ($stow_path, $package, $target, $source) = @_; + # Calculate the path to the package directory or sub-directory + # whose contents need to be stowed, relative to the current + # (target directory). This is needed so that we can check it's a + # valid directory, and can read its contents to iterate over them. + # + # Note that $source refers to the same package (sub-)directory, + # but instead it's relative to the target directory or + # sub-directory where the symlink will be installed when the plans + # are executed. my $path = join_paths($stow_path, $package, $target); return if $self->should_skip_target_which_is_stow_dir($target); From 72084f6fecbd2f7d850af8a1236f572d4bc7b303 Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Sat, 9 Mar 2024 17:35:35 +0000 Subject: [PATCH 377/482] Add a comment explaining that $node_target can be adjusted for dot- prefix --- lib/Stow.pm.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Stow.pm.in b/lib/Stow.pm.in index a64233e..75bac9e 100755 --- a/lib/Stow.pm.in +++ b/lib/Stow.pm.in @@ -426,7 +426,7 @@ sub stow_contents { $self->stow_node( $stow_path, $package, - $node_target, # target + $node_target, # target, potentially adjusted for dot- prefix join_paths($source, $node), # source ); } From b7bf77da52ca9a6e6e8683f3ed0f39e500edbadf Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Sat, 9 Mar 2024 17:36:19 +0000 Subject: [PATCH 378/482] Add a missing period to the stow_contents() comments. --- lib/Stow.pm.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Stow.pm.in b/lib/Stow.pm.in index 75bac9e..77d4ccf 100755 --- a/lib/Stow.pm.in +++ b/lib/Stow.pm.in @@ -444,7 +444,7 @@ sub stow_contents { # : $source => relative path to symlink source from the dir of target # Returns : n/a # Throws : fatal exception if a conflict arises -# Comments : stow_node() and stow_contents() are mutually recursive +# Comments : stow_node() and stow_contents() are mutually recursive. # : $source and $target are used for creating the symlink # : $path is used for folding/unfolding trees as necessary #============================================================================ From 4e2776224f1a35e1948dc8c1e388f94323e447da Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Sat, 9 Mar 2024 17:38:20 +0000 Subject: [PATCH 379/482] Tweak text of error and debug messages --- lib/Stow.pm.in | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/Stow.pm.in b/lib/Stow.pm.in index 77d4ccf..7b2551c 100755 --- a/lib/Stow.pm.in +++ b/lib/Stow.pm.in @@ -400,7 +400,7 @@ sub stow_contents { debug(3, 0, $msg); debug(4, 1, "=> $source"); - error("stow_contents() called with non-directory path: $path") + error("stow_contents() called with non-directory package path: $path") unless -d $path; error("stow_contents() called with non-directory target: $target") unless $self->is_a_node($target); @@ -454,7 +454,7 @@ sub stow_node { my $path = join_paths($stow_path, $package, $target); - debug(3, 0, "Stowing $stow_path / $package / $target"); + debug(3, 0, "Stowing entry $stow_path / $package / $target"); debug(4, 1, "=> $source"); # Don't try to stow absolute symlinks (they can't be unstowed) From 9ce37d95759803313b4dbff8ff49f17f8702d674 Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Sat, 9 Mar 2024 17:49:49 +0000 Subject: [PATCH 380/482] Remove $stow_path parameter from unstow_{contents,node}{,_orig}() Unlike with the stow_{contents,node}{,_orig}() counterpart functions, when unstowing, it's not necessary to pass the $stow_path parameter because it can never differ from $self->{stow_path}. The stow_*() functions need this for the corner case of unfolding a tree which is stowed from a different stow directory to the one being used for the current stowing operation (see the "Multiple Stow Directories" section of the manual). --- lib/Stow.pm.in | 46 ++++++++++++++++++---------------------------- 1 file changed, 18 insertions(+), 28 deletions(-) diff --git a/lib/Stow.pm.in b/lib/Stow.pm.in index 7b2551c..313cb83 100755 --- a/lib/Stow.pm.in +++ b/lib/Stow.pm.in @@ -278,14 +278,12 @@ sub plan_unstow { debug(2, 0, "Planning unstow of package $package..."); if ($self->{compat}) { $self->unstow_contents_orig( - $self->{stow_path}, $package, '.', ); } else { $self->unstow_contents( - $self->{stow_path}, $package, '.', ); @@ -626,9 +624,7 @@ sub marked_stow_dir { #===== METHOD =============================================================== # Name : unstow_contents_orig() # Purpose : unstow the contents of the given directory -# Parameters: $stow_path => relative path from current (i.e. target) directory -# : to the stow dir containing the package to be unstowed -# : $package => the package whose contents are being unstowed +# Parameters: $package => the package whose contents are being unstowed # : $target => relative path to symlink target from the current directory # Returns : n/a # Throws : a fatal error if directory cannot be read @@ -637,9 +633,9 @@ sub marked_stow_dir { #============================================================================ sub unstow_contents_orig { my $self = shift; - my ($stow_path, $package, $target) = @_; + my ($package, $target) = @_; - my $path = join_paths($stow_path, $package, $target); + my $path = join_paths($self->{stow_path}, $package, $target); return if $self->should_skip_target_which_is_stow_dir($target); @@ -664,17 +660,15 @@ sub unstow_contents_orig { next NODE if $node eq '.'; next NODE if $node eq '..'; my $node_target = join_paths($target, $node); - next NODE if $self->ignore($stow_path, $package, $node_target); - $self->unstow_node_orig($stow_path, $package, $node_target); + next NODE if $self->ignore($self->{stow_path}, $package, $node_target); + $self->unstow_node_orig($package, $node_target); } } #===== METHOD =============================================================== # Name : unstow_node_orig() # Purpose : unstow the given node -# Parameters: $stow_path => relative path from current (i.e. target) directory -# : to the stow dir containing the node to be stowed -# : $package => the package containing the node being stowed +# Parameters: $package => the package containing the node being stowed # : $target => relative path to symlink target from the current directory # Returns : n/a # Throws : fatal error if a conflict arises @@ -682,9 +676,9 @@ sub unstow_contents_orig { #============================================================================ sub unstow_node_orig { my $self = shift; - my ($stow_path, $package, $target) = @_; + my ($package, $target) = @_; - my $path = join_paths($stow_path, $package, $target); + my $path = join_paths($self->{stow_path}, $package, $target); debug(3, 0, "Unstowing $target (compat mode)"); debug(4, 1, "source path is $path"); @@ -727,7 +721,7 @@ sub unstow_node_orig { } } elsif (-d $target) { - $self->unstow_contents_orig($stow_path, $package, $target); + $self->unstow_contents_orig($package, $target); # This action may have made the parent directory foldable if (my $parent = $self->foldable($target)) { @@ -750,9 +744,7 @@ sub unstow_node_orig { #===== METHOD =============================================================== # Name : unstow_contents() # Purpose : unstow the contents of the given directory -# Parameters: $stow_path => relative path from current (i.e. target) directory -# : to the stow dir containing the package to be unstowed -# : $package => the package whose contents are being unstowed +# Parameters: $package => the package whose contents are being unstowed # : $target => relative path to symlink target from the current directory # Returns : n/a # Throws : a fatal error if directory cannot be read @@ -761,9 +753,9 @@ sub unstow_node_orig { #============================================================================ sub unstow_contents { my $self = shift; - my ($stow_path, $package, $target) = @_; + my ($package, $target) = @_; - my $path = join_paths($stow_path, $package, $target); + my $path = join_paths($self->{stow_path}, $package, $target); return if $self->should_skip_target_which_is_stow_dir($target); @@ -791,7 +783,7 @@ sub unstow_contents { next NODE if $node eq '.'; next NODE if $node eq '..'; my $node_target = join_paths($target, $node); - next NODE if $self->ignore($stow_path, $package, $node_target); + next NODE if $self->ignore($self->{stow_path}, $package, $node_target); if ($self->{dotfiles}) { my $adj_node_target = adjust_dotfile($node_target); @@ -799,7 +791,7 @@ sub unstow_contents { $node_target = $adj_node_target; } - $self->unstow_node($stow_path, $package, $node_target); + $self->unstow_node($package, $node_target); } if (-d $target) { $self->cleanup_invalid_links($target); @@ -809,9 +801,7 @@ sub unstow_contents { #===== METHOD =============================================================== # Name : unstow_node() # Purpose : unstow the given node -# Parameters: $stow_path => relative path from current (i.e. target) directory -# : to the stow dir containing the node to be stowed -# : $package => the package containing the node being unstowed +# Parameters: $package => the package containing the node being unstowed # : $target => relative path to symlink target from the current directory # Returns : n/a # Throws : fatal error if a conflict arises @@ -819,9 +809,9 @@ sub unstow_contents { #============================================================================ sub unstow_node { my $self = shift; - my ($stow_path, $package, $target) = @_; + my ($package, $target) = @_; - my $path = join_paths($stow_path, $package, $target); + my $path = join_paths($self->{stow_path}, $package, $target); debug(3, 1, "Unstowing $path"); debug(4, 2, "target is $target"); @@ -893,7 +883,7 @@ sub unstow_node { elsif (-e $target) { debug(4, 2, "Evaluate existing node: $target"); if (-d $target) { - $self->unstow_contents($stow_path, $package, $target); + $self->unstow_contents($package, $target); # This action may have made the parent directory foldable if (my $parent = $self->foldable($target)) { From aa03922520a261f187d7493d60589e7dc24ac0ee Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Sat, 9 Mar 2024 17:52:17 +0000 Subject: [PATCH 381/482] manual: fix duplicated "of" typo --- doc/stow.texi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/stow.texi b/doc/stow.texi index d57c7f6..87c83bd 100644 --- a/doc/stow.texi +++ b/doc/stow.texi @@ -816,7 +816,7 @@ This is much faster and cleaner than performing two separate invocations of stow, because redundant folding/unfolding operations can be factored out. In addition, all the operations are calculated and merged before being executed (@pxref{Deferred Operation}), so the -amount of of time in which GNU Emacs is unavailable is minimised. +amount of time in which GNU Emacs is unavailable is minimised. You can mix and match any number of actions, for example, From 9db0de3005d49d27e0a31e5d6bc9655a78444165 Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Sat, 9 Mar 2024 18:11:00 +0000 Subject: [PATCH 382/482] Add some helpful comments Explain a few things in preparation for a bugfix. --- lib/Stow.pm.in | 11 +++++++++-- t/find_stowed_path.t | 3 +++ 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/lib/Stow.pm.in b/lib/Stow.pm.in index 313cb83..9413f8f 100755 --- a/lib/Stow.pm.in +++ b/lib/Stow.pm.in @@ -202,6 +202,11 @@ sub set_stow_dir { my $stow_dir = canon_path($self->{dir}); my $target = canon_path($self->{target}); + + # Calculate relative path from target directory to stow directory. + # This will be commonly used as a prefix for constructing and + # recognising symlinks "installed" in the target directory which + # point to package files under the stow directory. $self->{stow_path} = File::Spec->abs2rel($stow_dir, $target); debug(2, 0, "stow dir is $stow_dir"); @@ -925,8 +930,10 @@ sub link_owned_by_package { #===== METHOD =============================================================== # Name : find_stowed_path() -# Purpose : determine whether the given link points to a member of a -# : stowed package +# Purpose : determine whether the given link within the target directory +# : is a stowed path pointing to a member of a package under the +# : stow dir, and if so, obtain a breakdown of information about +# : this stowed path. # Parameters: $target => path to a symbolic link under current directory. # : Must share a common prefix with $self->{stow_path} # : $source => where that link points to (needed because link diff --git a/t/find_stowed_path.t b/t/find_stowed_path.t index 7b82520..4a61427 100755 --- a/t/find_stowed_path.t +++ b/t/find_stowed_path.t @@ -62,6 +62,9 @@ is($path, "", "empty path"); is($stow_path, "", "empty stow path"); is($package, "", "target is not stowed"); +# Make a second stow directory within the target directory, so that we +# can check that links to package files within that second stow +# directory are detected correctly. make_path("$TEST_DIR/target/stow2"); make_file("$TEST_DIR/target/stow2/.stow"); From 1657c5b7728484f519657783baf9ad5f6b6b1fb4 Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Sat, 9 Mar 2024 18:11:29 +0000 Subject: [PATCH 383/482] t/find_stowed_path.t: Add a couple of missing spaces --- t/find_stowed_path.t | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/t/find_stowed_path.t b/t/find_stowed_path.t index 4a61427..d723e66 100755 --- a/t/find_stowed_path.t +++ b/t/find_stowed_path.t @@ -69,7 +69,7 @@ make_path("$TEST_DIR/target/stow2"); make_file("$TEST_DIR/target/stow2/.stow"); ($path, $stow_path, $package) = - $stow->find_stowed_path("$TEST_DIR/target/a/b/c","../../stow2/a/b/c"); + $stow->find_stowed_path("$TEST_DIR/target/a/b/c", "../../stow2/a/b/c"); is($path, "$TEST_DIR/target/stow2/a/b/c", "path"); is($stow_path, "$TEST_DIR/target/stow2", "stow path"); is($package, "a", "detect alternate stow directory"); @@ -77,7 +77,7 @@ is($package, "a", "detect alternate stow directory"); # Possible corner case with rogue symlink pointing to ancestor of # stow dir. ($path, $stow_path, $package) = - $stow->find_stowed_path("$TEST_DIR/target/a/b/c","../../.."); + $stow->find_stowed_path("$TEST_DIR/target/a/b/c", "../../.."); is($path, "", "path"); is($stow_path, "", "stow path"); is($package, "", "corner case - link points to ancestor of stow dir"); From 66ca2826d604af6316bb6181502e829c98f0f978 Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Sat, 30 Mar 2024 12:55:56 +0000 Subject: [PATCH 384/482] Highlight an issue with prove overriding TEST_VERBOSE --- CONTRIBUTING.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 39c4052..1bcd0f4 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -82,6 +82,9 @@ or to run the whole suite: prove +However currently there is an issue where this interferes with +`TEST_VERBOSE`. + Translating Stow ---------------- From d1480195b6905d97d1eacab0cbe220a80a9ef1e9 Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Sat, 30 Mar 2024 12:57:55 +0000 Subject: [PATCH 385/482] Move setting of cperl-indent-level to .dir-locals.el This removes duplication. --- .dir-locals.el | 3 ++- bin/chkstow.in | 1 - bin/stow.in | 1 - lib/Stow.pm.in | 1 - lib/Stow/Util.pm.in | 1 - t/testutil.pm | 1 - 6 files changed, 2 insertions(+), 6 deletions(-) diff --git a/.dir-locals.el b/.dir-locals.el index 97211a4..2982323 100644 --- a/.dir-locals.el +++ b/.dir-locals.el @@ -1 +1,2 @@ -((cperl-mode . ((dumb-jump-force-searcher . rg)))) +((cperl-mode . ((dumb-jump-force-searcher . rg) + (cperl-indent-level . 4)))) diff --git a/bin/chkstow.in b/bin/chkstow.in index b583b32..e23774d 100755 --- a/bin/chkstow.in +++ b/bin/chkstow.in @@ -123,6 +123,5 @@ sub list { # Local variables: # mode: perl -# cperl-indent-level: 4 # End: # vim: ft=perl diff --git a/bin/stow.in b/bin/stow.in index 76b150c..9147fd1 100755 --- a/bin/stow.in +++ b/bin/stow.in @@ -849,6 +849,5 @@ sub version { # Local variables: # mode: perl -# cperl-indent-level: 4 # end: # vim: ft=perl diff --git a/lib/Stow.pm.in b/lib/Stow.pm.in index 9413f8f..d8d064f 100755 --- a/lib/Stow.pm.in +++ b/lib/Stow.pm.in @@ -2165,7 +2165,6 @@ EOF # Local variables: # mode: perl -# cperl-indent-level: 4 # end: # vim: ft=perl diff --git a/lib/Stow/Util.pm.in b/lib/Stow/Util.pm.in index f8f0cd4..e182d1d 100644 --- a/lib/Stow/Util.pm.in +++ b/lib/Stow/Util.pm.in @@ -237,6 +237,5 @@ sub adjust_dotfile { # Local variables: # mode: perl -# cperl-indent-level: 4 # end: # vim: ft=perl diff --git a/t/testutil.pm b/t/testutil.pm index 3913cfc..f7f4e1d 100755 --- a/t/testutil.pm +++ b/t/testutil.pm @@ -313,6 +313,5 @@ sub is_nonexistent_path { # Local variables: # mode: perl -# cperl-indent-level: 4 # end: # vim: ft=perl From ff4d87efaffe3789dd9e205d5e34583255feceb6 Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Sat, 30 Mar 2024 19:27:12 +0000 Subject: [PATCH 386/482] Disable emacs auto-fill-mode This completely messes up the current function documentation. --- .dir-locals.el | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.dir-locals.el b/.dir-locals.el index 2982323..346c78e 100644 --- a/.dir-locals.el +++ b/.dir-locals.el @@ -1,2 +1,3 @@ ((cperl-mode . ((dumb-jump-force-searcher . rg) - (cperl-indent-level . 4)))) + (cperl-indent-level . 4) + (eval . (auto-fill-mode -1))))) From 4d711fc4ac6f37e2d77a6886a6b75a71cb9149e7 Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Fri, 29 Mar 2024 22:52:12 +0000 Subject: [PATCH 387/482] Make join_paths correctly handle absolute paths Previously join_paths() was incorrectly handling absolute paths, for example join_paths('a/b', '/c/d') would return 'a/b/c/d' rather than '/c/d'. This was a problem when following a symlink in find_stowed_path(), because if the symlink was not owned by Stow and pointed to an absolute path, find_stowed_path() might accidentally deem the link owned by Stow, if c/d was a valid path relative to the current directory. --- lib/Stow/Util.pm.in | 41 +++++++++++----- t/join_paths.t | 117 +++++++++++++------------------------------- 2 files changed, 61 insertions(+), 97 deletions(-) diff --git a/lib/Stow/Util.pm.in b/lib/Stow/Util.pm.in index e182d1d..7c1c8d5 100644 --- a/lib/Stow/Util.pm.in +++ b/lib/Stow/Util.pm.in @@ -32,6 +32,7 @@ Supporting utility routines for L. use strict; use warnings; +use File::Spec; use POSIX qw(getcwd); use base qw(Exporter); @@ -147,29 +148,43 @@ sub debug { # Parameters: path1, path2, ... => paths # Returns : concatenation of given paths # Throws : n/a -# Comments : factors out redundant path elements: -# : '//' => '/' and 'a/b/../c' => 'a/c' +# Comments : Factors out some redundant path elements: +# : '//' => '/', and 'a/b/../c' => 'a/c'. This is needed even +# : though b could be a symlink to elsewhere as noted in the +# : perldoc for File::Spec->canonpath(), because the way +# : join_paths() is used relies on this. #============================================================================ sub join_paths { my @paths = @_; - # weed out empty components and concatenate - my $result = join '/', grep {! /\A\z/} @paths; + debug(5, 5, "| Joining: @paths"); + my $result = ''; + for my $part (@paths) { + next if ! length $part; # probably shouldn't happen? + $part = File::Spec->canonpath($part); - # factor out back references and remove redundant /'s) - my @result = (); - PART: - for my $part (split m{/+}, $result) { - next PART if $part eq '.'; - if (@result && $part eq '..' && $result[-1] ne '..') { - pop @result; + if (substr($part, 0, 1) eq '/') { + $result = $part; # absolute path, so ignore all previous parts } else { - push @result, $part; + $result .= '/' if length $result && $result ne '/'; + $result .= $part; } + debug(7, 6, "| Join now: $result"); } + debug(6, 5, "| Joined: $result"); - return join '/', @result; + # Need this to remove any initial ./ + $result = File::Spec->canonpath($result); + + # remove foo/.. + 1 while $result =~ s,(^|/)(?!\.\.)[^/]+/\.\.(/|$),$1,; + debug(6, 5, "| After .. removal: $result"); + + $result = File::Spec->canonpath($result); + debug(5, 5, "| Final join: $result"); + + return $result; } #===== METHOD =============================================================== diff --git a/t/join_paths.t b/t/join_paths.t index fa96d66..40c5a8f 100755 --- a/t/join_paths.t +++ b/t/join_paths.t @@ -22,91 +22,40 @@ use strict; use warnings; -use Stow::Util qw(join_paths); +use Stow::Util qw(join_paths set_debug_level); -use Test::More tests => 14; +#set_debug_level(4); -is( - join_paths('a/b/c', 'd/e/f'), - 'a/b/c/d/e/f' - => 'simple' +use Test::More tests => 22; + +my @TESTS = ( + [['a/b/c', 'd/e/f'], 'a/b/c/d/e/f' => 'simple'], + [['a/b/c', '/d/e/f'], '/d/e/f' => 'relative then absolute'], + [['/a/b/c', 'd/e/f'], '/a/b/c/d/e/f' => 'absolute then relative'], + [['/a/b/c', '/d/e/f'], '/d/e/f' => 'two absolutes'], + [['/a/b/c/', '/d/e/f/'], '/d/e/f' => 'two absolutes with trailing /'], + [['///a/b///c//', '/d///////e/f'], '/d/e/f' => "multiple /'s, absolute"], + [['///a/b///c//', 'd///////e/f'], '/a/b/c/d/e/f' => "multiple /'s, relative"], + [['', 'a/b/c'], 'a/b/c' => 'first empty'], + [['a/b/c', ''], 'a/b/c' => 'second empty'], + [['/', 'a/b/c'], '/a/b/c' => 'first is /'], + [['a/b/c', '/'], '/' => 'second is /'], + [['../a1/b1/../c1/', 'a2/../b2/e2'], '../a1/c1/b2/e2' => 'relative with ../'], + [['../a1/b1/../c1/', '/a2/../b2/e2'], '/b2/e2' => 'absolute with ../'], + [['../a1/../../c1', 'a2/../../'], '../..' => 'lots of ../'], + [['./', '../a2'], '../a2' => 'drop any "./"'], + [['./a1', '../../a2'], '../a2' => 'drop any "./foo"'], + [['a/b/c', '.'], 'a/b/c' => '. on RHS'], + [['a/b/c', '.', 'd/e'], 'a/b/c/d/e' => '. in middle'], + [['0', 'a/b'], '0/a/b' => '0 at start'], + [['/0', 'a/b'], '/0/a/b' => '/0 at start'], + [['a/b/c', '0', 'd/e'], 'a/b/c/0/d/e' => '0 in middle'], + [['a/b', '0'], 'a/b/0' => '0 at end'], ); -is( - join_paths('/a/b/c', '/d/e/f'), - '/a/b/c/d/e/f' - => 'leading /' -); - -is( - join_paths('/a/b/c/', '/d/e/f/'), - '/a/b/c/d/e/f' - => 'trailing /' -); - -is( - join_paths('///a/b///c//', '/d///////e/f'), - '/a/b/c/d/e/f' - => 'mltiple /\'s' -); - -is( - join_paths('', 'a/b/c'), - 'a/b/c' - => 'first empty' -); - -is( - join_paths('a/b/c', ''), - 'a/b/c' - => 'second empty' -); - -is( - join_paths('/', 'a/b/c'), - '/a/b/c' - => 'first is /' -); - -is( - join_paths('a/b/c', '/'), - 'a/b/c' - => 'second is /' -); - -is( - join_paths('///a/b///c//', '/d///////e/f'), - '/a/b/c/d/e/f' - => 'multiple /\'s' -); - - -is( - join_paths('../a1/b1/../c1/', '/a2/../b2/e2'), - '../a1/c1/b2/e2' - => 'simple deref ".."' -); - -is( - join_paths('../a1/b1/../c1/d1/e1', '../a2/../b2/c2/d2/../e2'), - '../a1/c1/d1/b2/c2/e2' - => 'complex deref ".."' -); - -is( - join_paths('../a1/../../c1', 'a2/../../'), - '../..' - => 'too many ".."' -); - -is( - join_paths('./a1', '../../a2'), - '../a2' - => 'drop any "./"' -); - -is( - join_paths('a/b/c', '.'), - 'a/b/c' - => '. on RHS' -); +for my $test (@TESTS) { + my ($inputs, $expected, $scenario) = @$test; + my $got = join_paths(@$inputs); + my $descr = "$scenario: in=[" . join(', ', map "'$_'", @$inputs) . "] exp=[$expected] got=[$got]"; + is($got, $expected, $descr); +} From 287d8016f6df8afabdb3196ccaefd42a5d95a06c Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Sun, 31 Mar 2024 11:59:52 +0100 Subject: [PATCH 388/482] join_paths: improve docs to clarify purpose / differences join_paths() is used in specific ways and has specific behaviour required which is nuanced and not obvious at first sight. So make this explicit for future reference. --- lib/Stow/Util.pm.in | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/lib/Stow/Util.pm.in b/lib/Stow/Util.pm.in index 7c1c8d5..851f425 100644 --- a/lib/Stow/Util.pm.in +++ b/lib/Stow/Util.pm.in @@ -149,10 +149,20 @@ sub debug { # Returns : concatenation of given paths # Throws : n/a # Comments : Factors out some redundant path elements: -# : '//' => '/', and 'a/b/../c' => 'a/c'. This is needed even -# : though b could be a symlink to elsewhere as noted in the -# : perldoc for File::Spec->canonpath(), because the way -# : join_paths() is used relies on this. +# : '//' => '/', and 'a/b/../c' => 'a/c'. We need this function +# : with this behaviour, even though b could be a symlink to +# : elsewhere, as noted in the perldoc for File::Spec->canonpath(). +# : This behaviour is deliberately different to +# : Stow::Util::canon_path(), because the way join_paths() is used +# : relies on this. Firstly, there is no guarantee that the paths +# : exist, so a filesystem check is inappropriate. +# : +# : For example, it's used to determine the path from the target +# : directory to a symlink destination. So if a symlink +# : path/to/target/a/b/c points to ../../../stow/pkg/a/b/c, +# : then joining path/to/target/a/b with ../../../stow/pkg/a/b/c +# : yields path/to/stow/pkg/a/b/c, and it's crucial that the +# : path/to/stow prefix matches a recognisable stow directory. #============================================================================ sub join_paths { my @paths = @_; From a2beb7b371aceec1e8a5ea0a0103bd77d8d92046 Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Sat, 30 Mar 2024 14:03:56 +0000 Subject: [PATCH 389/482] Separate treatment of .stow and .nonstow marked dirs Placing a .stow file in a directory tells Stow that this directory should be considered a Stow directory. This is already well-documented. There was an undocumented and slightly broken feature where placing a .nonstow file in a directory was treated in exactly the same way. The intention was for .nonstow to cause Stow to skip stowing into and unstowing from that directory and any of its descendants. However, it also caused Stow to consider symlinks into any of those directories as owned by Stow, even though that was clearly not the intention. So separate treatment of .stow and .nonstow markers, so that while both provide protection against Stow stowing and unstowing, only .stow affects the symlink ownership logic in find_stowed_path() and marked_stow_dir(). Probably no one uses the undocumented .nonstow feature, so it may make sense to remove this in future. --- lib/Stow.pm.in | 32 +++++++++++++++++++------------- t/unstow.t | 2 +- t/unstow_orig.t | 4 ++-- 3 files changed, 22 insertions(+), 16 deletions(-) diff --git a/lib/Stow.pm.in b/lib/Stow.pm.in index d8d064f..5b986f1 100755 --- a/lib/Stow.pm.in +++ b/lib/Stow.pm.in @@ -395,7 +395,7 @@ sub stow_contents { # are executed. my $path = join_paths($stow_path, $package, $target); - return if $self->should_skip_target_which_is_stow_dir($target); + return if $self->should_skip_target($target); my $cwd = getcwd(); my $msg = "Stowing contents of $path (cwd=$cwd)"; @@ -587,15 +587,16 @@ sub stow_node { } #===== METHOD =============================================================== -# Name : should_skip_target_which_is_stow_dir() +# Name : should_skip_target() # Purpose : determine whether target is a stow directory which should # : not be stowed to or unstowed from # Parameters: $target => relative path to symlink target from the current directory # Returns : true iff target is a stow directory # Throws : n/a -# Comments : none +# Comments : cwd must be the top-level target directory, otherwise +# : marked_stow_dir() won't work. #============================================================================ -sub should_skip_target_which_is_stow_dir { +sub should_skip_target { my $self = shift; my ($target) = @_; @@ -606,22 +607,27 @@ sub should_skip_target_which_is_stow_dir { } if ($self->marked_stow_dir($target)) { + warn "WARNING: skipping marked Stow directory $target\n"; + return 1; + } + + if (-e join_paths($target, ".nonstow")) { warn "WARNING: skipping protected directory $target\n"; return 1; } - debug(4, 1, "$target not protected"); + debug(4, 1, "$target not protected; shouldn't skip"); return 0; } +# cwd must be the top-level target directory, otherwise +# marked_stow_dir() won't work. sub marked_stow_dir { my $self = shift; - my ($target) = @_; - for my $f (".stow", ".nonstow") { - if (-e join_paths($target, $f)) { - debug(4, 2, "$target contained $f"); - return 1; - } + my ($path) = @_; + if (-e join_paths($path, ".stow")) { + debug(5, 5, "> $path contained .stow"); + return 1; } return 0; } @@ -642,7 +648,7 @@ sub unstow_contents_orig { my $path = join_paths($self->{stow_path}, $package, $target); - return if $self->should_skip_target_which_is_stow_dir($target); + return if $self->should_skip_target($target); my $cwd = getcwd(); my $msg = "Unstowing from $target (compat mode, cwd=$cwd, stow dir=$self->{stow_path})"; @@ -762,7 +768,7 @@ sub unstow_contents { my $path = join_paths($self->{stow_path}, $package, $target); - return if $self->should_skip_target_which_is_stow_dir($target); + return if $self->should_skip_target($target); my $cwd = getcwd(); my $msg = "Unstowing from $target (cwd=$cwd, stow dir=$self->{stow_path})"; diff --git a/t/unstow.t b/t/unstow.t index 5cabf26..01a7a30 100755 --- a/t/unstow.t +++ b/t/unstow.t @@ -193,7 +193,7 @@ ok( => q(don't unlink any nodes under another stow directory) ); like($stderr, - qr/WARNING: skipping protected directory stow2/ + qr/WARNING: skipping marked Stow directory stow2/ => "unstowing from ourself should skip stow"); uncapture_stderr(); diff --git a/t/unstow_orig.t b/t/unstow_orig.t index e0f595c..e893c56 100755 --- a/t/unstow_orig.t +++ b/t/unstow_orig.t @@ -216,8 +216,8 @@ uncapture_stderr(); sub check_protected_dirs_skipped { for my $dir (qw{stow stow2}) { like($stderr, - qr/WARNING: skipping protected directory $dir/ - => "warn when skipping protected directory $dir"); + qr/WARNING: skipping marked Stow directory $dir/ + => "warn when skipping marked directory $dir"); } uncapture_stderr(); } From 08b06ccb40d6031a98d629545ec19dc20c500604 Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Sun, 31 Mar 2024 11:52:45 +0100 Subject: [PATCH 390/482] t/cleanup_invalid_links: divide into subtests This makes the code and test output both more legible. --- t/cleanup_invalid_links.t | 77 ++++++++++++++++++++------------------- 1 file changed, 39 insertions(+), 38 deletions(-) diff --git a/t/cleanup_invalid_links.t b/t/cleanup_invalid_links.t index 3b54b71..1635641 100755 --- a/t/cleanup_invalid_links.t +++ b/t/cleanup_invalid_links.t @@ -22,10 +22,11 @@ use strict; use warnings; -use Test::More tests => 6; +use Test::More tests => 3; use English qw(-no_match_vars); use testutil; +use Stow::Util; init_test_dirs(); cd("$TEST_DIR/target"); @@ -34,48 +35,48 @@ my $stow; # Note that each of the following tests use a distinct set of files -# -# nothing to clean in a simple tree -# +subtest('nothing to clean in a simple tree' => sub { + plan tests => 1; + make_path('../stow/pkg1/bin1'); + make_file('../stow/pkg1/bin1/file1'); + make_link('bin1', '../stow/pkg1/bin1'); -make_path('../stow/pkg1/bin1'); -make_file('../stow/pkg1/bin1/file1'); -make_link('bin1', '../stow/pkg1/bin1'); + $stow = new_Stow(); + $stow->cleanup_invalid_links('./'); + is( + scalar($stow->get_tasks), 0 + => 'nothing to clean' + ); +}); -$stow = new_Stow(); -$stow->cleanup_invalid_links('./'); -is( - scalar($stow->get_tasks), 0 - => 'nothing to clean' -); +subtest('cleanup a bad link in a simple tree' => sub { + plan tests => 3; -# -# cleanup a bad link in a simple tree -# -make_path('bin2'); -make_path('../stow/pkg2/bin2'); -make_file('../stow/pkg2/bin2/file2a'); -make_link('bin2/file2a', '../../stow/pkg2/bin2/file2a'); -make_invalid_link('bin2/file2b', '../../stow/pkg2/bin2/file2b'); + make_path('bin2'); + make_path('../stow/pkg2/bin2'); + make_file('../stow/pkg2/bin2/file2a'); + make_link('bin2/file2a', '../../stow/pkg2/bin2/file2a'); + make_invalid_link('bin2/file2b', '../../stow/pkg2/bin2/file2b'); -$stow = new_Stow(); -$stow->cleanup_invalid_links('bin2'); -is($stow->get_conflict_count, 0, 'no conflicts cleaning up bad link'); -is(scalar($stow->get_tasks), 1, 'one task cleaning up bad link'); -is($stow->link_task_action('bin2/file2b'), 'remove', 'removal task for bad link'); + $stow = new_Stow(); + $stow->cleanup_invalid_links('bin2'); + is($stow->get_conflict_count, 0, 'no conflicts cleaning up bad link'); + is(scalar($stow->get_tasks), 1, 'one task cleaning up bad link'); + is($stow->link_task_action('bin2/file2b'), 'remove', 'removal task for bad link'); +}); -# -# dont cleanup a bad link not owned by stow -# +subtest("don't cleanup a bad link not owned by stow" => sub { + plan tests => 2; -make_path('bin3'); -make_path('../stow/pkg3/bin3'); -make_file('../stow/pkg3/bin3/file3a'); -make_link('bin3/file3a', '../../stow/pkg3/bin3/file3a'); -make_invalid_link('bin3/file3b', '../../empty'); + make_path('bin3'); + make_path('../stow/pkg3/bin3'); + make_file('../stow/pkg3/bin3/file3a'); + make_link('bin3/file3a', '../../stow/pkg3/bin3/file3a'); + make_invalid_link('bin3/file3b', '../../empty'); -$stow = new_Stow(); -$stow->cleanup_invalid_links('bin3'); -is($stow->get_conflict_count, 0, 'no conflicts cleaning up bad link not owned by stow'); -is(scalar($stow->get_tasks), 0, 'no tasks cleaning up bad link not owned by stow'); + $stow = new_Stow(); + $stow->cleanup_invalid_links('bin3'); + is($stow->get_conflict_count, 0, 'no conflicts cleaning up bad link not owned by stow'); + is(scalar($stow->get_tasks), 0, 'no tasks cleaning up bad link not owned by stow'); +}); From 541faf68ebb8599679c1c370ec3e8a501ec4bf38 Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Sun, 31 Mar 2024 11:58:39 +0100 Subject: [PATCH 391/482] cleanup_invalid_links: improve docs --- lib/Stow.pm.in | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/lib/Stow.pm.in b/lib/Stow.pm.in index 5b986f1..e5f105d 100755 --- a/lib/Stow.pm.in +++ b/lib/Stow.pm.in @@ -1014,14 +1014,17 @@ sub find_stowed_path { #===== METHOD ================================================================ # Name : cleanup_invalid_links() -# Purpose : clean up invalid links that may block folding +# Purpose : clean up orphaned links that may block folding # Parameters: $dir => path to directory to check # Returns : n/a # Throws : no exceptions -# Comments : removing files from a stowed package is probably a bad practice -# : so this kind of clean up is not _really_ stow's responsibility; -# : however, failing to clean up can block tree folding, so we'll do -# : it anyway +# Comments : This is invoked by unstow_contents(). +# : We only clean up links which are both orphaned and owned by +# : Stow, i.e. they point to a non-existent location within a +# : Stow package. These can block tree folding, and they can +# : easily occur when a file in Stow package is renamed or removed, +# : so the benefit should outweigh the low risk of actually someone +# : wanting to keep an orphaned link to within a Stow package. #============================================================================= sub cleanup_invalid_links { my $self = shift; From 877fc0ce7e3eaac5982eef6dc7a6399e517121c8 Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Sun, 31 Mar 2024 11:53:54 +0100 Subject: [PATCH 392/482] cleanup_invalid_links: add test for non-cleanup of an unowned link --- t/cleanup_invalid_links.t | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/t/cleanup_invalid_links.t b/t/cleanup_invalid_links.t index 1635641..a859356 100755 --- a/t/cleanup_invalid_links.t +++ b/t/cleanup_invalid_links.t @@ -22,7 +22,7 @@ use strict; use warnings; -use Test::More tests => 3; +use Test::More tests => 4; use English qw(-no_match_vars); use testutil; @@ -50,7 +50,7 @@ subtest('nothing to clean in a simple tree' => sub { ); }); -subtest('cleanup a bad link in a simple tree' => sub { +subtest('cleanup an orphaned owned link in a simple tree' => sub { plan tests => 3; make_path('bin2'); @@ -80,3 +80,19 @@ subtest("don't cleanup a bad link not owned by stow" => sub { is($stow->get_conflict_count, 0, 'no conflicts cleaning up bad link not owned by stow'); is(scalar($stow->get_tasks), 0, 'no tasks cleaning up bad link not owned by stow'); }); + +subtest("don't cleanup a valid link in the target not owned by stow" => sub { + plan tests => 2; + + make_path('bin4'); + make_path('../stow/pkg4/bin4'); + make_file('../stow/pkg4/bin4/file3a'); + make_link('bin4/file3a', '../../stow/pkg4/bin4/file3a'); + make_file("unowned"); + make_link('bin4/file3b', '../unowned'); + + $stow = new_Stow(); + $stow->cleanup_invalid_links('bin4'); + is($stow->get_conflict_count, 0, 'no conflicts cleaning up bad link not owned by stow'); + is(scalar($stow->get_tasks), 0, 'no tasks cleaning up bad link not owned by stow'); +}); From 8436768144337736b54e15387b156f9b58e78dbc Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Wed, 11 Nov 2020 19:43:25 +0000 Subject: [PATCH 393/482] Eliminate erroneous warning when unstowing (#65) When unstowing a package, cleanup_invalid_links() is invoked to remove any invalid links owned by Stow. It was invoking link_owned_by_package() to check whether each existing link is owned by Stow. This in turn called find_stowed_path() which since 40a080718505 was not allowing for the possibility that it could be passed a symlink *not* owned by Stow with an absolute target and consequently emitting an erroneous warning. So remove this erroneous warning, and refactor find_stowed_path() to use two new helper functions for detecting stow directories: link_dest_within_stow_dir() and find_containing_marked_stow_dir(). Also refactor the logic within each to be simpler and more accurate, and add more test cases to the corresponding parts of the test suite. Fixes #65. Closes #103. https://github.com/aspiers/stow/issues/65 --- NEWS | 9 ++ lib/Stow.pm.in | 193 ++++++++++++++++++++++------------ t/find_stowed_path.t | 155 +++++++++++++++++++-------- t/link_dest_within_stow_dir.t | 88 ++++++++++++++++ 4 files changed, 331 insertions(+), 114 deletions(-) create mode 100755 t/link_dest_within_stow_dir.t diff --git a/NEWS b/NEWS index f14d101..d95c164 100644 --- a/NEWS +++ b/NEWS @@ -2,6 +2,15 @@ News file for Stow. * Changes in version 2.3.2 +*** Eliminated a spurious warning on unstowing + + 2.3.1 introduced a benign but annoying warning when unstowing + in certain circumstances. It looked like: + + BUG in find_stowed_path? Absolute/relative mismatch between Stow dir X and path Y + + This was caused by erroneous logic, and has now been fixed. + *** Improved debug output Extra output resulting from use of the -v / --verbose flag diff --git a/lib/Stow.pm.in b/lib/Stow.pm.in index e5f105d..297bf9f 100755 --- a/lib/Stow.pm.in +++ b/lib/Stow.pm.in @@ -936,80 +936,129 @@ sub link_owned_by_package { #===== METHOD =============================================================== # Name : find_stowed_path() -# Purpose : determine whether the given link within the target directory +# Purpose : determine whether the given symlink within the target directory # : is a stowed path pointing to a member of a package under the # : stow dir, and if so, obtain a breakdown of information about # : this stowed path. -# Parameters: $target => path to a symbolic link under current directory. -# : Must share a common prefix with $self->{stow_path} -# : $source => where that link points to (needed because link +# Parameters: $target => path to a symbolic link somewhere under +# : the target directory, relative to the +# : top-level target directory (which is also +# : expected to be the current directory). +# : $ldest => where that link points to (needed because link # : might not exist yet due to two-phase approach, -# : so we can't just call readlink()). This must be -# : expressed relative to (the directory containing) -# : $target. -# Returns : ($path, $stow_path, $package) where $path and $stow_path are -# : relative from the current (i.e. target) directory. $path -# : is the full relative path, $stow_path is the relative path -# : to the stow directory, and $package is the name of the package. -# : or ('', '', '') if link is not owned by stow +# : so we can't just call readlink()). If this is +# : owned by Stow, it will be expressed relative to +# : (the directory containing) $target. However if +# : it's not, it could of course be relative or absolute, +# : point absolutely anywhere, and could even be +# : dangling. +# Returns : ($path, $stow_path, $package) where $path and $stow_path +# : are relative from the top-level target directory. $path +# : is the full relative path to the member of the package +# : pointed to by $ldest; $stow_path is the relative path +# : to the stow directory; and $package is the name of the +# : package; or ('', '', '') if link is not owned by stow. # Throws : n/a -# Comments : Allow for stow dir not being under target dir. -# : We could put more logic under here for multiple stow dirs. +# Comments : cwd must be the top-level target directory, otherwise +# : find_containing_marked_stow_dir() won't work. +# : Allow for stow dir not being under target dir. #============================================================================ sub find_stowed_path { my $self = shift; - my ($target, $source) = @_; + my ($target, $ldest) = @_; - # Evaluate softlink relative to its target - my $path = join_paths(parent($target), $source); - debug(4, 2, "is path $path owned by stow?"); - - # Search for .stow files - this allows us to detect links - # owned by stow directories other than the current one. - my $dir = ''; - my @path = split m{/+}, $path; - for my $i (0 .. $#path) { - my $part = $path[$i]; - $dir = join_paths($dir, $part); - if ($self->marked_stow_dir($dir)) { - # FIXME - not sure if this can ever happen - internal_error("find_stowed_path() called directly on stow dir") - if $i == $#path; - - debug(4, 3, "yes - $dir was marked as a stow dir"); - my $package = $path[$i + 1]; - return ($path, $dir, $package); - } - } - - # If no .stow file was found, we need to find out whether it's - # owned by the current stow directory, in which case $path will be - # a prefix of $self->{stow_path}. - if (substr($path, 0, 1) eq '/' xor substr($self->{stow_path}, 0, 1) eq '/') - { - warn "BUG in find_stowed_path? Absolute/relative mismatch between " . - "Stow dir $self->{stow_path} and path $path"; - } - - my @stow_path = split m{/+}, $self->{stow_path}; - - # Strip off common prefixes until one is empty - while (@path && @stow_path) { - if ((shift @path) ne (shift @stow_path)) { - debug(4, 3, "no - either $path not under $self->{stow_path} or vice-versa"); - return ('', '', ''); - } - } - - if (@stow_path) { # @path must be empty - debug(4, 3, "no - $path is not under $self->{stow_path}"); + if (substr($ldest, 0, 1) eq '/') { + # Symlink points to an absolute path, therefore it cannot be + # owned by Stow. return ('', '', ''); } - my $package = shift @path; + # Evaluate softlink relative to its target, without relying on + # what's actually on the filesystem, since the link might not + # exist yet. + debug(4, 2, "find_stowed_path(target=$target; source=$ldest)"); + my $dest = join_paths(parent($target), $ldest); + debug(4, 3, "is symlink destination $dest owned by stow?"); - debug(4, 3, "yes - by $package in " . join_paths(@path)); - return ($path, $self->{stow_path}, $package); + # First check whether the link is owned by the current stow + # directory, in which case $dest will be a prefix of + # $self->{stow_path}. + my ($package, $path) = $self->link_dest_within_stow_dir($dest); + if (length $package) { + debug(4, 3, "yes - package $package in $self->{stow_path} may contain $path"); + return ($dest, $self->{stow_path}, $package); + } + + # If no .stow file was found, we need to find out whether it's + my ($stow_path, $ext_package) = $self->find_containing_marked_stow_dir($dest); + if (length $stow_path) { + debug(5, 5, "yes - $stow_path in $dest was marked as a stow dir; package=$ext_package"); + return ($dest, $stow_path, $ext_package); + } + + return ('', '', ''); +} + +#===== METHOD ================================================================ +# Name : link_dest_within_stow_dir +# Purpose : detect whether symlink destination is within current stow dir +# Parameters: $ldest - destination of the symlink relative +# Returns : ($package, $path) - package within the current stow dir +# : and subpath within that package which the symlink points to +#============================================================================= +sub link_dest_within_stow_dir { + my $self = shift; + my ($ldest) = @_; + + debug(4, 4, "common prefix? ldest=$ldest; stow_path=$self->{stow_path}"); + + my $removed = $ldest =~ s,^\Q$self->{stow_path}/,,; + if (! $removed) { + debug(4, 3, "no - $ldest not under $self->{stow_path}"); + return ('', ''); + } + + debug(4, 4, "remaining after removing $self->{stow_path}: $ldest"); + my @dirs = File::Spec->splitdir($ldest); + my $package = shift @dirs; + my $path = File::Spec->catdir(@dirs); + return ($package, $path); +} + +#===== METHOD ================================================================ +# Name : find_containing_marked_stow_dir +# Purpose : detect whether path is within a marked stow directory +# Parameters: $path => path to directory to check +# Returns : ($stow_path, $package) where $stow_path is the highest directory +# : (relative from the top-level target directory) which is marked +# : as a Stow directory, and $package is the containing package; +# : or ('', '') if no containing directory is marked as a stow +# : directory. +# Comments : cwd must be the top-level target directory, otherwise +# : marked_stow_dir() won't work. +#============================================================================= +sub find_containing_marked_stow_dir { + my $self = shift; + my ($path) = @_; + + # Search for .stow files - this allows us to detect links + # owned by stow directories other than the current one. + my @segments = File::Spec->splitdir($path); + for my $last_segment (0 .. $#segments) { + my $path = join_paths(@segments[0 .. $last_segment]); + debug(5, 5, "is $path marked stow dir?"); + if ($self->marked_stow_dir($path)) { + if ($last_segment == $#segments) { + # This should probably never happen. Even if it did, + # there would be no way of calculating $package. + internal_error("find_stowed_path() called directly on stow dir"); + } + + my $package = $segments[$last_segment + 1]; + return ($path, $package); + } + } + return ('', ''); } #===== METHOD ================================================================ @@ -1066,24 +1115,30 @@ sub cleanup_invalid_links { # Where is the link pointing? # (don't use read_a_link() here) - my $source = readlink($node_path); - if (not $source) { + my $ldest = readlink($node_path); + if (not $ldest) { error("Could not read link $node_path"); } - if (-e join_paths($dir, $source)) { - debug(4, 2, "Link target $source exists; skipping clean up"); + my $target = join_paths($dir, $ldest); + debug(4, 2, "join $dir $ldest"); + if (-e $target) { + debug(4, 2, "Link target $ldest exists at $target; skipping clean up"); next; } + else { + debug(4, 2, "Link target $ldest doesn't exist at $target"); + } debug(3, 1, - "Checking whether valid link $node_path -> $source is " . + "Checking whether valid link $node_path -> $ldest is " . "owned by stow"); - if ($self->link_owned_by_package($node_path, $source)) { + my $owner = $self->link_owned_by_package($node_path, $ldest); + if ($owner) { # owned by stow - debug(2, 0, "--- removing stale link: $node_path => " . - join_paths($dir, $source)); + debug(2, 0, "--- removing link owned by $owner: $node_path => " . + join_paths($dir, $ldest)); $self->do_unlink($node_path); } } diff --git a/t/find_stowed_path.t b/t/find_stowed_path.t index d723e66..8ae4fca 100755 --- a/t/find_stowed_path.t +++ b/t/find_stowed_path.t @@ -16,68 +16,133 @@ # along with this program. If not, see https://www.gnu.org/licenses/. # -# Testing find_stowed_path() +# Testing Stow:: find_stowed_path() # use strict; use warnings; -use Test::More tests => 18; +use Test::More tests => 10; use testutil; use Stow::Util qw(set_debug_level); init_test_dirs(); -my $stow = new_Stow(dir => "$TEST_DIR/stow"); -#set_debug_level(4); +subtest("find link to a stowed path with relative target" => sub { + plan tests => 3; -my ($path, $stow_path, $package) = - $stow->find_stowed_path("$TEST_DIR/target/a/b/c", "../../../stow/a/b/c"); -is($path, "$TEST_DIR/stow/a/b/c", "path"); -is($stow_path, "$TEST_DIR/stow", "stow path"); -is($package, "a", "package"); + # This is a relative path, unlike $ABS_TEST_DIR below. + my $target = "$TEST_DIR/target"; -cd("$TEST_DIR/target"); -$stow->set_stow_dir("../stow"); -($path, $stow_path, $package) = - $stow->find_stowed_path("a/b/c", "../../../stow/a/b/c"); -is($path, "../stow/a/b/c", "path from target directory"); -is($stow_path, "../stow", "stow path from target directory"); -is($package, "a", "from target directory"); + my $stow = new_Stow(dir => "$TEST_DIR/stow", target => $target); + my ($path, $stow_path, $package) = + $stow->find_stowed_path("a/b/c", "../../../stow/a/b/c"); + is($path, "../stow/a/b/c", "path"); + is($stow_path, "../stow", "stow path"); + is($package, "a", "package"); +}); -make_path("stow"); -cd("../.."); -$stow->set_stow_dir("$TEST_DIR/target/stow"); +my $stow = new_Stow(dir => "$ABS_TEST_DIR/stow", target => "$ABS_TEST_DIR/target"); -($path, $stow_path, $package) = - $stow->find_stowed_path("$TEST_DIR/target/a/b/c", "../../stow/a/b/c"); -is($path, "$TEST_DIR/target/stow/a/b/c", "path"); -is($stow_path, "$TEST_DIR/target/stow", "stow path"); -is($package, "a", "stow is subdir of target directory"); +# Required by creation of stow2 and stow2/.stow below +cd("$ABS_TEST_DIR/target"); -($path, $stow_path, $package) = - $stow->find_stowed_path("$TEST_DIR/target/a/b/c", "../../empty"); -is($path, "", "empty path"); -is($stow_path, "", "empty stow path"); -is($package, "", "target is not stowed"); +subtest("find link to a stowed path" => sub { + plan tests => 3; + my ($path, $stow_path, $package) = + $stow->find_stowed_path("a/b/c", "../../../stow/a/b/c"); + is($path, "../stow/a/b/c", "path from target directory"); + is($stow_path, "../stow", "stow path from target directory"); + is($package, "a", "from target directory"); +}); + +subtest("find link to alien path not owned by Stow" => sub { + plan tests => 3; + my ($path, $stow_path, $package) = + $stow->find_stowed_path("a/b/c", "../../alien"); + is($path, "", "alien is not stowed, so path is empty"); + is($stow_path, "", "alien, so stow path is empty"); + is($package, "", "alien is not stowed in any package"); +}); # Make a second stow directory within the target directory, so that we -# can check that links to package files within that second stow -# directory are detected correctly. -make_path("$TEST_DIR/target/stow2"); -make_file("$TEST_DIR/target/stow2/.stow"); +# can check that links to package files within that stow directory are +# detected correctly. +make_path("stow2"); -($path, $stow_path, $package) = - $stow->find_stowed_path("$TEST_DIR/target/a/b/c", "../../stow2/a/b/c"); -is($path, "$TEST_DIR/target/stow2/a/b/c", "path"); -is($stow_path, "$TEST_DIR/target/stow2", "stow path"); -is($package, "a", "detect alternate stow directory"); +# However this second stow directory is still "alien" to stow until we +# put a .stow file in it. So first test a symlink pointing to a path +# within this second stow directory +subtest("second stow dir still alien without .stow" => sub { + plan tests => 3; + my ($path, $stow_path, $package) = + $stow->find_stowed_path("a/b/c", "../../stow2/a/b/c"); + is($path, "", "stow2 not a stow dir yet, so path is empty"); + is($stow_path, "", "stow2 not a stow dir yet so stow path is empty"); + is($package, "", "not stowed in any recognised package yet"); +}); -# Possible corner case with rogue symlink pointing to ancestor of -# stow dir. -($path, $stow_path, $package) = - $stow->find_stowed_path("$TEST_DIR/target/a/b/c", "../../.."); -is($path, "", "path"); -is($stow_path, "", "stow path"); -is($package, "", "corner case - link points to ancestor of stow dir"); +# Now make stow2 a secondary stow directory and test that +make_file("stow2/.stow"); + +subtest(".stow makes second stow dir owned by Stow" => sub { + plan tests => 3; + my ($path, $stow_path, $package) = + $stow->find_stowed_path("a/b/c", "../../stow2/a/b/c"); + is($path, "stow2/a/b/c", "path"); + is($stow_path, "stow2", "stow path"); + is($package, "a", "detect alternate stow directory"); +}); + +subtest("relative symlink pointing to target dir" => sub { + plan tests => 3; + my ($path, $stow_path, $package) = + $stow->find_stowed_path("a/b/c", "../../.."); + # Technically the target dir is not owned by Stow, since + # Stow won't touch the target dir itself, only its contents. + is($path, "", "path"); + is($stow_path, "", "stow path"); + is($package, "", "corner case - link points to target dir"); +}); + +subtest("relative symlink pointing to parent of target dir" => sub { + plan tests => 3; + my ($path, $stow_path, $package) = + $stow->find_stowed_path("a/b/c", "../../../.."); + is($path, "", "path"); + is($stow_path, "", "stow path"); + is($package, "", "corner case - link points to parent of target dir"); +}); + +subtest("unowned symlink pointing to absolute path inside target" => sub { + plan tests => 3; + my ($path, $stow_path, $package) = + $stow->find_stowed_path("a/b/c", "$ABS_TEST_DIR/target/d"); + is($path, "", "path"); + is($stow_path, "", "stow path"); + is($package, "", "symlink unowned by Stow points to absolute path outside target directory"); +}); + +subtest("unowned symlink pointing to absolute path outside target" => sub { + plan tests => 3; + my ($path, $stow_path, $package) = + $stow->find_stowed_path("a/b/c", "/dev/null"); + is($path, "", "path"); + is($stow_path, "", "stow path"); + is($package, "", "symlink unowned by Stow points to absolute path outside target directory"); +}); + +# Now make stow2 the primary stow directory and test that it still +# works when the stow directory is under the target directory +$stow->set_stow_dir("$ABS_TEST_DIR/target/stow2"); + +subtest("stow2 becomes the primary stow directory" => sub { + plan tests => 3; + + my ($path, $stow_path, $package) = + $stow->find_stowed_path("a/b/c", "../../stow2/a/b/c"); + is($path, "stow2/a/b/c", "path in stow2"); + is($stow_path, "stow2", "stow path for stow2"); + is($package, "a", "stow2 is subdir of target directory"); +}); diff --git a/t/link_dest_within_stow_dir.t b/t/link_dest_within_stow_dir.t new file mode 100755 index 0000000..01ec2f4 --- /dev/null +++ b/t/link_dest_within_stow_dir.t @@ -0,0 +1,88 @@ +#!/usr/bin/perl +# +# This file is part of GNU Stow. +# +# GNU Stow is free software: you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# GNU Stow is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see https://www.gnu.org/licenses/. + +# +# Testing Stow::link_dest_within_stow_dir() +# + +use strict; +use warnings; + +use Test::More tests => 6; + +use testutil; +use Stow::Util; + +init_test_dirs(); + +# This is a relative path, unlike $ABS_TEST_DIR below. +my $stow = new_Stow(dir => "$TEST_DIR/stow", + target => "$TEST_DIR/target"); + +subtest("relative stow dir, link to top-level package file" => sub { + plan tests => 2; + my ($package, $path) = + $stow->link_dest_within_stow_dir("../stow/pkg/dir/file"); + is($package, "pkg", "package"); + is($path, "dir/file", "path"); +}); + +subtest("relative stow dir, link to second-level package file" => sub { + plan tests => 2; + my ($package, $path) = + $stow->link_dest_within_stow_dir("../stow/pkg/dir/subdir/file"); + is($package, "pkg", "package"); + is($path, "dir/subdir/file", "path"); +}); + +# This is an absolute path, unlike $TEST_DIR above. +$stow = new_Stow(dir => "$ABS_TEST_DIR/stow", + target => "$ABS_TEST_DIR/target"); + +subtest("relative stow dir, link to second-level package file" => sub { + plan tests => 2; + my ($package, $path) = + $stow->link_dest_within_stow_dir("../stow/pkg/dir/file"); + is($package, "pkg", "package"); + is($path, "dir/file", "path"); +}); + +subtest("absolute stow dir, link to top-level package file" => sub { + plan tests => 2; + my ($package, $path) = + $stow->link_dest_within_stow_dir("../stow/pkg/dir/subdir/file"); + is($package, "pkg", "package"); + is($path, "dir/subdir/file", "path"); +}); + +# Links with destination in the target are not pointing within +# the stow dir, so they're not owned by stow. +subtest("link to path in target" => sub { + plan tests => 2; + my ($package, $path) = + $stow->link_dest_within_stow_dir("./alien"); + is($path, "", "alien is in target, so path is empty"); + is($package, "", "alien is in target, so package is empty"); +}); + +subtest("link to path outside target and stow dir" => sub { + plan tests => 2; + my ($package, $path) = + $stow->link_dest_within_stow_dir("../alien"); + is($path, "", "alien is outside, so path is empty"); + is($package, "", "alien is outside, so package is empty"); +}); From d12f107f3c3d45f5b6fa762bdd86e354fe19f242 Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Sun, 31 Mar 2024 14:11:36 +0100 Subject: [PATCH 394/482] NEWS: more updates in preparation for next release --- NEWS | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/NEWS b/NEWS index d95c164..f414592 100644 --- a/NEWS +++ b/NEWS @@ -16,7 +16,7 @@ News file for Stow. Extra output resulting from use of the -v / --verbose flag now appears in a more logical and understandable way. -*** Minor janitorial tasks +*** Janitorial tasks Users are not substantially affected by these changes. @@ -24,7 +24,13 @@ News file for Stow. ***** Made some small improvements to the documentation -***** Added a CONTRIBUTING.md file +***** Improve readability of source code + + Quite a few extra details have been added in comments to clarify + how the code works. Some variable names have also been + improved. + +***** Added a =CONTRIBUTING.md= file ***** Add a =watch= target to =Makefile= @@ -43,7 +49,11 @@ News file for Stow. [[https://lars.ingebrigtsen.no/2020/01/06/whatever-happened-to-news-gmane-org/][gmane has been dead for quite a while.]] -***** Add support for source navigation in emacs via [[https://github.com/jacktasia/dumb-jump][dumb-jump]]. +***** Improve support for navigating / editing source via emacs + +******* Support source navigation in emacs via [[https://github.com/jacktasia/dumb-jump][dumb-jump]]. + +******* Configure cperl-mode to match existing coding style. *** Various maintainer tweaks From 2791d00d06de6ae9790db3f2e22e921723b74f9d Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Sun, 31 Mar 2024 15:14:28 +0100 Subject: [PATCH 395/482] manual: Expand the definition of symlinks and disambiguate "target" Target can have two opposing meanings: 1. the target directory where symlinks are managed by Stow, and 2. the destinations of those symlinks So try to move away from this by using the word "destination" for symlinks. --- doc/stow.texi | 47 +++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 41 insertions(+), 6 deletions(-) diff --git a/doc/stow.texi b/doc/stow.texi index 87c83bd..e7d88e6 100644 --- a/doc/stow.texi +++ b/doc/stow.texi @@ -258,15 +258,50 @@ target directory, @file{/usr/local/stow} is the stow directory, @file{/usr/local/stow/perl} is the package directory, and @file{bin/perl} within is part of the installation image. +@anchor{symlink} @cindex symlink +@cindex symlink source +@cindex symlink destination @cindex relative symlink @cindex absolute symlink -A @dfn{symlink} is a symbolic link. A symlink can be @dfn{relative} or -@dfn{absolute}. An absolute symlink names a full path; that is, one -starting from @file{/}. A relative symlink names a relative path; that -is, one not starting from @file{/}. The target of a relative symlink is -computed starting from the symlink's own directory. Stow only -creates relative symlinks. +A @dfn{symlink} is a symbolic link, i.e. an entry on the filesystem +whose path is sometimes called the @dfn{symlink source}, which points to +another location on the filesystem called the @dfn{symlink destination}. +There is no guarantee that the destination actually exists. + +In general, symlinks can be @dfn{relative} or @dfn{absolute}. A symlink +is absolute when the destination names a full path; that is, one +starting from @file{/}. A symlink is relative when the destination +names a relative path; that is, one not starting from @file{/}. The +destination of a relative symlink is computed starting from the +symlink's own directory, i.e. the directory containing the symlink +source. + +@quotation Note +Stow only creates symlinks within the target directory which point to +locations @emph{outside} the target directory and inside the stow +directory. + +Consequently, we avoid referring to symlink destinations as symlink +@emph{targets}, since this would result in the word ``target'' having +two different meanings: + +@enumerate + +@item +the target directory, i.e.@: the directory into which Stow targets +installation, where symlinks are managed by Stow, and + +@item +the destinations of those symlinks. + +@end enumerate + +If we did not avoid the second meaning of ``target'', then it would lead +to confusing language, such as describing Stow as installing symlinks +into the target directory which point to targets @emph{outside} the +target directory. +@end quotation @c =========================================================================== @node Invoking Stow, Ignore Lists, Terminology, Top From 11d4ff01d774af872e2eb9b399ee24dc683774fc Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Sun, 31 Mar 2024 15:25:35 +0100 Subject: [PATCH 396/482] manual: avoid double spaces after "i.e." --- doc/stow.texi | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/doc/stow.texi b/doc/stow.texi index e7d88e6..7aa5f0e 100644 --- a/doc/stow.texi +++ b/doc/stow.texi @@ -222,7 +222,7 @@ to be installed in a particular directory structure --- e.g., with A @dfn{target directory} is the root of a tree in which one or more packages wish to @emph{appear} to be installed. @file{/usr/local} is a common choice for this, but by no means the only such location. Another -common choice is @file{~} (i.e. the user's @code{$HOME} directory) in +common choice is @file{~} (i.e.@: the user's @code{$HOME} directory) in the case where Stow is being used to manage the user's configuration (``dotfiles'') and other files in their @code{$HOME}. The examples in this manual will use @file{/usr/local} as the target directory. @@ -264,7 +264,7 @@ target directory, @file{/usr/local/stow} is the stow directory, @cindex symlink destination @cindex relative symlink @cindex absolute symlink -A @dfn{symlink} is a symbolic link, i.e. an entry on the filesystem +A @dfn{symlink} is a symbolic link, i.e.@: an entry on the filesystem whose path is sometimes called the @dfn{symlink source}, which points to another location on the filesystem called the @dfn{symlink destination}. There is no guarantee that the destination actually exists. @@ -274,7 +274,7 @@ is absolute when the destination names a full path; that is, one starting from @file{/}. A symlink is relative when the destination names a relative path; that is, one not starting from @file{/}. The destination of a relative symlink is computed starting from the -symlink's own directory, i.e. the directory containing the symlink +symlink's own directory, i.e.@: the directory containing the symlink source. @quotation Note @@ -421,7 +421,7 @@ refolding (@pxref{tree refolding}). If a new subdirectory is encountered whilst stowing a new package, the subdirectory is created within the target, and its contents are symlinked, rather than just creating a symlink for the directory. If removal of symlinks whilst -unstowing a package causes a subtree to be foldable (i.e. only +unstowing a package causes a subtree to be foldable (i.e.@: only containing symlinks to a single package), that subtree will not be removed and replaced with a symlink. From 1be40c053248c6b5d2b5110bb192d2d7dc3e6583 Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Sun, 31 Mar 2024 15:33:14 +0100 Subject: [PATCH 397/482] Stow.pm: reformat comments Some methods had comments with a prefix which made the paragraph inconveniently narrow, and made refilling it really awkward. So switch to a more natural comment style. --- lib/Stow.pm.in | 274 ++++++++++++++++++++++++++----------------------- 1 file changed, 144 insertions(+), 130 deletions(-) diff --git a/lib/Stow.pm.in b/lib/Stow.pm.in index 297bf9f..ce68784 100755 --- a/lib/Stow.pm.in +++ b/lib/Stow.pm.in @@ -334,16 +334,17 @@ sub plan_stow { }); } -#===== METHOD =============================================================== +# ===== METHOD =============================================================== # Name : within_target_do() # Purpose : execute code within target directory, preserving cwd # Parameters: $code => anonymous subroutine to execute within target dir # Returns : n/a # Throws : n/a -# Comments : This is done to ensure that the consumer of the Stow interface -# : doesn't have to worry about (a) what their cwd is, and -# : (b) that their cwd might change. -#============================================================================ +# +# This is done to ensure that the consumer of the Stow interface +# doesn't have to worry about (a) what their cwd is, and (b) that +# their cwd might change. +# ============================================================================ sub within_target_do { my $self = shift; my ($code) = @_; @@ -359,7 +360,7 @@ sub within_target_do { debug(3, 0, "cwd restored to $cwd"); } -#===== METHOD =============================================================== +# ===== METHOD =============================================================== # Name : stow_contents() # Purpose : stow the contents of the given directory # Parameters: $stow_path => relative path from current (i.e. target) directory @@ -376,10 +377,11 @@ sub within_target_do { # : to symlink source # Returns : n/a # Throws : a fatal error if directory cannot be read -# Comments : stow_node() and stow_contents() are mutually recursive. -# : $source and $target are used for creating the symlink -# : $path is used for folding/unfolding trees as necessary -#============================================================================ +# +# stow_node() and stow_contents() are mutually recursive. $source and +# $target are used for creating the symlink $path is used for +# folding/unfolding trees as necessary +# ============================================================================ sub stow_contents { my $self = shift; my ($stow_path, $package, $target, $source) = @_; @@ -435,7 +437,7 @@ sub stow_contents { } } -#===== METHOD =============================================================== +# ===== METHOD =============================================================== # Name : stow_node() # Purpose : stow the given node # Parameters: $stow_path => relative path from current (i.e. target) directory @@ -447,10 +449,11 @@ sub stow_contents { # : $source => relative path to symlink source from the dir of target # Returns : n/a # Throws : fatal exception if a conflict arises -# Comments : stow_node() and stow_contents() are mutually recursive. -# : $source and $target are used for creating the symlink -# : $path is used for folding/unfolding trees as necessary -#============================================================================ +# +# stow_node() and stow_contents() are mutually recursive. $source and +# $target are used for creating the symlink $path is used for +# folding/unfolding trees as necessary +# ============================================================================ sub stow_node { my $self = shift; my ($stow_path, $package, $target, $source) = @_; @@ -586,16 +589,17 @@ sub stow_node { return; } -#===== METHOD =============================================================== +# ===== METHOD =============================================================== # Name : should_skip_target() # Purpose : determine whether target is a stow directory which should # : not be stowed to or unstowed from # Parameters: $target => relative path to symlink target from the current directory # Returns : true iff target is a stow directory # Throws : n/a -# Comments : cwd must be the top-level target directory, otherwise -# : marked_stow_dir() won't work. -#============================================================================ +# +# cwd must be the top-level target directory, otherwise +# marked_stow_dir() won't work. +# ============================================================================ sub should_skip_target { my $self = shift; my ($target) = @_; @@ -632,16 +636,17 @@ sub marked_stow_dir { return 0; } -#===== METHOD =============================================================== +# ===== METHOD =============================================================== # Name : unstow_contents_orig() # Purpose : unstow the contents of the given directory # Parameters: $package => the package whose contents are being unstowed # : $target => relative path to symlink target from the current directory # Returns : n/a # Throws : a fatal error if directory cannot be read -# Comments : unstow_node_orig() and unstow_contents_orig() are mutually recursive -# : Here we traverse the target tree, rather than the source tree. -#============================================================================ +# +# unstow_node_orig() and unstow_contents_orig() are mutually recursive. +# Here we traverse the target tree, rather than the source tree. +# ============================================================================ sub unstow_contents_orig { my $self = shift; my ($package, $target) = @_; @@ -676,15 +681,16 @@ sub unstow_contents_orig { } } -#===== METHOD =============================================================== +# ===== METHOD =============================================================== # Name : unstow_node_orig() # Purpose : unstow the given node # Parameters: $package => the package containing the node being stowed # : $target => relative path to symlink target from the current directory # Returns : n/a # Throws : fatal error if a conflict arises -# Comments : unstow_node() and unstow_contents() are mutually recursive -#============================================================================ +# +# unstow_node() and unstow_contents() are mutually recursive. +# ============================================================================ sub unstow_node_orig { my $self = shift; my ($package, $target) = @_; @@ -752,16 +758,17 @@ sub unstow_node_orig { return; } -#===== METHOD =============================================================== +# ===== METHOD =============================================================== # Name : unstow_contents() # Purpose : unstow the contents of the given directory # Parameters: $package => the package whose contents are being unstowed # : $target => relative path to symlink target from the current directory # Returns : n/a # Throws : a fatal error if directory cannot be read -# Comments : unstow_node() and unstow_contents() are mutually recursive -# : Here we traverse the source tree, rather than the target tree. -#============================================================================ +# +# unstow_node() and unstow_contents() are mutually recursive. +# Here we traverse the source tree, rather than the target tree. +# ============================================================================ sub unstow_contents { my $self = shift; my ($package, $target) = @_; @@ -809,15 +816,16 @@ sub unstow_contents { } } -#===== METHOD =============================================================== +# ===== METHOD =============================================================== # Name : unstow_node() # Purpose : unstow the given node # Parameters: $package => the package containing the node being unstowed # : $target => relative path to symlink target from the current directory # Returns : n/a # Throws : fatal error if a conflict arises -# Comments : unstow_node() and unstow_contents() are mutually recursive -#============================================================================ +# +# unstow_node() and unstow_contents() are mutually recursive. +# ============================================================================ sub unstow_node { my $self = shift; my ($package, $target) = @_; @@ -915,7 +923,7 @@ sub unstow_node { return; } -#===== METHOD =============================================================== +# ===== METHOD =============================================================== # Name : link_owned_by_package() # Purpose : determine whether the given link points to a member of a # : stowed package @@ -923,8 +931,9 @@ sub unstow_node { # : $source => where that link points to # Returns : the package iff link is owned by stow, otherwise '' # Throws : n/a -# Comments : lossy wrapper around find_stowed_path() -#============================================================================ +# +# lossy wrapper around find_stowed_path(). +# ============================================================================ sub link_owned_by_package { my $self = shift; my ($target, $source) = @_; @@ -934,7 +943,7 @@ sub link_owned_by_package { return $package; } -#===== METHOD =============================================================== +# ===== METHOD =============================================================== # Name : find_stowed_path() # Purpose : determine whether the given symlink within the target directory # : is a stowed path pointing to a member of a package under the @@ -959,10 +968,11 @@ sub link_owned_by_package { # : to the stow directory; and $package is the name of the # : package; or ('', '', '') if link is not owned by stow. # Throws : n/a -# Comments : cwd must be the top-level target directory, otherwise -# : find_containing_marked_stow_dir() won't work. -# : Allow for stow dir not being under target dir. -#============================================================================ +# +# cwd must be the top-level target directory, otherwise +# find_containing_marked_stow_dir() won't work. Allow for stow dir +# not being under target dir. +# ============================================================================ sub find_stowed_path { my $self = shift; my ($target, $ldest) = @_; @@ -999,13 +1009,13 @@ sub find_stowed_path { return ('', '', ''); } -#===== METHOD ================================================================ +# ===== METHOD ================================================================ # Name : link_dest_within_stow_dir # Purpose : detect whether symlink destination is within current stow dir # Parameters: $ldest - destination of the symlink relative # Returns : ($package, $path) - package within the current stow dir # : and subpath within that package which the symlink points to -#============================================================================= +# ============================================================================= sub link_dest_within_stow_dir { my $self = shift; my ($ldest) = @_; @@ -1025,7 +1035,7 @@ sub link_dest_within_stow_dir { return ($package, $path); } -#===== METHOD ================================================================ +# ===== METHOD ================================================================ # Name : find_containing_marked_stow_dir # Purpose : detect whether path is within a marked stow directory # Parameters: $path => path to directory to check @@ -1034,9 +1044,10 @@ sub link_dest_within_stow_dir { # : as a Stow directory, and $package is the containing package; # : or ('', '') if no containing directory is marked as a stow # : directory. -# Comments : cwd must be the top-level target directory, otherwise -# : marked_stow_dir() won't work. -#============================================================================= +# +# cwd must be the top-level target directory, otherwise +# marked_stow_dir() won't work. +# ============================================================================= sub find_containing_marked_stow_dir { my $self = shift; my ($path) = @_; @@ -1061,20 +1072,21 @@ sub find_containing_marked_stow_dir { return ('', ''); } -#===== METHOD ================================================================ +# ===== METHOD ================================================================ # Name : cleanup_invalid_links() # Purpose : clean up orphaned links that may block folding # Parameters: $dir => path to directory to check # Returns : n/a # Throws : no exceptions -# Comments : This is invoked by unstow_contents(). -# : We only clean up links which are both orphaned and owned by -# : Stow, i.e. they point to a non-existent location within a -# : Stow package. These can block tree folding, and they can -# : easily occur when a file in Stow package is renamed or removed, -# : so the benefit should outweigh the low risk of actually someone -# : wanting to keep an orphaned link to within a Stow package. -#============================================================================= +# +# This is invoked by unstow_contents(). We only clean up links which +# are both orphaned and owned by Stow, i.e. they point to a +# non-existent location within a Stow package. These can block tree +# folding, and they can easily occur when a file in Stow package is +# renamed or removed, so the benefit should outweigh the low risk of +# actually someone wanting to keep an orphaned link to within a Stow +# package. +# ============================================================================= sub cleanup_invalid_links { my $self = shift; my ($dir) = @_; @@ -1146,15 +1158,16 @@ sub cleanup_invalid_links { } -#===== METHOD =============================================================== +# ===== METHOD =============================================================== # Name : foldable() # Purpose : determine whether a tree can be folded # Parameters: $target => path to a directory # Returns : path to the parent dir iff the tree can be safely folded # Throws : n/a -# Comments : the path returned is relative to the parent of $target, -# : that is, it can be used as the source for a replacement symlink -#============================================================================ +# +# The path returned is relative to the parent of $target, i.e. it can +# be used as the source for a replacement symlink. +# ============================================================================ sub foldable { my $self = shift; my ($target) = @_; @@ -1216,15 +1229,16 @@ sub foldable { } } -#===== METHOD =============================================================== +# ===== METHOD =============================================================== # Name : fold_tree() # Purpose : fold the given tree # Parameters: $source => link to the folded tree source # : $target => directory that we will replace with a link to $source # Returns : n/a # Throws : none -# Comments : only called iff foldable() is true so we can remove some checks -#============================================================================ +# +# Only called iff foldable() is true so we can remove some checks. +# ============================================================================ sub fold_tree { my $self = shift; my ($target, $source) = @_; @@ -1249,15 +1263,14 @@ sub fold_tree { } -#===== METHOD =============================================================== +# ===== METHOD =============================================================== # Name : conflict() # Purpose : handle conflicts in stow operations # Parameters: $package => the package involved with the conflicting operation # : $message => a description of the conflict # Returns : n/a # Throws : none -# Comments : none -#============================================================================ +# ============================================================================ sub conflict { my $self = shift; my ($action, $package, $message) = @_; @@ -1326,7 +1339,7 @@ sub get_action_count { return $self->{action_count}; } -#===== METHOD ================================================================ +# ===== METHOD ================================================================ # Name : ignore # Purpose : determine if the given path matches a regex in our ignore list # Parameters: $stow_path => the stow directory containing the package @@ -1335,8 +1348,7 @@ sub get_action_count { # : relative to its package directory # Returns : true iff the path should be ignored # Throws : no exceptions -# Comments : none -#============================================================================= +# ============================================================================= sub ignore { my $self = shift; my ($stow_path, $package, $target) = @_; @@ -1512,14 +1524,13 @@ sub get_default_global_ignore_regexps { return $class->get_ignore_regexps_from_fh(\*DATA); } -#===== METHOD ================================================================ +# ===== METHOD ================================================================ # Name : defer # Purpose : determine if the given path matches a regex in our defer list # Parameters: $path # Returns : Boolean # Throws : no exceptions -# Comments : none -#============================================================================= +# ============================================================================= sub defer { my $self = shift; my ($path) = @_; @@ -1530,14 +1541,13 @@ sub defer { return 0; } -#===== METHOD ================================================================ +# ===== METHOD ================================================================ # Name : override # Purpose : determine if the given path matches a regex in our override list # Parameters: $path # Returns : Boolean # Throws : no exceptions -# Comments : none -#============================================================================= +# ============================================================================= sub override { my $self = shift; my ($path) = @_; @@ -1555,14 +1565,13 @@ sub override { # ############################################################################## -#===== METHOD =============================================================== +# ===== METHOD =============================================================== # Name : process_tasks() # Purpose : process each task in the tasks list # Parameters: none # Returns : n/a # Throws : fatal error if tasks list is corrupted or a task fails -# Comments : none -#============================================================================ +# ============================================================================ sub process_tasks { my $self = shift; @@ -1584,16 +1593,17 @@ sub process_tasks { debug(2, 0, "Processing tasks... done"); } -#===== METHOD =============================================================== +# ===== METHOD =============================================================== # Name : process_task() # Purpose : process a single task # Parameters: $task => the task to process # Returns : n/a # Throws : fatal error if task fails -# Comments : Must run from within target directory. -# : Task involve either creating or deleting dirs and symlinks -# : an action is set to 'skip' if it is found to be redundant -#============================================================================ +# +# Must run from within target directory. Task involve either creating +# or deleting dirs and symlinks an action is set to 'skip' if it is +# found to be redundant +# ============================================================================ sub process_task { my $self = shift; my ($task) = @_; @@ -1640,14 +1650,13 @@ sub process_task { internal_error("bad task action: $task->{action}"); } -#===== METHOD =============================================================== +# ===== METHOD =============================================================== # Name : link_task_action() # Purpose : finds the link task action for the given path, if there is one # Parameters: $path # Returns : 'remove', 'create', or '' if there is no action # Throws : a fatal exception if an invalid action is found -# Comments : none -#============================================================================ +# ============================================================================ sub link_task_action { my $self = shift; my ($path) = @_; @@ -1665,14 +1674,13 @@ sub link_task_action { return $action; } -#===== METHOD =============================================================== +# ===== METHOD =============================================================== # Name : dir_task_action() # Purpose : finds the dir task action for the given path, if there is one # Parameters: $path # Returns : 'remove', 'create', or '' if there is no action # Throws : a fatal exception if an invalid action is found -# Comments : none -#============================================================================ +# ============================================================================ sub dir_task_action { my $self = shift; my ($path) = @_; @@ -1690,15 +1698,14 @@ sub dir_task_action { return $action; } -#===== METHOD =============================================================== +# ===== METHOD =============================================================== # Name : parent_link_scheduled_for_removal() # Purpose : determine whether the given path or any parent thereof # : is a link scheduled for removal # Parameters: $path # Returns : Boolean # Throws : none -# Comments : none -#============================================================================ +# ============================================================================ sub parent_link_scheduled_for_removal { my $self = shift; my ($path) = @_; @@ -1718,15 +1725,16 @@ sub parent_link_scheduled_for_removal { return 0; } -#===== METHOD =============================================================== +# ===== METHOD =============================================================== # Name : is_a_link() # Purpose : determine if the given path is a current or planned link # Parameters: $path # Returns : Boolean # Throws : none -# Comments : returns false if an existing link is scheduled for removal -# : and true if a non-existent link is scheduled for creation -#============================================================================ +# +# Returns false if an existing link is scheduled for removal and true +# if a non-existent link is scheduled for creation. +# ============================================================================ sub is_a_link { my $self = shift; my ($path) = @_; @@ -1754,16 +1762,17 @@ sub is_a_link { return 0; } -#===== METHOD =============================================================== +# ===== METHOD =============================================================== # Name : is_a_dir() # Purpose : determine if the given path is a current or planned directory # Parameters: $path # Returns : Boolean # Throws : none -# Comments : returns false if an existing directory is scheduled for removal -# : and true if a non-existent directory is scheduled for creation -# : we also need to be sure we are not just following a link -#============================================================================ +# +# Returns false if an existing directory is scheduled for removal and +# true if a non-existent directory is scheduled for creation. We also +# need to be sure we are not just following a link. +# ============================================================================ sub is_a_dir { my $self = shift; my ($path) = @_; @@ -1789,16 +1798,17 @@ sub is_a_dir { return 0; } -#===== METHOD =============================================================== +# ===== METHOD =============================================================== # Name : is_a_node() # Purpose : determine whether the given path is a current or planned node # Parameters: $path # Returns : Boolean # Throws : none -# Comments : returns false if an existing node is scheduled for removal -# : true if a non-existent node is scheduled for creation -# : we also need to be sure we are not just following a link -#============================================================================ +# +# Returns false if an existing node is scheduled for removal true if a +# non-existent node is scheduled for creation. we also need to be +# sure we are not just following a link. +# ============================================================================ sub is_a_node { my $self = shift; my ($path) = @_; @@ -1861,15 +1871,14 @@ sub is_a_node { return 0; } -#===== METHOD =============================================================== +# ===== METHOD =============================================================== # Name : read_a_link() # Purpose : return the source of a current or planned link # Parameters: $path => path to the link target # Returns : a string # Throws : fatal exception if the given path is not a current or planned # : link -# Comments : none -#============================================================================ +# ============================================================================ sub read_a_link { my $self = shift; my ($path) = @_; @@ -1894,15 +1903,16 @@ sub read_a_link { internal_error("read_a_link() passed a non link path: $path\n"); } -#===== METHOD =============================================================== +# ===== METHOD =============================================================== # Name : do_link() # Purpose : wrap 'link' operation for later processing # Parameters: $oldfile => the existing file to link to # : $newfile => the file to link # Returns : n/a # Throws : error if this clashes with an existing planned operation -# Comments : cleans up operations that undo previous operations -#============================================================================ +# +# Cleans up operations that undo previous operations. +# ============================================================================ sub do_link { my $self = shift; my ($oldfile, $newfile) = @_; @@ -1972,14 +1982,15 @@ sub do_link { return; } -#===== METHOD =============================================================== +# ===== METHOD =============================================================== # Name : do_unlink() # Purpose : wrap 'unlink' operation for later processing # Parameters: $file => the file to unlink # Returns : n/a # Throws : error if this clashes with an existing planned operation -# Comments : will remove an existing planned link -#============================================================================ +# +# Will remove an existing planned link. +# ============================================================================ sub do_unlink { my $self = shift; my ($file) = @_; @@ -2027,16 +2038,18 @@ sub do_unlink { return; } -#===== METHOD =============================================================== +# ===== METHOD =============================================================== # Name : do_mkdir() # Purpose : wrap 'mkdir' operation # Parameters: $dir => the directory to remove # Returns : n/a # Throws : fatal exception if operation fails -# Comments : outputs a message if 'verbose' option is set -# : does not perform operation if 'simulate' option is set -# Comments : cleans up operations that undo previous operations -#============================================================================ +# +# Outputs a message if 'verbose' option is set. +# Does not perform operation if 'simulate' option is set. +# +# Cleans up operations that undo previous operations. +# ============================================================================ sub do_mkdir { my $self = shift; my ($dir) = @_; @@ -2090,15 +2103,16 @@ sub do_mkdir { return; } -#===== METHOD =============================================================== +# ===== METHOD =============================================================== # Name : do_rmdir() # Purpose : wrap 'rmdir' operation # Parameters: $dir => the directory to remove # Returns : n/a # Throws : fatal exception if operation fails -# Comments : outputs a message if 'verbose' option is set -# : does not perform operation if 'simulate' option is set -#============================================================================ +# +# Outputs a message if 'verbose' option is set. +# Does not perform operation if 'simulate' option is set. +# ============================================================================ sub do_rmdir { my $self = shift; my ($dir) = @_; @@ -2144,15 +2158,16 @@ sub do_rmdir { return; } -#===== METHOD =============================================================== +# ===== METHOD =============================================================== # Name : do_mv() # Purpose : wrap 'move' operation for later processing # Parameters: $src => the file to move # : $dst => the path to move it to # Returns : n/a # Throws : error if this clashes with an existing planned operation -# Comments : alters contents of package installation image in stow dir -#============================================================================ +# +# Alters contents of package installation image in stow dir. +# ============================================================================ sub do_mv { my $self = shift; my ($src, $dst) = @_; @@ -2198,14 +2213,13 @@ sub do_mv { # FIXME: Ideally these should be in a separate module. -#===== PRIVATE SUBROUTINE =================================================== +# ===== PRIVATE SUBROUTINE =================================================== # Name : internal_error() # Purpose : output internal error message in a consistent form and die # Parameters: $message => error message to output # Returns : n/a # Throws : n/a -# Comments : none -#============================================================================ +# ============================================================================ sub internal_error { my ($format, @args) = @_; my $error = sprintf($format, @args); From f4f3836c5f2b5a6ad2598926ae4f0969f95c3f36 Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Sun, 31 Mar 2024 15:38:38 +0100 Subject: [PATCH 398/482] Stow.pm: rename $ldest to $link_dest for clarity --- lib/Stow.pm.in | 45 +++++++++++++++++++++++---------------------- lib/Stow/Util.pm.in | 4 ++-- 2 files changed, 25 insertions(+), 24 deletions(-) diff --git a/lib/Stow.pm.in b/lib/Stow.pm.in index ce68784..3ed5679 100755 --- a/lib/Stow.pm.in +++ b/lib/Stow.pm.in @@ -953,7 +953,8 @@ sub link_owned_by_package { # : the target directory, relative to the # : top-level target directory (which is also # : expected to be the current directory). -# : $ldest => where that link points to (needed because link +# : +# : $link_dest => where that link points to (needed because link # : might not exist yet due to two-phase approach, # : so we can't just call readlink()). If this is # : owned by Stow, it will be expressed relative to @@ -964,7 +965,7 @@ sub link_owned_by_package { # Returns : ($path, $stow_path, $package) where $path and $stow_path # : are relative from the top-level target directory. $path # : is the full relative path to the member of the package -# : pointed to by $ldest; $stow_path is the relative path +# : pointed to by $link_dest; $stow_path is the relative path # : to the stow directory; and $package is the name of the # : package; or ('', '', '') if link is not owned by stow. # Throws : n/a @@ -975,9 +976,9 @@ sub link_owned_by_package { # ============================================================================ sub find_stowed_path { my $self = shift; - my ($target, $ldest) = @_; + my ($target, $link_dest) = @_; - if (substr($ldest, 0, 1) eq '/') { + if (substr($link_dest, 0, 1) eq '/') { # Symlink points to an absolute path, therefore it cannot be # owned by Stow. return ('', '', ''); @@ -986,8 +987,8 @@ sub find_stowed_path { # Evaluate softlink relative to its target, without relying on # what's actually on the filesystem, since the link might not # exist yet. - debug(4, 2, "find_stowed_path(target=$target; source=$ldest)"); - my $dest = join_paths(parent($target), $ldest); + debug(4, 2, "find_stowed_path(target=$target; source=$link_dest)"); + my $dest = join_paths(parent($target), $link_dest); debug(4, 3, "is symlink destination $dest owned by stow?"); # First check whether the link is owned by the current stow @@ -1012,24 +1013,24 @@ sub find_stowed_path { # ===== METHOD ================================================================ # Name : link_dest_within_stow_dir # Purpose : detect whether symlink destination is within current stow dir -# Parameters: $ldest - destination of the symlink relative +# Parameters: $link_dest - destination of the symlink relative # Returns : ($package, $path) - package within the current stow dir # : and subpath within that package which the symlink points to # ============================================================================= sub link_dest_within_stow_dir { my $self = shift; - my ($ldest) = @_; + my ($link_dest) = @_; - debug(4, 4, "common prefix? ldest=$ldest; stow_path=$self->{stow_path}"); + debug(4, 4, "common prefix? link_dest=$link_dest; stow_path=$self->{stow_path}"); - my $removed = $ldest =~ s,^\Q$self->{stow_path}/,,; + my $removed = $link_dest =~ s,^\Q$self->{stow_path}/,,; if (! $removed) { - debug(4, 3, "no - $ldest not under $self->{stow_path}"); + debug(4, 3, "no - $link_dest not under $self->{stow_path}"); return ('', ''); } - debug(4, 4, "remaining after removing $self->{stow_path}: $ldest"); - my @dirs = File::Spec->splitdir($ldest); + debug(4, 4, "remaining after removing $self->{stow_path}: $link_dest"); + my @dirs = File::Spec->splitdir($link_dest); my $package = shift @dirs; my $path = File::Spec->catdir(@dirs); return ($package, $path); @@ -1127,30 +1128,30 @@ sub cleanup_invalid_links { # Where is the link pointing? # (don't use read_a_link() here) - my $ldest = readlink($node_path); - if (not $ldest) { + my $link_dest = readlink($node_path); + if (not $link_dest) { error("Could not read link $node_path"); } - my $target = join_paths($dir, $ldest); - debug(4, 2, "join $dir $ldest"); + my $target = join_paths($dir, $link_dest); + debug(4, 2, "join $dir $link_dest"); if (-e $target) { - debug(4, 2, "Link target $ldest exists at $target; skipping clean up"); + debug(4, 2, "Link target $link_dest exists at $target; skipping clean up"); next; } else { - debug(4, 2, "Link target $ldest doesn't exist at $target"); + debug(4, 2, "Link target $link_dest doesn't exist at $target"); } debug(3, 1, - "Checking whether valid link $node_path -> $ldest is " . + "Checking whether valid link $node_path -> $link_dest is " . "owned by stow"); - my $owner = $self->link_owned_by_package($node_path, $ldest); + my $owner = $self->link_owned_by_package($node_path, $link_dest); if ($owner) { # owned by stow debug(2, 0, "--- removing link owned by $owner: $node_path => " . - join_paths($dir, $ldest)); + join_paths($dir, $link_dest)); $self->do_unlink($node_path); } } diff --git a/lib/Stow/Util.pm.in b/lib/Stow/Util.pm.in index 851f425..3b7dc3e 100644 --- a/lib/Stow/Util.pm.in +++ b/lib/Stow/Util.pm.in @@ -239,10 +239,10 @@ sub restore_cwd { } sub adjust_dotfile { - my ($target) = @_; + my ($link_dest) = @_; my @result = (); - for my $part (split m{/+}, $target) { + for my $part (split m{/+}, $link_dest) { if (($part ne "dot-") && ($part ne "dot-.")) { $part =~ s/^dot-/./; } From 245dc83849f6babc767f60eae0f4463cddf048d3 Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Sun, 31 Mar 2024 16:10:08 +0100 Subject: [PATCH 399/482] Stow.pm: reformat old comment style as pod As previously noted, the old comment style was difficult to edit. It's also not idiomatic Perl style, so reformat as pod. This exposes more of the inner workings of Stow as documentation, but that shouldn't be a problem. As part of this change, remove outdated and sometimes misleading information about if/when each function throws an exception. --- NEWS | 5 +- lib/Stow.pm.in | 1031 +++++++++++++++++++++++++++++++----------------- 2 files changed, 667 insertions(+), 369 deletions(-) diff --git a/NEWS b/NEWS index f414592..9d18951 100644 --- a/NEWS +++ b/NEWS @@ -22,13 +22,14 @@ News file for Stow. ***** Added some more information from the web page to the README -***** Made some small improvements to the documentation +***** Made some improvements to the documentation ***** Improve readability of source code Quite a few extra details have been added in comments to clarify how the code works. Some variable names have also been - improved. + improved. The comments of many Stow class methods have been + converted into Perl POD format. ***** Added a =CONTRIBUTING.md= file diff --git a/lib/Stow.pm.in b/lib/Stow.pm.in index 3ed5679..cc28565 100755 --- a/lib/Stow.pm.in +++ b/lib/Stow.pm.in @@ -334,17 +334,24 @@ sub plan_stow { }); } -# ===== METHOD =============================================================== -# Name : within_target_do() -# Purpose : execute code within target directory, preserving cwd -# Parameters: $code => anonymous subroutine to execute within target dir -# Returns : n/a -# Throws : n/a -# -# This is done to ensure that the consumer of the Stow interface -# doesn't have to worry about (a) what their cwd is, and (b) that -# their cwd might change. -# ============================================================================ +=head2 within_target_do($code) + +Execute code within target directory, preserving cwd. + +=over 4 + +=item $code + +Anonymous subroutine to execute within target dir. + +=back + +This is done to ensure that the consumer of the Stow interface doesn't +have to worry about (a) what their cwd is, and (b) that their cwd +might change. + +=cut + sub within_target_do { my $self = shift; my ($code) = @_; @@ -360,28 +367,41 @@ sub within_target_do { debug(3, 0, "cwd restored to $cwd"); } -# ===== METHOD =============================================================== -# Name : stow_contents() -# Purpose : stow the contents of the given directory -# Parameters: $stow_path => relative path from current (i.e. target) directory -# : to the stow dir containing the package to be stowed. -# : This can differ from $self->{stow_path} when unfolding -# : a (sub)tree which is already stowed from a package -# : in a different stow directory (see the "Multiple Stow -# : Directories" section of the manual). -# : $package => the package whose contents are being stowed -# : $target => subpath relative to package directory which needs -# : stowing as a symlink at subpath relative to target -# : directory. -# : $source => relative path from the (sub)dir of target -# : to symlink source -# Returns : n/a -# Throws : a fatal error if directory cannot be read -# -# stow_node() and stow_contents() are mutually recursive. $source and -# $target are used for creating the symlink $path is used for -# folding/unfolding trees as necessary -# ============================================================================ +=head2 stow_contents($stow_path, $package, $target, $source) + +Stow the contents of the given directory. + +=over 4 + +=item $stow_path + +Relative path from current (i.e. target) directory to the stow dir +containing the package to be stowed. This can differ from +C<$self->{stow_path}> when unfolding a (sub)tree which is already +stowed from a package in a different stow directory (see the "Multiple +Stow Directories" section of the manual). + +=item $package + +The package whose contents are being stowed. + +=item $target + +Subpath relative to package directory which needs stowing as a symlink +at subpath relative to target directory. + +=item $source + +Relative path from the (sub)dir of target to symlink source. + +=back + +C and C are mutually recursive. $source +and $target are used for creating the symlink. C<$path> is used for +folding/unfolding trees as necessary. + +=cut + sub stow_contents { my $self = shift; my ($stow_path, $package, $target, $source) = @_; @@ -437,23 +457,41 @@ sub stow_contents { } } -# ===== METHOD =============================================================== -# Name : stow_node() -# Purpose : stow the given node -# Parameters: $stow_path => relative path from current (i.e. target) directory -# : to the stow dir containing the node to be stowed -# : $package => the package containing the node being stowed -# : $target => subpath relative to package directory of node which -# : needs stowing as a symlink at subpath relative to -# : target directory. -# : $source => relative path to symlink source from the dir of target -# Returns : n/a -# Throws : fatal exception if a conflict arises -# -# stow_node() and stow_contents() are mutually recursive. $source and -# $target are used for creating the symlink $path is used for -# folding/unfolding trees as necessary -# ============================================================================ +=head2 stow_node($stow_path, $package, $target, $source) + +Stow the given node + +=over 4 + +=item $stow_path + +Relative path from current (i.e. target) directory to the stow dir +containing the node to be stowed. This can differ from +C<$self->{stow_path}> when unfolding a (sub)tree which is already +stowed from a package in a different stow directory (see the "Multiple +Stow Directories" section of the manual). + +=item $package + +The package containing the node being stowed + +=item $target + +Subpath relative to package directory of node which needs stowing as a +symlink at subpath relative to target directory. + +=item $source + +Relative path to symlink source from the dir of target. + +=back + +C and C are mutually recursive. $source +and $target are used for creating the symlink C<$path> is used for +folding/unfolding trees as necessary. + +=cut + sub stow_node { my $self = shift; my ($stow_path, $package, $target, $source) = @_; @@ -589,17 +627,24 @@ sub stow_node { return; } -# ===== METHOD =============================================================== -# Name : should_skip_target() -# Purpose : determine whether target is a stow directory which should -# : not be stowed to or unstowed from -# Parameters: $target => relative path to symlink target from the current directory -# Returns : true iff target is a stow directory -# Throws : n/a -# -# cwd must be the top-level target directory, otherwise -# marked_stow_dir() won't work. -# ============================================================================ +=head2 should_skip_target($target) + +Determine whether target is a stow directory which should +not be stowed to or unstowed from. + +=over 4 + +=item $target => relative path to symlink target from the current directory + +=back + +Returns true iff target is a stow directory + +cwd must be the top-level target directory, otherwise +C won't work. + +=cut + sub should_skip_target { my $self = shift; my ($target) = @_; @@ -636,17 +681,27 @@ sub marked_stow_dir { return 0; } -# ===== METHOD =============================================================== -# Name : unstow_contents_orig() -# Purpose : unstow the contents of the given directory -# Parameters: $package => the package whose contents are being unstowed -# : $target => relative path to symlink target from the current directory -# Returns : n/a -# Throws : a fatal error if directory cannot be read -# -# unstow_node_orig() and unstow_contents_orig() are mutually recursive. -# Here we traverse the target tree, rather than the source tree. -# ============================================================================ +=head2 unstow_contents_orig($package, $target) + +Unstow the contents of the given directory + +=over 4 + +=item $package + +The package whose contents are being unstowed. + +=item $target + +Relative path to symlink target from the current directory. + +=back + +unstow_node_orig() and unstow_contents_orig() are mutually recursive. +Here we traverse the target tree, rather than the source tree. + +=cut + sub unstow_contents_orig { my $self = shift; my ($package, $target) = @_; @@ -681,16 +736,26 @@ sub unstow_contents_orig { } } -# ===== METHOD =============================================================== -# Name : unstow_node_orig() -# Purpose : unstow the given node -# Parameters: $package => the package containing the node being stowed -# : $target => relative path to symlink target from the current directory -# Returns : n/a -# Throws : fatal error if a conflict arises -# -# unstow_node() and unstow_contents() are mutually recursive. -# ============================================================================ +=head2 unstow_node_orig($package, $target) + +Unstow the given node + +=over 4 + +=item $package + +The package containing the node being stowed. + +=item $target + +Relative path to symlink target from the current directory. + +=back + +C and C are mutually recursive. + +=cut + sub unstow_node_orig { my $self = shift; my ($package, $target) = @_; @@ -758,17 +823,27 @@ sub unstow_node_orig { return; } -# ===== METHOD =============================================================== -# Name : unstow_contents() -# Purpose : unstow the contents of the given directory -# Parameters: $package => the package whose contents are being unstowed -# : $target => relative path to symlink target from the current directory -# Returns : n/a -# Throws : a fatal error if directory cannot be read -# -# unstow_node() and unstow_contents() are mutually recursive. -# Here we traverse the source tree, rather than the target tree. -# ============================================================================ +=head2 unstow_contents($package, $target) + +Unstow the contents of the given directory + +=over 4 + +=item $package + +The package whose contents are being unstowed. + +=item $target + +Relative path to symlink target from the current directory. + +=back + +C and C are mutually recursive. +Here we traverse the source tree, rather than the target tree. + +=cut + sub unstow_contents { my $self = shift; my ($package, $target) = @_; @@ -816,16 +891,26 @@ sub unstow_contents { } } -# ===== METHOD =============================================================== -# Name : unstow_node() -# Purpose : unstow the given node -# Parameters: $package => the package containing the node being unstowed -# : $target => relative path to symlink target from the current directory -# Returns : n/a -# Throws : fatal error if a conflict arises -# -# unstow_node() and unstow_contents() are mutually recursive. -# ============================================================================ +=head2 unstow_node($package, $target) + +Unstow the given node. + +=over 4 + +=item $package + +The package containing the node being unstowed. + +=item $target + +Relative path to symlink target from the current directory. + +=back + +C and C are mutually recursive. + +=cut + sub unstow_node { my $self = shift; my ($package, $target) = @_; @@ -923,17 +1008,29 @@ sub unstow_node { return; } -# ===== METHOD =============================================================== -# Name : link_owned_by_package() -# Purpose : determine whether the given link points to a member of a -# : stowed package -# Parameters: $target => path to a symbolic link under current directory -# : $source => where that link points to -# Returns : the package iff link is owned by stow, otherwise '' -# Throws : n/a -# -# lossy wrapper around find_stowed_path(). -# ============================================================================ +=head2 link_owned_by_package($target, $source) + +Determine whether the given link points to a member of a stowed +package. + +=over 4 + +=item $target + +Path to a symbolic link under current directory. + +=item $source + +Where that link points to. + +=back + +Lossy wrapper around find_stowed_path(). + +Returns the package iff link is owned by stow, otherwise ''. + +=cut + sub link_owned_by_package { my $self = shift; my ($target, $source) = @_; @@ -943,37 +1040,44 @@ sub link_owned_by_package { return $package; } -# ===== METHOD =============================================================== -# Name : find_stowed_path() -# Purpose : determine whether the given symlink within the target directory -# : is a stowed path pointing to a member of a package under the -# : stow dir, and if so, obtain a breakdown of information about -# : this stowed path. -# Parameters: $target => path to a symbolic link somewhere under -# : the target directory, relative to the -# : top-level target directory (which is also -# : expected to be the current directory). -# : -# : $link_dest => where that link points to (needed because link -# : might not exist yet due to two-phase approach, -# : so we can't just call readlink()). If this is -# : owned by Stow, it will be expressed relative to -# : (the directory containing) $target. However if -# : it's not, it could of course be relative or absolute, -# : point absolutely anywhere, and could even be -# : dangling. -# Returns : ($path, $stow_path, $package) where $path and $stow_path -# : are relative from the top-level target directory. $path -# : is the full relative path to the member of the package -# : pointed to by $link_dest; $stow_path is the relative path -# : to the stow directory; and $package is the name of the -# : package; or ('', '', '') if link is not owned by stow. -# Throws : n/a -# -# cwd must be the top-level target directory, otherwise -# find_containing_marked_stow_dir() won't work. Allow for stow dir -# not being under target dir. -# ============================================================================ +=head2 find_stowed_path($target, $link_dest) + +Determine whether the given symlink within the target directory is a +stowed path pointing to a member of a package under the stow dir, and +if so, obtain a breakdown of information about this stowed path. + +=over 4 + +=item $target + +Path to a symbolic link somewhere under the target directory, relative +to the top-level target directory (which is also expected to be the +current directory). + +=item $link_dest + +Where that link points to (needed because link might not exist yet due +to two-phase approach, so we can't just call C). If this +is owned by Stow, it will be expressed relative to (the directory +containing) C<$target>. However if it's not, it could of course be +relative or absolute, point absolutely anywhere, and could even be +dangling. + +=back + +Returns C<($path, $stow_path, $package)> where C<$path> and +C<$stow_path> are relative from the top-level target directory. +C<$path> is the full relative path to the member of the package +pointed to by C<$link_dest>; C<$stow_path> is the relative path to the +stow directory; and C<$package> is the name of the package; or C<('', +'', '')> if link is not owned by stow. + +cwd must be the top-level target directory, otherwise +C won't work. Allow for stow dir +not being under target dir. + +=cut + sub find_stowed_path { my $self = shift; my ($target, $link_dest) = @_; @@ -1010,13 +1114,21 @@ sub find_stowed_path { return ('', '', ''); } -# ===== METHOD ================================================================ -# Name : link_dest_within_stow_dir -# Purpose : detect whether symlink destination is within current stow dir -# Parameters: $link_dest - destination of the symlink relative -# Returns : ($package, $path) - package within the current stow dir -# : and subpath within that package which the symlink points to -# ============================================================================= +=head2 link_dest_within_stow_dir($link_dest) + +Detect whether symlink destination is within current stow dir + +=over 4 + +=item $link_dest - destination of the symlink relative + +=back + +Returns C<($package, $path)> - package within the current stow dir +and subpath within that package which the symlink points to. + +=cut + sub link_dest_within_stow_dir { my $self = shift; my ($link_dest) = @_; @@ -1036,19 +1148,27 @@ sub link_dest_within_stow_dir { return ($package, $path); } -# ===== METHOD ================================================================ -# Name : find_containing_marked_stow_dir -# Purpose : detect whether path is within a marked stow directory -# Parameters: $path => path to directory to check -# Returns : ($stow_path, $package) where $stow_path is the highest directory -# : (relative from the top-level target directory) which is marked -# : as a Stow directory, and $package is the containing package; -# : or ('', '') if no containing directory is marked as a stow -# : directory. -# -# cwd must be the top-level target directory, otherwise -# marked_stow_dir() won't work. -# ============================================================================= +=head2 find_containing_marked_stow_dir($path) + +Detect whether path is within a marked stow directory + +=over 4 + +=item $path => path to directory to check + +=back + +Returns C<($stow_path, $package)> where C<$stow_path> is the highest +directory (relative from the top-level target directory) which is +marked as a Stow directory, and C<$package> is the containing package; +or C<('', '')> if no containing directory is marked as a stow +directory. + +cwd must be the top-level target directory, otherwise +C won't work. + +=cut + sub find_containing_marked_stow_dir { my $self = shift; my ($path) = @_; @@ -1073,21 +1193,27 @@ sub find_containing_marked_stow_dir { return ('', ''); } -# ===== METHOD ================================================================ -# Name : cleanup_invalid_links() -# Purpose : clean up orphaned links that may block folding -# Parameters: $dir => path to directory to check -# Returns : n/a -# Throws : no exceptions -# -# This is invoked by unstow_contents(). We only clean up links which -# are both orphaned and owned by Stow, i.e. they point to a -# non-existent location within a Stow package. These can block tree -# folding, and they can easily occur when a file in Stow package is -# renamed or removed, so the benefit should outweigh the low risk of -# actually someone wanting to keep an orphaned link to within a Stow -# package. -# ============================================================================= +=head2 cleanup_invalid_links($dir) + +Clean up orphaned links that may block folding + +=over 4 + +=item $dir + +Path to directory to check + +=back + +This is invoked by C. We only clean up links which +are both orphaned and owned by Stow, i.e. they point to a non-existent +location within a Stow package. These can block tree folding, and +they can easily occur when a file in Stow package is renamed or +removed, so the benefit should outweigh the low risk of actually +someone wanting to keep an orphaned link to within a Stow package. + +=cut + sub cleanup_invalid_links { my $self = shift; my ($dir) = @_; @@ -1159,16 +1285,24 @@ sub cleanup_invalid_links { } -# ===== METHOD =============================================================== -# Name : foldable() -# Purpose : determine whether a tree can be folded -# Parameters: $target => path to a directory -# Returns : path to the parent dir iff the tree can be safely folded -# Throws : n/a -# -# The path returned is relative to the parent of $target, i.e. it can -# be used as the source for a replacement symlink. -# ============================================================================ +=head2 foldable($target) + +Determine whether a tree can be folded + +=over 4 + +=item $target + +path to a directory + +=back + +Returns path to the parent dir iff the tree can be safely folded. The +path returned is relative to the parent of $target, i.e. it can be +used as the source for a replacement symlink. + +=cut + sub foldable { my $self = shift; my ($target) = @_; @@ -1230,16 +1364,26 @@ sub foldable { } } -# ===== METHOD =============================================================== -# Name : fold_tree() -# Purpose : fold the given tree -# Parameters: $source => link to the folded tree source -# : $target => directory that we will replace with a link to $source -# Returns : n/a -# Throws : none -# -# Only called iff foldable() is true so we can remove some checks. -# ============================================================================ +=head2 fold_tree($target, source) + +Fold the given tree + +=over 4 + +=item $target + +directory that we will replace with a link to $source + +=item $source + +link to the folded tree source + +=back + +Only called iff foldable() is true so we can remove some checks. + +=cut + sub fold_tree { my $self = shift; my ($target, $source) = @_; @@ -1264,14 +1408,24 @@ sub fold_tree { } -# ===== METHOD =============================================================== -# Name : conflict() -# Purpose : handle conflicts in stow operations -# Parameters: $package => the package involved with the conflicting operation -# : $message => a description of the conflict -# Returns : n/a -# Throws : none -# ============================================================================ +=head2 conflict($package, $message) + +Handle conflicts in stow operations + +=over 4 + +=item $package + +the package involved with the conflicting operation + +=item $message + +a description of the conflict + +=back + +=cut + sub conflict { my $self = shift; my ($action, $package, $message) = @_; @@ -1340,16 +1494,31 @@ sub get_action_count { return $self->{action_count}; } -# ===== METHOD ================================================================ -# Name : ignore -# Purpose : determine if the given path matches a regex in our ignore list -# Parameters: $stow_path => the stow directory containing the package -# : $package => the package containing the path -# : $target => the path to check against the ignore list -# : relative to its package directory -# Returns : true iff the path should be ignored -# Throws : no exceptions -# ============================================================================= +=head2 ignore($stow_path, $package, $target) + +Determine if the given path matches a regex in our ignore list. + +=over 4 + +=item $stow_path + +the stow directory containing the package + +=item $package + +the package containing the path + +=item $target + +the path to check against the ignore list relative to its package +directory + +=back + +Returns true iff the path should be ignored. + +=cut + sub ignore { my $self = shift; my ($stow_path, $package, $target) = @_; @@ -1525,13 +1694,20 @@ sub get_default_global_ignore_regexps { return $class->get_ignore_regexps_from_fh(\*DATA); } -# ===== METHOD ================================================================ -# Name : defer -# Purpose : determine if the given path matches a regex in our defer list -# Parameters: $path -# Returns : Boolean -# Throws : no exceptions -# ============================================================================= +=head2 defer($path) + +Determine if the given path matches a regex in our C list + +=over 4 + +=item $path + +=back + +Returns boolean. + +=cut + sub defer { my $self = shift; my ($path) = @_; @@ -1542,13 +1718,20 @@ sub defer { return 0; } -# ===== METHOD ================================================================ -# Name : override -# Purpose : determine if the given path matches a regex in our override list -# Parameters: $path -# Returns : Boolean -# Throws : no exceptions -# ============================================================================= +=head2 override($path) + +Determine if the given path matches a regex in our C list + +=over 4 + +=item $path + +=back + +Returns boolean + +=cut + sub override { my $self = shift; my ($path) = @_; @@ -1566,13 +1749,21 @@ sub override { # ############################################################################## -# ===== METHOD =============================================================== -# Name : process_tasks() -# Purpose : process each task in the tasks list -# Parameters: none -# Returns : n/a -# Throws : fatal error if tasks list is corrupted or a task fails -# ============================================================================ +=head2 process_tasks() + +Process each task in the tasks list + +=over 4 + +=item none + +=back + +Returns : n/a +Throws : fatal error if tasks list is corrupted or a task fails + +=cut + sub process_tasks { my $self = shift; @@ -1594,17 +1785,25 @@ sub process_tasks { debug(2, 0, "Processing tasks... done"); } -# ===== METHOD =============================================================== -# Name : process_task() -# Purpose : process a single task -# Parameters: $task => the task to process -# Returns : n/a -# Throws : fatal error if task fails -# -# Must run from within target directory. Task involve either creating -# or deleting dirs and symlinks an action is set to 'skip' if it is -# found to be redundant -# ============================================================================ +=head2 process_task($task) + +Process a single task. + +=over 4 + +=item $task => the task to process + +=back + +Returns : n/a +Throws : fatal error if task fails +# # +Must run from within target directory. Task involve either creating +or deleting dirs and symlinks an action is set to 'skip' if it is +found to be redundant + +=cut + sub process_task { my $self = shift; my ($task) = @_; @@ -1651,13 +1850,21 @@ sub process_task { internal_error("bad task action: $task->{action}"); } -# ===== METHOD =============================================================== -# Name : link_task_action() -# Purpose : finds the link task action for the given path, if there is one -# Parameters: $path -# Returns : 'remove', 'create', or '' if there is no action -# Throws : a fatal exception if an invalid action is found -# ============================================================================ +=head2 link_task_action($path) + +Finds the link task action for the given path, if there is one + +=over 4 + +=item $path + +=back + +Returns C<'remove'>, C<'create'>, or C<''> if there is no action. +Throws a fatal exception if an invalid action is found. + +=cut + sub link_task_action { my $self = shift; my ($path) = @_; @@ -1675,13 +1882,21 @@ sub link_task_action { return $action; } -# ===== METHOD =============================================================== -# Name : dir_task_action() -# Purpose : finds the dir task action for the given path, if there is one -# Parameters: $path -# Returns : 'remove', 'create', or '' if there is no action -# Throws : a fatal exception if an invalid action is found -# ============================================================================ +=head2 dir_task_action($path) + +Finds the dir task action for the given path, if there is one. + +=over 4 + +=item $path + +=back + +Returns C<'remove'>, C<'create'>, or C<''> if there is no action. +Throws a fatal exception if an invalid action is found. + +=cut + sub dir_task_action { my $self = shift; my ($path) = @_; @@ -1699,14 +1914,21 @@ sub dir_task_action { return $action; } -# ===== METHOD =============================================================== -# Name : parent_link_scheduled_for_removal() -# Purpose : determine whether the given path or any parent thereof -# : is a link scheduled for removal -# Parameters: $path -# Returns : Boolean -# Throws : none -# ============================================================================ +=head2 parent_link_scheduled_for_removal($path) + +Determine whether the given path or any parent thereof is a link +scheduled for removal + +=over 4 + +=item $path + +=back + +Returns boolean + +=cut + sub parent_link_scheduled_for_removal { my $self = shift; my ($path) = @_; @@ -1726,16 +1948,21 @@ sub parent_link_scheduled_for_removal { return 0; } -# ===== METHOD =============================================================== -# Name : is_a_link() -# Purpose : determine if the given path is a current or planned link -# Parameters: $path -# Returns : Boolean -# Throws : none -# -# Returns false if an existing link is scheduled for removal and true -# if a non-existent link is scheduled for creation. -# ============================================================================ +=head2 is_a_link($path) + +Determine if the given path is a current or planned link. + +=over 4 + +=item $path + +=back + +Returns false if an existing link is scheduled for removal and true if +a non-existent link is scheduled for creation. + +=cut + sub is_a_link { my $self = shift; my ($path) = @_; @@ -1763,17 +1990,22 @@ sub is_a_link { return 0; } -# ===== METHOD =============================================================== -# Name : is_a_dir() -# Purpose : determine if the given path is a current or planned directory -# Parameters: $path -# Returns : Boolean -# Throws : none -# -# Returns false if an existing directory is scheduled for removal and -# true if a non-existent directory is scheduled for creation. We also -# need to be sure we are not just following a link. -# ============================================================================ +=head2 is_a_dir($path) + +Determine if the given path is a current or planned directory + +=over 4 + +=item $path + +=back + +Returns false if an existing directory is scheduled for removal and +true if a non-existent directory is scheduled for creation. We also +need to be sure we are not just following a link. + +=cut + sub is_a_dir { my $self = shift; my ($path) = @_; @@ -1799,17 +2031,22 @@ sub is_a_dir { return 0; } -# ===== METHOD =============================================================== -# Name : is_a_node() -# Purpose : determine whether the given path is a current or planned node -# Parameters: $path -# Returns : Boolean -# Throws : none -# -# Returns false if an existing node is scheduled for removal true if a -# non-existent node is scheduled for creation. we also need to be -# sure we are not just following a link. -# ============================================================================ +=head2 is_a_node($path) + +Determine whether the given path is a current or planned node. + +=over 4 + +=item $path + +=back + +Returns false if an existing node is scheduled for removal, or true if +a non-existent node is scheduled for creation. We also need to be +sure we are not just following a link. + +=cut + sub is_a_node { my $self = shift; my ($path) = @_; @@ -1872,14 +2109,23 @@ sub is_a_node { return 0; } -# ===== METHOD =============================================================== -# Name : read_a_link() -# Purpose : return the source of a current or planned link -# Parameters: $path => path to the link target -# Returns : a string -# Throws : fatal exception if the given path is not a current or planned -# : link -# ============================================================================ +=head2 read_a_link($path) + +Return the source of a current or planned link + +=over 4 + +=item $path + +path to the link target + +=back + +Returns a string. Throws a fatal exception if the given path is not a +current or planned link. + +=cut + sub read_a_link { my $self = shift; my ($path) = @_; @@ -1904,16 +2150,27 @@ sub read_a_link { internal_error("read_a_link() passed a non link path: $path\n"); } -# ===== METHOD =============================================================== -# Name : do_link() -# Purpose : wrap 'link' operation for later processing -# Parameters: $oldfile => the existing file to link to -# : $newfile => the file to link -# Returns : n/a -# Throws : error if this clashes with an existing planned operation -# -# Cleans up operations that undo previous operations. -# ============================================================================ +=head2 do_link($oldfile, $newfile) + +Wrap 'link' operation for later processing + +=over 4 + +=item $oldfile + +the existing file to link to + +=item $newfile + +the file to link + +=back + +Throws an error if this clashes with an existing planned operation. +Cleans up operations that undo previous operations. + +=cut + sub do_link { my $self = shift; my ($oldfile, $newfile) = @_; @@ -1983,15 +2240,23 @@ sub do_link { return; } -# ===== METHOD =============================================================== -# Name : do_unlink() -# Purpose : wrap 'unlink' operation for later processing -# Parameters: $file => the file to unlink -# Returns : n/a -# Throws : error if this clashes with an existing planned operation -# -# Will remove an existing planned link. -# ============================================================================ +=head2 do_unlink($file) + +Wrap 'unlink' operation for later processing + +=over 4 + +=item $file + +the file to unlink + +=back + +Throws an error if this clashes with an existing planned operation. +Will remove an existing planned link. + +=cut + sub do_unlink { my $self = shift; my ($file) = @_; @@ -2039,18 +2304,24 @@ sub do_unlink { return; } -# ===== METHOD =============================================================== -# Name : do_mkdir() -# Purpose : wrap 'mkdir' operation -# Parameters: $dir => the directory to remove -# Returns : n/a -# Throws : fatal exception if operation fails -# -# Outputs a message if 'verbose' option is set. -# Does not perform operation if 'simulate' option is set. -# -# Cleans up operations that undo previous operations. -# ============================================================================ +=head2 do_mkdir($dir) + +Wrap 'mkdir' operation + +=over 4 + +=item $dir + +the directory to remove + +=back + +Throws a fatal exception if operation fails. Outputs a message if +'verbose' option is set. Does not perform operation if 'simulate' +option is set. Cleans up operations that undo previous operations. + +=cut + sub do_mkdir { my $self = shift; my ($dir) = @_; @@ -2104,16 +2375,24 @@ sub do_mkdir { return; } -# ===== METHOD =============================================================== -# Name : do_rmdir() -# Purpose : wrap 'rmdir' operation -# Parameters: $dir => the directory to remove -# Returns : n/a -# Throws : fatal exception if operation fails -# -# Outputs a message if 'verbose' option is set. -# Does not perform operation if 'simulate' option is set. -# ============================================================================ +=head2 do_rmdir($dir) + +Wrap 'rmdir' operation + +=over 4 + +=item $dir + +the directory to remove + +=back + +Throws a fatal exception if operation fails. Outputs a message if +'verbose' option is set. Does not perform operation if 'simulate' +option is set. + +=cut + sub do_rmdir { my $self = shift; my ($dir) = @_; @@ -2159,16 +2438,27 @@ sub do_rmdir { return; } -# ===== METHOD =============================================================== -# Name : do_mv() -# Purpose : wrap 'move' operation for later processing -# Parameters: $src => the file to move -# : $dst => the path to move it to -# Returns : n/a -# Throws : error if this clashes with an existing planned operation -# -# Alters contents of package installation image in stow dir. -# ============================================================================ +=head2 do_mv($src, $dst) + +Wrap 'move' operation for later processing. + +=over 4 + +=item $src + +the file to move + +=item $dst + +the path to move it to + +=back + +Throws an error if this clashes with an existing planned operation. +Alters contents of package installation image in stow dir. + +=cut + sub do_mv { my $self = shift; my ($src, $dst) = @_; @@ -2217,10 +2507,17 @@ sub do_mv { # ===== PRIVATE SUBROUTINE =================================================== # Name : internal_error() # Purpose : output internal error message in a consistent form and die -# Parameters: $message => error message to output -# Returns : n/a -# Throws : n/a -# ============================================================================ +=over 4 + +=item $message => error message to output + +=back + +Returns : n/a +Throws : n/a + +=cut + sub internal_error { my ($format, @args) = @_; my $error = sprintf($format, @args); From 373ef62e703fe2209a6af4bee32e51b433c8fa2c Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Sun, 31 Mar 2024 18:59:19 +0100 Subject: [PATCH 400/482] manual: clarify that installation image is pre-installation --- doc/stow.texi | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/doc/stow.texi b/doc/stow.texi index 7aa5f0e..bea2725 100644 --- a/doc/stow.texi +++ b/doc/stow.texi @@ -243,6 +243,11 @@ installation image for Perl includes: a @file{bin} directory containing containing Texinfo documentation; a @file{lib/perl} directory containing Perl libraries; and a @file{man/man1} directory containing man pages. +@quotation Note +This is a @emph{pre-}installation image which exists even before Stow +has installed any symlinks into the target directory which point to it. +@end quotation + @cindex package directory @cindex package name A @dfn{package directory} is the root of a tree containing the From e8c46cf0588fddd26c3d2198cf5ea4d4f8d1a49b Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Sun, 31 Mar 2024 19:02:23 +0100 Subject: [PATCH 401/482] manual: disambiguate meaning of "source" --- doc/stow.texi | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/doc/stow.texi b/doc/stow.texi index bea2725..2cfd050 100644 --- a/doc/stow.texi +++ b/doc/stow.texi @@ -306,6 +306,24 @@ If we did not avoid the second meaning of ``target'', then it would lead to confusing language, such as describing Stow as installing symlinks into the target directory which point to targets @emph{outside} the target directory. + +Similarly, the word ``source'' can have two different meanings in this +context: + +@enumerate + +@item +the installation image, or some of its contents, and + +@item +the location of symlinks (the ``source'' of the link, vs. its +destination). + +@end enumerate + +Therefore it should also be avoided, or at least care taken to ensure +that the meaning is not ambiguous. + @end quotation @c =========================================================================== From 8c09d41054ebfaa23dbde3bf0cfbea0eac7d5a88 Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Sun, 31 Mar 2024 23:51:14 +0100 Subject: [PATCH 402/482] add unit tests for adjust_dotfiles() --- t/dotfiles.t | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/t/dotfiles.t b/t/dotfiles.t index 2116f90..6f0f583 100755 --- a/t/dotfiles.t +++ b/t/dotfiles.t @@ -22,16 +22,35 @@ use strict; use warnings; -use testutil; - -use Test::More tests => 10; +use Test::More tests => 11; use English qw(-no_match_vars); +use Stow::Util qw(adjust_dotfile); use testutil; init_test_dirs(); cd("$TEST_DIR/target"); +subtest('adjust_dotfile()', sub { + plan tests => 9; + my @TESTS = ( + ['file'], + ['dot-file', '.file'], + ['dir1/file'], + ['dir1/dir2/file'], + ['dir1/dir2/dot-file', 'dir1/dir2/.file'], + ['dir1/dot-dir2/file', 'dir1/.dir2/file'], + ['dir1/dot-dir2/dot-file', 'dir1/.dir2/.file'], + ['dot-dir1/dot-dir2/dot-file', '.dir1/.dir2/.file'], + ['dot-dir1/dot-dir2/file', '.dir1/.dir2/file'], + ); + for my $test (@TESTS) { + my ($input, $expected) = @$test; + $expected ||= $input; + is(adjust_dotfile($input), $expected); + } +}); + my $stow; # From bffc347a19096f5bfb5a139de22f6b141d0a8665 Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Mon, 1 Apr 2024 00:06:24 +0100 Subject: [PATCH 403/482] Remove hard tabs --- lib/Stow.pm.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Stow.pm.in b/lib/Stow.pm.in index 22e49a2..dd581d7 100755 --- a/lib/Stow.pm.in +++ b/lib/Stow.pm.in @@ -329,7 +329,7 @@ sub plan_stow { $package, '.', $pkg_path, # source from target - 0, + 0, ); debug(2, 0, "Planning stow of package $package... done"); $self->{action_count}++; From 48c6b5956b1b29b903ba5a4e3f75d464b0c14064 Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Mon, 1 Apr 2024 00:07:06 +0100 Subject: [PATCH 404/482] Add emacs config to prevent insertion of hard tabs --- .dir-locals.el | 1 + 1 file changed, 1 insertion(+) diff --git a/.dir-locals.el b/.dir-locals.el index 346c78e..1840735 100644 --- a/.dir-locals.el +++ b/.dir-locals.el @@ -1,3 +1,4 @@ ((cperl-mode . ((dumb-jump-force-searcher . rg) (cperl-indent-level . 4) + (indent-tabs-mode . nil) (eval . (auto-fill-mode -1))))) From c2da8b416de2c5c49d6002870b7ccf7f6a652d4d Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Mon, 1 Apr 2024 00:34:19 +0100 Subject: [PATCH 405/482] do_link(): improve variable names --- lib/Stow.pm.in | 40 ++++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/lib/Stow.pm.in b/lib/Stow.pm.in index dd581d7..f155295 100755 --- a/lib/Stow.pm.in +++ b/lib/Stow.pm.in @@ -2159,17 +2159,17 @@ sub read_a_link { internal_error("read_a_link() passed a non link path: $path\n"); } -=head2 do_link($oldfile, $newfile) +=head2 do_link($link_dest, $link_src) Wrap 'link' operation for later processing =over 4 -=item $oldfile +=item $link_dest the existing file to link to -=item $newfile +=item $link_src the file to link @@ -2182,17 +2182,17 @@ Cleans up operations that undo previous operations. sub do_link { my $self = shift; - my ($oldfile, $newfile) = @_; + my ($link_dest, $link_src) = @_; - if (exists $self->{dir_task_for}{$newfile}) { - my $task_ref = $self->{dir_task_for}{$newfile}; + if (exists $self->{dir_task_for}{$link_src}) { + my $task_ref = $self->{dir_task_for}{$link_src}; if ($task_ref->{action} eq 'create') { if ($task_ref->{type} eq 'dir') { internal_error( "new link (%s => %s) clashes with planned new directory", - $newfile, - $oldfile, + $link_src, + $link_dest, ); } } @@ -2204,11 +2204,11 @@ sub do_link { } } - if (exists $self->{link_task_for}{$newfile}) { - my $task_ref = $self->{link_task_for}{$newfile}; + if (exists $self->{link_task_for}{$link_src}) { + my $task_ref = $self->{link_task_for}{$link_src}; if ($task_ref->{action} eq 'create') { - if ($task_ref->{source} ne $oldfile) { + if ($task_ref->{source} ne $link_dest) { internal_error( "new link clashes with planned new link: %s => %s", $task_ref->{path}, @@ -2216,16 +2216,16 @@ sub do_link { ) } else { - debug(1, 0, "LINK: $newfile => $oldfile (duplicates previous action)"); + debug(1, 0, "LINK: $link_src => $link_dest (duplicates previous action)"); return; } } elsif ($task_ref->{action} eq 'remove') { - if ($task_ref->{source} eq $oldfile) { + if ($task_ref->{source} eq $link_dest) { # No need to remove a link we are going to recreate - debug(1, 0, "LINK: $newfile => $oldfile (reverts previous action)"); - $self->{link_task_for}{$newfile}->{action} = 'skip'; - delete $self->{link_task_for}{$newfile}; + debug(1, 0, "LINK: $link_src => $link_dest (reverts previous action)"); + $self->{link_task_for}{$link_src}->{action} = 'skip'; + delete $self->{link_task_for}{$link_src}; return; } # We may need to remove a link to replace it so continue @@ -2236,15 +2236,15 @@ sub do_link { } # Creating a new link - debug(1, 0, "LINK: $newfile => $oldfile"); + debug(1, 0, "LINK: $link_src => $link_dest"); my $task = { action => 'create', type => 'link', - path => $newfile, - source => $oldfile, + path => $link_src, + source => $link_dest, }; push @{ $self->{tasks} }, $task; - $self->{link_task_for}{$newfile} = $task; + $self->{link_task_for}{$link_src} = $task; return; } From f60c203c459516ca89ba3baf9ddf1a79ecaf001e Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Mon, 1 Apr 2024 00:34:39 +0100 Subject: [PATCH 406/482] should_skip_target(): add docs explaining its purpose --- lib/Stow.pm.in | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/Stow.pm.in b/lib/Stow.pm.in index f155295..8391a4a 100755 --- a/lib/Stow.pm.in +++ b/lib/Stow.pm.in @@ -641,7 +641,10 @@ sub stow_node { =head2 should_skip_target($target) Determine whether target is a stow directory which should -not be stowed to or unstowed from. +not be stowed to or unstowed from. This mechanism protects +stow directories from being altered by stow, and is a necessary +safety check because the stow directory could live beneath the +target directory. =over 4 From e0212d4f4977bf203108887a48c684ed1b8d4f4a Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Mon, 1 Apr 2024 00:35:35 +0100 Subject: [PATCH 407/482] stow_node(): fix odd whitespace --- lib/Stow.pm.in | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/Stow.pm.in b/lib/Stow.pm.in index 8391a4a..3163621 100755 --- a/lib/Stow.pm.in +++ b/lib/Stow.pm.in @@ -557,7 +557,8 @@ sub stow_node { $self->do_link($source, $target); } elsif ($self->is_a_dir(join_paths(parent($target), $existing_source)) && - $self->is_a_dir(join_paths(parent($target), $source)) ) { + $self->is_a_dir(join_paths(parent($target), $source))) + { # If the existing link points to a directory, # and the proposed new link points to a directory, From 0871a483cf3687dc71f25da54ef76f2b2aa58e2a Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Mon, 1 Apr 2024 00:39:18 +0100 Subject: [PATCH 408/482] rename $existing_source => $existing_link_dest Source can be ambiguous, as mentioned in the manual. --- lib/Stow.pm.in | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/lib/Stow.pm.in b/lib/Stow.pm.in index 3163621..a2390d0 100755 --- a/lib/Stow.pm.in +++ b/lib/Stow.pm.in @@ -525,15 +525,15 @@ sub stow_node { # Does the target already exist? if ($self->is_a_link($target)) { # Where is the link pointing? - my $existing_source = $self->read_a_link($target); - if (not $existing_source) { + my $existing_link_dest = $self->read_a_link($target); + if (not $existing_link_dest) { error("Could not read link: $target"); } - debug(4, 1, "Evaluate existing link: $target => $existing_source"); + debug(4, 1, "Evaluate existing link: $target => $existing_link_dest"); # Does it point to a node under any stow directory? my ($existing_path, $existing_stow_path, $existing_package) = - $self->find_stowed_path($target, $existing_source); + $self->find_stowed_path($target, $existing_link_dest); if (not $existing_path) { $self->conflict( 'stow', @@ -545,7 +545,7 @@ sub stow_node { # Does the existing $target actually point to anything? if ($self->is_a_node($existing_path)) { - if ($existing_source eq $source) { + if ($existing_link_dest eq $source) { debug(2, 0, "--- Skipping $target as it already points to $source"); } elsif ($self->defer($target)) { @@ -556,7 +556,7 @@ sub stow_node { $self->do_unlink($target); $self->do_link($source, $target); } - elsif ($self->is_a_dir(join_paths(parent($target), $existing_source)) && + elsif ($self->is_a_dir(join_paths(parent($target), $existing_link_dest)) && $self->is_a_dir(join_paths(parent($target), $source))) { @@ -571,7 +571,7 @@ sub stow_node { $existing_stow_path, $existing_package, $target, - join_paths('..', $existing_source), + join_paths('..', $existing_link_dest), $level + 1, ); $self->stow_contents( @@ -587,7 +587,7 @@ sub stow_node { 'stow', $package, "existing target is stowed to a different package: " - . "$target => $existing_source" + . "$target => $existing_link_dest" ); } } From a328c2cd4b16e409489440930c3562ed5242e80a Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Mon, 1 Apr 2024 01:55:31 +0100 Subject: [PATCH 409/482] t/stow: convert to subtests() --- t/stow.t | 884 +++++++++++++++++++++++++++---------------------------- 1 file changed, 434 insertions(+), 450 deletions(-) diff --git a/t/stow.t b/t/stow.t index 0563457..9e97b48 100755 --- a/t/stow.t +++ b/t/stow.t @@ -22,7 +22,7 @@ use strict; use warnings; -use Test::More tests => 118; +use Test::More tests => 21; use Test::Output; use English qw(-no_match_vars); @@ -37,520 +37,504 @@ my %conflicts; # Note that each of the following tests use a distinct set of files -# -# stow a simple tree minimally -# -$stow = new_Stow(dir => '../stow'); +subtest('stow a simple tree minimally', sub { + plan tests => 2; + my $stow = new_Stow(dir => '../stow'); -make_path('../stow/pkg1/bin1'); -make_file('../stow/pkg1/bin1/file1'); + make_path('../stow/pkg1/bin1'); + make_file('../stow/pkg1/bin1/file1'); -$stow->plan_stow('pkg1'); -$stow->process_tasks(); -is_deeply([ $stow->get_conflicts ], [], 'no conflicts with minimal stow'); -is( - readlink('bin1'), - '../stow/pkg1/bin1', - => 'minimal stow of a simple tree' -); - -# -# stow a simple tree into an existing directory -# -$stow = new_Stow(); - -make_path('../stow/pkg2/lib2'); -make_file('../stow/pkg2/lib2/file2'); -make_path('lib2'); - -$stow->plan_stow('pkg2'); -$stow->process_tasks(); -is( - readlink('lib2/file2'), - '../../stow/pkg2/lib2/file2', - => 'stow simple tree to existing directory' -); - -# -# unfold existing tree -# -$stow = new_Stow(); - -make_path('../stow/pkg3a/bin3'); -make_file('../stow/pkg3a/bin3/file3a'); -make_link('bin3' => '../stow/pkg3a/bin3'); # emulate stow - -make_path('../stow/pkg3b/bin3'); -make_file('../stow/pkg3b/bin3/file3b'); - -$stow->plan_stow('pkg3b'); -$stow->process_tasks(); -ok( - -d 'bin3' && - readlink('bin3/file3a') eq '../../stow/pkg3a/bin3/file3a' && - readlink('bin3/file3b') eq '../../stow/pkg3b/bin3/file3b' - => 'target already has 1 stowed package' -); - -# -# Link to a new dir 'bin4' conflicts with existing non-dir so can't -# unfold -# -$stow = new_Stow(); - -make_file('bin4'); # this is a file but named like a directory -make_path('../stow/pkg4/bin4'); -make_file('../stow/pkg4/bin4/file4'); - -$stow->plan_stow('pkg4'); -%conflicts = $stow->get_conflicts(); -ok( - $stow->get_conflict_count == 1 && - $conflicts{stow}{pkg4}[0] =~ - qr/existing target is neither a link nor a directory/ - => 'link to new dir bin4 conflicts with existing non-directory' -); - -# -# Link to a new dir 'bin4a' conflicts with existing non-dir so can't -# unfold even with --adopt -# -#$stow = new_Stow(adopt => 1); -$stow = new_Stow(); - -make_file('bin4a'); # this is a file but named like a directory -make_path('../stow/pkg4a/bin4a'); -make_file('../stow/pkg4a/bin4a/file4a'); - -$stow->plan_stow('pkg4a'); -%conflicts = $stow->get_conflicts(); -ok( - $stow->get_conflict_count == 1 && - $conflicts{stow}{pkg4a}[0] =~ - qr/existing target is neither a link nor a directory/ - => 'link to new dir bin4a conflicts with existing non-directory' -); - -# -# Link to files 'file4b' and 'bin4b' conflict with existing files -# without --adopt -# -$stow = new_Stow(); - -# Populate target -make_file('file4b', 'file4b - version originally in target'); -make_path ('bin4b'); -make_file('bin4b/file4b', 'bin4b/file4b - version originally in target'); - -# Populate -make_path ('../stow/pkg4b/bin4b'); -make_file('../stow/pkg4b/file4b', 'file4b - version originally in stow package'); -make_file('../stow/pkg4b/bin4b/file4b', 'bin4b/file4b - version originally in stow package'); - -$stow->plan_stow('pkg4b'); -%conflicts = $stow->get_conflicts(); -is($stow->get_conflict_count, 2 => 'conflict per file'); -for my $i (0, 1) { - like( - $conflicts{stow}{pkg4b}[$i], - qr/existing target is neither a link nor a directory/ - => 'link to file4b conflicts with existing non-directory' - ); -} - -# -# Link to files 'file4b' and 'bin4b' do not conflict with existing -# files when --adopt is given -# -$stow = new_Stow(adopt => 1); - -# Populate target -make_file('file4c', "file4c - version originally in target\n"); -make_path ('bin4c'); -make_file('bin4c/file4c', "bin4c/file4c - version originally in target\n"); - -# Populate -make_path ('../stow/pkg4c/bin4c'); -make_file('../stow/pkg4c/file4c', "file4c - version originally in stow package\n"); -make_file('../stow/pkg4c/bin4c/file4c', "bin4c/file4c - version originally in stow package\n"); - -$stow->plan_stow('pkg4c'); -is($stow->get_conflict_count, 0 => 'no conflicts with --adopt'); -is($stow->get_tasks, 4 => 'two tasks per file'); -$stow->process_tasks(); -for my $file ('file4c', 'bin4c/file4c') { - ok(-l $file, "$file turned into a symlink"); + $stow->plan_stow('pkg1'); + $stow->process_tasks(); + is_deeply([ $stow->get_conflicts ], [], 'no conflicts with minimal stow'); is( - readlink $file, - (index($file, '/') == -1 ? '' : '../' ) - . "../stow/pkg4c/$file" => "$file points to right place" + readlink('bin1'), + '../stow/pkg1/bin1', + => 'minimal stow of a simple tree' ); - is(cat_file($file), "$file - version originally in target\n" => "$file has right contents"); -} +}); +subtest('stow a simple tree into an existing directory', sub { + plan tests => 1; + my $stow = new_Stow(); -# -# Target already exists but is not owned by stow -# -$stow = new_Stow(); + make_path('../stow/pkg2/lib2'); + make_file('../stow/pkg2/lib2/file2'); + make_path('lib2'); -make_path('bin5'); -make_invalid_link('bin5/file5','../../empty'); -make_path('../stow/pkg5/bin5/file5'); + $stow->plan_stow('pkg2'); + $stow->process_tasks(); + is( + readlink('lib2/file2'), + '../../stow/pkg2/lib2/file2', + => 'stow simple tree to existing directory' + ); +}); -$stow->plan_stow('pkg5'); -%conflicts = $stow->get_conflicts(); -like( - $conflicts{stow}{pkg5}[-1], - qr/not owned by stow/ - => 'target already exists but is not owned by stow' -); +subtest('unfold existing tree', sub { + plan tests => 3; + my $stow = new_Stow(); -# -# Replace existing but invalid target -# -$stow = new_Stow(); + make_path('../stow/pkg3a/bin3'); + make_file('../stow/pkg3a/bin3/file3a'); + make_link('bin3' => '../stow/pkg3a/bin3'); # emulate stow -make_invalid_link('file6','../stow/path-does-not-exist'); -make_path('../stow/pkg6'); -make_file('../stow/pkg6/file6'); + make_path('../stow/pkg3b/bin3'); + make_file('../stow/pkg3b/bin3/file3b'); -$stow->plan_stow('pkg6'); -$stow->process_tasks(); -is( - readlink('file6'), - '../stow/pkg6/file6' - => 'replace existing but invalid target' -); + $stow->plan_stow('pkg3b'); + $stow->process_tasks(); + ok(-d 'bin3'); + is(readlink('bin3/file3a'), '../../stow/pkg3a/bin3/file3a'); + is(readlink('bin3/file3b'), '../../stow/pkg3b/bin3/file3b' + => 'target already has 1 stowed package'); +}); -# -# Target already exists, is owned by stow, but points to a non-directory -# (can't unfold) -# -$stow = new_Stow(); -#set_debug_level(4); +subtest("Link to a new dir 'bin4' conflicts with existing non-dir so can't unfold", sub { + plan tests => 2; + my $stow = new_Stow(); -make_path('bin7'); -make_path('../stow/pkg7a/bin7'); -make_file('../stow/pkg7a/bin7/node7'); -make_link('bin7/node7','../../stow/pkg7a/bin7/node7'); -make_path('../stow/pkg7b/bin7/node7'); -make_file('../stow/pkg7b/bin7/node7/file7'); + make_file('bin4'); # this is a file but named like a directory + make_path('../stow/pkg4/bin4'); + make_file('../stow/pkg4/bin4/file4'); -$stow->plan_stow('pkg7b'); -%conflicts = $stow->get_conflicts(); -like( - $conflicts{stow}{pkg7b}[-1], - qr/existing target is stowed to a different package/ - => 'link to new dir conflicts with existing stowed non-directory' -); + $stow->plan_stow('pkg4'); + %conflicts = $stow->get_conflicts(); + is($stow->get_conflict_count, 1); + ok($conflicts{stow}{pkg4}[0] =~ + qr/existing target is neither a link nor a directory/ + => 'link to new dir bin4 conflicts with existing non-directory' + ); +}); -# -# stowing directories named 0 -# -$stow = new_Stow(); +subtest("Link to a new dir 'bin4a' conflicts with existing non-dir " . + "so can't unfold even with --adopt", sub { + plan tests => 2; + #my $stow = new_Stow(adopt => 1); + my $stow = new_Stow(); -make_path('../stow/pkg8a/0'); -make_file('../stow/pkg8a/0/file8a'); -make_link('0' => '../stow/pkg8a/0'); # emulate stow + make_file('bin4a'); # this is a file but named like a directory + make_path('../stow/pkg4a/bin4a'); + make_file('../stow/pkg4a/bin4a/file4a'); -make_path('../stow/pkg8b/0'); -make_file('../stow/pkg8b/0/file8b'); + $stow->plan_stow('pkg4a'); + %conflicts = $stow->get_conflicts(); + is($stow->get_conflict_count, 1); + like($conflicts{stow}{pkg4a}[0], + qr/existing target is neither a link nor a directory/ + => 'link to new dir bin4a conflicts with existing non-directory' + ); +}); -$stow->plan_stow('pkg8b'); -$stow->process_tasks(); -ok( - $stow->get_conflict_count == 0 && - -d '0' && - readlink('0/file8a') eq '../../stow/pkg8a/0/file8a' && - readlink('0/file8b') eq '../../stow/pkg8b/0/file8b' - => 'stowing directories named 0' -); +subtest("Link to files 'file4b' and 'bin4b' conflict with existing files", sub { + plan tests => 3; + my $stow = new_Stow(); -# -# overriding already stowed documentation -# -$stow = new_Stow(override => ['man9', 'info9']); + # Populate target + make_file('file4b', 'file4b - version originally in target'); + make_path ('bin4b'); + make_file('bin4b/file4b', 'bin4b/file4b - version originally in target'); -make_path('../stow/pkg9a/man9/man1'); -make_file('../stow/pkg9a/man9/man1/file9.1'); -make_path('man9/man1'); -make_link('man9/man1/file9.1' => '../../../stow/pkg9a/man9/man1/file9.1'); # emulate stow + # Populate + make_path ('../stow/pkg4b/bin4b'); + make_file('../stow/pkg4b/file4b', 'file4b - version originally in stow package'); + make_file('../stow/pkg4b/bin4b/file4b', 'bin4b/file4b - version originally in stow package'); -make_path('../stow/pkg9b/man9/man1'); -make_file('../stow/pkg9b/man9/man1/file9.1'); + $stow->plan_stow('pkg4b'); + %conflicts = $stow->get_conflicts(); + is($stow->get_conflict_count, 2 => 'conflict per file'); + for my $i (0, 1) { + like( + $conflicts{stow}{pkg4b}[$i], + qr/existing target is neither a link nor a directory/ + => 'link to file4b conflicts with existing non-directory' + ); + } +}); -$stow->plan_stow('pkg9b'); -$stow->process_tasks(); -ok( - $stow->get_conflict_count == 0 && - readlink('man9/man1/file9.1') eq '../../../stow/pkg9b/man9/man1/file9.1' - => 'overriding existing documentation files' -); +subtest("Link to files 'file4b' and 'bin4b' do not conflict with existing", sub { + plan tests => 8; + my $stow = new_Stow(adopt => 1); -# -# deferring to already stowed documentation -# -$stow = new_Stow(defer => ['man10', 'info10']); + # Populate target + make_file('file4c', "file4c - version originally in target\n"); + make_path ('bin4c'); + make_file('bin4c/file4c', "bin4c/file4c - version originally in target\n"); -make_path('../stow/pkg10a/man10/man1'); -make_file('../stow/pkg10a/man10/man1/file10.1'); -make_path('man10/man1'); -make_link('man10/man1/file10.1' => '../../../stow/pkg10a/man10/man1/file10.1'); # emulate stow + # Populate + make_path ('../stow/pkg4c/bin4c'); + make_file('../stow/pkg4c/file4c', "file4c - version originally in stow package\n"); + make_file('../stow/pkg4c/bin4c/file4c', "bin4c/file4c - version originally in stow package\n"); -make_path('../stow/pkg10b/man10/man1'); -make_file('../stow/pkg10b/man10/man1/file10.1'); + $stow->plan_stow('pkg4c'); + is($stow->get_conflict_count, 0 => 'no conflicts with --adopt'); + is($stow->get_tasks, 4 => 'two tasks per file'); + $stow->process_tasks(); + for my $file ('file4c', 'bin4c/file4c') { + ok(-l $file, "$file turned into a symlink"); + is( + readlink $file, + (index($file, '/') == -1 ? '' : '../' ) + . "../stow/pkg4c/$file" => "$file points to right place" + ); + is(cat_file($file), "$file - version originally in target\n" => "$file has right contents"); + } -$stow->plan_stow('pkg10b'); -is($stow->get_tasks, 0, 'no tasks to process'); -ok( - $stow->get_conflict_count == 0 && - readlink('man10/man1/file10.1') eq '../../../stow/pkg10a/man10/man1/file10.1' - => 'defer to existing documentation files' -); +}); -# -# Ignore temp files -# -$stow = new_Stow(ignore => ['~', '\.#.*']); +subtest("Target already exists but is not owned by stow", sub { + plan tests => 1; + my $stow = new_Stow(); -make_path('../stow/pkg11/man11/man1'); -make_file('../stow/pkg11/man11/man1/file11.1'); -make_file('../stow/pkg11/man11/man1/file11.1~'); -make_file('../stow/pkg11/man11/man1/.#file11.1'); -make_path('man11/man1'); + make_path('bin5'); + make_invalid_link('bin5/file5','../../empty'); + make_path('../stow/pkg5/bin5/file5'); -$stow->plan_stow('pkg11'); -$stow->process_tasks(); -ok( - $stow->get_conflict_count == 0 && - readlink('man11/man1/file11.1') eq '../../../stow/pkg11/man11/man1/file11.1' && - !-e 'man11/man1/file11.1~' && - !-e 'man11/man1/.#file11.1' - => 'ignore temp files' -); + $stow->plan_stow('pkg5'); + %conflicts = $stow->get_conflicts(); + like( + $conflicts{stow}{pkg5}[-1], + qr/not owned by stow/ + => 'target already exists but is not owned by stow' + ); +}); -# -# stowing links library files -# -$stow = new_Stow(); +subtest("Replace existing but invalid target", sub { + plan tests => 1; + my $stow = new_Stow(); -make_path('../stow/pkg12/lib12/'); -make_file('../stow/pkg12/lib12/lib.so.1'); -make_link('../stow/pkg12/lib12/lib.so', 'lib.so.1'); + make_invalid_link('file6','../stow/path-does-not-exist'); + make_path('../stow/pkg6'); + make_file('../stow/pkg6/file6'); -make_path('lib12/'); + $stow->plan_stow('pkg6'); + $stow->process_tasks(); + is( + readlink('file6'), + '../stow/pkg6/file6' + => 'replace existing but invalid target' + ); +}); -$stow->plan_stow('pkg12'); -$stow->process_tasks(); -ok( - $stow->get_conflict_count == 0 && - readlink('lib12/lib.so.1') eq '../../stow/pkg12/lib12/lib.so.1' && - readlink('lib12/lib.so' ) eq '../../stow/pkg12/lib12/lib.so' - => 'stow links to libraries' -); +subtest("Target already exists, is owned by stow, but points to a non-directory", sub { + plan tests => 1; + my $stow = new_Stow(); + #set_debug_level(4); -# -# unfolding to stow links to library files -# -$stow = new_Stow(); + make_path('bin7'); + make_path('../stow/pkg7a/bin7'); + make_file('../stow/pkg7a/bin7/node7'); + make_link('bin7/node7','../../stow/pkg7a/bin7/node7'); + make_path('../stow/pkg7b/bin7/node7'); + make_file('../stow/pkg7b/bin7/node7/file7'); -make_path('../stow/pkg13a/lib13/'); -make_file('../stow/pkg13a/lib13/liba.so.1'); -make_link('../stow/pkg13a/lib13/liba.so', 'liba.so.1'); -make_link('lib13','../stow/pkg13a/lib13'); + $stow->plan_stow('pkg7b'); + %conflicts = $stow->get_conflicts(); + like( + $conflicts{stow}{pkg7b}[-1], + qr/existing target is stowed to a different package/ + => 'link to new dir conflicts with existing stowed non-directory' + ); +}); -make_path('../stow/pkg13b/lib13/'); -make_file('../stow/pkg13b/lib13/libb.so.1'); -make_link('../stow/pkg13b/lib13/libb.so', 'libb.so.1'); +subtest("stowing directories named 0", sub { + plan tests => 4; + my $stow = new_Stow(); -$stow->plan_stow('pkg13b'); -$stow->process_tasks(); -ok( - $stow->get_conflict_count == 0 && - readlink('lib13/liba.so.1') eq '../../stow/pkg13a/lib13/liba.so.1' && - readlink('lib13/liba.so' ) eq '../../stow/pkg13a/lib13/liba.so' && - readlink('lib13/libb.so.1') eq '../../stow/pkg13b/lib13/libb.so.1' && - readlink('lib13/libb.so' ) eq '../../stow/pkg13b/lib13/libb.so' - => 'unfolding to stow links to libraries' -); + make_path('../stow/pkg8a/0'); + make_file('../stow/pkg8a/0/file8a'); + make_link('0' => '../stow/pkg8a/0'); # emulate stow -# -# stowing to stow dir should fail -# -make_path('stow'); -$stow = new_Stow(dir => 'stow'); + make_path('../stow/pkg8b/0'); + make_file('../stow/pkg8b/0/file8b'); -make_path('stow/pkg14/stow/pkg15'); -make_file('stow/pkg14/stow/pkg15/node15'); + $stow->plan_stow('pkg8b'); + $stow->process_tasks(); + is($stow->get_conflict_count, 0); + ok(-d '0'); + is(readlink('0/file8a'), '../../stow/pkg8a/0/file8a'); + is(readlink('0/file8b'), '../../stow/pkg8b/0/file8b' + => 'stowing directories named 0' + ); +}); -capture_stderr(); -$stow->plan_stow('pkg14'); -is($stow->get_tasks, 0, 'no tasks to process'); -ok( - $stow->get_conflict_count == 0 && - ! -l 'stow/pkg15' - => "stowing to stow dir should fail" -); -like($stderr, - qr/WARNING: skipping target which was current stow directory stow/ - => "stowing to stow dir should give warning"); -uncapture_stderr(); +subtest("overriding already stowed documentation", sub { + plan tests => 2; + my $stow = new_Stow(override => ['man9', 'info9']); -# -# stow a simple tree minimally when cwd isn't target -# -cd('../..'); -$stow = new_Stow(dir => "$TEST_DIR/stow", target => "$TEST_DIR/target"); + make_path('../stow/pkg9a/man9/man1'); + make_file('../stow/pkg9a/man9/man1/file9.1'); + make_path('man9/man1'); + make_link('man9/man1/file9.1' => '../../../stow/pkg9a/man9/man1/file9.1'); # emulate stow -make_path("$TEST_DIR/stow/pkg16/bin16"); -make_file("$TEST_DIR/stow/pkg16/bin16/file16"); + make_path('../stow/pkg9b/man9/man1'); + make_file('../stow/pkg9b/man9/man1/file9.1'); -$stow->plan_stow('pkg16'); -$stow->process_tasks(); -is_deeply([ $stow->get_conflicts ], [], 'no conflicts with minimal stow'); -is( - readlink("$TEST_DIR/target/bin16"), - '../stow/pkg16/bin16', - => "minimal stow of a simple tree when cwd isn't target" -); + $stow->plan_stow('pkg9b'); + $stow->process_tasks(); + is($stow->get_conflict_count, 0); + is(readlink('man9/man1/file9.1'), '../../../stow/pkg9b/man9/man1/file9.1' + => 'overriding existing documentation files' + ); +}); -# -# stow a simple tree minimally to absolute stow dir when cwd isn't -# target -# -$stow = new_Stow(dir => canon_path("$TEST_DIR/stow"), - target => "$TEST_DIR/target"); +subtest("deferring to already stowed documentation", sub { + plan tests => 3; + my $stow = new_Stow(defer => ['man10', 'info10']); -make_path("$TEST_DIR/stow/pkg17/bin17"); -make_file("$TEST_DIR/stow/pkg17/bin17/file17"); + make_path('../stow/pkg10a/man10/man1'); + make_file('../stow/pkg10a/man10/man1/file10.1'); + make_path('man10/man1'); + make_link('man10/man1/file10.1' => '../../../stow/pkg10a/man10/man1/file10.1'); # emulate stow -$stow->plan_stow('pkg17'); -$stow->process_tasks(); -is_deeply([ $stow->get_conflicts ], [], 'no conflicts with minimal stow'); -is( - readlink("$TEST_DIR/target/bin17"), - '../stow/pkg17/bin17', - => "minimal stow of a simple tree with absolute stow dir" -); + make_path('../stow/pkg10b/man10/man1'); + make_file('../stow/pkg10b/man10/man1/file10.1'); -# -# stow a simple tree minimally with absolute stow AND target dirs when -# cwd isn't target -# -$stow = new_Stow(dir => canon_path("$TEST_DIR/stow"), - target => canon_path("$TEST_DIR/target")); + $stow->plan_stow('pkg10b'); + is($stow->get_tasks, 0, 'no tasks to process'); + is($stow->get_conflict_count, 0); + is(readlink('man10/man1/file10.1'), '../../../stow/pkg10a/man10/man1/file10.1' + => 'defer to existing documentation files' + ); +}); -make_path("$TEST_DIR/stow/pkg18/bin18"); -make_file("$TEST_DIR/stow/pkg18/bin18/file18"); +subtest("Ignore temp files", sub { + plan tests => 4; + my $stow = new_Stow(ignore => ['~', '\.#.*']); -$stow->plan_stow('pkg18'); -$stow->process_tasks(); -is_deeply([ $stow->get_conflicts ], [], 'no conflicts with minimal stow'); -is( - readlink("$TEST_DIR/target/bin18"), - '../stow/pkg18/bin18', - => "minimal stow of a simple tree with absolute stow and target dirs" -); + make_path('../stow/pkg11/man11/man1'); + make_file('../stow/pkg11/man11/man1/file11.1'); + make_file('../stow/pkg11/man11/man1/file11.1~'); + make_file('../stow/pkg11/man11/man1/.#file11.1'); + make_path('man11/man1'); -# -# stow a tree with no-folding enabled - -# no new folded directories should be created, and existing -# folded directories should be split open (unfolded) where -# (and only where) necessary -# -cd("$TEST_DIR/target"); + $stow->plan_stow('pkg11'); + $stow->process_tasks(); + is($stow->get_conflict_count, 0); + is(readlink('man11/man1/file11.1'), '../../../stow/pkg11/man11/man1/file11.1'); + ok(!-e 'man11/man1/file11.1~'); + ok(!-e 'man11/man1/.#file11.1' + => 'ignore temp files' + ); +}); -sub create_pkg { - my ($id, $pkg) = @_; +subtest("stowing links library files", sub { + plan tests => 3; + my $stow = new_Stow(); - my $stow_pkg = "../stow/$id-$pkg"; - make_path ($stow_pkg); - make_file("$stow_pkg/$id-file-$pkg"); + make_path('../stow/pkg12/lib12/'); + make_file('../stow/pkg12/lib12/lib.so.1'); + make_link('../stow/pkg12/lib12/lib.so', 'lib.so.1'); - # create a shallow hierarchy specific to this package which isn't - # yet stowed - make_path ("$stow_pkg/$id-$pkg-only-new"); - make_file("$stow_pkg/$id-$pkg-only-new/$id-file-$pkg"); + make_path('lib12/'); - # create a deeper hierarchy specific to this package which isn't - # yet stowed - make_path ("$stow_pkg/$id-$pkg-only-new2/subdir"); - make_file("$stow_pkg/$id-$pkg-only-new2/subdir/$id-file-$pkg"); - make_link("$stow_pkg/$id-$pkg-only-new2/current", "subdir"); + $stow->plan_stow('pkg12'); + $stow->process_tasks(); + is($stow->get_conflict_count, 0); + is(readlink('lib12/lib.so.1'), '../../stow/pkg12/lib12/lib.so.1'); + is(readlink('lib12/lib.so'), '../../stow/pkg12/lib12/lib.so' + => 'stow links to libraries' + ); +}); - # create a hierarchy specific to this package which is already - # stowed via a folded tree - make_path ("$stow_pkg/$id-$pkg-only-old"); - make_link("$id-$pkg-only-old", "$stow_pkg/$id-$pkg-only-old"); - make_file("$stow_pkg/$id-$pkg-only-old/$id-file-$pkg"); +subtest("unfolding to stow links to library files", sub { + plan tests => 5; + my $stow = new_Stow(); - # create a shared hierarchy which this package uses - make_path ("$stow_pkg/$id-shared"); - make_file("$stow_pkg/$id-shared/$id-file-$pkg"); + make_path('../stow/pkg13a/lib13/'); + make_file('../stow/pkg13a/lib13/liba.so.1'); + make_link('../stow/pkg13a/lib13/liba.so', 'liba.so.1'); + make_link('lib13','../stow/pkg13a/lib13'); - # create a partially shared hierarchy which this package uses - make_path ("$stow_pkg/$id-shared2/subdir-$pkg"); - make_file("$stow_pkg/$id-shared2/$id-file-$pkg"); - make_file("$stow_pkg/$id-shared2/subdir-$pkg/$id-file-$pkg"); -} + make_path('../stow/pkg13b/lib13/'); + make_file('../stow/pkg13b/lib13/libb.so.1'); + make_link('../stow/pkg13b/lib13/libb.so', 'libb.so.1'); -foreach my $pkg (qw{a b}) { - create_pkg('no-folding', $pkg); -} + $stow->plan_stow('pkg13b'); + $stow->process_tasks(); + is($stow->get_conflict_count, 0); + is(readlink('lib13/liba.so.1'), '../../stow/pkg13a/lib13/liba.so.1'); + is(readlink('lib13/liba.so' ), '../../stow/pkg13a/lib13/liba.so'); + is(readlink('lib13/libb.so.1'), '../../stow/pkg13b/lib13/libb.so.1'); + is(readlink('lib13/libb.so' ), '../../stow/pkg13b/lib13/libb.so' + => 'unfolding to stow links to libraries' + ); +}); -$stow = new_Stow('no-folding' => 1); -$stow->plan_stow('no-folding-a'); -is_deeply([ $stow->get_conflicts ], [] => 'no conflicts with --no-folding'); -my @tasks = $stow->get_tasks; -use Data::Dumper; -is(scalar(@tasks), 13 => "6 dirs, 7 links") || warn Dumper(\@tasks); -$stow->process_tasks(); +subtest("stowing to stow dir should fail", sub { + plan tests => 4; + make_path('stow'); + $stow = new_Stow(dir => 'stow'); -sub check_no_folding { - my ($pkg) = @_; - my $stow_pkg = "../stow/no-folding-$pkg"; - is_link("no-folding-file-$pkg", "$stow_pkg/no-folding-file-$pkg"); + make_path('stow/pkg14/stow/pkg15'); + make_file('stow/pkg14/stow/pkg15/node15'); - # check existing folded tree is untouched - is_link("no-folding-$pkg-only-old", "$stow_pkg/no-folding-$pkg-only-old"); + capture_stderr(); + $stow->plan_stow('pkg14'); + is($stow->get_tasks, 0, 'no tasks to process'); + is($stow->get_conflict_count, 0); + ok( + ! -l 'stow/pkg15' + => "stowing to stow dir should fail" + ); + like($stderr, + qr/WARNING: skipping target which was current stow directory stow/ + => "stowing to stow dir should give warning"); + uncapture_stderr(); +}); - # check newly stowed shallow tree is not folded - is_dir_not_symlink("no-folding-$pkg-only-new"); - is_link("no-folding-$pkg-only-new/no-folding-file-$pkg", - "../$stow_pkg/no-folding-$pkg-only-new/no-folding-file-$pkg"); +subtest("stow a simple tree minimally when cwd isn't target", sub { + plan tests => 2; + cd('../..'); + $stow = new_Stow(dir => "$TEST_DIR/stow", target => "$TEST_DIR/target"); - # check newly stowed deeper tree is not folded - is_dir_not_symlink("no-folding-$pkg-only-new2"); - is_dir_not_symlink("no-folding-$pkg-only-new2/subdir"); - is_link("no-folding-$pkg-only-new2/subdir/no-folding-file-$pkg", - "../../$stow_pkg/no-folding-$pkg-only-new2/subdir/no-folding-file-$pkg"); - is_link("no-folding-$pkg-only-new2/current", - "../$stow_pkg/no-folding-$pkg-only-new2/current"); + make_path("$TEST_DIR/stow/pkg16/bin16"); + make_file("$TEST_DIR/stow/pkg16/bin16/file16"); - # check shared tree is not folded. first time round this will be - # newly stowed. - is_dir_not_symlink('no-folding-shared'); - is_link("no-folding-shared/no-folding-file-$pkg", - "../$stow_pkg/no-folding-shared/no-folding-file-$pkg"); + $stow->plan_stow('pkg16'); + $stow->process_tasks(); + is_deeply([ $stow->get_conflicts ], [], 'no conflicts with minimal stow'); + is( + readlink("$TEST_DIR/target/bin16"), + '../stow/pkg16/bin16', + => "minimal stow of a simple tree when cwd isn't target" + ); +}); - # check partially shared tree is not folded. first time round this - # will be newly stowed. - is_dir_not_symlink('no-folding-shared2'); - is_link("no-folding-shared2/no-folding-file-$pkg", - "../$stow_pkg/no-folding-shared2/no-folding-file-$pkg"); - is_link("no-folding-shared2/no-folding-file-$pkg", - "../$stow_pkg/no-folding-shared2/no-folding-file-$pkg"); -} +subtest("stow a simple tree minimally to absolute stow dir when cwd isn't", sub { + plan tests => 2; + my $stow = new_Stow(dir => canon_path("$TEST_DIR/stow"), + target => "$TEST_DIR/target"); -check_no_folding('a'); + make_path("$TEST_DIR/stow/pkg17/bin17"); + make_file("$TEST_DIR/stow/pkg17/bin17/file17"); -$stow = new_Stow('no-folding' => 1); -$stow->plan_stow('no-folding-b'); -is_deeply([ $stow->get_conflicts ], [] => 'no conflicts with --no-folding'); -@tasks = $stow->get_tasks; -is(scalar(@tasks), 11 => '4 dirs, 7 links') || warn Dumper(\@tasks); -$stow->process_tasks(); + $stow->plan_stow('pkg17'); + $stow->process_tasks(); + is_deeply([ $stow->get_conflicts ], [], 'no conflicts with minimal stow'); + is( + readlink("$TEST_DIR/target/bin17"), + '../stow/pkg17/bin17', + => "minimal stow of a simple tree with absolute stow dir" + ); +}); -check_no_folding('a'); -check_no_folding('b'); +subtest("stow a simple tree minimally with absolute stow AND target dirs when", sub { + plan tests => 2; + my $stow = new_Stow(dir => canon_path("$TEST_DIR/stow"), + target => canon_path("$TEST_DIR/target")); + + make_path("$TEST_DIR/stow/pkg18/bin18"); + make_file("$TEST_DIR/stow/pkg18/bin18/file18"); + + $stow->plan_stow('pkg18'); + $stow->process_tasks(); + is_deeply([ $stow->get_conflicts ], [], 'no conflicts with minimal stow'); + is( + readlink("$TEST_DIR/target/bin18"), + '../stow/pkg18/bin18', + => "minimal stow of a simple tree with absolute stow and target dirs" + ); +}); + +subtest("stow a tree with no-folding enabled", sub { + plan tests => 82; + # folded directories should be split open (unfolded) where + # (and only where) necessary + # + cd("$TEST_DIR/target"); + + sub create_pkg { + my ($id, $pkg) = @_; + + my $stow_pkg = "../stow/$id-$pkg"; + make_path ($stow_pkg); + make_file("$stow_pkg/$id-file-$pkg"); + + # create a shallow hierarchy specific to this package which isn't + # yet stowed + make_path ("$stow_pkg/$id-$pkg-only-new"); + make_file("$stow_pkg/$id-$pkg-only-new/$id-file-$pkg"); + + # create a deeper hierarchy specific to this package which isn't + # yet stowed + make_path ("$stow_pkg/$id-$pkg-only-new2/subdir"); + make_file("$stow_pkg/$id-$pkg-only-new2/subdir/$id-file-$pkg"); + make_link("$stow_pkg/$id-$pkg-only-new2/current", "subdir"); + + # create a hierarchy specific to this package which is already + # stowed via a folded tree + make_path ("$stow_pkg/$id-$pkg-only-old"); + make_link("$id-$pkg-only-old", "$stow_pkg/$id-$pkg-only-old"); + make_file("$stow_pkg/$id-$pkg-only-old/$id-file-$pkg"); + + # create a shared hierarchy which this package uses + make_path ("$stow_pkg/$id-shared"); + make_file("$stow_pkg/$id-shared/$id-file-$pkg"); + + # create a partially shared hierarchy which this package uses + make_path ("$stow_pkg/$id-shared2/subdir-$pkg"); + make_file("$stow_pkg/$id-shared2/$id-file-$pkg"); + make_file("$stow_pkg/$id-shared2/subdir-$pkg/$id-file-$pkg"); + } + + foreach my $pkg (qw{a b}) { + create_pkg('no-folding', $pkg); + } + + $stow = new_Stow('no-folding' => 1); + $stow->plan_stow('no-folding-a'); + is_deeply([ $stow->get_conflicts ], [] => 'no conflicts with --no-folding'); + my @tasks = $stow->get_tasks; + use Data::Dumper; + is(scalar(@tasks), 13 => "6 dirs, 7 links") || warn Dumper(\@tasks); + $stow->process_tasks(); + + sub check_no_folding { + my ($pkg) = @_; + my $stow_pkg = "../stow/no-folding-$pkg"; + is_link("no-folding-file-$pkg", "$stow_pkg/no-folding-file-$pkg"); + + # check existing folded tree is untouched + is_link("no-folding-$pkg-only-old", "$stow_pkg/no-folding-$pkg-only-old"); + + # check newly stowed shallow tree is not folded + is_dir_not_symlink("no-folding-$pkg-only-new"); + is_link("no-folding-$pkg-only-new/no-folding-file-$pkg", + "../$stow_pkg/no-folding-$pkg-only-new/no-folding-file-$pkg"); + + # check newly stowed deeper tree is not folded + is_dir_not_symlink("no-folding-$pkg-only-new2"); + is_dir_not_symlink("no-folding-$pkg-only-new2/subdir"); + is_link("no-folding-$pkg-only-new2/subdir/no-folding-file-$pkg", + "../../$stow_pkg/no-folding-$pkg-only-new2/subdir/no-folding-file-$pkg"); + is_link("no-folding-$pkg-only-new2/current", + "../$stow_pkg/no-folding-$pkg-only-new2/current"); + + # check shared tree is not folded. first time round this will be + # newly stowed. + is_dir_not_symlink('no-folding-shared'); + is_link("no-folding-shared/no-folding-file-$pkg", + "../$stow_pkg/no-folding-shared/no-folding-file-$pkg"); + + # check partially shared tree is not folded. first time round this + # will be newly stowed. + is_dir_not_symlink('no-folding-shared2'); + is_link("no-folding-shared2/no-folding-file-$pkg", + "../$stow_pkg/no-folding-shared2/no-folding-file-$pkg"); + is_link("no-folding-shared2/no-folding-file-$pkg", + "../$stow_pkg/no-folding-shared2/no-folding-file-$pkg"); + } + + check_no_folding('a'); + + $stow = new_Stow('no-folding' => 1); + $stow->plan_stow('no-folding-b'); + is_deeply([ $stow->get_conflicts ], [] => 'no conflicts with --no-folding'); + @tasks = $stow->get_tasks; + is(scalar(@tasks), 11 => '4 dirs, 7 links') || warn Dumper(\@tasks); + $stow->process_tasks(); + + check_no_folding('a'); + check_no_folding('b'); +}); From 86f03d115d9687c17e06ac0012801a8f62b6b9c4 Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Mon, 1 Apr 2024 02:30:47 +0100 Subject: [PATCH 410/482] t/dotfiles.t: switch to subtests --- t/dotfiles.t | 276 ++++++++++++++++++++++++--------------------------- 1 file changed, 128 insertions(+), 148 deletions(-) diff --git a/t/dotfiles.t b/t/dotfiles.t index 6f0f583..83874ca 100755 --- a/t/dotfiles.t +++ b/t/dotfiles.t @@ -22,7 +22,7 @@ use strict; use warnings; -use Test::More tests => 11; +use Test::More tests => 10; use English qw(-no_match_vars); use Stow::Util qw(adjust_dotfile); @@ -53,177 +53,157 @@ subtest('adjust_dotfile()', sub { my $stow; -# -# stow a dotfile marked with 'dot' prefix -# +subtest("stow a dotfile marked with 'dot' prefix", sub { + plan tests => 1; + $stow = new_Stow(dir => '../stow', dotfiles => 1); + make_path('../stow/dotfiles'); + make_file('../stow/dotfiles/dot-foo'); -$stow = new_Stow(dir => '../stow', dotfiles => 1); + $stow->plan_stow('dotfiles'); + $stow->process_tasks(); + is( + readlink('.foo'), + '../stow/dotfiles/dot-foo', + => 'processed dotfile' + ); +}); -make_path('../stow/dotfiles'); -make_file('../stow/dotfiles/dot-foo'); +subtest("ensure that turning off dotfile processing links files as usual", sub { + plan tests => 1; + $stow = new_Stow(dir => '../stow', dotfiles => 0); + make_path('../stow/dotfiles'); + make_file('../stow/dotfiles/dot-foo'); -$stow->plan_stow('dotfiles'); -$stow->process_tasks(); -is( - readlink('.foo'), - '../stow/dotfiles/dot-foo', - => 'processed dotfile' -); + $stow->plan_stow('dotfiles'); + $stow->process_tasks(); + is( + readlink('dot-foo'), + '../stow/dotfiles/dot-foo', + => 'unprocessed dotfile' + ); -# -# ensure that turning off dotfile processing links files as usual -# +}); -$stow = new_Stow(dir => '../stow', dotfiles => 0); +subtest("stow folder marked with 'dot' prefix", sub { + plan tests => 1; + $stow = new_Stow(dir => '../stow', dotfiles => 1); -make_path('../stow/dotfiles'); -make_file('../stow/dotfiles/dot-foo'); + make_path('../stow/dotfiles/dot-emacs'); + make_file('../stow/dotfiles/dot-emacs/init.el'); -$stow->plan_stow('dotfiles'); -$stow->process_tasks(); -is( - readlink('dot-foo'), - '../stow/dotfiles/dot-foo', - => 'unprocessed dotfile' -); + $stow->plan_stow('dotfiles'); + $stow->process_tasks(); + is( + readlink('.emacs'), + '../stow/dotfiles/dot-emacs', + => 'processed dotfile folder' + ); +}); +subtest("process folder marked with 'dot' prefix when directory exists is target", sub { + plan tests => 1; + $stow = new_Stow(dir => '../stow', dotfiles => 1); -# -# stow folder marked with 'dot' prefix -# + make_path('../stow/dotfiles/dot-emacs.d'); + make_file('../stow/dotfiles/dot-emacs.d/init.el'); + make_path('.emacs.d'); -$stow = new_Stow(dir => '../stow', dotfiles => 1); + $stow->plan_stow('dotfiles'); + $stow->process_tasks(); + is( + readlink('.emacs.d/init.el'), + '../../stow/dotfiles/dot-emacs.d/init.el', + => 'processed dotfile folder when folder exists (1 level)' + ); +}); -make_path('../stow/dotfiles/dot-emacs'); -make_file('../stow/dotfiles/dot-emacs/init.el'); +subtest("process folder marked with 'dot' prefix when directory exists is target (2 levels)", sub { + plan tests => 1; + $stow = new_Stow(dir => '../stow', dotfiles => 1); -$stow->plan_stow('dotfiles'); -$stow->process_tasks(); -is( - readlink('.emacs'), - '../stow/dotfiles/dot-emacs', - => 'processed dotfile folder' -); + make_path('../stow/dotfiles/dot-emacs.d/dot-emacs.d'); + make_file('../stow/dotfiles/dot-emacs.d/dot-emacs.d/init.el'); + make_path('.emacs.d'); -# -# process folder marked with 'dot' prefix -# when directory exists is target -# + $stow->plan_stow('dotfiles'); + $stow->process_tasks(); + is( + readlink('.emacs.d/.emacs.d'), + '../../stow/dotfiles/dot-emacs.d/dot-emacs.d', + => 'processed dotfile folder exists (2 levels)' + ); +}); -$stow = new_Stow(dir => '../stow', dotfiles => 1); +subtest("process folder marked with 'dot' prefix when directory exists is target", sub { + plan tests => 1; + $stow = new_Stow(dir => '../stow', dotfiles => 1); -make_path('../stow/dotfiles/dot-emacs.d'); -make_file('../stow/dotfiles/dot-emacs.d/init.el'); -make_path('.emacs.d'); + make_path('../stow/dotfiles/dot-one/dot-two'); + make_file('../stow/dotfiles/dot-one/dot-two/three'); + make_path('.one/.two'); -$stow->plan_stow('dotfiles'); -$stow->process_tasks(); -is( - readlink('.emacs.d/init.el'), - '../../stow/dotfiles/dot-emacs.d/init.el', - => 'processed dotfile folder when folder exists (1 level)' -); + $stow->plan_stow('dotfiles'); + $stow->process_tasks(); + is( + readlink('./.one/.two/three'), + '../../../stow/dotfiles/dot-one/dot-two/three', + => 'processed dotfile 2 folder exists (2 levels)' + ); -# -# process folder marked with 'dot' prefix -# when directory exists is target (2 levels) -# +}); -$stow = new_Stow(dir => '../stow', dotfiles => 1); +subtest("dot-. should not have that part expanded.", sub { + plan tests => 2; + $stow = new_Stow(dir => '../stow', dotfiles => 1); -make_path('../stow/dotfiles/dot-emacs.d/dot-emacs.d'); -make_file('../stow/dotfiles/dot-emacs.d/dot-emacs.d/init.el'); -make_path('.emacs.d'); + make_path('../stow/dotfiles'); + make_file('../stow/dotfiles/dot-'); -$stow->plan_stow('dotfiles'); -$stow->process_tasks(); -is( - readlink('.emacs.d/.emacs.d'), - '../../stow/dotfiles/dot-emacs.d/dot-emacs.d', - => 'processed dotfile folder exists (2 levels)' -); + make_path('../stow/dotfiles/dot-.'); + make_file('../stow/dotfiles/dot-./foo'); -# -# process folder marked with 'dot' prefix -# when directory exists is target -# + $stow->plan_stow('dotfiles'); + $stow->process_tasks(); + is( + readlink('dot-'), + '../stow/dotfiles/dot-', + => 'processed dotfile' + ); + is( + readlink('dot-.'), + '../stow/dotfiles/dot-.', + => 'unprocessed dotfile' + ); +}); -$stow = new_Stow(dir => '../stow', dotfiles => 1); +subtest("simple unstow scenario", sub { + plan tests => 3; + $stow = new_Stow(dir => '../stow', dotfiles => 1); -make_path('../stow/dotfiles/dot-one/dot-two'); -make_file('../stow/dotfiles/dot-one/dot-two/three'); -make_path('.one/.two'); + make_path('../stow/dotfiles'); + make_file('../stow/dotfiles/dot-bar'); + make_link('.bar', '../stow/dotfiles/dot-bar'); -$stow->plan_stow('dotfiles'); -$stow->process_tasks(); -is( - readlink('./.one/.two/three'), - '../../../stow/dotfiles/dot-one/dot-two/three', - => 'processed dotfile 2 folder exists (2 levels)' -); + $stow->plan_unstow('dotfiles'); + $stow->process_tasks(); + is($stow->get_conflict_count, 0); + ok(-f '../stow/dotfiles/dot-bar'); + ok(! -e '.bar' => 'unstow a simple dotfile'); +}); +subtest("unstow process folder marked with 'dot' prefix when directory exists is target", sub { + plan tests => 4; + $stow = new_Stow(dir => '../stow', dotfiles => 1); -# -# "$DOT_PREFIX." should not have that part expanded. -# + make_path('../stow/dotfiles/dot-emacs.d'); + make_file('../stow/dotfiles/dot-emacs.d/init.el'); + make_path('.emacs.d'); + make_link('.emacs.d/init.el', '../../stow/dotfiles/dot-emacs.d/init.el'); -$stow = new_Stow(dir => '../stow', dotfiles => 1); - -make_path('../stow/dotfiles'); -make_file('../stow/dotfiles/dot-'); - -make_path('../stow/dotfiles/dot-.'); -make_file('../stow/dotfiles/dot-./foo'); - -$stow->plan_stow('dotfiles'); -$stow->process_tasks(); -is( - readlink('dot-'), - '../stow/dotfiles/dot-', - => 'processed dotfile' -); -is( - readlink('dot-.'), - '../stow/dotfiles/dot-.', - => 'unprocessed dotfile' -); - -# -# simple unstow scenario -# - -$stow = new_Stow(dir => '../stow', dotfiles => 1); - -make_path('../stow/dotfiles'); -make_file('../stow/dotfiles/dot-bar'); -make_link('.bar', '../stow/dotfiles/dot-bar'); - -$stow->plan_unstow('dotfiles'); -$stow->process_tasks(); -ok( - $stow->get_conflict_count == 0 && - -f '../stow/dotfiles/dot-bar' && ! -e '.bar' - => 'unstow a simple dotfile' -); - -# -# unstow process folder marked with 'dot' prefix -# when directory exists is target -# - -$stow = new_Stow(dir => '../stow', dotfiles => 1); - -make_path('../stow/dotfiles/dot-emacs.d'); -make_file('../stow/dotfiles/dot-emacs.d/init.el'); -make_path('.emacs.d'); -make_link('.emacs.d/init.el', '../../stow/dotfiles/dot-emacs.d/init.el'); - -$stow->plan_unstow('dotfiles'); -$stow->process_tasks(); -ok( - $stow->get_conflict_count == 0 && - -f '../stow/dotfiles/dot-emacs.d/init.el' && - ! -e '.emacs.d/init.el' && - -d '.emacs.d/' - => 'unstow dotfile folder when folder already exists' -); + $stow->plan_unstow('dotfiles'); + $stow->process_tasks(); + is($stow->get_conflict_count, 0); + ok(-f '../stow/dotfiles/dot-emacs.d/init.el'); + ok(! -e '.emacs.d/init.el'); + ok(-d '.emacs.d/' => 'unstow dotfile folder when folder already exists'); +}); From 1f752a3c94cbd87d9644f9d2731abfcc13dd8289 Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Mon, 1 Apr 2024 11:17:59 +0100 Subject: [PATCH 411/482] stow_node: rename $target => $target_subpath The $target variable was ambiguous, as it could have referred to the path to the target directory, or the path to a sub-directory in the target, as well as its intended meaning of a subpath relative to the target directory. So rename it to try to find the balance between clarity and verbosity. --- lib/Stow.pm.in | 84 +++++++++++++++++++++++++------------------------- 1 file changed, 42 insertions(+), 42 deletions(-) diff --git a/lib/Stow.pm.in b/lib/Stow.pm.in index a2390d0..4625fcf 100755 --- a/lib/Stow.pm.in +++ b/lib/Stow.pm.in @@ -464,7 +464,7 @@ sub stow_contents { } } -=head2 stow_node($stow_path, $package, $target, $source) +=head2 stow_node($stow_path, $package, $target_subpath, $source) Stow the given node @@ -482,7 +482,7 @@ Stow Directories" section of the manual). The package containing the node being stowed -=item $target +=item $target_subpath Subpath relative to package directory of node which needs stowing as a symlink at subpath relative to target directory. @@ -493,19 +493,19 @@ Relative path to symlink source from the dir of target. =back -C and C are mutually recursive. $source -and $target are used for creating the symlink C<$path> is used for -folding/unfolding trees as necessary. +C and C are mutually recursive. +C<$source> and C<$target_subpath> are used for creating the symlink. +C<$target_subpath> is used for folding/unfolding trees as necessary. =cut sub stow_node { my $self = shift; - my ($stow_path, $package, $target, $source, $level) = @_; + my ($stow_path, $package, $target_subpath, $source, $level) = @_; - my $path = join_paths($stow_path, $package, $target); + my $path = join_paths($stow_path, $package, $target_subpath); - debug(3, 0, "Stowing entry $stow_path / $package / $target"); + debug(3, 0, "Stowing entry $stow_path / $package / $target_subpath"); debug(4, 1, "=> $source"); # Don't try to stow absolute symlinks (they can't be unstowed) @@ -523,61 +523,61 @@ sub stow_node { } # Does the target already exist? - if ($self->is_a_link($target)) { + if ($self->is_a_link($target_subpath)) { # Where is the link pointing? - my $existing_link_dest = $self->read_a_link($target); + my $existing_link_dest = $self->read_a_link($target_subpath); if (not $existing_link_dest) { - error("Could not read link: $target"); + error("Could not read link: $target_subpath"); } - debug(4, 1, "Evaluate existing link: $target => $existing_link_dest"); + debug(4, 1, "Evaluate existing link: $target_subpath => $existing_link_dest"); # Does it point to a node under any stow directory? my ($existing_path, $existing_stow_path, $existing_package) = - $self->find_stowed_path($target, $existing_link_dest); + $self->find_stowed_path($target_subpath, $existing_link_dest); if (not $existing_path) { $self->conflict( 'stow', $package, - "existing target is not owned by stow: $target" + "existing target is not owned by stow: $target_subpath" ); return; # XXX # } - # Does the existing $target actually point to anything? + # Does the existing $target_subpath actually point to anything? if ($self->is_a_node($existing_path)) { if ($existing_link_dest eq $source) { - debug(2, 0, "--- Skipping $target as it already points to $source"); + debug(2, 0, "--- Skipping $target_subpath as it already points to $source"); } - elsif ($self->defer($target)) { - debug(2, 0, "--- Deferring installation of: $target"); + elsif ($self->defer($target_subpath)) { + debug(2, 0, "--- Deferring installation of: $target_subpath"); } - elsif ($self->override($target)) { - debug(2, 0, "--- Overriding installation of: $target"); - $self->do_unlink($target); - $self->do_link($source, $target); + elsif ($self->override($target_subpath)) { + debug(2, 0, "--- Overriding installation of: $target_subpath"); + $self->do_unlink($target_subpath); + $self->do_link($source, $target_subpath); } - elsif ($self->is_a_dir(join_paths(parent($target), $existing_link_dest)) && - $self->is_a_dir(join_paths(parent($target), $source))) + elsif ($self->is_a_dir(join_paths(parent($target_subpath), $existing_link_dest)) && + $self->is_a_dir(join_paths(parent($target_subpath), $source))) { # If the existing link points to a directory, # and the proposed new link points to a directory, # then we can unfold (split open) the tree at that point - debug(2, 0, "--- Unfolding $target which was already owned by $existing_package"); - $self->do_unlink($target); - $self->do_mkdir($target); + debug(2, 0, "--- Unfolding $target_subpath which was already owned by $existing_package"); + $self->do_unlink($target_subpath); + $self->do_mkdir($target_subpath); $self->stow_contents( $existing_stow_path, $existing_package, - $target, + $target_subpath, join_paths('..', $existing_link_dest), $level + 1, ); $self->stow_contents( $self->{stow_path}, $package, - $target, + $target_subpath, join_paths('..', $source), $level + 1, ); @@ -587,54 +587,54 @@ sub stow_node { 'stow', $package, "existing target is stowed to a different package: " - . "$target => $existing_link_dest" + . "$target_subpath => $existing_link_dest" ); } } else { # The existing link is invalid, so replace it with a good link debug(2, 0, "--- replacing invalid link: $path"); - $self->do_unlink($target); - $self->do_link($source, $target); + $self->do_unlink($target_subpath); + $self->do_link($source, $target_subpath); } } - elsif ($self->is_a_node($target)) { - debug(4, 1, "Evaluate existing node: $target"); - if ($self->is_a_dir($target)) { + elsif ($self->is_a_node($target_subpath)) { + debug(4, 1, "Evaluate existing node: $target_subpath"); + if ($self->is_a_dir($target_subpath)) { $self->stow_contents( $self->{stow_path}, $package, - $target, + $target_subpath, join_paths('..', $source), $level + 1, ); } else { if ($self->{adopt}) { - $self->do_mv($target, $path); - $self->do_link($source, $target); + $self->do_mv($target_subpath, $path); + $self->do_link($source, $target_subpath); } else { $self->conflict( 'stow', $package, - "existing target is neither a link nor a directory: $target" + "existing target is neither a link nor a directory: $target_subpath" ); } } } elsif ($self->{'no-folding'} && -d $path && ! -l $path) { - $self->do_mkdir($target); + $self->do_mkdir($target_subpath); $self->stow_contents( $self->{stow_path}, $package, - $target, + $target_subpath, join_paths('..', $source), $level + 1, ); } else { - $self->do_link($source, $target); + $self->do_link($source, $target_subpath); } return; } From cc592bdc44599ea5b5c5b957c3411858680c21e3 Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Mon, 1 Apr 2024 11:40:26 +0100 Subject: [PATCH 412/482] unstow_node: extract new unstow_valid_link() sub --- lib/Stow.pm.in | 64 +++++++++++++++++++++++++++----------------------- 1 file changed, 35 insertions(+), 29 deletions(-) diff --git a/lib/Stow.pm.in b/lib/Stow.pm.in index 4625fcf..bd7e8dd 100755 --- a/lib/Stow.pm.in +++ b/lib/Stow.pm.in @@ -962,35 +962,7 @@ sub unstow_node { # Does the existing $target actually point to anything? if (-e $existing_path) { - # Does link points to the right place? - - # Adjust for dotfile if necessary. - if ($self->{dotfiles}) { - $existing_path = adjust_dotfile($existing_path); - } - - if ($existing_path eq $path) { - $self->do_unlink($target); - } - - # XXX we quietly ignore links that are stowed to a different - # package. - - #elsif (defer($target)) { - # debug(2, 0, "--- deferring to installation of: $target"); - #} - #elsif ($self->override($target)) { - # debug(2, 0, "--- overriding installation of: $target"); - # $self->do_unlink($target); - #} - #else { - # $self->conflict( - # 'unstow', - # $package, - # "existing target is stowed to a different package: " - # . "$target => $existing_source" - # ); - #} + $self->unstow_valid_link($path, $target, $existing_path); } else { debug(2, 0, "--- removing invalid link into a stow directory: $path"); @@ -1021,6 +993,40 @@ sub unstow_node { return; } +sub unstow_valid_link { + my $self = shift; + my ($path, $target, $existing_path) = @_; + # Does link points to the right place? + + # Adjust for dotfile if necessary. + if ($self->{dotfiles}) { + $existing_path = adjust_dotfile($existing_path); + } + + if ($existing_path eq $path) { + $self->do_unlink($target); + } + + # XXX we quietly ignore links that are stowed to a different + # package. + + #elsif (defer($target)) { + # debug(2, 0, "--- deferring to installation of: $target"); + #} + #elsif ($self->override($target)) { + # debug(2, 0, "--- overriding installation of: $target"); + # $self->do_unlink($target); + #} + #else { + # $self->conflict( + # 'unstow', + # $package, + # "existing target is stowed to a different package: " + # . "$target => $existing_source" + # ); + #} +} + =head2 link_owned_by_package($target, $source) Determine whether the given link points to a member of a stowed From 42cc1d2e608bae0248ccfe057c229ee1586e6ea8 Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Mon, 1 Apr 2024 11:46:10 +0100 Subject: [PATCH 413/482] unstow_node: extract new unstow_link_node() sub --- lib/Stow.pm.in | 72 +++++++++++++++++++++++++++----------------------- 1 file changed, 39 insertions(+), 33 deletions(-) diff --git a/lib/Stow.pm.in b/lib/Stow.pm.in index bd7e8dd..3be67ed 100755 --- a/lib/Stow.pm.in +++ b/lib/Stow.pm.in @@ -935,39 +935,7 @@ sub unstow_node { # Does the target exist? if ($self->is_a_link($target)) { - debug(4, 2, "Evaluate existing link: $target"); - - # Where is the link pointing? - my $existing_source = $self->read_a_link($target); - if (not $existing_source) { - error("Could not read link: $target"); - } - - if ($existing_source =~ m{\A/}) { - warn "Ignoring an absolute symlink: $target => $existing_source\n"; - return; # XXX # - } - - # Does it point to a node under any stow directory? - my ($existing_path, $existing_stow_path, $existing_package) = - $self->find_stowed_path($target, $existing_source); - if (not $existing_path) { - $self->conflict( - 'unstow', - $package, - "existing target is not owned by stow: $target => $existing_source" - ); - return; # XXX # - } - - # Does the existing $target actually point to anything? - if (-e $existing_path) { - $self->unstow_valid_link($path, $target, $existing_path); - } - else { - debug(2, 0, "--- removing invalid link into a stow directory: $path"); - $self->do_unlink($target); - } + $self->unstow_link_node($package, $target, $path); } elsif (-e $target) { debug(4, 2, "Evaluate existing node: $target"); @@ -993,6 +961,44 @@ sub unstow_node { return; } +sub unstow_link_node { + my $self = shift; + my ($package, $target, $path) = @_; + debug(4, 2, "Evaluate existing link: $target"); + + # Where is the link pointing? + my $existing_source = $self->read_a_link($target); + if (not $existing_source) { + error("Could not read link: $target"); + } + + if ($existing_source =~ m{\A/}) { + warn "Ignoring an absolute symlink: $target => $existing_source\n"; + return; # XXX # + } + + # Does it point to a node under any stow directory? + my ($existing_path, $existing_stow_path, $existing_package) = + $self->find_stowed_path($target, $existing_source); + if (not $existing_path) { + $self->conflict( + 'unstow', + $package, + "existing target is not owned by stow: $target => $existing_source" + ); + return; # XXX # + } + + # Does the existing $target actually point to anything? + if (-e $existing_path) { + $self->unstow_valid_link($path, $target, $existing_path); + } + else { + debug(2, 0, "--- removing invalid link into a stow directory: $path"); + $self->do_unlink($target); + } +} + sub unstow_valid_link { my $self = shift; my ($path, $target, $existing_path) = @_; From 517384407b5fa5b60be8edadd4515cfd81972694 Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Mon, 1 Apr 2024 11:49:07 +0100 Subject: [PATCH 414/482] unstow_node: extract new unstow_existing_node() sub --- lib/Stow.pm.in | 38 ++++++++++++++++++++++---------------- 1 file changed, 22 insertions(+), 16 deletions(-) diff --git a/lib/Stow.pm.in b/lib/Stow.pm.in index 3be67ed..7fdd2ee 100755 --- a/lib/Stow.pm.in +++ b/lib/Stow.pm.in @@ -938,22 +938,7 @@ sub unstow_node { $self->unstow_link_node($package, $target, $path); } elsif (-e $target) { - debug(4, 2, "Evaluate existing node: $target"); - if (-d $target) { - $self->unstow_contents($package, $target, $source); - - # This action may have made the parent directory foldable - if (my $parent = $self->foldable($target)) { - $self->fold_tree($target, $parent); - } - } - else { - $self->conflict( - 'unstow', - $package, - "existing target is neither a link nor a directory: $target", - ); - } + $self->unstow_existing_node($package, $target, $source); } else { debug(2, 1, "$target did not exist to be unstowed"); @@ -1033,6 +1018,27 @@ sub unstow_valid_link { #} } +sub unstow_existing_node { + my $self = shift; + my ($package, $target, $source) = @_; + debug(4, 2, "Evaluate existing node: $target"); + if (-d $target) { + $self->unstow_contents($package, $target, $source); + + # This action may have made the parent directory foldable + if (my $parent = $self->foldable($target)) { + $self->fold_tree($target, $parent); + } + } + else { + $self->conflict( + 'unstow', + $package, + "existing target is neither a link nor a directory: $target", + ); + } +} + =head2 link_owned_by_package($target, $source) Determine whether the given link points to a member of a stowed From 456424c560daad8b059b981ca5db9d85a18d4cb5 Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Mon, 1 Apr 2024 12:12:27 +0100 Subject: [PATCH 415/482] unstow_node_orig: replace a bunch of duplicated code with unstow_link_node() --- lib/Stow.pm.in | 55 ++++++++++++++------------------------------------ 1 file changed, 15 insertions(+), 40 deletions(-) diff --git a/lib/Stow.pm.in b/lib/Stow.pm.in index 7fdd2ee..bebca44 100755 --- a/lib/Stow.pm.in +++ b/lib/Stow.pm.in @@ -782,40 +782,7 @@ sub unstow_node_orig { # Does the target exist? if ($self->is_a_link($target)) { - debug(4, 1, "Evaluate existing link: $target"); - - # Where is the link pointing? - my $existing_source = $self->read_a_link($target); - if (not $existing_source) { - error("Could not read link: $target"); - } - - # Does it point to a node under any stow directory? - my ($existing_path, $existing_stow_path, $existing_package) = - $self->find_stowed_path($target, $existing_source); - if (not $existing_path) { - # We're traversing the target tree not the package tree, - # so we definitely expect to find stuff not owned by stow. - # Therefore we can't flag a conflict. - return; # XXX # - } - - # Does the existing $target actually point to anything? - if (-e $existing_path) { - # Does link point to the right place? - if ($existing_path eq $path) { - $self->do_unlink($target); - } - elsif ($self->override($target)) { - debug(2, 0, "--- overriding installation of: $target"); - $self->do_unlink($target); - } - # else leave it alone - } - else { - debug(2, 0, "--- removing invalid link into a stow directory: $path"); - $self->do_unlink($target); - } + $self->unstow_link_node($package, $target, $path); } elsif (-d $target) { $self->unstow_contents_orig($package, $target); @@ -966,12 +933,20 @@ sub unstow_link_node { my ($existing_path, $existing_stow_path, $existing_package) = $self->find_stowed_path($target, $existing_source); if (not $existing_path) { - $self->conflict( - 'unstow', - $package, - "existing target is not owned by stow: $target => $existing_source" - ); - return; # XXX # + if ($self->{compat}) { + # We're traversing the target tree not the package tree, + # so we definitely expect to find stuff not owned by stow. + # Therefore we can't flag a conflict. + return; + } + else { + $self->conflict( + 'unstow', + $package, + "existing target is not owned by stow: $target => $existing_source" + ); + } + return; } # Does the existing $target actually point to anything? From 4054d40a2afa95f69139f7c66bc8548dc9f97673 Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Mon, 1 Apr 2024 12:13:21 +0100 Subject: [PATCH 416/482] emacs: tweak more cperl indentation config to match existing style --- .dir-locals.el | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.dir-locals.el b/.dir-locals.el index 1840735..2dc381f 100644 --- a/.dir-locals.el +++ b/.dir-locals.el @@ -1,4 +1,6 @@ ((cperl-mode . ((dumb-jump-force-searcher . rg) (cperl-indent-level . 4) + (cperl-close-paren-offset . -4) + (cperl-indent-subs-specially . nil) (indent-tabs-mode . nil) (eval . (auto-fill-mode -1))))) From 0782be7106d3498c3525db8e8a863b3a54b1f21f Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Mon, 1 Apr 2024 13:00:51 +0100 Subject: [PATCH 417/482] Remove unstow_*_orig() functions Refactor the compat mode code to reuse the existing unstow_contents() and unstow_node(). This allows us to remove the parallel versions in unstow_contents_orig() and unstow_node(), which contained a lot of duplicated code and were a significant maintenance burden. --- lib/Stow.pm.in | 182 +++++++++++++------------------------------------ 1 file changed, 47 insertions(+), 135 deletions(-) diff --git a/lib/Stow.pm.in b/lib/Stow.pm.in index bebca44..215eb7e 100755 --- a/lib/Stow.pm.in +++ b/lib/Stow.pm.in @@ -281,20 +281,11 @@ sub plan_unstow { error("The stow directory $self->{stow_path} does not contain package $package"); } debug(2, 0, "Planning unstow of package $package..."); - if ($self->{compat}) { - $self->unstow_contents_orig( - $package, - '.', - $pkg_path, - ); - } - else { - $self->unstow_contents( - $package, - '.', - $pkg_path, - ); - } + $self->unstow_contents( + $package, + '.', + $pkg_path, + ); debug(2, 0, "Planning unstow of package $package... done"); $self->{action_count}++; } @@ -696,115 +687,6 @@ sub marked_stow_dir { return 0; } -=head2 unstow_contents_orig($package, $target) - -Unstow the contents of the given directory - -=over 4 - -=item $package - -The package whose contents are being unstowed. - -=item $target - -Relative path to symlink target from the current directory. - -=back - -unstow_node_orig() and unstow_contents_orig() are mutually recursive. -Here we traverse the target tree, rather than the source tree. - -=cut - -sub unstow_contents_orig { - my $self = shift; - my ($package, $target) = @_; - - my $path = join_paths($self->{stow_path}, $package, $target); - - return if $self->should_skip_target($target); - - my $cwd = getcwd(); - my $msg = "Unstowing from $target (compat mode, cwd=$cwd, stow dir=$self->{stow_path})"; - $msg =~ s!$ENV{HOME}(/|$)!~$1!g; - debug(3, 0, $msg); - debug(4, 1, "source path is $path"); - # In compat mode we traverse the target tree not the source tree, - # so we're unstowing the contents of /target/foo, there's no - # guarantee that the corresponding /stow/mypkg/foo exists. - error("unstow_contents_orig() called with non-directory target: $target") - unless -d $target; - - opendir my $DIR, $target - or error("cannot read directory: $target ($!)"); - my @listing = readdir $DIR; - closedir $DIR; - - NODE: - for my $node (@listing) { - next NODE if $node eq '.'; - next NODE if $node eq '..'; - my $node_target = join_paths($target, $node); - next NODE if $self->ignore($self->{stow_path}, $package, $node_target); - $self->unstow_node_orig($package, $node_target); - } -} - -=head2 unstow_node_orig($package, $target) - -Unstow the given node - -=over 4 - -=item $package - -The package containing the node being stowed. - -=item $target - -Relative path to symlink target from the current directory. - -=back - -C and C are mutually recursive. - -=cut - -sub unstow_node_orig { - my $self = shift; - my ($package, $target) = @_; - - my $path = join_paths($self->{stow_path}, $package, $target); - - debug(3, 0, "Unstowing $target (compat mode)"); - debug(4, 1, "source path is $path"); - - # Does the target exist? - if ($self->is_a_link($target)) { - $self->unstow_link_node($package, $target, $path); - } - elsif (-d $target) { - $self->unstow_contents_orig($package, $target); - - # This action may have made the parent directory foldable - if (my $parent = $self->foldable($target)) { - $self->fold_tree($target, $parent); - } - } - elsif (-e $target) { - $self->conflict( - 'unstow', - $package, - "existing target is neither a link nor a directory: $target", - ); - } - else { - debug(2, 0, "$target did not exist to be unstowed"); - } - return; -} - =head2 unstow_contents($package, $target) Unstow the contents of the given directory @@ -837,17 +719,29 @@ sub unstow_contents { $msg =~ s!$ENV{HOME}/!~/!g; debug(3, 0, $msg); debug(4, 1, "source path is $path"); - # We traverse the source tree not the target tree, so $path must exist. - error("unstow_contents() called with non-directory path: $path") - unless -d $path; - # When called at the top level, $target should exist. And - # unstow_node() should only call this via mutual recursion if - # $target exists. - error("unstow_contents() called with invalid target: $target") - unless $self->is_a_node($target); - opendir my $DIR, $path - or error("cannot read directory: $path ($!)"); + if ($self->{compat}) { + # In compat mode we traverse the target tree not the source tree, + # so we're unstowing the contents of /target/foo, there's no + # guarantee that the corresponding /stow/mypkg/foo exists. + error("unstow_contents() in compat mode called with non-directory target: $target") + unless -d $target; + } + else { + # We traverse the source tree not the target tree, so $path must exist. + error("unstow_contents() called with non-directory path: $path") + unless -d $path; + + # When called at the top level, $target should exist. And + # unstow_node() should only call this via mutual recursion if + # $target exists. + error("unstow_contents() called with invalid target: $target") + unless $self->is_a_node($target); + } + + my $dir = $self->{compat} ? $target : $path; + opendir my $DIR, $dir + or error("cannot read directory: $dir ($!)"); my @listing = readdir $DIR; closedir $DIR; @@ -866,7 +760,8 @@ sub unstow_contents { $self->unstow_node($package, $node_target, join_paths($path, $node)); } - if (-d $target) { + + if (! $self->{compat} && -d $target) { $self->cleanup_invalid_links($target); } } @@ -904,8 +799,25 @@ sub unstow_node { if ($self->is_a_link($target)) { $self->unstow_link_node($package, $target, $path); } + elsif ($self->{compat} && -d $target) { + $self->unstow_contents($package, $target, $path); + + # This action may have made the parent directory foldable + if (my $parent = $self->foldable($target)) { + $self->fold_tree($target, $parent); + } + } elsif (-e $target) { - $self->unstow_existing_node($package, $target, $source); + if ($self->{compat}) { + $self->conflict( + 'unstow', + $package, + "existing target is neither a link nor a directory: $target", + ); + } + else { + $self->unstow_existing_node($package, $target, $source); + } } else { debug(2, 1, "$target did not exist to be unstowed"); From 8a17d8b4f202c5ce6095ae571d7b9158dfea83ad Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Mon, 1 Apr 2024 15:12:46 +0100 Subject: [PATCH 418/482] manual: use American punctuation of "vs." GNU and Stow are both originally from the USA, so it makes sense to stay consistent with American English. --- doc/stow.texi | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/doc/stow.texi b/doc/stow.texi index 2cfd050..80cc2d2 100644 --- a/doc/stow.texi +++ b/doc/stow.texi @@ -99,7 +99,7 @@ appear to be installed in a single directory tree. * Multiple Stow Directories:: Further segregating software. * Target Maintenance:: Cleaning up mistakes. * Resource Files:: Setting default command line options. -* Compile-time vs Install-time:: Faking out `make install'. +* Compile-time vs. Install-time:: Faking out `make install'. * Bootstrapping:: When stow and perl are not yet stowed. * Reporting Bugs:: How, what, where, and when to report. * Known Bugs:: Don't report any of these. @@ -316,7 +316,7 @@ context: the installation image, or some of its contents, and @item -the location of symlinks (the ``source'' of the link, vs. its +the location of symlinks (the ``source'' of the link, vs.@: its destination). @end enumerate @@ -954,7 +954,7 @@ directory. @end table @c =========================================================================== -@node Resource Files, Compile-time vs Install-time, Target Maintenance, Top +@node Resource Files, Compile-time vs. Install-time, Target Maintenance, Top @chapter Resource Files @cindex resource files @cindex configuration files @@ -1021,8 +1021,8 @@ resource files. This is also true of any package names given in the resource file. @c =========================================================================== -@node Compile-time vs Install-time, Bootstrapping, Resource Files, Top -@chapter Compile-time vs Install-time +@node Compile-time vs. Install-time, Bootstrapping, Resource Files, Top +@chapter Compile-time vs. Install-time Software whose installation is managed with Stow needs to be installed in one place (the package directory, e.g. @file{/usr/local/stow/perl}) @@ -1104,7 +1104,7 @@ following sections. @end menu @c --------------------------------------------------------------------------- -@node GNU Emacs, Other FSF Software, Compile-time vs Install-time, Compile-time vs Install-time +@node GNU Emacs, Other FSF Software, Compile-time vs. Install-time, Compile-time vs. Install-time @section GNU Emacs Although the Free Software Foundation has many enlightened practices @@ -1137,7 +1137,7 @@ make do-install prefix=/usr/local/stow/emacs @end example @c --------------------------------------------------------------------------- -@node Other FSF Software, Cygnus Software, GNU Emacs, Compile-time vs Install-time +@node Other FSF Software, Cygnus Software, GNU Emacs, Compile-time vs. Install-time @section Other FSF Software The Free Software Foundation, the organization behind the GNU project, @@ -1158,7 +1158,7 @@ and @samp{make install} steps to work correctly without needing to ``fool'' the build process. @c --------------------------------------------------------------------------- -@node Cygnus Software, Perl and Perl 5 Modules, Other FSF Software, Compile-time vs Install-time +@node Cygnus Software, Perl and Perl 5 Modules, Other FSF Software, Compile-time vs. Install-time @section Cygnus Software Cygnus is a commercial supplier and supporter of GNU software. It has @@ -1187,7 +1187,7 @@ is recompiling files. Usually it will work just fine; otherwise, install manually. @c --------------------------------------------------------------------------- -@node Perl and Perl 5 Modules, , Cygnus Software, Compile-time vs Install-time +@node Perl and Perl 5 Modules, , Cygnus Software, Compile-time vs. Install-time @section Perl and Perl 5 Modules Perl 4.036 allows you to specify different locations for installation @@ -1290,7 +1290,7 @@ find cpan.* \( -name .exists -o -name perllocal.pod \) -print | \ @c --------------------------------------------------------------------------- -@node Bootstrapping, Reporting Bugs, Compile-time vs Install-time, Top +@node Bootstrapping, Reporting Bugs, Compile-time vs. Install-time, Top @chapter Bootstrapping Suppose you have a stow directory all set up and ready to go: From 10c86841de328f14947e4a245de2282cdca80426 Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Mon, 1 Apr 2024 15:15:58 +0100 Subject: [PATCH 419/482] stow_contents / unstow_node: rename $target => $target_sub{dir,path} This is very similar to a previous commit which did the same rename in stow_node(). The $target variable was ambiguous, as it could have referred to the path to the target directory, or the path to a sub-directory in the target, as well as its intended meaning of a subpath relative to the target directory. So rename it to try to find the balance between clarity and verbosity. --- lib/Stow.pm.in | 167 ++++++++++++++++++++++++------------------------- 1 file changed, 83 insertions(+), 84 deletions(-) diff --git a/lib/Stow.pm.in b/lib/Stow.pm.in index 215eb7e..6e874fd 100755 --- a/lib/Stow.pm.in +++ b/lib/Stow.pm.in @@ -361,7 +361,7 @@ sub within_target_do { debug(3, 0, "cwd restored to $cwd"); } -=head2 stow_contents($stow_path, $package, $target, $source) +=head2 stow_contents($stow_path, $package, $target_subdir, $source) Stow the contents of the given directory. @@ -379,7 +379,7 @@ Stow Directories" section of the manual). The package whose contents are being stowed. -=item $target +=item $target_subdir Subpath relative to package directory which needs stowing as a symlink at subpath relative to target directory. @@ -390,15 +390,14 @@ Relative path from the (sub)dir of target to symlink source. =back -C and C are mutually recursive. $source -and $target are used for creating the symlink. C<$path> is used for -folding/unfolding trees as necessary. +C and C are mutually recursive. +C<$source> and C<$target_subdir> are used for creating the symlink. =cut sub stow_contents { my $self = shift; - my ($stow_path, $package, $target, $source, $level) = @_; + my ($stow_path, $package, $target_subdir, $source, $level) = @_; # Calculate the path to the package directory or sub-directory # whose contents need to be stowed, relative to the current @@ -414,7 +413,7 @@ sub stow_contents { my $n = 0; my $path = join '/', map { (++$n <= $level) ? ( ) : $_ } (split m{/+}, $source); - return if $self->should_skip_target($target); + return if $self->should_skip_target($target_subdir); my $cwd = getcwd(); my $msg = "Stowing contents of $path (cwd=$cwd)"; @@ -424,8 +423,8 @@ sub stow_contents { error("stow_contents() called with non-directory package path: $path") unless -d $path; - error("stow_contents() called with non-directory target: $target") - unless $self->is_a_node($target); + error("stow_contents() called with non-directory target: $target_subdir") + unless $self->is_a_node($target_subdir); opendir my $DIR, $path or error("cannot read directory: $path ($!)"); @@ -436,7 +435,7 @@ sub stow_contents { for my $node (@listing) { next NODE if $node eq '.'; next NODE if $node eq '..'; - my $node_target = join_paths($target, $node); + my $node_target = join_paths($target_subdir, $node); next NODE if $self->ignore($stow_path, $package, $node_target); if ($self->{dotfiles}) { @@ -630,17 +629,17 @@ sub stow_node { return; } -=head2 should_skip_target($target) +=head2 should_skip_target($target_subdir) -Determine whether target is a stow directory which should -not be stowed to or unstowed from. This mechanism protects -stow directories from being altered by stow, and is a necessary -safety check because the stow directory could live beneath the -target directory. +Determine whether C<$target_subdir> is a stow directory which should +not be stowed to or unstowed from. This mechanism protects stow +directories from being altered by stow, and is a necessary safety +check because the stow directory could live beneath the target +directory. =over 4 -=item $target => relative path to symlink target from the current directory +=item $target_subdir => relative path to symlink target from the current directory =back @@ -710,12 +709,12 @@ Here we traverse the source tree, rather than the target tree. sub unstow_contents { my $self = shift; - my ($package, $target, $path) = @_; + my ($package, $target_subdir, $path) = @_; - return if $self->should_skip_target($target); + return if $self->should_skip_target($target_subdir); my $cwd = getcwd(); - my $msg = "Unstowing from $target (cwd=$cwd, stow dir=$self->{stow_path})"; + my $msg = "Unstowing from $target_subdir (cwd=$cwd, stow dir=$self->{stow_path})"; $msg =~ s!$ENV{HOME}/!~/!g; debug(3, 0, $msg); debug(4, 1, "source path is $path"); @@ -724,22 +723,22 @@ sub unstow_contents { # In compat mode we traverse the target tree not the source tree, # so we're unstowing the contents of /target/foo, there's no # guarantee that the corresponding /stow/mypkg/foo exists. - error("unstow_contents() in compat mode called with non-directory target: $target") - unless -d $target; + error("unstow_contents() in compat mode called with non-directory target: $target_subdir") + unless -d $target_subdir; } else { # We traverse the source tree not the target tree, so $path must exist. error("unstow_contents() called with non-directory path: $path") unless -d $path; - # When called at the top level, $target should exist. And + # When called at the top level, $target_subdir should exist. And # unstow_node() should only call this via mutual recursion if - # $target exists. - error("unstow_contents() called with invalid target: $target") - unless $self->is_a_node($target); + # $target_subdir exists. + error("unstow_contents() called with invalid target: $target_subdir") + unless $self->is_a_node($target_subdir); } - my $dir = $self->{compat} ? $target : $path; + my $dir = $self->{compat} ? $target_subdir : $path; opendir my $DIR, $dir or error("cannot read directory: $dir ($!)"); my @listing = readdir $DIR; @@ -749,7 +748,7 @@ sub unstow_contents { for my $node (@listing) { next NODE if $node eq '.'; next NODE if $node eq '..'; - my $node_target = join_paths($target, $node); + my $node_target = join_paths($target_subdir, $node); next NODE if $self->ignore($self->{stow_path}, $package, $node_target); if ($self->{dotfiles}) { @@ -761,12 +760,12 @@ sub unstow_contents { $self->unstow_node($package, $node_target, join_paths($path, $node)); } - if (! $self->{compat} && -d $target) { - $self->cleanup_invalid_links($target); + if (! $self->{compat} && -d $target_subdir) { + $self->cleanup_invalid_links($target_subdir); } } -=head2 unstow_node($package, $target) +=head2 unstow_node($package, $target_subpath) Unstow the given node. @@ -776,7 +775,7 @@ Unstow the given node. The package containing the node being unstowed. -=item $target +=item $target_subpath Relative path to symlink target from the current directory. @@ -788,62 +787,62 @@ C and C are mutually recursive. sub unstow_node { my $self = shift; - my ($package, $target, $source) = @_; + my ($package, $target_subpath, $source) = @_; - my $path = join_paths($self->{stow_path}, $package, $target); + my $path = join_paths($self->{stow_path}, $package, $target_subpath); debug(3, 1, "Unstowing $path"); - debug(4, 2, "target is $target"); + debug(4, 2, "target is $target_subpath"); # Does the target exist? - if ($self->is_a_link($target)) { - $self->unstow_link_node($package, $target, $path); + if ($self->is_a_link($target_subpath)) { + $self->unstow_link_node($package, $target_subpath, $path); } - elsif ($self->{compat} && -d $target) { - $self->unstow_contents($package, $target, $path); + elsif ($self->{compat} && -d $target_subpath) { + $self->unstow_contents($package, $target_subpath, $path); # This action may have made the parent directory foldable - if (my $parent = $self->foldable($target)) { - $self->fold_tree($target, $parent); + if (my $parent = $self->foldable($target_subpath)) { + $self->fold_tree($target_subpath, $parent); } } - elsif (-e $target) { + elsif (-e $target_subpath) { if ($self->{compat}) { $self->conflict( 'unstow', $package, - "existing target is neither a link nor a directory: $target", + "existing target is neither a link nor a directory: $target_subpath", ); } else { - $self->unstow_existing_node($package, $target, $source); + $self->unstow_existing_node($package, $target_subpath, $source); } } else { - debug(2, 1, "$target did not exist to be unstowed"); + debug(2, 1, "$target_subpath did not exist to be unstowed"); } return; } sub unstow_link_node { my $self = shift; - my ($package, $target, $path) = @_; - debug(4, 2, "Evaluate existing link: $target"); + my ($package, $target_subpath, $path) = @_; + debug(4, 2, "Evaluate existing link: $target_subpath"); # Where is the link pointing? - my $existing_source = $self->read_a_link($target); + my $existing_source = $self->read_a_link($target_subpath); if (not $existing_source) { - error("Could not read link: $target"); + error("Could not read link: $target_subpath"); } if ($existing_source =~ m{\A/}) { - warn "Ignoring an absolute symlink: $target => $existing_source\n"; + warn "Ignoring an absolute symlink: $target_subpath => $existing_source\n"; return; # XXX # } # Does it point to a node under any stow directory? my ($existing_path, $existing_stow_path, $existing_package) = - $self->find_stowed_path($target, $existing_source); + $self->find_stowed_path($target_subpath, $existing_source); if (not $existing_path) { if ($self->{compat}) { # We're traversing the target tree not the package tree, @@ -855,25 +854,25 @@ sub unstow_link_node { $self->conflict( 'unstow', $package, - "existing target is not owned by stow: $target => $existing_source" + "existing target is not owned by stow: $target_subpath => $existing_source" ); } return; } - # Does the existing $target actually point to anything? + # Does the existing $target_subpath actually point to anything? if (-e $existing_path) { - $self->unstow_valid_link($path, $target, $existing_path); + $self->unstow_valid_link($path, $target_subpath, $existing_path); } else { debug(2, 0, "--- removing invalid link into a stow directory: $path"); - $self->do_unlink($target); + $self->do_unlink($target_subpath); } } sub unstow_valid_link { my $self = shift; - my ($path, $target, $existing_path) = @_; + my ($path, $target_subpath, $existing_path) = @_; # Does link points to the right place? # Adjust for dotfile if necessary. @@ -882,58 +881,58 @@ sub unstow_valid_link { } if ($existing_path eq $path) { - $self->do_unlink($target); + $self->do_unlink($target_subpath); } # XXX we quietly ignore links that are stowed to a different # package. - #elsif (defer($target)) { - # debug(2, 0, "--- deferring to installation of: $target"); + #elsif (defer($target_subpath)) { + # debug(2, 0, "--- deferring to installation of: $target_subpath"); #} - #elsif ($self->override($target)) { - # debug(2, 0, "--- overriding installation of: $target"); - # $self->do_unlink($target); + #elsif ($self->override($target_subpath)) { + # debug(2, 0, "--- overriding installation of: $target_subpath"); + # $self->do_unlink($target_subpath); #} #else { # $self->conflict( # 'unstow', # $package, # "existing target is stowed to a different package: " - # . "$target => $existing_source" + # . "$target_subpath => $existing_source" # ); #} } sub unstow_existing_node { my $self = shift; - my ($package, $target, $source) = @_; - debug(4, 2, "Evaluate existing node: $target"); - if (-d $target) { - $self->unstow_contents($package, $target, $source); + my ($package, $target_subpath, $source) = @_; + debug(4, 2, "Evaluate existing node: $target_subpath"); + if (-d $target_subpath) { + $self->unstow_contents($package, $target_subpath, $source); # This action may have made the parent directory foldable - if (my $parent = $self->foldable($target)) { - $self->fold_tree($target, $parent); + if (my $parent = $self->foldable($target_subpath)) { + $self->fold_tree($target_subpath, $parent); } } else { $self->conflict( 'unstow', $package, - "existing target is neither a link nor a directory: $target", + "existing target is neither a link nor a directory: $target_subpath", ); } } -=head2 link_owned_by_package($target, $source) +=head2 link_owned_by_package($target_subpath, $source) Determine whether the given link points to a member of a stowed package. =over 4 -=item $target +=item $target_subpath Path to a symbolic link under current directory. @@ -951,14 +950,14 @@ Returns the package iff link is owned by stow, otherwise ''. sub link_owned_by_package { my $self = shift; - my ($target, $source) = @_; + my ($target_subpath, $source) = @_; my ($path, $stow_path, $package) = - $self->find_stowed_path($target, $source); + $self->find_stowed_path($target_subpath, $source); return $package; } -=head2 find_stowed_path($target, $link_dest) +=head2 find_stowed_path($target_subpath, $link_dest) Determine whether the given symlink within the target directory is a stowed path pointing to a member of a package under the stow dir, and @@ -966,7 +965,7 @@ if so, obtain a breakdown of information about this stowed path. =over 4 -=item $target +=item $target_subpath Path to a symbolic link somewhere under the target directory, relative to the top-level target directory (which is also expected to be the @@ -977,7 +976,7 @@ current directory). Where that link points to (needed because link might not exist yet due to two-phase approach, so we can't just call C). If this is owned by Stow, it will be expressed relative to (the directory -containing) C<$target>. However if it's not, it could of course be +containing) C<$target_subpath>. However if it's not, it could of course be relative or absolute, point absolutely anywhere, and could even be dangling. @@ -998,7 +997,7 @@ not being under target dir. sub find_stowed_path { my $self = shift; - my ($target, $link_dest) = @_; + my ($target_subpath, $link_dest) = @_; if (substr($link_dest, 0, 1) eq '/') { # Symlink points to an absolute path, therefore it cannot be @@ -1009,8 +1008,8 @@ sub find_stowed_path { # Evaluate softlink relative to its target, without relying on # what's actually on the filesystem, since the link might not # exist yet. - debug(4, 2, "find_stowed_path(target=$target; source=$link_dest)"); - my $dest = join_paths(parent($target), $link_dest); + debug(4, 2, "find_stowed_path(target=$target_subpath; source=$link_dest)"); + my $dest = join_paths(parent($target_subpath), $link_dest); debug(4, 3, "is symlink destination $dest owned by stow?"); # First check whether the link is owned by the current stow @@ -1177,14 +1176,14 @@ sub cleanup_invalid_links { error("Could not read link $node_path"); } - my $target = join_paths($dir, $link_dest); + my $target_subpath = join_paths($dir, $link_dest); debug(4, 2, "join $dir $link_dest"); - if (-e $target) { - debug(4, 2, "Link target $link_dest exists at $target; skipping clean up"); + if (-e $target_subpath) { + debug(4, 2, "Link target $link_dest exists at $target_subpath; skipping clean up"); next; } else { - debug(4, 2, "Link target $link_dest doesn't exist at $target"); + debug(4, 2, "Link target $link_dest doesn't exist at $target_subpath"); } debug(3, 1, From caefb641b8291e2c5edc72ab5d4b92b8b976d8c2 Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Mon, 1 Apr 2024 15:49:19 +0100 Subject: [PATCH 420/482] find_stowed_path: reintroduce missing comment lines These lines were accidentally removed by 84367681. --- lib/Stow.pm.in | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/Stow.pm.in b/lib/Stow.pm.in index 6e874fd..8dd0958 100755 --- a/lib/Stow.pm.in +++ b/lib/Stow.pm.in @@ -1022,6 +1022,8 @@ sub find_stowed_path { } # If no .stow file was found, we need to find out whether it's + # owned by the current stow directory, in which case $path will be + # a prefix of $self->{stow_path}. my ($stow_path, $ext_package) = $self->find_containing_marked_stow_dir($dest); if (length $stow_path) { debug(5, 5, "yes - $stow_path in $dest was marked as a stow dir; package=$ext_package"); From c0060443ee63a59317ec4035c79c48a5b765a7bf Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Mon, 1 Apr 2024 15:58:09 +0100 Subject: [PATCH 421/482] marked_stow_dir: rename $path to $dir It's always a directory, so make this explicit. --- lib/Stow.pm.in | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/Stow.pm.in b/lib/Stow.pm.in index 8dd0958..82be277 100755 --- a/lib/Stow.pm.in +++ b/lib/Stow.pm.in @@ -678,9 +678,9 @@ sub should_skip_target { # marked_stow_dir() won't work. sub marked_stow_dir { my $self = shift; - my ($path) = @_; - if (-e join_paths($path, ".stow")) { - debug(5, 5, "> $path contained .stow"); + my ($dir) = @_; + if (-e join_paths($dir, ".stow")) { + debug(5, 5, "> $dir contained .stow"); return 1; } return 0; From 75c892abc6a7dcf830aa29eb4930bb8e0ff0505e Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Mon, 1 Apr 2024 16:06:12 +0100 Subject: [PATCH 422/482] unstow_* helpers: rename $path to $pkg_path_from_cwd $path is horribly vague, so rename to be more informative. --- lib/Stow.pm.in | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/Stow.pm.in b/lib/Stow.pm.in index 82be277..fd4c0f3 100755 --- a/lib/Stow.pm.in +++ b/lib/Stow.pm.in @@ -826,7 +826,7 @@ sub unstow_node { sub unstow_link_node { my $self = shift; - my ($package, $target_subpath, $path) = @_; + my ($package, $target_subpath, $pkg_path_from_cwd) = @_; debug(4, 2, "Evaluate existing link: $target_subpath"); # Where is the link pointing? @@ -862,17 +862,17 @@ sub unstow_link_node { # Does the existing $target_subpath actually point to anything? if (-e $existing_path) { - $self->unstow_valid_link($path, $target_subpath, $existing_path); + $self->unstow_valid_link($pkg_path_from_cwd, $target_subpath, $existing_path); } else { - debug(2, 0, "--- removing invalid link into a stow directory: $path"); + debug(2, 0, "--- removing invalid link into a stow directory: $pkg_path_from_cwd"); $self->do_unlink($target_subpath); } } sub unstow_valid_link { my $self = shift; - my ($path, $target_subpath, $existing_path) = @_; + my ($pkg_path_from_cwd, $target_subpath, $existing_path) = @_; # Does link points to the right place? # Adjust for dotfile if necessary. @@ -880,7 +880,7 @@ sub unstow_valid_link { $existing_path = adjust_dotfile($existing_path); } - if ($existing_path eq $path) { + if ($existing_path eq $pkg_path_from_cwd) { $self->do_unlink($target_subpath); } @@ -952,7 +952,7 @@ sub link_owned_by_package { my $self = shift; my ($target_subpath, $source) = @_; - my ($path, $stow_path, $package) = + my ($pkg_path_from_cwd, $stow_path, $package) = $self->find_stowed_path($target_subpath, $source); return $package; } From 170d1616928835553978e346a72bf74982cc8cbf Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Mon, 1 Apr 2024 16:07:09 +0100 Subject: [PATCH 423/482] find_containing_marked_stow_dir: rename $path to $pkg_path_from_cwd $path is horribly vague, so rename to be more informative. --- lib/Stow.pm.in | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/lib/Stow.pm.in b/lib/Stow.pm.in index fd4c0f3..4861e51 100755 --- a/lib/Stow.pm.in +++ b/lib/Stow.pm.in @@ -1067,13 +1067,13 @@ sub link_dest_within_stow_dir { return ($package, $path); } -=head2 find_containing_marked_stow_dir($path) +=head2 find_containing_marked_stow_dir($pkg_path_from_cwd) Detect whether path is within a marked stow directory =over 4 -=item $path => path to directory to check +=item $pkg_path_from_cwd => path to directory to check =back @@ -1090,15 +1090,15 @@ C won't work. sub find_containing_marked_stow_dir { my $self = shift; - my ($path) = @_; + my ($pkg_path_from_cwd) = @_; # Search for .stow files - this allows us to detect links # owned by stow directories other than the current one. - my @segments = File::Spec->splitdir($path); + my @segments = File::Spec->splitdir($pkg_path_from_cwd); for my $last_segment (0 .. $#segments) { - my $path = join_paths(@segments[0 .. $last_segment]); - debug(5, 5, "is $path marked stow dir?"); - if ($self->marked_stow_dir($path)) { + my $pkg_path_from_cwd = join_paths(@segments[0 .. $last_segment]); + debug(5, 5, "is $pkg_path_from_cwd marked stow dir?"); + if ($self->marked_stow_dir($pkg_path_from_cwd)) { if ($last_segment == $#segments) { # This should probably never happen. Even if it did, # there would be no way of calculating $package. @@ -1106,7 +1106,7 @@ sub find_containing_marked_stow_dir { } my $package = $segments[$last_segment + 1]; - return ($path, $package); + return ($pkg_path_from_cwd, $package); } } return ('', ''); From 6b9bbc9cbbb9e7205bb7c57b175b517d36f6ce24 Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Mon, 1 Apr 2024 16:08:56 +0100 Subject: [PATCH 424/482] link_dest_within_stow_dir: rename $path to $pkg_subpath $path is horribly vague, so rename to be more informative. --- lib/Stow.pm.in | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/Stow.pm.in b/lib/Stow.pm.in index 4861e51..80b1907 100755 --- a/lib/Stow.pm.in +++ b/lib/Stow.pm.in @@ -1043,8 +1043,8 @@ Detect whether symlink destination is within current stow dir =back -Returns C<($package, $path)> - package within the current stow dir -and subpath within that package which the symlink points to. +Returns C<($package, $pkg_subpath)> - package within the current stow +dir and subpath within that package which the symlink points to. =cut @@ -1063,8 +1063,8 @@ sub link_dest_within_stow_dir { debug(4, 4, "remaining after removing $self->{stow_path}: $link_dest"); my @dirs = File::Spec->splitdir($link_dest); my $package = shift @dirs; - my $path = File::Spec->catdir(@dirs); - return ($package, $path); + my $pkg_subpath = File::Spec->catdir(@dirs); + return ($package, $pkg_subpath); } =head2 find_containing_marked_stow_dir($pkg_path_from_cwd) From 0daf352200dd1694fec772c30b0453d25a002501 Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Mon, 1 Apr 2024 16:16:52 +0100 Subject: [PATCH 425/482] unstow_node: rename $path to $pkg_path_from_cwd $path is horribly vague, so rename to be more informative. --- lib/Stow.pm.in | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/Stow.pm.in b/lib/Stow.pm.in index 80b1907..0228483 100755 --- a/lib/Stow.pm.in +++ b/lib/Stow.pm.in @@ -789,17 +789,17 @@ sub unstow_node { my $self = shift; my ($package, $target_subpath, $source) = @_; - my $path = join_paths($self->{stow_path}, $package, $target_subpath); + my $pkg_path_from_cwd = join_paths($self->{stow_path}, $package, $target_subpath); - debug(3, 1, "Unstowing $path"); + debug(3, 1, "Unstowing $pkg_path_from_cwd"); debug(4, 2, "target is $target_subpath"); # Does the target exist? if ($self->is_a_link($target_subpath)) { - $self->unstow_link_node($package, $target_subpath, $path); + $self->unstow_link_node($package, $target_subpath, $pkg_path_from_cwd); } elsif ($self->{compat} && -d $target_subpath) { - $self->unstow_contents($package, $target_subpath, $path); + $self->unstow_contents($package, $target_subpath, $pkg_path_from_cwd); # This action may have made the parent directory foldable if (my $parent = $self->foldable($target_subpath)) { From 2851b36df4ffb18750e01b1e53f9ef000e78d2a3 Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Mon, 1 Apr 2024 16:18:52 +0100 Subject: [PATCH 426/482] find_stowed_path: rename $path / $dest to $pkg_path_from_cwd $path is horribly vague, so rename to be more informative. --- lib/Stow.pm.in | 35 ++++++++++++++++++----------------- 1 file changed, 18 insertions(+), 17 deletions(-) diff --git a/lib/Stow.pm.in b/lib/Stow.pm.in index 0228483..2aa48a8 100755 --- a/lib/Stow.pm.in +++ b/lib/Stow.pm.in @@ -982,12 +982,13 @@ dangling. =back -Returns C<($path, $stow_path, $package)> where C<$path> and -C<$stow_path> are relative from the top-level target directory. -C<$path> is the full relative path to the member of the package -pointed to by C<$link_dest>; C<$stow_path> is the relative path to the -stow directory; and C<$package> is the name of the package; or C<('', -'', '')> if link is not owned by stow. +Returns C<($pkg_path_from_cwd, $stow_path, $package)> where +C<$pkg_path_from_cwd> and C<$stow_path> are relative from the +top-level target directory. C<$pkg_path_from_cwd> is the full +relative path to the member of the package pointed to by +C<$link_dest>; C<$stow_path> is the relative path to the stow +directory; and C<$package> is the name of the package; or C<('', '', +'')> if link is not owned by stow. cwd must be the top-level target directory, otherwise C won't work. Allow for stow dir @@ -1009,25 +1010,25 @@ sub find_stowed_path { # what's actually on the filesystem, since the link might not # exist yet. debug(4, 2, "find_stowed_path(target=$target_subpath; source=$link_dest)"); - my $dest = join_paths(parent($target_subpath), $link_dest); - debug(4, 3, "is symlink destination $dest owned by stow?"); + my $pkg_path_from_cwd = join_paths(parent($target_subpath), $link_dest); + debug(4, 3, "is symlink destination $pkg_path_from_cwd owned by stow?"); # First check whether the link is owned by the current stow - # directory, in which case $dest will be a prefix of + # directory, in which case $pkg_path_from_cwd will be a prefix of # $self->{stow_path}. - my ($package, $path) = $self->link_dest_within_stow_dir($dest); + my ($package, $pkg_subpath) = $self->link_dest_within_stow_dir($pkg_path_from_cwd); if (length $package) { - debug(4, 3, "yes - package $package in $self->{stow_path} may contain $path"); - return ($dest, $self->{stow_path}, $package); + debug(4, 3, "yes - package $package in $self->{stow_path} may contain $pkg_subpath"); + return ($pkg_path_from_cwd, $self->{stow_path}, $package); } # If no .stow file was found, we need to find out whether it's - # owned by the current stow directory, in which case $path will be - # a prefix of $self->{stow_path}. - my ($stow_path, $ext_package) = $self->find_containing_marked_stow_dir($dest); + # owned by the current stow directory, in which case + # $pkg_path_from_cwd will be a prefix of $self->{stow_path}. + my ($stow_path, $ext_package) = $self->find_containing_marked_stow_dir($pkg_path_from_cwd); if (length $stow_path) { - debug(5, 5, "yes - $stow_path in $dest was marked as a stow dir; package=$ext_package"); - return ($dest, $stow_path, $ext_package); + debug(5, 5, "yes - $stow_path in $pkg_path_from_cwd was marked as a stow dir; package=$ext_package"); + return ($pkg_path_from_cwd, $stow_path, $ext_package); } return ('', '', ''); From 6cf41850b3c422bcdc81c4ddbe2a88cf130b14e2 Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Mon, 1 Apr 2024 16:34:01 +0100 Subject: [PATCH 427/482] foldable: rename $target => $target_subdir The $target variable was ambiguous, as it could have referred to the path to the target directory, or the path to a sub-directory in the target, as well as its intended meaning of a subpath relative to the target directory. So rename it to try to find the balance between clarity and verbosity. --- NEWS | 2 +- lib/Stow.pm.in | 24 ++++++++++++------------ 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/NEWS b/NEWS index 9d18951..6e27494 100644 --- a/NEWS +++ b/NEWS @@ -27,7 +27,7 @@ News file for Stow. ***** Improve readability of source code Quite a few extra details have been added in comments to clarify - how the code works. Some variable names have also been + how the code works. Many variable names have also been improved. The comments of many Stow class methods have been converted into Perl POD format. diff --git a/lib/Stow.pm.in b/lib/Stow.pm.in index 2aa48a8..1e3fb05 100755 --- a/lib/Stow.pm.in +++ b/lib/Stow.pm.in @@ -1205,36 +1205,36 @@ sub cleanup_invalid_links { } -=head2 foldable($target) +=head2 foldable($target_subdir) Determine whether a tree can be folded =over 4 -=item $target +=item $target_subdir path to a directory =back Returns path to the parent dir iff the tree can be safely folded. The -path returned is relative to the parent of $target, i.e. it can be +path returned is relative to the parent of $target_subdir, i.e. it can be used as the source for a replacement symlink. =cut sub foldable { my $self = shift; - my ($target) = @_; + my ($target_subdir) = @_; - debug(3, 2, "Is $target foldable?"); + debug(3, 2, "Is $target_subdir foldable?"); if ($self->{'no-folding'}) { debug(3, 3, "no because --no-folding enabled"); return ''; } - opendir my $DIR, $target - or error(qq{Cannot read directory "$target" ($!)\n}); + opendir my $DIR, $target_subdir + or error(qq{Cannot read directory "$target_subdir" ($!)\n}); my @listing = readdir $DIR; closedir $DIR; @@ -1245,7 +1245,7 @@ sub foldable { next NODE if $node eq '.'; next NODE if $node eq '..'; - my $path = join_paths($target, $node); + my $path = join_paths($target_subdir, $node); # Skip nodes scheduled for removal next NODE if not $self->is_a_node($path); @@ -1267,16 +1267,16 @@ sub foldable { } return '' if not $parent; - # If we get here then all nodes inside $target are links, and those links + # If we get here then all nodes inside $target_subdir are links, and those links # point to nodes inside the same directory. # chop of leading '..' to get the path to the common parent directory - # relative to the parent of our $target + # relative to the parent of our $target_subdir $parent =~ s{\A\.\./}{}; # If the resulting path is owned by stow, we can fold it - if ($self->link_owned_by_package($target, $parent)) { - debug(3, 3, "$target is foldable"); + if ($self->link_owned_by_package($target_subdir, $parent)) { + debug(3, 3, "$target_subdir is foldable"); return $parent; } else { From 2c255af1876f0a38bce8044c5529cbacd590554a Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Mon, 1 Apr 2024 17:00:13 +0100 Subject: [PATCH 428/482] t/unstow_orig: split into subtests --- t/unstow_orig.t | 591 +++++++++++++++++++++++------------------------- 1 file changed, 285 insertions(+), 306 deletions(-) diff --git a/t/unstow_orig.t b/t/unstow_orig.t index e893c56..94f771d 100755 --- a/t/unstow_orig.t +++ b/t/unstow_orig.t @@ -23,7 +23,7 @@ use strict; use warnings; use File::Spec qw(make_path); -use Test::More tests => 37; +use Test::More tests => 17; use Test::Output; use English qw(-no_match_vars); @@ -38,366 +38,345 @@ cd("$TEST_DIR/target"); my $stow; my %conflicts; -# -# unstow a simple tree minimally -# +subtest("unstow a simple tree minimally", sub { + plan tests => 3; + my $stow = new_compat_Stow(); -$stow = new_compat_Stow(); + make_path('../stow/pkg1/bin1'); + make_file('../stow/pkg1/bin1/file1'); + make_link('bin1', '../stow/pkg1/bin1'); -make_path('../stow/pkg1/bin1'); -make_file('../stow/pkg1/bin1/file1'); -make_link('bin1', '../stow/pkg1/bin1'); + $stow->plan_unstow('pkg1'); + $stow->process_tasks(); + is($stow->get_conflict_count, 0); + ok(-f '../stow/pkg1/bin1/file1'); + ok(! -e 'bin1' => 'unstow a simple tree'); +}); -$stow->plan_unstow('pkg1'); -$stow->process_tasks(); -ok( - $stow->get_conflict_count == 0 && - -f '../stow/pkg1/bin1/file1' && ! -e 'bin1' - => 'unstow a simple tree' -); +subtest("unstow a simple tree from an existing directory", sub { + plan tests => 3; + my $stow = new_compat_Stow(); -# -# unstow a simple tree from an existing directory -# -$stow = new_compat_Stow(); + make_path('lib2'); + make_path('../stow/pkg2/lib2'); + make_file('../stow/pkg2/lib2/file2'); + make_link('lib2/file2', '../../stow/pkg2/lib2/file2'); + $stow->plan_unstow('pkg2'); + $stow->process_tasks(); + is($stow->get_conflict_count, 0); + ok(-f '../stow/pkg2/lib2/file2'); + ok(-d 'lib2' + => 'unstow simple tree from a pre-existing directory' + ); +}); -make_path('lib2'); -make_path('../stow/pkg2/lib2'); -make_file('../stow/pkg2/lib2/file2'); -make_link('lib2/file2', '../../stow/pkg2/lib2/file2'); -$stow->plan_unstow('pkg2'); -$stow->process_tasks(); -ok( - $stow->get_conflict_count == 0 && - -f '../stow/pkg2/lib2/file2' && -d 'lib2' - => 'unstow simple tree from a pre-existing directory' -); +subtest("fold tree after unstowing", sub { + plan tests => 3; + my $stow = new_compat_Stow(); -# -# fold tree after unstowing -# -$stow = new_compat_Stow(); + make_path('bin3'); -make_path('bin3'); + make_path('../stow/pkg3a/bin3'); + make_file('../stow/pkg3a/bin3/file3a'); + make_link('bin3/file3a' => '../../stow/pkg3a/bin3/file3a'); # emulate stow -make_path('../stow/pkg3a/bin3'); -make_file('../stow/pkg3a/bin3/file3a'); -make_link('bin3/file3a' => '../../stow/pkg3a/bin3/file3a'); # emulate stow + make_path('../stow/pkg3b/bin3'); + make_file('../stow/pkg3b/bin3/file3b'); + make_link('bin3/file3b' => '../../stow/pkg3b/bin3/file3b'); # emulate stow + $stow->plan_unstow('pkg3b'); + $stow->process_tasks(); + is($stow->get_conflict_count, 0); + ok(-l 'bin3'); + is(readlink('bin3'), '../stow/pkg3a/bin3' + => 'fold tree after unstowing' + ); +}); -make_path('../stow/pkg3b/bin3'); -make_file('../stow/pkg3b/bin3/file3b'); -make_link('bin3/file3b' => '../../stow/pkg3b/bin3/file3b'); # emulate stow -$stow->plan_unstow('pkg3b'); -$stow->process_tasks(); -ok( - $stow->get_conflict_count == 0 && - -l 'bin3' && - readlink('bin3') eq '../stow/pkg3a/bin3' - => 'fold tree after unstowing' -); +subtest("existing link is owned by stow but is invalid so it gets removed anyway", sub { + plan tests => 2; + my $stow = new_compat_Stow(); -# -# existing link is owned by stow but is invalid so it gets removed anyway -# -$stow = new_compat_Stow(); + make_path('bin4'); + make_path('../stow/pkg4/bin4'); + make_file('../stow/pkg4/bin4/file4'); + make_invalid_link('bin4/file4', '../../stow/pkg4/bin4/does-not-exist'); -make_path('bin4'); -make_path('../stow/pkg4/bin4'); -make_file('../stow/pkg4/bin4/file4'); -make_invalid_link('bin4/file4', '../../stow/pkg4/bin4/does-not-exist'); + $stow->plan_unstow('pkg4'); + $stow->process_tasks(); + is($stow->get_conflict_count, 0); + ok(! -e 'bin4/file4' + => q(remove invalid link owned by stow) + ); +}); -$stow->plan_unstow('pkg4'); -$stow->process_tasks(); -ok( - $stow->get_conflict_count == 0 && - ! -e 'bin4/file4' - => q(remove invalid link owned by stow) -); +subtest("Existing link is not owned by stow", sub { + plan tests => 2; + my $stow = new_compat_Stow(); -# -# Existing link is not owned by stow -# -$stow = new_compat_Stow(); + make_path('../stow/pkg5/bin5'); + make_invalid_link('bin5', '../not-stow'); -make_path('../stow/pkg5/bin5'); -make_invalid_link('bin5', '../not-stow'); + $stow->plan_unstow('pkg5'); + # Unlike the corresponding stow_contents.t test, this doesn't + # cause any conflicts. + # + #like( + # $Conflicts[-1], qr(can't unlink.*not owned by stow) + # => q(existing link not owned by stow) + #); + ok(-l 'bin5'); + ok(readlink('bin5') eq '../not-stow' + => q(existing link not owned by stow) + ); +}); -$stow->plan_unstow('pkg5'); -# Unlike the corresponding stow_contents.t test, this doesn't -# cause any conflicts. -# -#like( -# $Conflicts[-1], qr(can't unlink.*not owned by stow) -# => q(existing link not owned by stow) -#); -ok( - -l 'bin5' && readlink('bin5') eq '../not-stow' - => q(existing link not owned by stow) -); +subtest("Target already exists, is owned by stow, but points to a different package", sub { + plan tests => 3; + my $stow = new_compat_Stow(); -# -# Target already exists, is owned by stow, but points to a different package -# -$stow = new_compat_Stow(); + make_path('bin6'); + make_path('../stow/pkg6a/bin6'); + make_file('../stow/pkg6a/bin6/file6'); + make_link('bin6/file6', '../../stow/pkg6a/bin6/file6'); -make_path('bin6'); -make_path('../stow/pkg6a/bin6'); -make_file('../stow/pkg6a/bin6/file6'); -make_link('bin6/file6', '../../stow/pkg6a/bin6/file6'); + make_path('../stow/pkg6b/bin6'); + make_file('../stow/pkg6b/bin6/file6'); -make_path('../stow/pkg6b/bin6'); -make_file('../stow/pkg6b/bin6/file6'); + $stow->plan_unstow('pkg6b'); + is($stow->get_conflict_count, 0); + ok(-l 'bin6/file6'); + ok( + readlink('bin6/file6') eq '../../stow/pkg6a/bin6/file6' + => q(ignore existing link that points to a different package) + ); +}); -$stow->plan_unstow('pkg6b'); -ok( - $stow->get_conflict_count == 0 && - -l 'bin6/file6' && - readlink('bin6/file6') eq '../../stow/pkg6a/bin6/file6' - => q(ignore existing link that points to a different package) -); +subtest("Don't unlink anything under the stow directory", sub { + plan tests => 5; + make_path('stow'); # make stow dir a subdir of target + my $stow = new_compat_Stow(dir => 'stow'); -# -# Don't unlink anything under the stow directory -# -make_path('stow'); # make out stow dir a subdir of target -$stow = new_compat_Stow(dir => 'stow'); + # emulate stowing into ourself (bizarre corner case or accident) + make_path('stow/pkg7a/stow/pkg7b'); + make_file('stow/pkg7a/stow/pkg7b/file7b'); + make_link('stow/pkg7b', '../stow/pkg7a/stow/pkg7b'); -# emulate stowing into ourself (bizarre corner case or accident) -make_path('stow/pkg7a/stow/pkg7b'); -make_file('stow/pkg7a/stow/pkg7b/file7b'); -make_link('stow/pkg7b', '../stow/pkg7a/stow/pkg7b'); + capture_stderr(); + $stow->plan_unstow('pkg7b'); + is($stow->get_tasks, 0, 'no tasks to process when unstowing pkg7b'); + is($stow->get_conflict_count, 0); + ok(-l 'stow/pkg7b'); + ok(readlink('stow/pkg7b') eq '../stow/pkg7a/stow/pkg7b' + => q(don't unlink any nodes under the stow directory) + ); + like($stderr, + qr/WARNING: skipping target which was current stow directory stow/ + => "warn when unstowing from ourself"); + uncapture_stderr(); +}); -capture_stderr(); -$stow->plan_unstow('pkg7b'); -is($stow->get_tasks, 0, 'no tasks to process when unstowing pkg7b'); -ok( - $stow->get_conflict_count == 0 && - -l 'stow/pkg7b' && - readlink('stow/pkg7b') eq '../stow/pkg7a/stow/pkg7b' - => q(don't unlink any nodes under the stow directory) -); -like($stderr, - qr/WARNING: skipping target which was current stow directory stow/ - => "warn when unstowing from ourself"); -uncapture_stderr(); +subtest("Don't unlink any nodes under another stow directory", sub { + plan tests => 5; + my $stow = new_compat_Stow(dir => 'stow'); -# -# Don't unlink any nodes under another stow directory -# -$stow = new_compat_Stow(dir => 'stow'); + make_path('stow2'); # make our alternate stow dir a subdir of target + make_file('stow2/.stow'); -make_path('stow2'); # make our alternate stow dir a subdir of target -make_file('stow2/.stow'); + # emulate stowing into ourself (bizarre corner case or accident) + make_path('stow/pkg8a/stow2/pkg8b'); + make_file('stow/pkg8a/stow2/pkg8b/file8b'); + make_link('stow2/pkg8b', '../stow/pkg8a/stow2/pkg8b'); -# emulate stowing into ourself (bizarre corner case or accident) -make_path('stow/pkg8a/stow2/pkg8b'); -make_file('stow/pkg8a/stow2/pkg8b/file8b'); -make_link('stow2/pkg8b', '../stow/pkg8a/stow2/pkg8b'); + capture_stderr(); + $stow->plan_unstow('pkg8a'); + is($stow->get_tasks, 0, 'no tasks to process when unstowing pkg8a'); + is($stow->get_conflict_count, 0); + ok(-l 'stow2/pkg8b'); + ok(readlink('stow2/pkg8b') eq '../stow/pkg8a/stow2/pkg8b' + => q(don't unlink any nodes under another stow directory) + ); + like($stderr, + qr/WARNING: skipping target which was current stow directory stow/ + => "warn when skipping unstowing"); + uncapture_stderr(); +}); -capture_stderr(); -$stow->plan_unstow('pkg8a'); -is($stow->get_tasks, 0, 'no tasks to process when unstowing pkg8a'); -ok( - $stow->get_conflict_count == 0 && - -l 'stow2/pkg8b' && - readlink('stow2/pkg8b') eq '../stow/pkg8a/stow2/pkg8b' - => q(don't unlink any nodes under another stow directory) -); -like($stderr, - qr/WARNING: skipping target which was current stow directory stow/ - => "warn when skipping unstowing"); -uncapture_stderr(); - -# -# overriding already stowed documentation -# - -# This will be used by this and subsequent tests +# This will be used by subsequent tests sub check_protected_dirs_skipped { for my $dir (qw{stow stow2}) { like($stderr, - qr/WARNING: skipping marked Stow directory $dir/ - => "warn when skipping marked directory $dir"); + qr/WARNING: skipping marked Stow directory $dir/ + => "warn when skipping marked directory $dir"); } uncapture_stderr(); } -$stow = new_compat_Stow(override => ['man9', 'info9']); -make_file('stow/.stow'); +subtest("overriding already stowed documentation", sub { + plan tests => 4; -make_path('../stow/pkg9a/man9/man1'); -make_file('../stow/pkg9a/man9/man1/file9.1'); -make_path('man9/man1'); -make_link('man9/man1/file9.1' => '../../../stow/pkg9a/man9/man1/file9.1'); # emulate stow + my $stow = new_compat_Stow(override => ['man9', 'info9']); + make_file('stow/.stow'); -make_path('../stow/pkg9b/man9/man1'); -make_file('../stow/pkg9b/man9/man1/file9.1'); -capture_stderr(); -$stow->plan_unstow('pkg9b'); -$stow->process_tasks(); -ok( - $stow->get_conflict_count == 0 && - !-l 'man9/man1/file9.1' - => 'overriding existing documentation files' -); -check_protected_dirs_skipped(); + make_path('../stow/pkg9a/man9/man1'); + make_file('../stow/pkg9a/man9/man1/file9.1'); + make_path('man9/man1'); + make_link('man9/man1/file9.1' => '../../../stow/pkg9a/man9/man1/file9.1'); # emulate stow -# -# deferring to already stowed documentation -# -$stow = new_compat_Stow(defer => ['man10', 'info10']); + make_path('../stow/pkg9b/man9/man1'); + make_file('../stow/pkg9b/man9/man1/file9.1'); + capture_stderr(); + $stow->plan_unstow('pkg9b'); + $stow->process_tasks(); + is($stow->get_conflict_count, 0); + ok(!-l 'man9/man1/file9.1' + => 'overriding existing documentation files' + ); + check_protected_dirs_skipped(); +}); -make_path('../stow/pkg10a/man10/man1'); -make_file('../stow/pkg10a/man10/man1/file10a.1'); -make_path('man10/man1'); -make_link('man10/man1/file10a.1' => '../../../stow/pkg10a/man10/man1/file10a.1'); +subtest("deferring to already stowed documentation", sub { + plan tests => 5; + my $stow = new_compat_Stow(defer => ['man10', 'info10']); -# need this to block folding -make_path('../stow/pkg10b/man10/man1'); -make_file('../stow/pkg10b/man10/man1/file10b.1'); -make_link('man10/man1/file10b.1' => '../../../stow/pkg10b/man10/man1/file10b.1'); + make_path('../stow/pkg10a/man10/man1'); + make_file('../stow/pkg10a/man10/man1/file10a.1'); + make_path('man10/man1'); + make_link('man10/man1/file10a.1' => '../../../stow/pkg10a/man10/man1/file10a.1'); + # need this to block folding + make_path('../stow/pkg10b/man10/man1'); + make_file('../stow/pkg10b/man10/man1/file10b.1'); + make_link('man10/man1/file10b.1' => '../../../stow/pkg10b/man10/man1/file10b.1'); -make_path('../stow/pkg10c/man10/man1'); -make_file('../stow/pkg10c/man10/man1/file10a.1'); -capture_stderr(); -$stow->plan_unstow('pkg10c'); -is($stow->get_tasks, 0, 'no tasks to process when unstowing pkg10c'); -ok( - $stow->get_conflict_count == 0 && - readlink('man10/man1/file10a.1') eq '../../../stow/pkg10a/man10/man1/file10a.1' - => 'defer to existing documentation files' -); -check_protected_dirs_skipped(); + make_path('../stow/pkg10c/man10/man1'); + make_file('../stow/pkg10c/man10/man1/file10a.1'); + capture_stderr(); + $stow->plan_unstow('pkg10c'); + is($stow->get_tasks, 0, 'no tasks to process when unstowing pkg10c'); + is($stow->get_conflict_count, 0); + ok(readlink('man10/man1/file10a.1') eq '../../../stow/pkg10a/man10/man1/file10a.1' + => 'defer to existing documentation files' + ); + check_protected_dirs_skipped(); +}); -# -# Ignore temp files -# -$stow = new_compat_Stow(ignore => ['~', '\.#.*']); +subtest("Ignore temp files", sub { + plan tests => 4; + my $stow = new_compat_Stow(ignore => ['~', '\.#.*']); -make_path('../stow/pkg12/man12/man1'); -make_file('../stow/pkg12/man12/man1/file12.1'); -make_file('../stow/pkg12/man12/man1/file12.1~'); -make_file('../stow/pkg12/man12/man1/.#file12.1'); -make_path('man12/man1'); -make_link('man12/man1/file12.1' => '../../../stow/pkg12/man12/man1/file12.1'); + make_path('../stow/pkg12/man12/man1'); + make_file('../stow/pkg12/man12/man1/file12.1'); + make_file('../stow/pkg12/man12/man1/file12.1~'); + make_file('../stow/pkg12/man12/man1/.#file12.1'); + make_path('man12/man1'); + make_link('man12/man1/file12.1' => '../../../stow/pkg12/man12/man1/file12.1'); -capture_stderr(); -$stow->plan_unstow('pkg12'); -$stow->process_tasks(); -ok( - $stow->get_conflict_count == 0 && - !-e 'man12/man1/file12.1' - => 'ignore temp files' -); -check_protected_dirs_skipped(); + capture_stderr(); + $stow->plan_unstow('pkg12'); + $stow->process_tasks(); + is($stow->get_conflict_count, 0); + ok(!-e 'man12/man1/file12.1' => 'ignore temp files'); + check_protected_dirs_skipped(); +}); -# -# Unstow an already unstowed package -# -$stow = new_compat_Stow(); -capture_stderr(); -$stow->plan_unstow('pkg12'); -is($stow->get_tasks, 0, 'no tasks to process when unstowing pkg12'); -ok( - $stow->get_conflict_count == 0 - => 'unstow already unstowed package pkg12' -); -check_protected_dirs_skipped(); +subtest("Unstow an already unstowed package", sub { + plan tests => 4; + my $stow = new_compat_Stow(); + capture_stderr(); + $stow->plan_unstow('pkg12'); + is($stow->get_tasks, 0, 'no tasks to process when unstowing pkg12'); + ok( + $stow->get_conflict_count == 0 + => 'unstow already unstowed package pkg12' + ); + check_protected_dirs_skipped(); +}); -# -# Unstow a never stowed package -# +subtest("Unstow a never stowed package", sub { + plan tests => 4; -eval { remove_dir("$TEST_DIR/target"); }; -mkdir("$TEST_DIR/target"); + eval { remove_dir("$TEST_DIR/target"); }; + mkdir("$TEST_DIR/target"); -$stow = new_compat_Stow(); -capture_stderr(); -$stow->plan_unstow('pkg12'); -is($stow->get_tasks, 0, 'no tasks to process when unstowing pkg12 which was never stowed'); -ok( - $stow->get_conflict_count == 0 - => 'unstow never stowed package pkg12' -); -check_protected_dirs_skipped(); + my $stow = new_compat_Stow(); + capture_stderr(); + $stow->plan_unstow('pkg12'); + is($stow->get_tasks, 0, 'no tasks to process when unstowing pkg12 which was never stowed'); + ok( + $stow->get_conflict_count == 0 + => 'unstow never stowed package pkg12' + ); + check_protected_dirs_skipped(); +}); -# -# Unstowing when target contains a real file shouldn't be an issue. -# -make_file('man12/man1/file12.1'); +subtest("Unstowing when target contains a real file shouldn't be an issue", sub { + plan tests => 5; + make_file('man12/man1/file12.1'); -$stow = new_compat_Stow(); -capture_stderr(); -$stow->plan_unstow('pkg12'); -is($stow->get_tasks, 0, 'no tasks to process when unstowing pkg12 for third time'); -%conflicts = $stow->get_conflicts; -ok( - $stow->get_conflict_count == 1 && - $conflicts{unstow}{pkg12}[0] - =~ m!existing target is neither a link nor a directory: man12/man1/file12\.1! - => 'unstow pkg12 for third time' -); -check_protected_dirs_skipped(); + my $stow = new_compat_Stow(); + capture_stderr(); + $stow->plan_unstow('pkg12'); + is($stow->get_tasks, 0, 'no tasks to process when unstowing pkg12 for third time'); + %conflicts = $stow->get_conflicts; + ok($stow->get_conflict_count == 1); + ok($conflicts{unstow}{pkg12}[0] + =~ m!existing target is neither a link nor a directory: man12/man1/file12\.1! + => 'unstow pkg12 for third time' + ); + check_protected_dirs_skipped(); +}); -# -# unstow a simple tree minimally when cwd isn't target -# -cd('../..'); -$stow = new_Stow(dir => "$TEST_DIR/stow", target => "$TEST_DIR/target"); +subtest("unstow a simple tree minimally when cwd isn't target", sub { + plan tests => 3; + cd('../..'); + my $stow = new_Stow(dir => "$TEST_DIR/stow", target => "$TEST_DIR/target"); -make_path("$TEST_DIR/stow/pkg13/bin13"); -make_file("$TEST_DIR/stow/pkg13/bin13/file13"); -make_link("$TEST_DIR/target/bin13", '../stow/pkg13/bin13'); + make_path("$TEST_DIR/stow/pkg13/bin13"); + make_file("$TEST_DIR/stow/pkg13/bin13/file13"); + make_link("$TEST_DIR/target/bin13", '../stow/pkg13/bin13'); -$stow->plan_unstow('pkg13'); -$stow->process_tasks(); -ok( - $stow->get_conflict_count == 0 && - -f "$TEST_DIR/stow/pkg13/bin13/file13" && ! -e "$TEST_DIR/target/bin13" - => 'unstow a simple tree' -); + $stow->plan_unstow('pkg13'); + $stow->process_tasks(); + is($stow->get_conflict_count, 0); + ok(-f "$TEST_DIR/stow/pkg13/bin13/file13"); + ok(! -e "$TEST_DIR/target/bin13" => 'unstow a simple tree'); +}); -# -# unstow a simple tree minimally with absolute stow dir when cwd isn't -# target -# -$stow = new_Stow(dir => canon_path("$TEST_DIR/stow"), - target => "$TEST_DIR/target"); +subtest("unstow a simple tree minimally with absolute stow dir when cwd isn't target", sub { + plan tests => 3; + my $stow = new_Stow(dir => canon_path("$TEST_DIR/stow"), + target => "$TEST_DIR/target"); -make_path("$TEST_DIR/stow/pkg14/bin14"); -make_file("$TEST_DIR/stow/pkg14/bin14/file14"); -make_link("$TEST_DIR/target/bin14", '../stow/pkg14/bin14'); + make_path("$TEST_DIR/stow/pkg14/bin14"); + make_file("$TEST_DIR/stow/pkg14/bin14/file14"); + make_link("$TEST_DIR/target/bin14", '../stow/pkg14/bin14'); -$stow->plan_unstow('pkg14'); -$stow->process_tasks(); -ok( - $stow->get_conflict_count == 0 && - -f "$TEST_DIR/stow/pkg14/bin14/file14" && ! -e "$TEST_DIR/target/bin14" - => 'unstow a simple tree with absolute stow dir' -); + $stow->plan_unstow('pkg14'); + $stow->process_tasks(); + is($stow->get_conflict_count, 0); + ok(-f "$TEST_DIR/stow/pkg14/bin14/file14"); + ok(! -e "$TEST_DIR/target/bin14" + => 'unstow a simple tree with absolute stow dir' + ); +}); -# -# unstow a simple tree minimally with absolute stow AND target dirs -# when cwd isn't target -# -$stow = new_Stow(dir => canon_path("$TEST_DIR/stow"), - target => canon_path("$TEST_DIR/target")); +subtest("unstow a simple tree minimally with absolute stow AND target dirs when cwd isn't target", sub { + plan tests => 3; + my $stow = new_Stow(dir => canon_path("$TEST_DIR/stow"), + target => canon_path("$TEST_DIR/target")); + make_path("$TEST_DIR/stow/pkg15/bin15"); + make_file("$TEST_DIR/stow/pkg15/bin15/file15"); + make_link("$TEST_DIR/target/bin15", '../stow/pkg15/bin15'); -make_path("$TEST_DIR/stow/pkg15/bin15"); -make_file("$TEST_DIR/stow/pkg15/bin15/file15"); -make_link("$TEST_DIR/target/bin15", '../stow/pkg15/bin15'); - -$stow->plan_unstow('pkg15'); -$stow->process_tasks(); -ok( - $stow->get_conflict_count == 0 && - -f "$TEST_DIR/stow/pkg15/bin15/file15" && ! -e "$TEST_DIR/target/bin15" - => 'unstow a simple tree with absolute stow and target dirs' -); - - -# Todo -# -# Test cleaning up subdirs with --paranoid option + $stow->plan_unstow('pkg15'); + $stow->process_tasks(); + is($stow->get_conflict_count, 0); + ok(-f "$TEST_DIR/stow/pkg15/bin15/file15"); + ok(! -e "$TEST_DIR/target/bin15" + => 'unstow a simple tree with absolute stow and target dirs' + ); +}); +# subtest("Test cleaning up subdirs with --paranoid option", sub { +# TODO +# }); From 79f90d39b3c61f1ac4d948a24adb5e0791d2e0a0 Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Mon, 1 Apr 2024 17:59:25 +0100 Subject: [PATCH 429/482] parent_link_scheduled_for_removal: tweak debug --- lib/Stow.pm.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Stow.pm.in b/lib/Stow.pm.in index 1e3fb05..9f9422b 100755 --- a/lib/Stow.pm.in +++ b/lib/Stow.pm.in @@ -1856,7 +1856,7 @@ sub parent_link_scheduled_for_removal { my $prefix = ''; for my $part (split m{/+}, $path) { $prefix = join_paths($prefix, $part); - debug(4, 2, "parent_link_scheduled_for_removal($path): prefix $prefix"); + debug(5, 2, "parent_link_scheduled_for_removal($path): prefix $prefix"); if (exists $self->{link_task_for}{$prefix} and $self->{link_task_for}{$prefix}->{action} eq 'remove') { debug(4, 2, "parent_link_scheduled_for_removal($path): link scheduled for removal"); From 1b597999e219e9f2d83f29aa05d771618685ec82 Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Mon, 1 Apr 2024 19:53:56 +0100 Subject: [PATCH 430/482] read_a_link: improve variable names $path is horribly vague, so rename to $link to be more informative. Also the use of "$target" to describe a link's destination is very confusing in the context of Stow for reasons explained in the manual. So rename to $link_dest. --- lib/Stow.pm.in | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/lib/Stow.pm.in b/lib/Stow.pm.in index 9f9422b..09bf965 100755 --- a/lib/Stow.pm.in +++ b/lib/Stow.pm.in @@ -2029,45 +2029,45 @@ sub is_a_node { return 0; } -=head2 read_a_link($path) +=head2 read_a_link($link) -Return the source of a current or planned link +Return the destination of a current or planned link. =over 4 -=item $path +=item $link -path to the link target +Path to the link target. =back -Returns a string. Throws a fatal exception if the given path is not a -current or planned link. +Returns the destination of the given link. Throws a fatal exception +if the given path is not a current or planned link. =cut sub read_a_link { my $self = shift; - my ($path) = @_; + my ($link) = @_; - if (my $action = $self->link_task_action($path)) { - debug(4, 1, "read_a_link($path): task exists with action $action"); + if (my $action = $self->link_task_action($link)) { + debug(4, 1, "read_a_link($link): task exists with action $action"); if ($action eq 'create') { - return $self->{link_task_for}{$path}->{source}; + return $self->{link_task_for}{$link}->{source}; } elsif ($action eq 'remove') { internal_error( - "read_a_link() passed a path that is scheduled for removal: $path" + "read_a_link() passed a path that is scheduled for removal: $link" ); } } - elsif (-l $path) { - debug(4, 1, "read_a_link($path): real link"); - my $target = readlink $path or error("Could not read link: $path ($!)"); - return $target; + elsif (-l $link) { + debug(4, 1, "read_a_link($link): real link"); + my $link_dest = readlink $link or error("Could not read link: $link ($!)"); + return $link_dest; } - internal_error("read_a_link() passed a non link path: $path\n"); + internal_error("read_a_link() passed a non-link path: $link\n"); } =head2 do_link($link_dest, $link_src) From 09a34e7272380266948b7a7065a488b9426034f9 Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Mon, 1 Apr 2024 18:49:01 +0100 Subject: [PATCH 431/482] foldable: add debug for different cases when not foldable --- lib/Stow.pm.in | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/lib/Stow.pm.in b/lib/Stow.pm.in index 09bf965..f84edaf 100755 --- a/lib/Stow.pm.in +++ b/lib/Stow.pm.in @@ -1229,7 +1229,7 @@ sub foldable { debug(3, 2, "Is $target_subdir foldable?"); if ($self->{'no-folding'}) { - debug(3, 3, "no because --no-folding enabled"); + debug(3, 3, "Not foldable because --no-folding enabled"); return ''; } @@ -1251,7 +1251,10 @@ sub foldable { next NODE if not $self->is_a_node($path); # If it's not a link then we can't fold its parent - return '' if not $self->is_a_link($path); + if (not $self->is_a_link($path)) { + debug(3, 3, "Not foldable because $path not a link"); + return ''; + } # Where is the link pointing? my $source = $self->read_a_link($path); @@ -1262,13 +1265,14 @@ sub foldable { $parent = parent($source) } elsif ($parent ne parent($source)) { + debug(3, 3, "Not foldable because $parent != parent of $source"); return ''; } } return '' if not $parent; - # If we get here then all nodes inside $target_subdir are links, and those links - # point to nodes inside the same directory. + # If we get here then all nodes inside $target_subdir are links, + # and those links point to nodes inside the same directory. # chop of leading '..' to get the path to the common parent directory # relative to the parent of our $target_subdir @@ -1280,6 +1284,7 @@ sub foldable { return $parent; } else { + debug(3, 3, "$target_subdir is not foldable"); return ''; } } From cc521ec14e3c8ea832f9ef28b68216a57105aebd Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Mon, 1 Apr 2024 19:57:54 +0100 Subject: [PATCH 432/482] foldable: rename $path to $target_node_path $path is horribly vague, so rename it to be more informative. --- lib/Stow.pm.in | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/lib/Stow.pm.in b/lib/Stow.pm.in index f84edaf..44edd4f 100755 --- a/lib/Stow.pm.in +++ b/lib/Stow.pm.in @@ -1241,25 +1241,24 @@ sub foldable { my $parent = ''; NODE: for my $node (@listing) { - next NODE if $node eq '.'; next NODE if $node eq '..'; - my $path = join_paths($target_subdir, $node); + my $target_node_path = join_paths($target_subdir, $node); # Skip nodes scheduled for removal - next NODE if not $self->is_a_node($path); + next NODE if not $self->is_a_node($target_node_path); # If it's not a link then we can't fold its parent - if (not $self->is_a_link($path)) { - debug(3, 3, "Not foldable because $path not a link"); + if (not $self->is_a_link($target_node_path)) { + debug(3, 3, "Not foldable because $target_node_path not a link"); return ''; } # Where is the link pointing? - my $source = $self->read_a_link($path); + my $source = $self->read_a_link($target_node_path); if (not $source) { - error("Could not read link $path"); + error("Could not read link $target_node_path"); } if ($parent eq '') { $parent = parent($source) From b5a467fd060ca8fb166cfb1cc875ebae89b95077 Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Mon, 1 Apr 2024 21:33:55 +0100 Subject: [PATCH 433/482] foldable: make more understandable Improve variable names, POD, and add helpful comments. --- lib/Stow.pm.in | 42 ++++++++++++++++++++++++++++-------------- 1 file changed, 28 insertions(+), 14 deletions(-) diff --git a/lib/Stow.pm.in b/lib/Stow.pm.in index 44edd4f..d4af9d3 100755 --- a/lib/Stow.pm.in +++ b/lib/Stow.pm.in @@ -1213,13 +1213,14 @@ Determine whether a tree can be folded =item $target_subdir -path to a directory +Path to the target sub-directory to check for foldability, relative to +the current directory (the top-level target directory). =back Returns path to the parent dir iff the tree can be safely folded. The -path returned is relative to the parent of $target_subdir, i.e. it can be -used as the source for a replacement symlink. +path returned is relative to the parent of C<$target_subdir>, i.e. it +can be used as the source for a replacement symlink. =cut @@ -1238,7 +1239,16 @@ sub foldable { my @listing = readdir $DIR; closedir $DIR; - my $parent = ''; + # We want to see if all the symlinks in $target_subdir point to + # files under the same parent subdirectory in the package + # (e.g. ../../stow/pkg1/common_dir/file1). So remember which + # parent subdirectory we've already seen, and if we come across a + # second one which is different, + # (e.g. ../../stow/pkg2/common_dir/file2), then $target_subdir + # common_dir which contains file{1,2} cannot be folded to be + # a symlink to (say) ../../stow/pkg1/common_dir. + my $parent_in_pkg = ''; + NODE: for my $node (@listing) { next NODE if $node eq '.'; @@ -1256,31 +1266,35 @@ sub foldable { } # Where is the link pointing? - my $source = $self->read_a_link($target_node_path); - if (not $source) { + my $link_dest = $self->read_a_link($target_node_path); + if (not $link_dest) { error("Could not read link $target_node_path"); } - if ($parent eq '') { - $parent = parent($source) + my $new_parent = parent($link_dest); + if ($parent_in_pkg eq '') { + $parent_in_pkg = $new_parent; } - elsif ($parent ne parent($source)) { - debug(3, 3, "Not foldable because $parent != parent of $source"); + elsif ($parent_in_pkg ne $new_parent) { + debug(3, 3, "Not foldable because $target_subdir contains links to entries in both $parent_in_pkg and $new_parent"); return ''; } } - return '' if not $parent; + if (not $parent_in_pkg) { + debug(3, 3, "Not foldable because $target_subdir contains no links"); + return ''; + } # If we get here then all nodes inside $target_subdir are links, # and those links point to nodes inside the same directory. # chop of leading '..' to get the path to the common parent directory # relative to the parent of our $target_subdir - $parent =~ s{\A\.\./}{}; + $parent_in_pkg =~ s{\A\.\./}{}; # If the resulting path is owned by stow, we can fold it - if ($self->link_owned_by_package($target_subdir, $parent)) { + if ($self->link_owned_by_package($target_subdir, $parent_in_pkg)) { debug(3, 3, "$target_subdir is foldable"); - return $parent; + return $parent_in_pkg; } else { debug(3, 3, "$target_subdir is not foldable"); From b137191d27b13f66bcb475741f973b4dcf86a510 Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Mon, 1 Apr 2024 21:21:06 +0100 Subject: [PATCH 434/482] stow_node: rename $second_source => $link_dest The use of the word "source" to describe a link's destination is confusing in the context of Stow for reasons explained in the manual. So rename the $second_source variable to avoid this. --- lib/Stow.pm.in | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/Stow.pm.in b/lib/Stow.pm.in index d4af9d3..da84bfc 100755 --- a/lib/Stow.pm.in +++ b/lib/Stow.pm.in @@ -500,12 +500,12 @@ sub stow_node { # Don't try to stow absolute symlinks (they can't be unstowed) if (-l $source) { - my $second_source = $self->read_a_link($source); - if ($second_source =~ m{\A/}) { + my $link_dest = $self->read_a_link($source); + if ($link_dest =~ m{\A/}) { $self->conflict( 'stow', $package, - "source is an absolute symlink $source => $second_source" + "source is an absolute symlink $source => $link_dest" ); debug(3, 0, "Absolute symlinks cannot be unstowed"); return; From a8c93487c37159b10885e06d2dcd00c8523895c0 Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Mon, 1 Apr 2024 21:24:35 +0100 Subject: [PATCH 435/482] stow_node: remove comments about implementation details from POD These don't add much value, and the reference to $source was out of date anyway. --- lib/Stow.pm.in | 2 -- 1 file changed, 2 deletions(-) diff --git a/lib/Stow.pm.in b/lib/Stow.pm.in index da84bfc..5de078c 100755 --- a/lib/Stow.pm.in +++ b/lib/Stow.pm.in @@ -484,8 +484,6 @@ Relative path to symlink source from the dir of target. =back C and C are mutually recursive. -C<$source> and C<$target_subpath> are used for creating the symlink. -C<$target_subpath> is used for folding/unfolding trees as necessary. =cut From 4525b9447ddef5f5234870df4f90754b368fac02 Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Mon, 1 Apr 2024 21:23:35 +0100 Subject: [PATCH 436/482] unstow_contents: remove reference to "source" The use of the word "source" is confusing in the context of Stow for reasons explained in the manual. --- lib/Stow.pm.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Stow.pm.in b/lib/Stow.pm.in index 5de078c..45fad24 100755 --- a/lib/Stow.pm.in +++ b/lib/Stow.pm.in @@ -701,7 +701,7 @@ Relative path to symlink target from the current directory. =back C and C are mutually recursive. -Here we traverse the source tree, rather than the target tree. +Here we traverse the package tree, rather than the target tree. =cut From 4272e7c4bba7b38f0468cbeb35e72388f5d49715 Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Mon, 1 Apr 2024 21:26:21 +0100 Subject: [PATCH 437/482] unstow_link_node: rename $existing_source => $link_dest The use of the word "source" to describe a link's destination is confusing in the context of Stow for reasons explained in the manual. So rename the $existing_source variable to $link_dest avoid this. --- lib/Stow.pm.in | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/Stow.pm.in b/lib/Stow.pm.in index 45fad24..67fd2b1 100755 --- a/lib/Stow.pm.in +++ b/lib/Stow.pm.in @@ -828,19 +828,19 @@ sub unstow_link_node { debug(4, 2, "Evaluate existing link: $target_subpath"); # Where is the link pointing? - my $existing_source = $self->read_a_link($target_subpath); - if (not $existing_source) { + my $link_dest = $self->read_a_link($target_subpath); + if (not $link_dest) { error("Could not read link: $target_subpath"); } - if ($existing_source =~ m{\A/}) { - warn "Ignoring an absolute symlink: $target_subpath => $existing_source\n"; + if ($link_dest =~ m{\A/}) { + warn "Ignoring an absolute symlink: $target_subpath => $link_dest\n"; return; # XXX # } # Does it point to a node under any stow directory? my ($existing_path, $existing_stow_path, $existing_package) = - $self->find_stowed_path($target_subpath, $existing_source); + $self->find_stowed_path($target_subpath, $link_dest); if (not $existing_path) { if ($self->{compat}) { # We're traversing the target tree not the package tree, @@ -852,7 +852,7 @@ sub unstow_link_node { $self->conflict( 'unstow', $package, - "existing target is not owned by stow: $target_subpath => $existing_source" + "existing target is not owned by stow: $target_subpath => $link_dest" ); } return; From 08e1c902ec0c5eec66aea11d792b6f2624b2c61f Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Mon, 1 Apr 2024 21:55:51 +0100 Subject: [PATCH 438/482] unstow_link_node: rename $existing_path Unqualified references to "path" are horribly vague, so rename to $existing_pkg_path_from_cwd for clarity. --- lib/Stow.pm.in | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/Stow.pm.in b/lib/Stow.pm.in index 67fd2b1..b7d590c 100755 --- a/lib/Stow.pm.in +++ b/lib/Stow.pm.in @@ -839,9 +839,9 @@ sub unstow_link_node { } # Does it point to a node under any stow directory? - my ($existing_path, $existing_stow_path, $existing_package) = + my ($existing_pkg_path_from_cwd, $existing_stow_path, $existing_package) = $self->find_stowed_path($target_subpath, $link_dest); - if (not $existing_path) { + if (not $existing_pkg_path_from_cwd) { if ($self->{compat}) { # We're traversing the target tree not the package tree, # so we definitely expect to find stuff not owned by stow. @@ -859,8 +859,8 @@ sub unstow_link_node { } # Does the existing $target_subpath actually point to anything? - if (-e $existing_path) { - $self->unstow_valid_link($pkg_path_from_cwd, $target_subpath, $existing_path); + if (-e $existing_pkg_path_from_cwd) { + $self->unstow_valid_link($pkg_path_from_cwd, $target_subpath, $existing_pkg_path_from_cwd); } else { debug(2, 0, "--- removing invalid link into a stow directory: $pkg_path_from_cwd"); From a337a2fcd0dd6f1da53cd4b3f49569a69cc91467 Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Mon, 1 Apr 2024 21:32:30 +0100 Subject: [PATCH 439/482] Change debug indentation in some helpers These helpers can be called at more deeply nested levels, so they should be indented more than they were. --- lib/Stow.pm.in | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/lib/Stow.pm.in b/lib/Stow.pm.in index b7d590c..29b1e99 100755 --- a/lib/Stow.pm.in +++ b/lib/Stow.pm.in @@ -1806,7 +1806,7 @@ sub link_task_action { my ($path) = @_; if (! exists $self->{link_task_for}{$path}) { - debug(4, 1, "link_task_action($path): no task"); + debug(4, 4, "| link_task_action($path): no task"); return ''; } @@ -1838,7 +1838,7 @@ sub dir_task_action { my ($path) = @_; if (! exists $self->{dir_task_for}{$path}) { - debug(4, 1, "dir_task_action($path): no task"); + debug(4, 4, "| dir_task_action($path): no task"); return ''; } @@ -1846,7 +1846,7 @@ sub dir_task_action { internal_error("bad task action: $action") unless $action eq 'remove' or $action eq 'create'; - debug(4, 1, "dir_task_action($path): dir task exists with action $action"); + debug(4, 4, "| dir_task_action($path): dir task exists with action $action"); return $action; } @@ -1872,15 +1872,15 @@ sub parent_link_scheduled_for_removal { my $prefix = ''; for my $part (split m{/+}, $path) { $prefix = join_paths($prefix, $part); - debug(5, 2, "parent_link_scheduled_for_removal($path): prefix $prefix"); + debug(5, 4, "| parent_link_scheduled_for_removal($path): prefix $prefix"); if (exists $self->{link_task_for}{$prefix} and $self->{link_task_for}{$prefix}->{action} eq 'remove') { - debug(4, 2, "parent_link_scheduled_for_removal($path): link scheduled for removal"); + debug(4, 4, "| parent_link_scheduled_for_removal($path): link scheduled for removal"); return 1; } } - debug(4, 2, "parent_link_scheduled_for_removal($path): returning false"); + debug(4, 4, "| parent_link_scheduled_for_removal($path): returning false"); return 0; } @@ -1902,15 +1902,15 @@ a non-existent link is scheduled for creation. sub is_a_link { my $self = shift; my ($path) = @_; - debug(4, 1, "is_a_link($path)"); + debug(4, 2, "is_a_link($path)"); if (my $action = $self->link_task_action($path)) { if ($action eq 'remove') { - debug(4, 1, "is_a_link($path): returning 0 (remove action found)"); + debug(4, 2, "is_a_link($path): returning 0 (remove action found)"); return 0; } elsif ($action eq 'create') { - debug(4, 1, "is_a_link($path): returning 1 (create action found)"); + debug(4, 2, "is_a_link($path): returning 1 (create action found)"); return 1; } } @@ -1918,11 +1918,11 @@ sub is_a_link { if (-l $path) { # Check if any of its parent are links scheduled for removal # (need this for edge case during unfolding) - debug(4, 1, "is_a_link($path): is a real link"); + debug(4, 2, "is_a_link($path): is a real link"); return $self->parent_link_scheduled_for_removal($path) ? 0 : 1; } - debug(4, 1, "is_a_link($path): returning 0"); + debug(4, 2, "is_a_link($path): returning 0"); return 0; } @@ -1986,7 +1986,7 @@ sure we are not just following a link. sub is_a_node { my $self = shift; my ($path) = @_; - debug(4, 1, "Checking whether $path is a current/planned node"); + debug(4, 4, "| Checking whether $path is a current/planned node"); my $laction = $self->link_task_action($path); my $daction = $self->dir_task_action($path); @@ -2037,11 +2037,11 @@ sub is_a_node { return 0 if $self->parent_link_scheduled_for_removal($path); if (-e $path) { - debug(4, 1, "is_a_node($path): really exists"); + debug(4, 3, "| is_a_node($path): really exists"); return 1; } - debug(4, 1, "is_a_node($path): returning false"); + debug(4, 3, "| is_a_node($path): returning false"); return 0; } @@ -2067,7 +2067,7 @@ sub read_a_link { my ($link) = @_; if (my $action = $self->link_task_action($link)) { - debug(4, 1, "read_a_link($link): task exists with action $action"); + debug(4, 2, "read_a_link($link): task exists with action $action"); if ($action eq 'create') { return $self->{link_task_for}{$link}->{source}; @@ -2079,7 +2079,7 @@ sub read_a_link { } } elsif (-l $link) { - debug(4, 1, "read_a_link($link): real link"); + debug(4, 2, "read_a_link($link): real link"); my $link_dest = readlink $link or error("Could not read link: $link ($!)"); return $link_dest; } From 221449d6408e2d0286f1dbed5604e27e2b83d2f4 Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Mon, 1 Apr 2024 21:36:58 +0100 Subject: [PATCH 440/482] unstow_node: remove redundant return --- lib/Stow.pm.in | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/Stow.pm.in b/lib/Stow.pm.in index 29b1e99..4b89b80 100755 --- a/lib/Stow.pm.in +++ b/lib/Stow.pm.in @@ -819,7 +819,6 @@ sub unstow_node { else { debug(2, 1, "$target_subpath did not exist to be unstowed"); } - return; } sub unstow_link_node { From 381fd71155120df515eef1df1ca8bccb90b12eda Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Mon, 1 Apr 2024 21:48:33 +0100 Subject: [PATCH 441/482] remove or rename XXX Remove old XXX FIXMEs which tell us nothing useful and may not be relevant any more. Also rename another XXX to an industry-standard FIXME. --- lib/Stow.pm.in | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/Stow.pm.in b/lib/Stow.pm.in index 4b89b80..d1ea59a 100755 --- a/lib/Stow.pm.in +++ b/lib/Stow.pm.in @@ -528,7 +528,7 @@ sub stow_node { $package, "existing target is not owned by stow: $target_subpath" ); - return; # XXX # + return; } # Does the existing $target_subpath actually point to anything? @@ -834,7 +834,7 @@ sub unstow_link_node { if ($link_dest =~ m{\A/}) { warn "Ignoring an absolute symlink: $target_subpath => $link_dest\n"; - return; # XXX # + return; } # Does it point to a node under any stow directory? @@ -881,7 +881,7 @@ sub unstow_valid_link { $self->do_unlink($target_subpath); } - # XXX we quietly ignore links that are stowed to a different + # FIXME: we quietly ignore links that are stowed to a different # package. #elsif (defer($target_subpath)) { From 3c904dade255db568439ff894e8da0b7a95345b2 Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Mon, 1 Apr 2024 21:51:24 +0100 Subject: [PATCH 442/482] link_owned_by_package: rename $source => $link_dest The use of the word "source" to describe a link's destination is confusing in the context of Stow for reasons explained in the manual. So rename the $source variable to avoid this. --- lib/Stow.pm.in | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/Stow.pm.in b/lib/Stow.pm.in index d1ea59a..af39212 100755 --- a/lib/Stow.pm.in +++ b/lib/Stow.pm.in @@ -922,7 +922,7 @@ sub unstow_existing_node { } } -=head2 link_owned_by_package($target_subpath, $source) +=head2 link_owned_by_package($target_subpath, $link_dest) Determine whether the given link points to a member of a stowed package. @@ -933,7 +933,7 @@ package. Path to a symbolic link under current directory. -=item $source +=item $link_dest Where that link points to. @@ -947,10 +947,10 @@ Returns the package iff link is owned by stow, otherwise ''. sub link_owned_by_package { my $self = shift; - my ($target_subpath, $source) = @_; + my ($target_subpath, $link_dest) = @_; my ($pkg_path_from_cwd, $stow_path, $package) = - $self->find_stowed_path($target_subpath, $source); + $self->find_stowed_path($target_subpath, $link_dest); return $package; } From c45a0632a96d873ed77d5d0bbedd961011b67f41 Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Mon, 1 Apr 2024 21:57:36 +0100 Subject: [PATCH 443/482] stow_node: rename $existing_path Unqualified references to "path" are horribly vague, so rename to $existing_pkg_path_from_cwd for clarity. --- lib/Stow.pm.in | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/Stow.pm.in b/lib/Stow.pm.in index af39212..678362d 100755 --- a/lib/Stow.pm.in +++ b/lib/Stow.pm.in @@ -520,9 +520,9 @@ sub stow_node { debug(4, 1, "Evaluate existing link: $target_subpath => $existing_link_dest"); # Does it point to a node under any stow directory? - my ($existing_path, $existing_stow_path, $existing_package) = + my ($existing_pkg_path_from_cwd, $existing_stow_path, $existing_package) = $self->find_stowed_path($target_subpath, $existing_link_dest); - if (not $existing_path) { + if (not $existing_pkg_path_from_cwd) { $self->conflict( 'stow', $package, @@ -532,7 +532,7 @@ sub stow_node { } # Does the existing $target_subpath actually point to anything? - if ($self->is_a_node($existing_path)) { + if ($self->is_a_node($existing_pkg_path_from_cwd)) { if ($existing_link_dest eq $source) { debug(2, 0, "--- Skipping $target_subpath as it already points to $source"); } From b3ed86d616ab89b21c6316fd2cb26638dcc38381 Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Mon, 1 Apr 2024 21:54:15 +0100 Subject: [PATCH 444/482] unstow_valid_link: rename $existing_path Unqualified references to "path" are horribly vague, so rename to $existing_pkg_path_from_cwd for clarity. --- lib/Stow.pm.in | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/Stow.pm.in b/lib/Stow.pm.in index 678362d..d1fe69d 100755 --- a/lib/Stow.pm.in +++ b/lib/Stow.pm.in @@ -869,15 +869,15 @@ sub unstow_link_node { sub unstow_valid_link { my $self = shift; - my ($pkg_path_from_cwd, $target_subpath, $existing_path) = @_; + my ($pkg_path_from_cwd, $target_subpath, $existing_pkg_path_from_cwd) = @_; # Does link points to the right place? # Adjust for dotfile if necessary. if ($self->{dotfiles}) { - $existing_path = adjust_dotfile($existing_path); + $existing_pkg_path_from_cwd = adjust_dotfile($existing_pkg_path_from_cwd); } - if ($existing_path eq $pkg_path_from_cwd) { + if ($existing_pkg_path_from_cwd eq $pkg_path_from_cwd) { $self->do_unlink($target_subpath); } From bae7890aa54581369f311dc93e5e8c88c5efe175 Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Mon, 1 Apr 2024 22:29:03 +0100 Subject: [PATCH 445/482] unstow_node / unstow_existing_node: rename foldable return value $parent is a bit vague so rename to $parent_in_pkg. --- lib/Stow.pm.in | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/Stow.pm.in b/lib/Stow.pm.in index d1fe69d..6689ce0 100755 --- a/lib/Stow.pm.in +++ b/lib/Stow.pm.in @@ -800,8 +800,8 @@ sub unstow_node { $self->unstow_contents($package, $target_subpath, $pkg_path_from_cwd); # This action may have made the parent directory foldable - if (my $parent = $self->foldable($target_subpath)) { - $self->fold_tree($target_subpath, $parent); + if (my $parent_in_pkg = $self->foldable($target_subpath)) { + $self->fold_tree($target_subpath, $parent_in_pkg); } } elsif (-e $target_subpath) { @@ -909,8 +909,8 @@ sub unstow_existing_node { $self->unstow_contents($package, $target_subpath, $source); # This action may have made the parent directory foldable - if (my $parent = $self->foldable($target_subpath)) { - $self->fold_tree($target_subpath, $parent); + if (my $parent_in_pkg = $self->foldable($target_subpath)) { + $self->fold_tree($target_subpath, $parent_in_pkg); } } else { From 8f6a320b50f9c59e63b457c873fd18dba35a87cd Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Mon, 1 Apr 2024 22:30:55 +0100 Subject: [PATCH 446/482] fold_tree: rename $source parameter to $pkg_subpath $source is vague and confusing as per the manual. --- lib/Stow.pm.in | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/Stow.pm.in b/lib/Stow.pm.in index 6689ce0..632207e 100755 --- a/lib/Stow.pm.in +++ b/lib/Stow.pm.in @@ -1299,7 +1299,7 @@ sub foldable { } } -=head2 fold_tree($target, source) +=head2 fold_tree($target, $pkg_subpath) Fold the given tree @@ -1307,9 +1307,9 @@ Fold the given tree =item $target -directory that we will replace with a link to $source +Directory that we will replace with a link to $pkg_subpath. -=item $source +=item $pkg_subpath link to the folded tree source @@ -1321,9 +1321,9 @@ Only called iff foldable() is true so we can remove some checks. sub fold_tree { my $self = shift; - my ($target, $source) = @_; + my ($target, $pkg_subpath) = @_; - debug(3, 0, "--- Folding tree: $target => $source"); + debug(3, 0, "--- Folding tree: $target => $pkg_subpath"); opendir my $DIR, $target or error(qq{Cannot read directory "$target" ($!)\n}); @@ -1338,7 +1338,7 @@ sub fold_tree { $self->do_unlink(join_paths($target, $node)); } $self->do_rmdir($target); - $self->do_link($source, $target); + $self->do_link($pkg_subpath, $target); return; } From 2c9065995c2efb6fa0265a04e501ce7d824877cb Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Mon, 1 Apr 2024 22:32:24 +0100 Subject: [PATCH 447/482] fold_tree: rename $target parameter to $target_subdir $target is vague and could refer to the top-level target directory, so rename to clarify. --- lib/Stow.pm.in | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/lib/Stow.pm.in b/lib/Stow.pm.in index 632207e..0074fde 100755 --- a/lib/Stow.pm.in +++ b/lib/Stow.pm.in @@ -1299,13 +1299,13 @@ sub foldable { } } -=head2 fold_tree($target, $pkg_subpath) +=head2 fold_tree($target_subdir, $pkg_subpath) Fold the given tree =over 4 -=item $target +=item $target_subdir Directory that we will replace with a link to $pkg_subpath. @@ -1321,12 +1321,12 @@ Only called iff foldable() is true so we can remove some checks. sub fold_tree { my $self = shift; - my ($target, $pkg_subpath) = @_; + my ($target_subdir, $pkg_subpath) = @_; - debug(3, 0, "--- Folding tree: $target => $pkg_subpath"); + debug(3, 0, "--- Folding tree: $target_subdir => $pkg_subpath"); - opendir my $DIR, $target - or error(qq{Cannot read directory "$target" ($!)\n}); + opendir my $DIR, $target_subdir + or error(qq{Cannot read directory "$target_subdir" ($!)\n}); my @listing = readdir $DIR; closedir $DIR; @@ -1334,11 +1334,11 @@ sub fold_tree { for my $node (@listing) { next NODE if $node eq '.'; next NODE if $node eq '..'; - next NODE if not $self->is_a_node(join_paths($target, $node)); - $self->do_unlink(join_paths($target, $node)); + next NODE if not $self->is_a_node(join_paths($target_subdir, $node)); + $self->do_unlink(join_paths($target_subdir, $node)); } - $self->do_rmdir($target); - $self->do_link($pkg_subpath, $target); + $self->do_rmdir($target_subdir); + $self->do_link($pkg_subpath, $target_subdir); return; } From 4cac249ddc93450b849b7957a90300852715ca22 Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Mon, 1 Apr 2024 23:37:06 +0100 Subject: [PATCH 448/482] rename $path => $target_path in node helpers is_a_node(), is_a_dir(), is_a_link() all operate on paths within the target directory, so make this explicit by avoiding the vague variable name "$path". --- lib/Stow.pm.in | 82 +++++++++++++++++++++++++------------------------- 1 file changed, 41 insertions(+), 41 deletions(-) diff --git a/lib/Stow.pm.in b/lib/Stow.pm.in index 0074fde..6c7027b 100755 --- a/lib/Stow.pm.in +++ b/lib/Stow.pm.in @@ -1849,14 +1849,14 @@ sub dir_task_action { return $action; } -=head2 parent_link_scheduled_for_removal($path) +=head2 parent_link_scheduled_for_removal($target_path) Determine whether the given path or any parent thereof is a link scheduled for removal =over 4 -=item $path +=item $target_path =back @@ -1866,30 +1866,30 @@ Returns boolean sub parent_link_scheduled_for_removal { my $self = shift; - my ($path) = @_; + my ($target_path) = @_; my $prefix = ''; - for my $part (split m{/+}, $path) { + for my $part (split m{/+}, $target_path) { $prefix = join_paths($prefix, $part); - debug(5, 4, "| parent_link_scheduled_for_removal($path): prefix $prefix"); + debug(5, 4, "| parent_link_scheduled_for_removal($target_path): prefix $prefix"); if (exists $self->{link_task_for}{$prefix} and $self->{link_task_for}{$prefix}->{action} eq 'remove') { - debug(4, 4, "| parent_link_scheduled_for_removal($path): link scheduled for removal"); + debug(4, 4, "| parent_link_scheduled_for_removal($target_path): link scheduled for removal"); return 1; } } - debug(4, 4, "| parent_link_scheduled_for_removal($path): returning false"); + debug(4, 4, "| parent_link_scheduled_for_removal($target_path): returning false"); return 0; } -=head2 is_a_link($path) +=head2 is_a_link($target_path) Determine if the given path is a current or planned link. =over 4 -=item $path +=item $target_path =back @@ -1900,38 +1900,38 @@ a non-existent link is scheduled for creation. sub is_a_link { my $self = shift; - my ($path) = @_; - debug(4, 2, "is_a_link($path)"); + my ($target_path) = @_; + debug(4, 2, "is_a_link($target_path)"); - if (my $action = $self->link_task_action($path)) { + if (my $action = $self->link_task_action($target_path)) { if ($action eq 'remove') { - debug(4, 2, "is_a_link($path): returning 0 (remove action found)"); + debug(4, 2, "is_a_link($target_path): returning 0 (remove action found)"); return 0; } elsif ($action eq 'create') { - debug(4, 2, "is_a_link($path): returning 1 (create action found)"); + debug(4, 2, "is_a_link($target_path): returning 1 (create action found)"); return 1; } } - if (-l $path) { + if (-l $target_path) { # Check if any of its parent are links scheduled for removal # (need this for edge case during unfolding) - debug(4, 2, "is_a_link($path): is a real link"); - return $self->parent_link_scheduled_for_removal($path) ? 0 : 1; + debug(4, 2, "is_a_link($target_path): is a real link"); + return $self->parent_link_scheduled_for_removal($target_path) ? 0 : 1; } - debug(4, 2, "is_a_link($path): returning 0"); + debug(4, 2, "is_a_link($target_path): returning 0"); return 0; } -=head2 is_a_dir($path) +=head2 is_a_dir($target_path) Determine if the given path is a current or planned directory =over 4 -=item $path +=item $target_path =back @@ -1943,10 +1943,10 @@ need to be sure we are not just following a link. sub is_a_dir { my $self = shift; - my ($path) = @_; - debug(4, 1, "is_a_dir($path)"); + my ($target_path) = @_; + debug(4, 1, "is_a_dir($target_path)"); - if (my $action = $self->dir_task_action($path)) { + if (my $action = $self->dir_task_action($target_path)) { if ($action eq 'remove') { return 0; } @@ -1955,24 +1955,24 @@ sub is_a_dir { } } - return 0 if $self->parent_link_scheduled_for_removal($path); + return 0 if $self->parent_link_scheduled_for_removal($target_path); - if (-d $path) { - debug(4, 1, "is_a_dir($path): real dir"); + if (-d $target_path) { + debug(4, 1, "is_a_dir($target_path): real dir"); return 1; } - debug(4, 1, "is_a_dir($path): returning false"); + debug(4, 1, "is_a_dir($target_path): returning false"); return 0; } -=head2 is_a_node($path) +=head2 is_a_node($target_path) Determine whether the given path is a current or planned node. =over 4 -=item $path +=item $target_path =back @@ -1984,19 +1984,19 @@ sure we are not just following a link. sub is_a_node { my $self = shift; - my ($path) = @_; - debug(4, 4, "| Checking whether $path is a current/planned node"); + my ($target_path) = @_; + debug(4, 4, "| Checking whether $target_path is a current/planned node"); - my $laction = $self->link_task_action($path); - my $daction = $self->dir_task_action($path); + my $laction = $self->link_task_action($target_path); + my $daction = $self->dir_task_action($target_path); if ($laction eq 'remove') { if ($daction eq 'remove') { - internal_error("removing link and dir: $path"); + internal_error("removing link and dir: $target_path"); return 0; } elsif ($daction eq 'create') { - # Assume that we're unfolding $path, and that the link + # Assume that we're unfolding $target_path, and that the link # removal action is earlier than the dir creation action # in the task queue. FIXME: is this a safe assumption? return 1; @@ -2007,13 +2007,13 @@ sub is_a_node { } elsif ($laction eq 'create') { if ($daction eq 'remove') { - # Assume that we're folding $path, and that the dir + # Assume that we're folding $target_path, and that the dir # removal action is earlier than the link creation action # in the task queue. FIXME: is this a safe assumption? return 1; } elsif ($daction eq 'create') { - internal_error("creating link and dir: $path"); + internal_error("creating link and dir: $target_path"); return 1; } else { # no dir action @@ -2033,14 +2033,14 @@ sub is_a_node { } } - return 0 if $self->parent_link_scheduled_for_removal($path); + return 0 if $self->parent_link_scheduled_for_removal($target_path); - if (-e $path) { - debug(4, 3, "| is_a_node($path): really exists"); + if (-e $target_path) { + debug(4, 3, "| is_a_node($target_path): really exists"); return 1; } - debug(4, 3, "| is_a_node($path): returning false"); + debug(4, 3, "| is_a_node($target_path): returning false"); return 0; } From 1282acf6b53a8cea447a254107659db4ae3b45a2 Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Mon, 1 Apr 2024 22:56:32 +0100 Subject: [PATCH 449/482] t/stow: use like() instead of ok(... =~ /.../) --- t/stow.t | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/t/stow.t b/t/stow.t index 9e97b48..b7260f5 100755 --- a/t/stow.t +++ b/t/stow.t @@ -101,7 +101,8 @@ subtest("Link to a new dir 'bin4' conflicts with existing non-dir so can't unfol $stow->plan_stow('pkg4'); %conflicts = $stow->get_conflicts(); is($stow->get_conflict_count, 1); - ok($conflicts{stow}{pkg4}[0] =~ + like( + $conflicts{stow}{pkg4}[0], qr/existing target is neither a link nor a directory/ => 'link to new dir bin4 conflicts with existing non-directory' ); From 67081cec02382f7e00d3bbaf6cfb7473f3b0cf0f Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Mon, 1 Apr 2024 23:31:36 +0100 Subject: [PATCH 450/482] testutil: use croak() instead of die() for more useful errors --- t/testutil.pm | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/t/testutil.pm b/t/testutil.pm index f7f4e1d..9c376b5 100755 --- a/t/testutil.pm +++ b/t/testutil.pm @@ -66,7 +66,7 @@ sub uncapture_stderr { } sub init_test_dirs { - -d "t" or die "Was expecting tests to be run from root of repo\n"; + -d "t" or croak "Was expecting tests to be run from root of repo\n"; # Create a run_from/ subdirectory for tests which want to run # from a separate directory outside the Stow directory or @@ -112,12 +112,12 @@ sub make_link { if (-l $target) { my $old_source = readlink join('/', parent($target), $source) - or die "$target is already a link but could not read link $target/$source"; + or croak "$target is already a link but could not read link $target/$source"; if ($old_source ne $source) { - die "$target already exists but points elsewhere\n"; + croak "$target already exists but points elsewhere\n"; } } - die "$target already exists and is not a link\n" if -e $target; + croak "$target already exists and is not a link\n" if -e $target; my $abs_target = File::Spec->rel2abs($target); my $target_container = dirname($abs_target); my $abs_source = File::Spec->rel2abs($source, $target_container); @@ -131,7 +131,7 @@ sub make_link { unless $invalid; } symlink $source, $target - or die "could not create link $target => $source ($!)\n"; + or croak "could not create link $target => $source ($!)\n"; } #===== SUBROUTINE =========================================================== @@ -161,11 +161,11 @@ sub make_file { my ($path, $contents) = @_; if (-e $path and ! -f $path) { - die "a non-file already exists at $path\n"; + croak "a non-file already exists at $path\n"; } open my $FILE ,'>', $path - or die "could not create file: $path ($!)\n"; + or croak "could not create file: $path ($!)\n"; print $FILE $contents if defined $contents; close $FILE; } @@ -182,9 +182,9 @@ sub make_file { sub remove_link { my ($path) = @_; if (not -l $path) { - die qq(remove_link() called with a non-link: $path); + croak qq(remove_link() called with a non-link: $path); } - unlink $path or die "could not remove link: $path ($!)\n"; + unlink $path or croak "could not remove link: $path ($!)\n"; return; } @@ -199,9 +199,9 @@ sub remove_link { sub remove_file { my ($path) = @_; if (-z $path) { - die "file at $path is non-empty\n"; + croak "file at $path is non-empty\n"; } - unlink $path or die "could not remove empty file: $path ($!)\n"; + unlink $path or croak "could not remove empty file: $path ($!)\n"; return; } @@ -217,10 +217,10 @@ sub remove_dir { my ($dir) = @_; if (not -d $dir) { - die "$dir is not a directory"; + croak "$dir is not a directory"; } - opendir my $DIR, $dir or die "cannot read directory: $dir ($!)\n"; + opendir my $DIR, $dir or croak "cannot read directory: $dir ($!)\n"; my @listing = readdir $DIR; closedir $DIR; @@ -231,16 +231,16 @@ sub remove_dir { my $path = "$dir/$node"; if (-l $path or (-f $path and -z $path) or $node eq $Stow::LOCAL_IGNORE_FILE) { - unlink $path or die "cannot unlink $path ($!)\n"; + unlink $path or croak "cannot unlink $path ($!)\n"; } elsif (-d "$path") { remove_dir($path); } else { - die "$path is not a link, directory, or empty file\n"; + croak "$path is not a link, directory, or empty file\n"; } } - rmdir $dir or die "cannot rmdir $dir ($!)\n"; + rmdir $dir or croak "cannot rmdir $dir ($!)\n"; return; } @@ -255,7 +255,7 @@ sub remove_dir { #============================================================================ sub cd { my ($dir) = @_; - chdir $dir or die "Failed to chdir($dir): $!\n"; + chdir $dir or croak "Failed to chdir($dir): $!\n"; } #===== SUBROUTINE =========================================================== @@ -268,7 +268,7 @@ sub cd { #============================================================================ sub cat_file { my ($file) = @_; - open F, $file or die "Failed to open($file): $!\n"; + open F, $file or croak "Failed to open($file): $!\n"; my $contents = join '', ; close(F); return $contents; From 4cde7eb19fb134cab34e9ec8fce718eb5aeeea14 Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Mon, 1 Apr 2024 23:25:46 +0100 Subject: [PATCH 451/482] t/stow.t: fix typos, whitespace, and ordering of lines --- t/stow.t | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/t/stow.t b/t/stow.t index b7260f5..a6b16bf 100755 --- a/t/stow.t +++ b/t/stow.t @@ -90,7 +90,7 @@ subtest('unfold existing tree', sub { => 'target already has 1 stowed package'); }); -subtest("Link to a new dir 'bin4' conflicts with existing non-dir so can't unfold", sub { +subtest("Package dir 'bin4' conflicts with existing non-dir so can't unfold", sub { plan tests => 2; my $stow = new_Stow(); @@ -108,7 +108,7 @@ subtest("Link to a new dir 'bin4' conflicts with existing non-dir so can't unfol ); }); -subtest("Link to a new dir 'bin4a' conflicts with existing non-dir " . +subtest("Package dir 'bin4a' conflicts with existing non-dir " . "so can't unfold even with --adopt", sub { plan tests => 2; #my $stow = new_Stow(adopt => 1); @@ -127,18 +127,19 @@ subtest("Link to a new dir 'bin4a' conflicts with existing non-dir " . ); }); -subtest("Link to files 'file4b' and 'bin4b' conflict with existing files", sub { +subtest("Package files 'file4b' and 'bin4b' conflict with existing files", sub { plan tests => 3; my $stow = new_Stow(); # Populate target make_file('file4b', 'file4b - version originally in target'); - make_path ('bin4b'); + make_path('bin4b'); make_file('bin4b/file4b', 'bin4b/file4b - version originally in target'); - # Populate - make_path ('../stow/pkg4b/bin4b'); + # Populate stow package + make_path('../stow/pkg4b'); make_file('../stow/pkg4b/file4b', 'file4b - version originally in stow package'); + make_path('../stow/pkg4b/bin4b'); make_file('../stow/pkg4b/bin4b/file4b', 'bin4b/file4b - version originally in stow package'); $stow->plan_stow('pkg4b'); @@ -153,7 +154,7 @@ subtest("Link to files 'file4b' and 'bin4b' conflict with existing files", sub { } }); -subtest("Link to files 'file4b' and 'bin4b' do not conflict with existing", sub { +subtest("Package files 'file4c' and 'bin4c' can adopt existing versions", sub { plan tests => 8; my $stow = new_Stow(adopt => 1); @@ -162,9 +163,10 @@ subtest("Link to files 'file4b' and 'bin4b' do not conflict with existing", sub make_path ('bin4c'); make_file('bin4c/file4c', "bin4c/file4c - version originally in target\n"); - # Populate - make_path ('../stow/pkg4c/bin4c'); + # Populate stow package + make_path('../stow/pkg4c'); make_file('../stow/pkg4c/file4c', "file4c - version originally in stow package\n"); + make_path ('../stow/pkg4c/bin4c'); make_file('../stow/pkg4c/bin4c/file4c', "bin4c/file4c - version originally in stow package\n"); $stow->plan_stow('pkg4c'); From 58c1946ed92445d6b721d935d4067cf544bc3547 Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Fri, 5 Apr 2024 00:51:27 +0100 Subject: [PATCH 452/482] Port Travis CI workflow to a GitHub CI workflow Travis is no longer free, so move to GitHub. (In the future ideally we should reduce dependencies on proprietary platforms.) --- .coveralls.yml | 1 + .github/workflows/test.yml | 80 ++++++++++++++++++++++++++++++++++++++ MANIFEST.SKIP | 2 + 3 files changed, 83 insertions(+) create mode 100644 .coveralls.yml create mode 100644 .github/workflows/test.yml diff --git a/.coveralls.yml b/.coveralls.yml new file mode 100644 index 0000000..3ac81fe --- /dev/null +++ b/.coveralls.yml @@ -0,0 +1 @@ +repo_token: xl1m2EiKjG4YlJQ0KjTTBNDRcAFD0lCVt diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..b2433de --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,80 @@ +# This file is part of GNU Stow. +# +# GNU Stow is free software: you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# GNU Stow is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see https://www.gnu.org/licenses/. + +name: Test suite + +on: + push: + branches: [master] + + pull_request: + branches: [master] + types: [opened, synchronize, reopened, ready_for_review] + +jobs: + # call-simple-perl-test: + # uses: perl-actions/github-workflows/.github/workflows/simple-perltester-workflow.yml@main + # with: + # since-perl: 5.14 + + test: + name: Perl ${{ matrix.perl-version }} + runs-on: ubuntu-latest + + strategy: + matrix: + perl-version: + - '5.38' + - '5.36' + - '5.34' + - '5.32' + - '5.30' + + container: + # This Docker image should avoid the need to run: + # + # cpanm -n Devel::Cover::Report::Coveralls + image: perldocker/perl-tester:${{ matrix.perl-version }} + + steps: + - run: apt-get update && apt-get install -y sudo texinfo texlive + + - name: Checkout code + uses: actions/checkout@v2 + +# - uses: awalsh128/cache-apt-pkgs-action@latest +# with: +# debug: true +# packages: texinfo texlive +# version: 1.0 + + - run: autoreconf --install + - name: ./configure && make + run: | + eval `perl -V:siteprefix` + # Note: this will complain Test::Output isn't yet installed: + ./configure --prefix=$siteprefix && make + + # but that's OK because we install it here: + make cpanm + + #- name: Run tests + # run: make test + + - run: make distcheck + - run: perl Build.PL + - run: ./Build build + - run: cover -test -report coveralls + - run: ./Build distcheck diff --git a/MANIFEST.SKIP b/MANIFEST.SKIP index 259024a..15a01d6 100644 --- a/MANIFEST.SKIP +++ b/MANIFEST.SKIP @@ -84,6 +84,8 @@ # Avoid test files tmp-testing-trees +.coveralls.yml +.github/workflows/ .travis.yml ^docker/ ^[a-zA-Z]*-docker.sh From 238346f13461eb2631bd03c57332bd6ac914c94b Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Fri, 5 Apr 2024 22:24:00 +0100 Subject: [PATCH 453/482] manual: clarify the pros and cons and history of --compat --- doc/stow.texi | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/doc/stow.texi b/doc/stow.texi index 80cc2d2..a875308 100644 --- a/doc/stow.texi +++ b/doc/stow.texi @@ -489,13 +489,15 @@ doing. Verbosity levels are from 0 to 5; 0 is the default. Using @item -p @itemx --compat -Scan the whole target tree when unstowing. By default, only -directories specified in the @dfn{installation image} are scanned -during an unstow operation. Scanning the whole tree can be -prohibitive if your target tree is very large. This option restores -the legacy behaviour; however, the @option{--badlinks} option to the -@command{chkstow} utility may be a better way of ensuring that your -installation does not have any dangling symlinks (@pxref{Target +Scan the whole target tree when unstowing. By default, only directories +specified in the @dfn{installation image} are scanned during an unstow +operation. Previously Stow scanned the whole tree, which can be +prohibitive if your target tree is very large, but on the other hand has +the advantage of unstowing previously stowed links which are no longer +present in the installation image and therefore orphaned. This option +restores the legacy behaviour; however, the @option{--badlinks} option +to the @command{chkstow} utility may be a better way of ensuring that +your installation does not have any dangling symlinks (@pxref{Target Maintenance}). @item -V From ebfbb6cc13c067ac8fb97d7700b4febf5b9a16e8 Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Thu, 4 Apr 2024 00:36:37 +0100 Subject: [PATCH 454/482] testutil: rename parameter names to be less confusing $target was the source of the link, and $source was the target (destination) of the link. Obviously this was hopelessly confusing, so rename to avoid this. --- t/testutil.pm | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/t/testutil.pm b/t/testutil.pm index 9c376b5..6cf179e 100755 --- a/t/testutil.pm +++ b/t/testutil.pm @@ -100,28 +100,28 @@ sub new_compat_Stow { #===== SUBROUTINE =========================================================== # Name : make_link() # Purpose : safely create a link -# Parameters: $target => path to the link -# : $source => where the new link should point -# : $invalid => true iff $source refers to non-existent file +# Parameters: $link_src => path to the link +# : $link_dest => where the new link should point +# : $invalid => true iff $link_dest refers to non-existent file # Returns : n/a # Throws : fatal error if the link can not be safely created # Comments : checks for existing nodes #============================================================================ sub make_link { - my ($target, $source, $invalid) = @_; + my ($link_src, $link_dest, $invalid) = @_; - if (-l $target) { - my $old_source = readlink join('/', parent($target), $source) - or croak "$target is already a link but could not read link $target/$source"; - if ($old_source ne $source) { - croak "$target already exists but points elsewhere\n"; + if (-l $link_src) { + my $old_source = readlink join('/', parent($link_src), $link_dest) + or croak "$link_src is already a link but could not read link $link_src/$link_dest"; + if ($old_source ne $link_dest) { + croak "$link_src already exists but points elsewhere\n"; } } - croak "$target already exists and is not a link\n" if -e $target; - my $abs_target = File::Spec->rel2abs($target); - my $target_container = dirname($abs_target); - my $abs_source = File::Spec->rel2abs($source, $target_container); - #warn "t $target c $target_container as $abs_source"; + croak "$link_src already exists and is not a link\n" if -e $link_src; + my $abs_target = File::Spec->rel2abs($link_src); + my $link_src_container = dirname($abs_target); + my $abs_source = File::Spec->rel2abs($link_dest, $link_src_container); + #warn "t $link_src c $link_src_container as $abs_source"; if (-e $abs_source) { croak "Won't make invalid link pointing to existing $abs_target" if $invalid; @@ -130,8 +130,8 @@ sub make_link { croak "Won't make link pointing to non-existent $abs_target" unless $invalid; } - symlink $source, $target - or croak "could not create link $target => $source ($!)\n"; + symlink $link_dest, $link_src + or croak "could not create link $link_src => $link_dest ($!)\n"; } #===== SUBROUTINE =========================================================== From bca711fac20e478b91652d300b92e5ebd807bb23 Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Sat, 6 Apr 2024 11:12:15 +0100 Subject: [PATCH 455/482] tests: use stderr_like() instead of home-grown STDERR capturing The STDERR capturing in testutil just reinvents Test::Output which we already use in chkstow.t, so it's pointless to reinvent that wheel. --- t/stow.t | 12 +++++----- t/testutil.pm | 16 ------------- t/unstow.t | 11 ++++----- t/unstow_orig.t | 61 ++++++++++++++++++++++++------------------------- 4 files changed, 41 insertions(+), 59 deletions(-) diff --git a/t/stow.t b/t/stow.t index a6b16bf..318eb6d 100755 --- a/t/stow.t +++ b/t/stow.t @@ -372,18 +372,18 @@ subtest("stowing to stow dir should fail", sub { make_path('stow/pkg14/stow/pkg15'); make_file('stow/pkg14/stow/pkg15/node15'); - capture_stderr(); - $stow->plan_stow('pkg14'); + stderr_like( + sub { $stow->plan_stow('pkg14'); }, + qr/WARNING: skipping target which was current stow directory stow/, + "stowing to stow dir should give warning" + ); + is($stow->get_tasks, 0, 'no tasks to process'); is($stow->get_conflict_count, 0); ok( ! -l 'stow/pkg15' => "stowing to stow dir should fail" ); - like($stderr, - qr/WARNING: skipping target which was current stow directory stow/ - => "stowing to stow dir should give warning"); - uncapture_stderr(); }); subtest("stow a simple tree minimally when cwd isn't target", sub { diff --git a/t/testutil.pm b/t/testutil.pm index 6cf179e..3507285 100755 --- a/t/testutil.pm +++ b/t/testutil.pm @@ -28,7 +28,6 @@ use Carp qw(croak); use File::Basename; use File::Path qw(make_path remove_tree); use File::Spec; -use IO::Scalar; use Test::More; use Stow; @@ -38,7 +37,6 @@ use base qw(Exporter); our @EXPORT = qw( $ABS_TEST_DIR $TEST_DIR - $stderr init_test_dirs cd new_Stow new_compat_Stow @@ -46,25 +44,11 @@ our @EXPORT = qw( remove_dir remove_file remove_link cat_file is_link is_dir_not_symlink is_nonexistent_path - capture_stderr uncapture_stderr ); our $TEST_DIR = 'tmp-testing-trees'; our $ABS_TEST_DIR = File::Spec->rel2abs('tmp-testing-trees'); -our $stderr; -my $tied_err; - -sub capture_stderr { - undef $stderr; - $tied_err = tie *STDERR, 'IO::Scalar', \$stderr; -} - -sub uncapture_stderr { - undef $tied_err; - untie *STDERR; -} - sub init_test_dirs { -d "t" or croak "Was expecting tests to be run from root of repo\n"; diff --git a/t/unstow.t b/t/unstow.t index 01a7a30..5e96dde 100755 --- a/t/unstow.t +++ b/t/unstow.t @@ -183,8 +183,11 @@ make_path('stow/pkg8a/stow2/pkg8b'); make_file('stow/pkg8a/stow2/pkg8b/file8b'); make_link('stow2/pkg8b', '../stow/pkg8a/stow2/pkg8b'); -capture_stderr(); -$stow->plan_unstow('pkg8a'); +stderr_like( + sub { $stow->plan_unstow('pkg8a'); }, + qr/WARNING: skipping marked Stow directory stow2/ + => "unstowing from ourself should skip stow" +); is($stow->get_tasks, 0, 'no tasks to process when unstowing pkg8a'); ok( $stow->get_conflict_count == 0 && @@ -192,10 +195,6 @@ ok( readlink('stow2/pkg8b') eq '../stow/pkg8a/stow2/pkg8b' => q(don't unlink any nodes under another stow directory) ); -like($stderr, - qr/WARNING: skipping marked Stow directory stow2/ - => "unstowing from ourself should skip stow"); -uncapture_stderr(); # # overriding already stowed documentation diff --git a/t/unstow_orig.t b/t/unstow_orig.t index 94f771d..ffe2df2 100755 --- a/t/unstow_orig.t +++ b/t/unstow_orig.t @@ -161,18 +161,17 @@ subtest("Don't unlink anything under the stow directory", sub { make_file('stow/pkg7a/stow/pkg7b/file7b'); make_link('stow/pkg7b', '../stow/pkg7a/stow/pkg7b'); - capture_stderr(); - $stow->plan_unstow('pkg7b'); + stderr_like( + sub { $stow->plan_unstow('pkg7b'); }, + qr/WARNING: skipping target which was current stow directory stow/ + => "warn when unstowing from ourself" + ); is($stow->get_tasks, 0, 'no tasks to process when unstowing pkg7b'); is($stow->get_conflict_count, 0); ok(-l 'stow/pkg7b'); ok(readlink('stow/pkg7b') eq '../stow/pkg7a/stow/pkg7b' => q(don't unlink any nodes under the stow directory) ); - like($stderr, - qr/WARNING: skipping target which was current stow directory stow/ - => "warn when unstowing from ourself"); - uncapture_stderr(); }); subtest("Don't unlink any nodes under another stow directory", sub { @@ -187,28 +186,28 @@ subtest("Don't unlink any nodes under another stow directory", sub { make_file('stow/pkg8a/stow2/pkg8b/file8b'); make_link('stow2/pkg8b', '../stow/pkg8a/stow2/pkg8b'); - capture_stderr(); - $stow->plan_unstow('pkg8a'); + stderr_like( + sub { $stow->plan_unstow('pkg8a'); }, + qr/WARNING: skipping target which was current stow directory stow/ + => "warn when skipping unstowing" + ); is($stow->get_tasks, 0, 'no tasks to process when unstowing pkg8a'); is($stow->get_conflict_count, 0); ok(-l 'stow2/pkg8b'); ok(readlink('stow2/pkg8b') eq '../stow/pkg8a/stow2/pkg8b' => q(don't unlink any nodes under another stow directory) ); - like($stderr, - qr/WARNING: skipping target which was current stow directory stow/ - => "warn when skipping unstowing"); - uncapture_stderr(); }); # This will be used by subsequent tests sub check_protected_dirs_skipped { + my $coderef = shift; + my $stderr = stderr_from { $coderef->(); }; for my $dir (qw{stow stow2}) { like($stderr, qr/WARNING: skipping marked Stow directory $dir/ => "warn when skipping marked directory $dir"); } - uncapture_stderr(); } subtest("overriding already stowed documentation", sub { @@ -224,14 +223,14 @@ subtest("overriding already stowed documentation", sub { make_path('../stow/pkg9b/man9/man1'); make_file('../stow/pkg9b/man9/man1/file9.1'); - capture_stderr(); - $stow->plan_unstow('pkg9b'); + check_protected_dirs_skipped( + sub { $stow->plan_unstow('pkg9b'); } + ); $stow->process_tasks(); is($stow->get_conflict_count, 0); ok(!-l 'man9/man1/file9.1' => 'overriding existing documentation files' ); - check_protected_dirs_skipped(); }); subtest("deferring to already stowed documentation", sub { @@ -250,14 +249,14 @@ subtest("deferring to already stowed documentation", sub { make_path('../stow/pkg10c/man10/man1'); make_file('../stow/pkg10c/man10/man1/file10a.1'); - capture_stderr(); - $stow->plan_unstow('pkg10c'); + check_protected_dirs_skipped( + sub { $stow->plan_unstow('pkg10c'); } + ); is($stow->get_tasks, 0, 'no tasks to process when unstowing pkg10c'); is($stow->get_conflict_count, 0); ok(readlink('man10/man1/file10a.1') eq '../../../stow/pkg10a/man10/man1/file10a.1' => 'defer to existing documentation files' ); - check_protected_dirs_skipped(); }); subtest("Ignore temp files", sub { @@ -271,25 +270,25 @@ subtest("Ignore temp files", sub { make_path('man12/man1'); make_link('man12/man1/file12.1' => '../../../stow/pkg12/man12/man1/file12.1'); - capture_stderr(); - $stow->plan_unstow('pkg12'); + check_protected_dirs_skipped( + sub { $stow->plan_unstow('pkg12'); } + ); $stow->process_tasks(); is($stow->get_conflict_count, 0); ok(!-e 'man12/man1/file12.1' => 'ignore temp files'); - check_protected_dirs_skipped(); }); subtest("Unstow an already unstowed package", sub { plan tests => 4; my $stow = new_compat_Stow(); - capture_stderr(); - $stow->plan_unstow('pkg12'); + check_protected_dirs_skipped( + sub { $stow->plan_unstow('pkg12'); } + ); is($stow->get_tasks, 0, 'no tasks to process when unstowing pkg12'); ok( $stow->get_conflict_count == 0 => 'unstow already unstowed package pkg12' ); - check_protected_dirs_skipped(); }); subtest("Unstow a never stowed package", sub { @@ -299,14 +298,14 @@ subtest("Unstow a never stowed package", sub { mkdir("$TEST_DIR/target"); my $stow = new_compat_Stow(); - capture_stderr(); - $stow->plan_unstow('pkg12'); + check_protected_dirs_skipped( + sub { $stow->plan_unstow('pkg12'); } + ); is($stow->get_tasks, 0, 'no tasks to process when unstowing pkg12 which was never stowed'); ok( $stow->get_conflict_count == 0 => 'unstow never stowed package pkg12' ); - check_protected_dirs_skipped(); }); subtest("Unstowing when target contains a real file shouldn't be an issue", sub { @@ -314,8 +313,9 @@ subtest("Unstowing when target contains a real file shouldn't be an issue", sub make_file('man12/man1/file12.1'); my $stow = new_compat_Stow(); - capture_stderr(); - $stow->plan_unstow('pkg12'); + check_protected_dirs_skipped( + sub { $stow->plan_unstow('pkg12'); } + ); is($stow->get_tasks, 0, 'no tasks to process when unstowing pkg12 for third time'); %conflicts = $stow->get_conflicts; ok($stow->get_conflict_count == 1); @@ -323,7 +323,6 @@ subtest("Unstowing when target contains a real file shouldn't be an issue", sub =~ m!existing target is neither a link nor a directory: man12/man1/file12\.1! => 'unstow pkg12 for third time' ); - check_protected_dirs_skipped(); }); subtest("unstow a simple tree minimally when cwd isn't target", sub { From 599944bce1d23941a5b5eacc5d1d2f38087e1651 Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Sat, 6 Apr 2024 11:44:36 +0100 Subject: [PATCH 456/482] t/unstow_orig.t: use is() for equality tests This is better because it outputs the mismatching values when the equality check fails. --- t/unstow_orig.t | 33 ++++++++++++++++++++++----------- 1 file changed, 22 insertions(+), 11 deletions(-) diff --git a/t/unstow_orig.t b/t/unstow_orig.t index ffe2df2..0c2a646 100755 --- a/t/unstow_orig.t +++ b/t/unstow_orig.t @@ -125,7 +125,9 @@ subtest("Existing link is not owned by stow", sub { # => q(existing link not owned by stow) #); ok(-l 'bin5'); - ok(readlink('bin5') eq '../not-stow' + is( + readlink('bin5'), + '../not-stow' => q(existing link not owned by stow) ); }); @@ -145,8 +147,9 @@ subtest("Target already exists, is owned by stow, but points to a different pack $stow->plan_unstow('pkg6b'); is($stow->get_conflict_count, 0); ok(-l 'bin6/file6'); - ok( - readlink('bin6/file6') eq '../../stow/pkg6a/bin6/file6' + is( + readlink('bin6/file6'), + '../../stow/pkg6a/bin6/file6' => q(ignore existing link that points to a different package) ); }); @@ -169,7 +172,9 @@ subtest("Don't unlink anything under the stow directory", sub { is($stow->get_tasks, 0, 'no tasks to process when unstowing pkg7b'); is($stow->get_conflict_count, 0); ok(-l 'stow/pkg7b'); - ok(readlink('stow/pkg7b') eq '../stow/pkg7a/stow/pkg7b' + is( + readlink('stow/pkg7b'), + '../stow/pkg7a/stow/pkg7b' => q(don't unlink any nodes under the stow directory) ); }); @@ -194,7 +199,9 @@ subtest("Don't unlink any nodes under another stow directory", sub { is($stow->get_tasks, 0, 'no tasks to process when unstowing pkg8a'); is($stow->get_conflict_count, 0); ok(-l 'stow2/pkg8b'); - ok(readlink('stow2/pkg8b') eq '../stow/pkg8a/stow2/pkg8b' + is( + readlink('stow2/pkg8b'), + '../stow/pkg8a/stow2/pkg8b' => q(don't unlink any nodes under another stow directory) ); }); @@ -254,7 +261,9 @@ subtest("deferring to already stowed documentation", sub { ); is($stow->get_tasks, 0, 'no tasks to process when unstowing pkg10c'); is($stow->get_conflict_count, 0); - ok(readlink('man10/man1/file10a.1') eq '../../../stow/pkg10a/man10/man1/file10a.1' + is( + readlink('man10/man1/file10a.1'), + '../../../stow/pkg10a/man10/man1/file10a.1' => 'defer to existing documentation files' ); }); @@ -285,8 +294,9 @@ subtest("Unstow an already unstowed package", sub { sub { $stow->plan_unstow('pkg12'); } ); is($stow->get_tasks, 0, 'no tasks to process when unstowing pkg12'); - ok( - $stow->get_conflict_count == 0 + is( + $stow->get_conflict_count, + 0 => 'unstow already unstowed package pkg12' ); }); @@ -302,8 +312,9 @@ subtest("Unstow a never stowed package", sub { sub { $stow->plan_unstow('pkg12'); } ); is($stow->get_tasks, 0, 'no tasks to process when unstowing pkg12 which was never stowed'); - ok( - $stow->get_conflict_count == 0 + is( + $stow->get_conflict_count, + 0 => 'unstow never stowed package pkg12' ); }); @@ -318,7 +329,7 @@ subtest("Unstowing when target contains a real file shouldn't be an issue", sub ); is($stow->get_tasks, 0, 'no tasks to process when unstowing pkg12 for third time'); %conflicts = $stow->get_conflicts; - ok($stow->get_conflict_count == 1); + is($stow->get_conflict_count, 1); ok($conflicts{unstow}{pkg12}[0] =~ m!existing target is neither a link nor a directory: man12/man1/file12\.1! => 'unstow pkg12 for third time' From 6d6781dcefdff96b3b0b5e9850eae534726c5cd7 Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Sat, 6 Apr 2024 11:58:56 +0100 Subject: [PATCH 457/482] t/unstow_orig.t: use like() for regexp matching tests This is better because it outputs the mismatching value when the matching check fails. --- t/unstow_orig.t | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/t/unstow_orig.t b/t/unstow_orig.t index 0c2a646..9d62bd9 100755 --- a/t/unstow_orig.t +++ b/t/unstow_orig.t @@ -330,8 +330,9 @@ subtest("Unstowing when target contains a real file shouldn't be an issue", sub is($stow->get_tasks, 0, 'no tasks to process when unstowing pkg12 for third time'); %conflicts = $stow->get_conflicts; is($stow->get_conflict_count, 1); - ok($conflicts{unstow}{pkg12}[0] - =~ m!existing target is neither a link nor a directory: man12/man1/file12\.1! + like( + $conflicts{unstow}{pkg12}[0], + qr!existing target is neither a link nor a directory: man12/man1/file12\.1! => 'unstow pkg12 for third time' ); }); From e9ad20576c65c48b3b988bf520830e17e6df39a9 Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Sat, 6 Apr 2024 11:59:23 +0100 Subject: [PATCH 458/482] t/unstow.t: convert to use subtests --- t/unstow.t | 561 ++++++++++++++++++++++++++--------------------------- 1 file changed, 275 insertions(+), 286 deletions(-) diff --git a/t/unstow.t b/t/unstow.t index 5e96dde..15288c9 100755 --- a/t/unstow.t +++ b/t/unstow.t @@ -22,7 +22,7 @@ use strict; use warnings; -use Test::More tests => 39; +use Test::More tests => 32; use Test::Output; use English qw(-no_match_vars); @@ -34,332 +34,321 @@ cd("$TEST_DIR/target"); # Note that each of the following tests use a distinct set of files -my $stow; -my %conflicts; +subtest("unstow a simple tree minimally", sub { + plan tests => 3; + my $stow = new_Stow(); -# -# unstow a simple tree minimally -# -$stow = new_Stow(); + make_path('../stow/pkg1/bin1'); + make_file('../stow/pkg1/bin1/file1'); + make_link('bin1', '../stow/pkg1/bin1'); -make_path('../stow/pkg1/bin1'); -make_file('../stow/pkg1/bin1/file1'); -make_link('bin1', '../stow/pkg1/bin1'); + $stow->plan_unstow('pkg1'); + $stow->process_tasks(); + is($stow->get_conflict_count, 0); + ok(-f '../stow/pkg1/bin1/file1'); + ok(! -e 'bin1' => 'unstow a simple tree'); +}); -$stow->plan_unstow('pkg1'); -$stow->process_tasks(); -ok( - $stow->get_conflict_count == 0 && - -f '../stow/pkg1/bin1/file1' && ! -e 'bin1' - => 'unstow a simple tree' -); +subtest("unstow a simple tree from an existing directory", sub { + plan tests => 3; + my $stow = new_Stow(); -# -# unstow a simple tree from an existing directory -# -$stow = new_Stow(); + make_path('lib2'); + make_path('../stow/pkg2/lib2'); + make_file('../stow/pkg2/lib2/file2'); + make_link('lib2/file2', '../../stow/pkg2/lib2/file2'); + $stow->plan_unstow('pkg2'); + $stow->process_tasks(); + is($stow->get_conflict_count, 0); + ok(-f '../stow/pkg2/lib2/file2'); + ok(-d 'lib2' + => 'unstow simple tree from a pre-existing directory' + ); +}); -make_path('lib2'); -make_path('../stow/pkg2/lib2'); -make_file('../stow/pkg2/lib2/file2'); -make_link('lib2/file2', '../../stow/pkg2/lib2/file2'); -$stow->plan_unstow('pkg2'); -$stow->process_tasks(); -ok( - $stow->get_conflict_count == 0 && - -f '../stow/pkg2/lib2/file2' && -d 'lib2' - => 'unstow simple tree from a pre-existing directory' -); +subtest("fold tree after unstowing", sub { + plan tests => 3; + my $stow = new_Stow(); -# -# fold tree after unstowing -# -$stow = new_Stow(); + make_path('bin3'); -make_path('bin3'); + make_path('../stow/pkg3a/bin3'); + make_file('../stow/pkg3a/bin3/file3a'); + make_link('bin3/file3a' => '../../stow/pkg3a/bin3/file3a'); # emulate stow -make_path('../stow/pkg3a/bin3'); -make_file('../stow/pkg3a/bin3/file3a'); -make_link('bin3/file3a' => '../../stow/pkg3a/bin3/file3a'); # emulate stow + make_path('../stow/pkg3b/bin3'); + make_file('../stow/pkg3b/bin3/file3b'); + make_link('bin3/file3b' => '../../stow/pkg3b/bin3/file3b'); # emulate stow + $stow->plan_unstow('pkg3b'); + $stow->process_tasks(); + is($stow->get_conflict_count, 0); + ok(-l 'bin3'); + is(readlink('bin3'), '../stow/pkg3a/bin3' + => 'fold tree after unstowing' + ); +}); -make_path('../stow/pkg3b/bin3'); -make_file('../stow/pkg3b/bin3/file3b'); -make_link('bin3/file3b' => '../../stow/pkg3b/bin3/file3b'); # emulate stow -$stow->plan_unstow('pkg3b'); -$stow->process_tasks(); -ok( - $stow->get_conflict_count == 0 && - -l 'bin3' && - readlink('bin3') eq '../stow/pkg3a/bin3' - => 'fold tree after unstowing' -); +subtest("existing link is owned by stow but is invalid so it gets removed anyway", sub { + plan tests => 2; + my $stow = new_Stow(); -# -# existing link is owned by stow but is invalid so it gets removed anyway -# -$stow = new_Stow(); + make_path('bin4'); + make_path('../stow/pkg4/bin4'); + make_file('../stow/pkg4/bin4/file4'); + make_invalid_link('bin4/file4', '../../stow/pkg4/bin4/does-not-exist'); -make_path('bin4'); -make_path('../stow/pkg4/bin4'); -make_file('../stow/pkg4/bin4/file4'); -make_invalid_link('bin4/file4', '../../stow/pkg4/bin4/does-not-exist'); + $stow->plan_unstow('pkg4'); + $stow->process_tasks(); + is($stow->get_conflict_count, 0); + ok(! -e 'bin4/file4' + => q(remove invalid link owned by stow) + ); +}); -$stow->plan_unstow('pkg4'); -$stow->process_tasks(); -ok( - $stow->get_conflict_count == 0 && - ! -e 'bin4/file4' - => q(remove invalid link owned by stow) -); +subtest("Existing link is not owned by stow", sub { + plan tests => 1; + my $stow = new_Stow(); -# -# Existing link is not owned by stow -# -$stow = new_Stow(); + make_path('../stow/pkg5/bin5'); + make_invalid_link('bin5', '../not-stow'); -make_path('../stow/pkg5/bin5'); -make_invalid_link('bin5', '../not-stow'); + $stow->plan_unstow('pkg5'); + my %conflicts = $stow->get_conflicts; + like( + $conflicts{unstow}{pkg5}[-1], + qr(existing target is not owned by stow) + => q(existing link not owned by stow) + ); +}); -$stow->plan_unstow('pkg5'); -%conflicts = $stow->get_conflicts; -like( - $conflicts{unstow}{pkg5}[-1], - qr(existing target is not owned by stow) - => q(existing link not owned by stow) -); +subtest("Target already exists, is owned by stow, but points to a different package", sub { + plan tests => 3; + my $stow = new_Stow(); -# -# Target already exists, is owned by stow, but points to a different package -# -$stow = new_Stow(); + make_path('bin6'); + make_path('../stow/pkg6a/bin6'); + make_file('../stow/pkg6a/bin6/file6'); + make_link('bin6/file6', '../../stow/pkg6a/bin6/file6'); -make_path('bin6'); -make_path('../stow/pkg6a/bin6'); -make_file('../stow/pkg6a/bin6/file6'); -make_link('bin6/file6', '../../stow/pkg6a/bin6/file6'); + make_path('../stow/pkg6b/bin6'); + make_file('../stow/pkg6b/bin6/file6'); -make_path('../stow/pkg6b/bin6'); -make_file('../stow/pkg6b/bin6/file6'); + $stow->plan_unstow('pkg6b'); + is($stow->get_conflict_count, 0); + ok(-l 'bin6/file6'); + is( + readlink('bin6/file6'), + '../../stow/pkg6a/bin6/file6' + => q(ignore existing link that points to a different package) + ); +}); -$stow->plan_unstow('pkg6b'); -ok( - $stow->get_conflict_count == 0 && - -l 'bin6/file6' && - readlink('bin6/file6') eq '../../stow/pkg6a/bin6/file6' - => q(ignore existing link that points to a different package) -); +subtest("Don't unlink anything under the stow directory", sub { + plan tests => 4; + make_path('stow'); # make out stow dir a subdir of target + my $stow = new_Stow(dir => 'stow'); -# -# Don't unlink anything under the stow directory -# -make_path('stow'); # make out stow dir a subdir of target -$stow = new_Stow(dir => 'stow'); + # emulate stowing into ourself (bizarre corner case or accident) + make_path('stow/pkg7a/stow/pkg7b'); + make_file('stow/pkg7a/stow/pkg7b/file7b'); + make_link('stow/pkg7b', '../stow/pkg7a/stow/pkg7b'); -# emulate stowing into ourself (bizarre corner case or accident) -make_path('stow/pkg7a/stow/pkg7b'); -make_file('stow/pkg7a/stow/pkg7b/file7b'); -make_link('stow/pkg7b', '../stow/pkg7a/stow/pkg7b'); + $stow->plan_unstow('pkg7b'); + is($stow->get_tasks, 0, 'no tasks to process when unstowing pkg7b'); + is($stow->get_conflict_count, 0); + ok(-l 'stow/pkg7b'); + is( + readlink('stow/pkg7b'), + '../stow/pkg7a/stow/pkg7b' + => q(don't unlink any nodes under the stow directory) + ); +}); -$stow->plan_unstow('pkg7b'); -is($stow->get_tasks, 0, 'no tasks to process when unstowing pkg7b'); -ok( - $stow->get_conflict_count == 0 && - -l 'stow/pkg7b' && - readlink('stow/pkg7b') eq '../stow/pkg7a/stow/pkg7b' - => q(don't unlink any nodes under the stow directory) -); +subtest("Don't unlink any nodes under another stow directory", sub { + plan tests => 5; + my $stow = new_Stow(dir => 'stow'); + + make_path('stow2'); # make our alternate stow dir a subdir of target + make_file('stow2/.stow'); + + # emulate stowing into ourself (bizarre corner case or accident) + make_path('stow/pkg8a/stow2/pkg8b'); + make_file('stow/pkg8a/stow2/pkg8b/file8b'); + make_link('stow2/pkg8b', '../stow/pkg8a/stow2/pkg8b'); + + stderr_like( + sub { $stow->plan_unstow('pkg8a'); }, + qr/WARNING: skipping marked Stow directory stow2/ + => "unstowing from ourself should skip stow" + ); + is($stow->get_tasks, 0, 'no tasks to process when unstowing pkg8a'); + is($stow->get_conflict_count, 0); + ok(-l 'stow2/pkg8b'); + is( + readlink('stow2/pkg8b'), + '../stow/pkg8a/stow2/pkg8b' + => q(don't unlink any nodes under another stow directory) + ); +}); + +subtest("overriding already stowed documentation", sub { + plan tests => 2; + my $stow = new_Stow(override => ['man9', 'info9']); + make_file('stow/.stow'); + + make_path('../stow/pkg9a/man9/man1'); + make_file('../stow/pkg9a/man9/man1/file9.1'); + make_path('man9/man1'); + make_link('man9/man1/file9.1' => '../../../stow/pkg9a/man9/man1/file9.1'); # emulate stow + + make_path('../stow/pkg9b/man9/man1'); + make_file('../stow/pkg9b/man9/man1/file9.1'); + $stow->plan_unstow('pkg9b'); + $stow->process_tasks(); + is($stow->get_conflict_count, 0); + ok(!-l 'man9/man1/file9.1' + => 'overriding existing documentation files' + ); +}); + +subtest("deferring to already stowed documentation", sub { + plan tests => 3; + my $stow = new_Stow(defer => ['man10', 'info10']); + + make_path('../stow/pkg10a/man10/man1'); + make_file('../stow/pkg10a/man10/man1/file10a.1'); + make_path('man10/man1'); + make_link('man10/man1/file10a.1' => '../../../stow/pkg10a/man10/man1/file10a.1'); + + # need this to block folding + make_path('../stow/pkg10b/man10/man1'); + make_file('../stow/pkg10b/man10/man1/file10b.1'); + make_link('man10/man1/file10b.1' => '../../../stow/pkg10b/man10/man1/file10b.1'); -# -# Don't unlink any nodes under another stow directory -# -$stow = new_Stow(dir => 'stow'); + make_path('../stow/pkg10c/man10/man1'); + make_file('../stow/pkg10c/man10/man1/file10a.1'); + $stow->plan_unstow('pkg10c'); + is($stow->get_tasks, 0, 'no tasks to process when unstowing pkg10c'); + is($stow->get_conflict_count, 0); + is( + readlink('man10/man1/file10a.1'), + '../../../stow/pkg10a/man10/man1/file10a.1' + => 'defer to existing documentation files' + ); +}); -make_path('stow2'); # make our alternate stow dir a subdir of target -make_file('stow2/.stow'); +subtest("Ignore temp files", sub { + plan tests => 2; + my $stow = new_Stow(ignore => ['~', '\.#.*']); -# emulate stowing into ourself (bizarre corner case or accident) -make_path('stow/pkg8a/stow2/pkg8b'); -make_file('stow/pkg8a/stow2/pkg8b/file8b'); -make_link('stow2/pkg8b', '../stow/pkg8a/stow2/pkg8b'); + make_path('../stow/pkg12/man12/man1'); + make_file('../stow/pkg12/man12/man1/file12.1'); + make_file('../stow/pkg12/man12/man1/file12.1~'); + make_file('../stow/pkg12/man12/man1/.#file12.1'); + make_path('man12/man1'); + make_link('man12/man1/file12.1' => '../../../stow/pkg12/man12/man1/file12.1'); -stderr_like( - sub { $stow->plan_unstow('pkg8a'); }, - qr/WARNING: skipping marked Stow directory stow2/ - => "unstowing from ourself should skip stow" -); -is($stow->get_tasks, 0, 'no tasks to process when unstowing pkg8a'); -ok( - $stow->get_conflict_count == 0 && - -l 'stow2/pkg8b' && - readlink('stow2/pkg8b') eq '../stow/pkg8a/stow2/pkg8b' - => q(don't unlink any nodes under another stow directory) -); + $stow->plan_unstow('pkg12'); + $stow->process_tasks(); + is($stow->get_conflict_count, 0); + ok(!-e 'man12/man1/file12.1' => 'ignore temp files'); +}); -# -# overriding already stowed documentation -# -$stow = new_Stow(override => ['man9', 'info9']); -make_file('stow/.stow'); +subtest("Unstow an already unstowed package", sub { + plan tests => 2; + my $stow = new_Stow(); + $stow->plan_unstow('pkg12'); + is($stow->get_tasks, 0, 'no tasks to process when unstowing pkg12'); + is( + $stow->get_conflict_count, 0 + => 'unstow already unstowed package pkg12' + ); +}); -make_path('../stow/pkg9a/man9/man1'); -make_file('../stow/pkg9a/man9/man1/file9.1'); -make_path('man9/man1'); -make_link('man9/man1/file9.1' => '../../../stow/pkg9a/man9/man1/file9.1'); # emulate stow +subtest("Unstow a never stowed package", sub { + plan tests => 2; -make_path('../stow/pkg9b/man9/man1'); -make_file('../stow/pkg9b/man9/man1/file9.1'); -$stow->plan_unstow('pkg9b'); -$stow->process_tasks(); -ok( - $stow->get_conflict_count == 0 && - !-l 'man9/man1/file9.1' - => 'overriding existing documentation files' -); + eval { remove_dir("$TEST_DIR/target"); }; + mkdir("$TEST_DIR/target"); -# -# deferring to already stowed documentation -# -$stow = new_Stow(defer => ['man10', 'info10']); + my $stow = new_Stow(); + $stow->plan_unstow('pkg12'); + is($stow->get_tasks, 0, 'no tasks to process when unstowing pkg12 which was never stowed'); + is( + $stow->get_conflict_count, + 0 + => 'unstow never stowed package pkg12' + ); +}); -make_path('../stow/pkg10a/man10/man1'); -make_file('../stow/pkg10a/man10/man1/file10a.1'); -make_path('man10/man1'); -make_link('man10/man1/file10a.1' => '../../../stow/pkg10a/man10/man1/file10a.1'); +subtest("Unstowing when target contains a real file shouldn't be an issue", sub { + plan tests => 3; + make_file('man12/man1/file12.1'); -# need this to block folding -make_path('../stow/pkg10b/man10/man1'); -make_file('../stow/pkg10b/man10/man1/file10b.1'); -make_link('man10/man1/file10b.1' => '../../../stow/pkg10b/man10/man1/file10b.1'); + my $stow = new_Stow(); + $stow->plan_unstow('pkg12'); + is($stow->get_tasks, 0, 'no tasks to process when unstowing pkg12 for third time'); + my %conflicts = $stow->get_conflicts; + is($stow->get_conflict_count, 1); + like( + $conflicts{unstow}{pkg12}[0], + qr!existing target is neither a link nor a directory: man12/man1/file12\.1! + => 'unstow pkg12 for third time' + ); +}); +subtest("unstow a simple tree minimally when cwd isn't target", sub { + plan tests => 3; + cd('../..'); + my $stow = new_Stow(dir => "$TEST_DIR/stow", target => "$TEST_DIR/target"); -make_path('../stow/pkg10c/man10/man1'); -make_file('../stow/pkg10c/man10/man1/file10a.1'); -$stow->plan_unstow('pkg10c'); -is($stow->get_tasks, 0, 'no tasks to process when unstowing pkg10c'); -ok( - $stow->get_conflict_count == 0 && - readlink('man10/man1/file10a.1') eq '../../../stow/pkg10a/man10/man1/file10a.1' - => 'defer to existing documentation files' -); + make_path("$TEST_DIR/stow/pkg13/bin13"); + make_file("$TEST_DIR/stow/pkg13/bin13/file13"); + make_link("$TEST_DIR/target/bin13", '../stow/pkg13/bin13'); -# -# Ignore temp files -# -$stow = new_Stow(ignore => ['~', '\.#.*']); + $stow->plan_unstow('pkg13'); + $stow->process_tasks(); + is($stow->get_conflict_count, 0); + ok(-f "$TEST_DIR/stow/pkg13/bin13/file13"); + ok(! -e "$TEST_DIR/target/bin13" => 'unstow a simple tree'); +}); -make_path('../stow/pkg12/man12/man1'); -make_file('../stow/pkg12/man12/man1/file12.1'); -make_file('../stow/pkg12/man12/man1/file12.1~'); -make_file('../stow/pkg12/man12/man1/.#file12.1'); -make_path('man12/man1'); -make_link('man12/man1/file12.1' => '../../../stow/pkg12/man12/man1/file12.1'); +subtest("unstow a simple tree minimally with absolute stow dir when cwd isn't target", sub { + plan tests => 3; + my $stow = new_Stow(dir => canon_path("$TEST_DIR/stow"), + target => "$TEST_DIR/target"); -$stow->plan_unstow('pkg12'); -$stow->process_tasks(); -ok( - $stow->get_conflict_count == 0 && - !-e 'man12/man1/file12.1' - => 'ignore temp files' -); + make_path("$TEST_DIR/stow/pkg14/bin14"); + make_file("$TEST_DIR/stow/pkg14/bin14/file14"); + make_link("$TEST_DIR/target/bin14", '../stow/pkg14/bin14'); -# -# Unstow an already unstowed package -# -$stow = new_Stow(); -$stow->plan_unstow('pkg12'); -is($stow->get_tasks, 0, 'no tasks to process when unstowing pkg12'); -ok( - $stow->get_conflict_count == 0 - => 'unstow already unstowed package pkg12' -); + $stow->plan_unstow('pkg14'); + $stow->process_tasks(); + is($stow->get_conflict_count, 0); + ok(-f "$TEST_DIR/stow/pkg14/bin14/file14"); + ok(! -e "$TEST_DIR/target/bin14" + => 'unstow a simple tree with absolute stow dir' + ); +}); -# -# Unstow a never stowed package -# +subtest("unstow a simple tree minimally with absolute stow AND target dirs when cwd isn't target", sub { + plan tests => 3; + my $stow = new_Stow(dir => canon_path("$TEST_DIR/stow"), + target => canon_path("$TEST_DIR/target")); -eval { remove_dir("$TEST_DIR/target"); }; -mkdir("$TEST_DIR/target"); + make_path("$TEST_DIR/stow/pkg15/bin15"); + make_file("$TEST_DIR/stow/pkg15/bin15/file15"); + make_link("$TEST_DIR/target/bin15", '../stow/pkg15/bin15'); -$stow = new_Stow(); -$stow->plan_unstow('pkg12'); -is($stow->get_tasks, 0, 'no tasks to process when unstowing pkg12 which was never stowed'); -ok( - $stow->get_conflict_count == 0 - => 'unstow never stowed package pkg12' -); - -# -# Unstowing when target contains a real file shouldn't be an issue. -# -make_file('man12/man1/file12.1'); - -$stow = new_Stow(); -$stow->plan_unstow('pkg12'); -is($stow->get_tasks, 0, 'no tasks to process when unstowing pkg12 for third time'); -%conflicts = $stow->get_conflicts; -ok( - $stow->get_conflict_count == 1 && - $conflicts{unstow}{pkg12}[0] - =~ m!existing target is neither a link nor a directory: man12/man1/file12\.1! - => 'unstow pkg12 for third time' -); - -# -# unstow a simple tree minimally when cwd isn't target -# -cd('../..'); -$stow = new_Stow(dir => "$TEST_DIR/stow", target => "$TEST_DIR/target"); - -make_path("$TEST_DIR/stow/pkg13/bin13"); -make_file("$TEST_DIR/stow/pkg13/bin13/file13"); -make_link("$TEST_DIR/target/bin13", '../stow/pkg13/bin13'); - -$stow->plan_unstow('pkg13'); -$stow->process_tasks(); -ok( - $stow->get_conflict_count == 0 && - -f "$TEST_DIR/stow/pkg13/bin13/file13" && ! -e "$TEST_DIR/target/bin13" - => 'unstow a simple tree' -); - -# -# unstow a simple tree minimally with absolute stow dir when cwd isn't -# target -# -$stow = new_Stow(dir => canon_path("$TEST_DIR/stow"), - target => "$TEST_DIR/target"); - -make_path("$TEST_DIR/stow/pkg14/bin14"); -make_file("$TEST_DIR/stow/pkg14/bin14/file14"); -make_link("$TEST_DIR/target/bin14", '../stow/pkg14/bin14'); - -$stow->plan_unstow('pkg14'); -$stow->process_tasks(); -ok( - $stow->get_conflict_count == 0 && - -f "$TEST_DIR/stow/pkg14/bin14/file14" && ! -e "$TEST_DIR/target/bin14" - => 'unstow a simple tree with absolute stow dir' -); - -# -# unstow a simple tree minimally with absolute stow AND target dirs -# when cwd isn't target -# -$stow = new_Stow(dir => canon_path("$TEST_DIR/stow"), - target => canon_path("$TEST_DIR/target")); - -make_path("$TEST_DIR/stow/pkg15/bin15"); -make_file("$TEST_DIR/stow/pkg15/bin15/file15"); -make_link("$TEST_DIR/target/bin15", '../stow/pkg15/bin15'); - -$stow->plan_unstow('pkg15'); -$stow->process_tasks(); -ok( - $stow->get_conflict_count == 0 && - -f "$TEST_DIR/stow/pkg15/bin15/file15" && ! -e "$TEST_DIR/target/bin15" - => 'unstow a simple tree with absolute stow and target dirs' -); + $stow->plan_unstow('pkg15'); + $stow->process_tasks(); + is($stow->get_conflict_count, 0); + ok(-f "$TEST_DIR/stow/pkg15/bin15/file15"); + ok(! -e "$TEST_DIR/target/bin15" + => 'unstow a simple tree with absolute stow and target dirs' + ); +}); # # unstow a tree with no-folding enabled - @@ -427,7 +416,7 @@ foreach my $pkg (qw{a b}) { create_and_stow_pkg('no-folding', $pkg); } -$stow = new_Stow('no-folding' => 1); +my $stow = new_Stow('no-folding' => 1); $stow->plan_unstow('no-folding-b'); is_deeply([ $stow->get_conflicts ], [] => 'no conflicts with --no-folding'); use Data::Dumper; From 2a647d125f36bafb79e173d8fce807efdb20025e Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Sat, 6 Apr 2024 13:33:53 +0100 Subject: [PATCH 459/482] iterate over directories in sorted order This makes behaviour more deterministic, and makes debugging easier. --- lib/Stow.pm.in | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/Stow.pm.in b/lib/Stow.pm.in index 6c7027b..b402d9a 100755 --- a/lib/Stow.pm.in +++ b/lib/Stow.pm.in @@ -432,7 +432,7 @@ sub stow_contents { closedir $DIR; NODE: - for my $node (@listing) { + for my $node (sort @listing) { next NODE if $node eq '.'; next NODE if $node eq '..'; my $node_target = join_paths($target_subdir, $node); @@ -743,7 +743,7 @@ sub unstow_contents { closedir $DIR; NODE: - for my $node (@listing) { + for my $node (sort @listing) { next NODE if $node eq '.'; next NODE if $node eq '..'; my $node_target = join_paths($target_subdir, $node); @@ -1148,7 +1148,7 @@ sub cleanup_invalid_links { closedir $DIR; NODE: - for my $node (@listing) { + for my $node (sort @listing) { next NODE if $node eq '.'; next NODE if $node eq '..'; @@ -1247,7 +1247,7 @@ sub foldable { my $parent_in_pkg = ''; NODE: - for my $node (@listing) { + for my $node (sort @listing) { next NODE if $node eq '.'; next NODE if $node eq '..'; @@ -1331,7 +1331,7 @@ sub fold_tree { closedir $DIR; NODE: - for my $node (@listing) { + for my $node (sort @listing) { next NODE if $node eq '.'; next NODE if $node eq '..'; next NODE if not $self->is_a_node(join_paths($target_subdir, $node)); From c691b8fa6eae1f55881f4890445314a4b2f42d27 Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Sat, 6 Apr 2024 14:39:16 +0100 Subject: [PATCH 460/482] Makefile.am: include DEFAULT_IGNORE_LIST in doc_deps --- Makefile.am | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Makefile.am b/Makefile.am index d5218eb..d6e004f 100644 --- a/Makefile.am +++ b/Makefile.am @@ -34,10 +34,10 @@ pmstow_DATA = lib/Stow/Util.pm export TEXI2DVI_BUILD_MODE = clean -doc_deps = $(info_TEXINFOS) doc/version.texi - DEFAULT_IGNORE_LIST = $(srcdir)/default-ignore-list +doc_deps = $(info_TEXINFOS) doc/version.texi $(DEFAULT_IGNORE_LIST) + TESTS_DIR = $(srcdir)/t TESTS_OUT = tmp-testing-trees TESTS_ENVIRONMENT = $(PERL) -Ibin -Ilib -I$(TESTS_DIR) From 7815bc8b445e05e1fde235360747440a8ad316da Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Sat, 6 Apr 2024 14:51:53 +0100 Subject: [PATCH 461/482] Revert "Remove unnecessary AM_MAKEINFOFLAGS tweak" This reverts commit 1a20a3f7eec823820b5cd01d566244e4fa968b73. It turns out that `texi2dvi` _does_ require `-I $(srcdir)` for `@verbatiminclude default-ignore-list` to work after all. It's needed not for a normal docs build, but when `make distcheck` is run, presumably because `distcheck` runs from a different directory. --- Makefile.am | 12 ++++++++++++ configure.ac | 3 ++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/Makefile.am b/Makefile.am index d6e004f..7bd43bd 100644 --- a/Makefile.am +++ b/Makefile.am @@ -33,6 +33,18 @@ pm_DATA = lib/Stow.pm pmstow_DATA = lib/Stow/Util.pm export TEXI2DVI_BUILD_MODE = clean +AM_MAKEINFOFLAGS = -I $(srcdir) + +# We require this -I parameter to ensure that the include of the +# default ignore list in the manual works correctly, even when the +# manual is being built via make distcheck from a different directory. +# Unfortunately this is the only way to do it: +# +# https://lists.gnu.org/archive/html/bug-automake/2008-09/msg00040.html +# +# even though it annoyingly produces a warning with the -Wall option +# to AM_INIT_AUTOMAKE which has to be silenced via -Wno-override. +TEXI2DVI = texi2dvi $(AM_MAKEINFOFLAGS) DEFAULT_IGNORE_LIST = $(srcdir)/default-ignore-list diff --git a/configure.ac b/configure.ac index 4b74c67..27d3b3b 100644 --- a/configure.ac +++ b/configure.ac @@ -19,7 +19,8 @@ AC_INIT([stow], [2.3.2], [bug-stow@gnu.org]) AC_PREREQ([2.61]) AC_CONFIG_AUX_DIR([automake]) # Unfortunately we have to disable warnings for overrides, because we -# need to override the built-in `check-TESTS' rule. +# need to override the built-in `check-TESTS' rule and also the TEXI2DVI +# variable. AM_INIT_AUTOMAKE([-Wall -Werror -Wno-override dist-bzip2 foreign]) AC_PROG_INSTALL From 748a34b211be0b4d577e387c1ccd6efe85021918 Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Sat, 6 Apr 2024 14:59:52 +0100 Subject: [PATCH 462/482] Revert "testutil: Add sanity check for cwd" This reverts commit 5d4e68291e24558a51376cf218cca9a1142dfff1. It turns out that this broke `make distcheck`. --- t/testutil.pm | 2 -- 1 file changed, 2 deletions(-) diff --git a/t/testutil.pm b/t/testutil.pm index 3507285..b7c1549 100755 --- a/t/testutil.pm +++ b/t/testutil.pm @@ -50,8 +50,6 @@ our $TEST_DIR = 'tmp-testing-trees'; our $ABS_TEST_DIR = File::Spec->rel2abs('tmp-testing-trees'); sub init_test_dirs { - -d "t" or croak "Was expecting tests to be run from root of repo\n"; - # Create a run_from/ subdirectory for tests which want to run # from a separate directory outside the Stow directory or # target directory. From 5bb65f60d60868abdb6683c1714ddd8e34661911 Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Sat, 6 Apr 2024 15:09:53 +0100 Subject: [PATCH 463/482] Update manifest files to keep ./Build distcheck happy --- MANIFEST | 2 ++ MANIFEST.SKIP | 7 +++++++ 2 files changed, 9 insertions(+) diff --git a/MANIFEST b/MANIFEST index 88255e6..8f7a812 100644 --- a/MANIFEST +++ b/MANIFEST @@ -12,6 +12,7 @@ Build.PL ChangeLog configure configure.ac +CONTRIBUTING.md COPYING default-ignore-list doc/ChangeLog.OLD @@ -43,6 +44,7 @@ t/find_stowed_path.t t/foldable.t t/ignore.t t/join_paths.t +t/link_dest_within_stow_dir.t t/parent.t t/stow.t t/rc_options.t diff --git a/MANIFEST.SKIP b/MANIFEST.SKIP index 259024a..ccab877 100644 --- a/MANIFEST.SKIP +++ b/MANIFEST.SKIP @@ -87,3 +87,10 @@ tmp-testing-trees .travis.yml ^docker/ ^[a-zA-Z]*-docker.sh + +# Avoid development config +.dir-locals.el +.dumbjump + +# Avoid CI +.github/ \ No newline at end of file From a070116621ffb135ff77e32689976129aa3805ca Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Sun, 7 Apr 2024 12:51:21 +0100 Subject: [PATCH 464/482] Fix Dockerfile by updating from jessie to bookworm --- docker/Dockerfile | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/docker/Dockerfile b/docker/Dockerfile index ec8f089..80ed7f3 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -16,10 +16,9 @@ # Build docker image: `docker build -t stowtest` # Run tests: (from stow src directory) # `docker run --rm -it -v $(pwd):$(pwd) -w $(pwd) stowtest` -FROM debian:jessie -RUN printf "deb http://archive.debian.org/debian/ jessie main\ndeb-src http://archive.debian.org/debian/ jessie main\ndeb http://security.debian.org jessie/updates main\ndeb-src http://security.debian.org jessie/updates main" > /etc/apt/sources.list +FROM debian:bookworm +RUN DEBIAN_FRONTEND=noninteractive apt-get update -qq RUN DEBIAN_FRONTEND=noninteractive \ -apt-get update -qq && \ apt-get install -y -q \ autoconf \ bzip2 \ From 5e21f47879f9546f905005ca4082af8075ea7e77 Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Sun, 7 Apr 2024 13:08:27 +0100 Subject: [PATCH 465/482] read_a_link(): clarify debug message when it's a real link --- lib/Stow.pm.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Stow.pm.in b/lib/Stow.pm.in index b402d9a..e844253 100755 --- a/lib/Stow.pm.in +++ b/lib/Stow.pm.in @@ -2078,7 +2078,7 @@ sub read_a_link { } } elsif (-l $link) { - debug(4, 2, "read_a_link($link): real link"); + debug(4, 2, "read_a_link($link): is a real link"); my $link_dest = readlink $link or error("Could not read link: $link ($!)"); return $link_dest; } From a7c251c316c83d34d51ac0aa2e154cac4ea578f9 Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Sun, 7 Apr 2024 14:08:59 +0100 Subject: [PATCH 466/482] tidy up MANIFEST.SKIP --- MANIFEST.SKIP | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/MANIFEST.SKIP b/MANIFEST.SKIP index 4fd408e..a771f30 100644 --- a/MANIFEST.SKIP +++ b/MANIFEST.SKIP @@ -84,15 +84,12 @@ # Avoid test files tmp-testing-trees -.coveralls.yml -.github/workflows/ -.travis.yml +^.coveralls.yml +^.github/workflows/ +^.travis.yml ^docker/ ^[a-zA-Z]*-docker.sh # Avoid development config -.dir-locals.el -.dumbjump - -# Avoid CI -.github/ \ No newline at end of file +^.dir-locals.el +^.dumbjump From 001b287b1be5f391189023469db25c832bbf9b4e Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Sun, 7 Apr 2024 14:09:15 +0100 Subject: [PATCH 467/482] allow playground/ directory for testing stuff --- .gitignore | 1 + CONTRIBUTING.md | 5 +++++ MANIFEST.SKIP | 1 + 3 files changed, 7 insertions(+) diff --git a/.gitignore b/.gitignore index dcb7f4d..81f5836 100644 --- a/.gitignore +++ b/.gitignore @@ -9,6 +9,7 @@ /bin/stow /doc/stow.info /doc/version.texi +/playground/ tmp-testing-trees/ _build/ autom4te.cache/ diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 1bcd0f4..6f6399c 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -85,6 +85,11 @@ or to run the whole suite: However currently there is an issue where this interferes with `TEST_VERBOSE`. +If you want to create test files for experimentation, it is +recommended to put them in a subdirectory called `playground/` since +this will be automatically ignored by git and the build process, +avoiding any undesirable complications. + Translating Stow ---------------- diff --git a/MANIFEST.SKIP b/MANIFEST.SKIP index a771f30..033f12a 100644 --- a/MANIFEST.SKIP +++ b/MANIFEST.SKIP @@ -89,6 +89,7 @@ tmp-testing-trees ^.travis.yml ^docker/ ^[a-zA-Z]*-docker.sh +^playground/ # Avoid development config ^.dir-locals.el From 06fdfc185f1e4c27c01347021fd258dd6466a03c Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Tue, 2 Apr 2024 00:36:51 +0100 Subject: [PATCH 468/482] merge unstow_orig.t into unstow.t and fix unstowing logic There was a ton of duplication which is not maintainable, so refactor everything into a single test which still covers the differences. This in turn revealed some issues in the unstowing logic: - We shouldn't conflict if we find a file which isn't a link or a directory; we can just skip over it. - Unstowing with `--dotfiles` was using the wrong variable to obtain the package path, and as a result having to perform an unnecessary call to `adjust_dotfile()`. So fix those at the same time. --- .gitignore | 2 +- MANIFEST | 1 - MANIFEST.SKIP | 2 +- Makefile.am | 2 +- lib/Stow.pm.in | 83 ++-------- t/dotfiles.t | 2 +- t/testutil.pm | 16 +- t/unstow.t | 357 +++++++++++++++++++++++++++++-------------- t/unstow_orig.t | 393 ------------------------------------------------ 9 files changed, 269 insertions(+), 589 deletions(-) delete mode 100755 t/unstow_orig.t diff --git a/.gitignore b/.gitignore index 81f5836..caf4ba3 100644 --- a/.gitignore +++ b/.gitignore @@ -10,7 +10,7 @@ /doc/stow.info /doc/version.texi /playground/ -tmp-testing-trees/ +tmp-testing-trees*/ _build/ autom4te.cache/ blib/ diff --git a/MANIFEST b/MANIFEST index 8f7a812..09cb2bf 100644 --- a/MANIFEST +++ b/MANIFEST @@ -50,7 +50,6 @@ t/stow.t t/rc_options.t t/testutil.pm t/unstow.t -t/unstow_orig.t tools/get-version THANKS TODO diff --git a/MANIFEST.SKIP b/MANIFEST.SKIP index 033f12a..522b3fd 100644 --- a/MANIFEST.SKIP +++ b/MANIFEST.SKIP @@ -83,7 +83,7 @@ ^doc/HOWTO-RELEASE$ # Avoid test files -tmp-testing-trees +tmp-testing-trees* ^.coveralls.yml ^.github/workflows/ ^.travis.yml diff --git a/Makefile.am b/Makefile.am index 7bd43bd..56abbef 100644 --- a/Makefile.am +++ b/Makefile.am @@ -51,7 +51,7 @@ DEFAULT_IGNORE_LIST = $(srcdir)/default-ignore-list doc_deps = $(info_TEXINFOS) doc/version.texi $(DEFAULT_IGNORE_LIST) TESTS_DIR = $(srcdir)/t -TESTS_OUT = tmp-testing-trees +TESTS_OUT = tmp-testing-trees tmp-testing-trees-compat TESTS_ENVIRONMENT = $(PERL) -Ibin -Ilib -I$(TESTS_DIR) # This is a kind of hack; TESTS needs to be set to ensure that the diff --git a/lib/Stow.pm.in b/lib/Stow.pm.in index e844253..40351bb 100755 --- a/lib/Stow.pm.in +++ b/lib/Stow.pm.in @@ -787,17 +787,15 @@ sub unstow_node { my $self = shift; my ($package, $target_subpath, $source) = @_; - my $pkg_path_from_cwd = join_paths($self->{stow_path}, $package, $target_subpath); - - debug(3, 1, "Unstowing $pkg_path_from_cwd"); + debug(3, 1, "Unstowing $source"); debug(4, 2, "target is $target_subpath"); # Does the target exist? if ($self->is_a_link($target_subpath)) { - $self->unstow_link_node($package, $target_subpath, $pkg_path_from_cwd); + $self->unstow_link_node($package, $target_subpath, $source); } - elsif ($self->{compat} && -d $target_subpath) { - $self->unstow_contents($package, $target_subpath, $pkg_path_from_cwd); + elsif (-d $target_subpath) { + $self->unstow_contents($package, $target_subpath, $source); # This action may have made the parent directory foldable if (my $parent_in_pkg = $self->foldable($target_subpath)) { @@ -805,16 +803,7 @@ sub unstow_node { } } elsif (-e $target_subpath) { - if ($self->{compat}) { - $self->conflict( - 'unstow', - $package, - "existing target is neither a link nor a directory: $target_subpath", - ); - } - else { - $self->unstow_existing_node($package, $target_subpath, $source); - } + debug(2, 1, "$target_subpath doesn't need to be unstowed"); } else { debug(2, 1, "$target_subpath did not exist to be unstowed"); @@ -859,7 +848,12 @@ sub unstow_link_node { # Does the existing $target_subpath actually point to anything? if (-e $existing_pkg_path_from_cwd) { - $self->unstow_valid_link($pkg_path_from_cwd, $target_subpath, $existing_pkg_path_from_cwd); + if ($existing_pkg_path_from_cwd eq $pkg_path_from_cwd) { + $self->do_unlink($target_subpath); + } + else { + debug(5, 3, "Ignoring link $target_subpath => $link_dest"); + } } else { debug(2, 0, "--- removing invalid link into a stow directory: $pkg_path_from_cwd"); @@ -867,61 +861,6 @@ sub unstow_link_node { } } -sub unstow_valid_link { - my $self = shift; - my ($pkg_path_from_cwd, $target_subpath, $existing_pkg_path_from_cwd) = @_; - # Does link points to the right place? - - # Adjust for dotfile if necessary. - if ($self->{dotfiles}) { - $existing_pkg_path_from_cwd = adjust_dotfile($existing_pkg_path_from_cwd); - } - - if ($existing_pkg_path_from_cwd eq $pkg_path_from_cwd) { - $self->do_unlink($target_subpath); - } - - # FIXME: we quietly ignore links that are stowed to a different - # package. - - #elsif (defer($target_subpath)) { - # debug(2, 0, "--- deferring to installation of: $target_subpath"); - #} - #elsif ($self->override($target_subpath)) { - # debug(2, 0, "--- overriding installation of: $target_subpath"); - # $self->do_unlink($target_subpath); - #} - #else { - # $self->conflict( - # 'unstow', - # $package, - # "existing target is stowed to a different package: " - # . "$target_subpath => $existing_source" - # ); - #} -} - -sub unstow_existing_node { - my $self = shift; - my ($package, $target_subpath, $source) = @_; - debug(4, 2, "Evaluate existing node: $target_subpath"); - if (-d $target_subpath) { - $self->unstow_contents($package, $target_subpath, $source); - - # This action may have made the parent directory foldable - if (my $parent_in_pkg = $self->foldable($target_subpath)) { - $self->fold_tree($target_subpath, $parent_in_pkg); - } - } - else { - $self->conflict( - 'unstow', - $package, - "existing target is neither a link nor a directory: $target_subpath", - ); - } -} - =head2 link_owned_by_package($target_subpath, $link_dest) Determine whether the given link points to a member of a stowed diff --git a/t/dotfiles.t b/t/dotfiles.t index 83874ca..5719eaa 100755 --- a/t/dotfiles.t +++ b/t/dotfiles.t @@ -187,7 +187,7 @@ subtest("simple unstow scenario", sub { $stow->plan_unstow('dotfiles'); $stow->process_tasks(); is($stow->get_conflict_count, 0); - ok(-f '../stow/dotfiles/dot-bar'); + ok(-f '../stow/dotfiles/dot-bar', 'package file untouched'); ok(! -e '.bar' => 'unstow a simple dotfile'); }); diff --git a/t/testutil.pm b/t/testutil.pm index b7c1549..2b4e097 100755 --- a/t/testutil.pm +++ b/t/testutil.pm @@ -24,7 +24,7 @@ package testutil; use strict; use warnings; -use Carp qw(croak); +use Carp qw(confess croak); use File::Basename; use File::Path qw(make_path remove_tree); use File::Spec; @@ -50,17 +50,21 @@ our $TEST_DIR = 'tmp-testing-trees'; our $ABS_TEST_DIR = File::Spec->rel2abs('tmp-testing-trees'); sub init_test_dirs { + my $test_dir = shift || $TEST_DIR; + my $abs_test_dir = File::Spec->rel2abs($test_dir); + # Create a run_from/ subdirectory for tests which want to run # from a separate directory outside the Stow directory or # target directory. for my $dir ("target", "stow", "run_from") { - my $path = "$TEST_DIR/$dir"; + my $path = "$test_dir/$dir"; -d $path and remove_tree($path); make_path($path); } # Don't let user's ~/.stow-global-ignore affect test results - $ENV{HOME} = $ABS_TEST_DIR; + $ENV{HOME} = $abs_test_dir; + return $abs_test_dir; } sub new_Stow { @@ -70,7 +74,11 @@ sub new_Stow { $opts{dir} ||= '../stow'; $opts{target} ||= '.'; $opts{test_mode} = 1; - return new Stow(%opts); + my $stow = eval { new Stow(%opts) }; + if ($@) { + confess "Error while trying to instantiate new Stow(%opts): $@"; + } + return $stow; } sub new_compat_Stow { diff --git a/t/unstow.t b/t/unstow.t index 15288c9..9fd7852 100755 --- a/t/unstow.t +++ b/t/unstow.t @@ -22,21 +22,70 @@ use strict; use warnings; -use Test::More tests => 32; +use File::Spec qw(make_path); +use POSIX qw(getcwd); +use Test::More tests => 49; use Test::Output; use English qw(-no_match_vars); use testutil; use Stow::Util qw(canon_path); -init_test_dirs(); -cd("$TEST_DIR/target"); +my $repo = getcwd(); -# Note that each of the following tests use a distinct set of files +init_test_dirs($TEST_DIR); -subtest("unstow a simple tree minimally", sub { +our $COMPAT_TEST_DIR = "${TEST_DIR}-compat"; +our $COMPAT_ABS_TEST_DIR = init_test_dirs($COMPAT_TEST_DIR); + +sub init_stow2 { + make_path('stow2'); # make our alternate stow dir a subdir of target + make_file('stow2/.stow'); +} + +# Run a subtest twice, with compat off then on, in parallel test trees. +# +# Params: $name[, $setup], $test_code +# +# $setup is an optional ref to an options hash to pass into the new +# Stow() constructor, or a ref to a sub which performs setup before +# the constructor gets called and then returns that options hash. +sub subtests { + my $name = shift; + my $setup = @_ == 2 ? shift : {}; + my $code = shift; + + $ENV{HOME} = $ABS_TEST_DIR; + cd($repo); + cd("$TEST_DIR/target"); + # cd first to allow setup to cd somewhere else. + my $opts = ref($setup) eq 'HASH' ? $setup : $setup->($TEST_DIR); + subtest($name, sub { + make_path($opts->{dir}) if $opts->{dir}; + my $stow = new_Stow(%$opts); + $code->($stow, $TEST_DIR); + }); + + $ENV{HOME} = $COMPAT_ABS_TEST_DIR; + cd($repo); + cd("$COMPAT_TEST_DIR/target"); + # cd first to allow setup to cd somewhere else. + $opts = ref $setup eq 'HASH' ? $setup : $setup->($COMPAT_TEST_DIR); + subtest("$name (compat mode)", sub { + make_path($opts->{dir}) if $opts->{dir}; + my $stow = new_compat_Stow(%$opts); + $code->($stow, $COMPAT_TEST_DIR); + }); +} + +sub plan_tests { + my ($stow, $count) = @_; + plan tests => $stow->{compat} ? $count + 2 : $count; +} + +subtests("unstow a simple tree minimally", sub { + my ($stow) = @_; plan tests => 3; - my $stow = new_Stow(); make_path('../stow/pkg1/bin1'); make_file('../stow/pkg1/bin1/file1'); @@ -44,14 +93,14 @@ subtest("unstow a simple tree minimally", sub { $stow->plan_unstow('pkg1'); $stow->process_tasks(); - is($stow->get_conflict_count, 0); + is($stow->get_conflict_count, 0, 'conflict count'); ok(-f '../stow/pkg1/bin1/file1'); ok(! -e 'bin1' => 'unstow a simple tree'); }); -subtest("unstow a simple tree from an existing directory", sub { +subtests("unstow a simple tree from an existing directory", sub { + my ($stow) = @_; plan tests => 3; - my $stow = new_Stow(); make_path('lib2'); make_path('../stow/pkg2/lib2'); @@ -59,16 +108,16 @@ subtest("unstow a simple tree from an existing directory", sub { make_link('lib2/file2', '../../stow/pkg2/lib2/file2'); $stow->plan_unstow('pkg2'); $stow->process_tasks(); - is($stow->get_conflict_count, 0); + is($stow->get_conflict_count, 0, 'conflict count'); ok(-f '../stow/pkg2/lib2/file2'); ok(-d 'lib2' => 'unstow simple tree from a pre-existing directory' ); }); -subtest("fold tree after unstowing", sub { +subtests("fold tree after unstowing", sub { + my ($stow) = @_; plan tests => 3; - my $stow = new_Stow(); make_path('bin3'); @@ -81,16 +130,16 @@ subtest("fold tree after unstowing", sub { make_link('bin3/file3b' => '../../stow/pkg3b/bin3/file3b'); # emulate stow $stow->plan_unstow('pkg3b'); $stow->process_tasks(); - is($stow->get_conflict_count, 0); + is($stow->get_conflict_count, 0, 'conflict count'); ok(-l 'bin3'); is(readlink('bin3'), '../stow/pkg3a/bin3' => 'fold tree after unstowing' ); }); -subtest("existing link is owned by stow but is invalid so it gets removed anyway", sub { +subtests("existing link is owned by stow but is invalid so it gets removed anyway", sub { + my ($stow) = @_; plan tests => 2; - my $stow = new_Stow(); make_path('bin4'); make_path('../stow/pkg4/bin4'); @@ -99,31 +148,57 @@ subtest("existing link is owned by stow but is invalid so it gets removed anyway $stow->plan_unstow('pkg4'); $stow->process_tasks(); - is($stow->get_conflict_count, 0); + is($stow->get_conflict_count, 0, 'conflict count'); ok(! -e 'bin4/file4' => q(remove invalid link owned by stow) ); }); subtest("Existing link is not owned by stow", sub { - plan tests => 1; + plan tests => 2; + $ENV{HOME} = $ABS_TEST_DIR; + cd($repo); + cd("$TEST_DIR/target"); my $stow = new_Stow(); make_path('../stow/pkg5/bin5'); make_invalid_link('bin5', '../not-stow'); $stow->plan_unstow('pkg5'); - my %conflicts = $stow->get_conflicts; - like( - $conflicts{unstow}{pkg5}[-1], - qr(existing target is not owned by stow) - => q(existing link not owned by stow) + is($stow->get_conflict_count, 1, 'conflict count'); + my %conflicts = $stow->get_conflicts(); + is_deeply( + \%conflicts, + { + 'unstow' => { + 'pkg5' => [ + 'existing target is not owned by stow: bin5 => ../not-stow' + ] + } + } + => "existing link not owned by stow" ); }); -subtest("Target already exists, is owned by stow, but points to a different package", sub { +subtest("Existing link is not owned by stow (compat mode)", sub { + plan tests => 2; + $ENV{HOME} = $COMPAT_ABS_TEST_DIR; + cd($repo); + cd("$COMPAT_TEST_DIR/target"); + my $stow = new_compat_Stow(); + + make_path('../stow/pkg5/bin5'); + make_invalid_link('bin5', '../not-stow'); + + $stow->plan_unstow('pkg5'); + # Unlike the non-compat test above, this doesn't cause any conflicts. + ok(-l 'bin5'); + is(readlink('bin5'), '../not-stow' => "existing link not owned by stow"); +}); + +subtests("Target already exists, is owned by stow, but points to a different package", sub { + my ($stow) = @_; plan tests => 3; - my $stow = new_Stow(); make_path('bin6'); make_path('../stow/pkg6a/bin6'); @@ -134,7 +209,7 @@ subtest("Target already exists, is owned by stow, but points to a different pack make_file('../stow/pkg6b/bin6/file6'); $stow->plan_unstow('pkg6b'); - is($stow->get_conflict_count, 0); + is($stow->get_conflict_count, 0, 'conflict count'); ok(-l 'bin6/file6'); is( readlink('bin6/file6'), @@ -143,19 +218,29 @@ subtest("Target already exists, is owned by stow, but points to a different pack ); }); -subtest("Don't unlink anything under the stow directory", sub { - plan tests => 4; - make_path('stow'); # make out stow dir a subdir of target - my $stow = new_Stow(dir => 'stow'); +subtests("Don't unlink anything under the stow directory", + sub { + make_path('stow'); + return { dir => 'stow' }; + # target dir defaults to parent of stow, which is target directory + }, + sub { + plan tests => 5; + my ($stow) = @_; - # emulate stowing into ourself (bizarre corner case or accident) + # Emulate stowing into ourself (bizarre corner case or accident): make_path('stow/pkg7a/stow/pkg7b'); make_file('stow/pkg7a/stow/pkg7b/file7b'); + # Make a package be a link to a package of the same name inside another package. make_link('stow/pkg7b', '../stow/pkg7a/stow/pkg7b'); - $stow->plan_unstow('pkg7b'); + stderr_like( + sub { $stow->plan_unstow('pkg7b'); }, + $stow->{compat} ? qr/WARNING: skipping target which was current stow directory stow/ : qr// + => "warn when unstowing from ourself" + ); is($stow->get_tasks, 0, 'no tasks to process when unstowing pkg7b'); - is($stow->get_conflict_count, 0); + is($stow->get_conflict_count, 0, 'conflict count'); ok(-l 'stow/pkg7b'); is( readlink('stow/pkg7b'), @@ -164,13 +249,16 @@ subtest("Don't unlink anything under the stow directory", sub { ); }); -subtest("Don't unlink any nodes under another stow directory", sub { +subtests("Don't unlink any nodes under another stow directory", + sub { + make_path('stow'); + return { dir => 'stow' }; + }, + sub { + my ($stow) = @_; plan tests => 5; - my $stow = new_Stow(dir => 'stow'); - - make_path('stow2'); # make our alternate stow dir a subdir of target - make_file('stow2/.stow'); + init_stow2(); # emulate stowing into ourself (bizarre corner case or accident) make_path('stow/pkg8a/stow2/pkg8b'); make_file('stow/pkg8a/stow2/pkg8b/file8b'); @@ -179,10 +267,10 @@ subtest("Don't unlink any nodes under another stow directory", sub { stderr_like( sub { $stow->plan_unstow('pkg8a'); }, qr/WARNING: skipping marked Stow directory stow2/ - => "unstowing from ourself should skip stow" + => "warn when skipping unstowing" ); is($stow->get_tasks, 0, 'no tasks to process when unstowing pkg8a'); - is($stow->get_conflict_count, 0); + is($stow->get_conflict_count, 0, 'conflict count'); ok(-l 'stow2/pkg8b'); is( readlink('stow2/pkg8b'), @@ -191,11 +279,24 @@ subtest("Don't unlink any nodes under another stow directory", sub { ); }); -subtest("overriding already stowed documentation", sub { - plan tests => 2; - my $stow = new_Stow(override => ['man9', 'info9']); - make_file('stow/.stow'); +# This will be used by subsequent tests +sub check_protected_dirs_skipped { + my ($stderr) = @_; + for my $dir (qw{stow stow2}) { + like($stderr, + qr/WARNING: skipping marked Stow directory $dir/ + => "warn when skipping marked directory $dir"); + } +} +subtests("overriding already stowed documentation", + {override => ['man9', 'info9']}, + sub { + my ($stow) = @_; + plan_tests($stow, 2); + + make_file('stow/.stow'); + init_stow2(); make_path('../stow/pkg9a/man9/man1'); make_file('../stow/pkg9a/man9/man1/file9.1'); make_path('man9/man1'); @@ -203,18 +304,22 @@ subtest("overriding already stowed documentation", sub { make_path('../stow/pkg9b/man9/man1'); make_file('../stow/pkg9b/man9/man1/file9.1'); - $stow->plan_unstow('pkg9b'); + my $stderr = stderr_from { $stow->plan_unstow('pkg9b') }; + check_protected_dirs_skipped($stderr) if $stow->{compat}; $stow->process_tasks(); - is($stow->get_conflict_count, 0); + is($stow->get_conflict_count, 0, 'conflict count'); ok(!-l 'man9/man1/file9.1' => 'overriding existing documentation files' ); }); -subtest("deferring to already stowed documentation", sub { - plan tests => 3; - my $stow = new_Stow(defer => ['man10', 'info10']); +subtests("deferring to already stowed documentation", + {defer => ['man10', 'info10']}, + sub { + my ($stow) = @_; + plan_tests($stow, 3); + init_stow2(); make_path('../stow/pkg10a/man10/man1'); make_file('../stow/pkg10a/man10/man1/file10a.1'); make_path('man10/man1'); @@ -225,12 +330,12 @@ subtest("deferring to already stowed documentation", sub { make_file('../stow/pkg10b/man10/man1/file10b.1'); make_link('man10/man1/file10b.1' => '../../../stow/pkg10b/man10/man1/file10b.1'); - make_path('../stow/pkg10c/man10/man1'); make_file('../stow/pkg10c/man10/man1/file10a.1'); - $stow->plan_unstow('pkg10c'); + my $stderr = stderr_from { $stow->plan_unstow('pkg10c') }; + check_protected_dirs_skipped($stderr) if $stow->{compat}; is($stow->get_tasks, 0, 'no tasks to process when unstowing pkg10c'); - is($stow->get_conflict_count, 0); + is($stow->get_conflict_count, 0, 'conflict count'); is( readlink('man10/man1/file10a.1'), '../../../stow/pkg10a/man10/man1/file10a.1' @@ -238,10 +343,13 @@ subtest("deferring to already stowed documentation", sub { ); }); -subtest("Ignore temp files", sub { - plan tests => 2; - my $stow = new_Stow(ignore => ['~', '\.#.*']); +subtests("Ignore temp files", + {ignore => ['~', '\.#.*']}, + sub { + my ($stow) = @_; + plan_tests($stow, 2); + init_stow2(); make_path('../stow/pkg12/man12/man1'); make_file('../stow/pkg12/man12/man1/file12.1'); make_file('../stow/pkg12/man12/man1/file12.1~'); @@ -249,103 +357,123 @@ subtest("Ignore temp files", sub { make_path('man12/man1'); make_link('man12/man1/file12.1' => '../../../stow/pkg12/man12/man1/file12.1'); - $stow->plan_unstow('pkg12'); + my $stderr = stderr_from { $stow->plan_unstow('pkg12') }; + check_protected_dirs_skipped($stderr) if $stow->{compat}; $stow->process_tasks(); - is($stow->get_conflict_count, 0); - ok(!-e 'man12/man1/file12.1' => 'ignore temp files'); + is($stow->get_conflict_count, 0, 'conflict count'); + ok(! -e 'man12/man1/file12.1' => 'man12/man1/file12.1 was unstowed'); }); -subtest("Unstow an already unstowed package", sub { - plan tests => 2; - my $stow = new_Stow(); - $stow->plan_unstow('pkg12'); +subtests("Unstow an already unstowed package", sub { + my ($stow) = @_; + plan_tests($stow, 2); + + my $stderr = stderr_from { $stow->plan_unstow('pkg12') }; + check_protected_dirs_skipped($stderr) if $stow->{compat}; is($stow->get_tasks, 0, 'no tasks to process when unstowing pkg12'); - is( - $stow->get_conflict_count, 0 - => 'unstow already unstowed package pkg12' - ); + is($stow->get_conflict_count, 0, 'conflict count'); }); -subtest("Unstow a never stowed package", sub { +subtests("Unstow a never stowed package", sub { + my ($stow) = @_; plan tests => 2; - eval { remove_dir("$TEST_DIR/target"); }; - mkdir("$TEST_DIR/target"); + eval { remove_dir($stow->{target}); }; + mkdir($stow->{target}); - my $stow = new_Stow(); $stow->plan_unstow('pkg12'); is($stow->get_tasks, 0, 'no tasks to process when unstowing pkg12 which was never stowed'); - is( - $stow->get_conflict_count, - 0 - => 'unstow never stowed package pkg12' - ); + is($stow->get_conflict_count, 0, 'conflict count'); }); -subtest("Unstowing when target contains a real file shouldn't be an issue", sub { - plan tests => 3; +subtests("Unstowing when target contains real files shouldn't be an issue", sub { + my ($stow) = @_; + plan tests => 4; + + # Test both a file which do / don't overlap with the package + make_path('man12/man1'); + make_file('man12/man1/alien'); make_file('man12/man1/file12.1'); - my $stow = new_Stow(); $stow->plan_unstow('pkg12'); is($stow->get_tasks, 0, 'no tasks to process when unstowing pkg12 for third time'); - my %conflicts = $stow->get_conflicts; - is($stow->get_conflict_count, 1); - like( - $conflicts{unstow}{pkg12}[0], - qr!existing target is neither a link nor a directory: man12/man1/file12\.1! - => 'unstow pkg12 for third time' - ); + is($stow->get_conflict_count, 0, 'conflict count'); + ok(-f 'man12/man1/alien', 'alien untouched'); + ok(-f 'man12/man1/file12.1', 'file overlapping with pkg untouched'); }); -subtest("unstow a simple tree minimally when cwd isn't target", sub { +subtests("unstow a simple tree minimally when cwd isn't target", + sub { + my $test_dir = shift; + cd($repo); + return { + dir => "$test_dir/stow", + target => "$test_dir/target" + } + }, + sub { + my ($stow, $test_dir) = @_; plan tests => 3; - cd('../..'); - my $stow = new_Stow(dir => "$TEST_DIR/stow", target => "$TEST_DIR/target"); - make_path("$TEST_DIR/stow/pkg13/bin13"); - make_file("$TEST_DIR/stow/pkg13/bin13/file13"); - make_link("$TEST_DIR/target/bin13", '../stow/pkg13/bin13'); + make_path("$test_dir/stow/pkg13/bin13"); + make_file("$test_dir/stow/pkg13/bin13/file13"); + make_link("$test_dir/target/bin13", '../stow/pkg13/bin13'); $stow->plan_unstow('pkg13'); $stow->process_tasks(); - is($stow->get_conflict_count, 0); - ok(-f "$TEST_DIR/stow/pkg13/bin13/file13"); - ok(! -e "$TEST_DIR/target/bin13" => 'unstow a simple tree'); + is($stow->get_conflict_count, 0, 'conflict count'); + ok(-f "$test_dir/stow/pkg13/bin13/file13", 'package file untouched'); + ok(! -e "$test_dir/target/bin13" => 'bin13/ unstowed'); }); -subtest("unstow a simple tree minimally with absolute stow dir when cwd isn't target", sub { +subtests("unstow a simple tree minimally with absolute stow dir when cwd isn't target", + sub { + my $test_dir = shift; + cd($repo); + return { + dir => canon_path("$test_dir/stow"), + target => "$test_dir/target" + }; + }, + sub { plan tests => 3; - my $stow = new_Stow(dir => canon_path("$TEST_DIR/stow"), - target => "$TEST_DIR/target"); + my ($stow, $test_dir) = @_; - make_path("$TEST_DIR/stow/pkg14/bin14"); - make_file("$TEST_DIR/stow/pkg14/bin14/file14"); - make_link("$TEST_DIR/target/bin14", '../stow/pkg14/bin14'); + make_path("$test_dir/stow/pkg14/bin14"); + make_file("$test_dir/stow/pkg14/bin14/file14"); + make_link("$test_dir/target/bin14", '../stow/pkg14/bin14'); $stow->plan_unstow('pkg14'); $stow->process_tasks(); - is($stow->get_conflict_count, 0); - ok(-f "$TEST_DIR/stow/pkg14/bin14/file14"); - ok(! -e "$TEST_DIR/target/bin14" + is($stow->get_conflict_count, 0, 'conflict count'); + ok(-f "$test_dir/stow/pkg14/bin14/file14"); + ok(! -e "$test_dir/target/bin14" => 'unstow a simple tree with absolute stow dir' ); }); -subtest("unstow a simple tree minimally with absolute stow AND target dirs when cwd isn't target", sub { +subtests("unstow a simple tree minimally with absolute stow AND target dirs when cwd isn't target", + sub { + my $test_dir = shift; + cd($repo); + return { + dir => canon_path("$test_dir/stow"), + target => canon_path("$test_dir/target") + }; + }, + sub { + my ($stow, $test_dir) = @_; plan tests => 3; - my $stow = new_Stow(dir => canon_path("$TEST_DIR/stow"), - target => canon_path("$TEST_DIR/target")); - make_path("$TEST_DIR/stow/pkg15/bin15"); - make_file("$TEST_DIR/stow/pkg15/bin15/file15"); - make_link("$TEST_DIR/target/bin15", '../stow/pkg15/bin15'); + make_path("$test_dir/stow/pkg15/bin15"); + make_file("$test_dir/stow/pkg15/bin15/file15"); + make_link("$test_dir/target/bin15", '../stow/pkg15/bin15'); $stow->plan_unstow('pkg15'); $stow->process_tasks(); - is($stow->get_conflict_count, 0); - ok(-f "$TEST_DIR/stow/pkg15/bin15/file15"); - ok(! -e "$TEST_DIR/target/bin15" + is($stow->get_conflict_count, 0, 'conflict count'); + ok(-f "$test_dir/stow/pkg15/bin15/file15"); + ok(! -e "$test_dir/target/bin15" => 'unstow a simple tree with absolute stow and target dirs' ); }); @@ -432,7 +560,6 @@ is_dir_not_symlink('no-folding-shared'); is_dir_not_symlink('no-folding-shared2'); is_dir_not_symlink('no-folding-shared2/subdir'); - -# Todo -# -# Test cleaning up subdirs with --paranoid option +# subtests("Test cleaning up subdirs with --paranoid option", sub { +# TODO +# }); diff --git a/t/unstow_orig.t b/t/unstow_orig.t deleted file mode 100755 index 9d62bd9..0000000 --- a/t/unstow_orig.t +++ /dev/null @@ -1,393 +0,0 @@ -#!/usr/bin/perl -# -# This file is part of GNU Stow. -# -# GNU Stow is free software: you can redistribute it and/or modify it -# under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# GNU Stow is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see https://www.gnu.org/licenses/. - -# -# Test unstowing packages in compat mode -# - -use strict; -use warnings; - -use File::Spec qw(make_path); -use Test::More tests => 17; -use Test::Output; -use English qw(-no_match_vars); - -use testutil; -use Stow::Util qw(canon_path); - -init_test_dirs(); -cd("$TEST_DIR/target"); - -# Note that each of the following tests use a distinct set of files - -my $stow; -my %conflicts; - -subtest("unstow a simple tree minimally", sub { - plan tests => 3; - my $stow = new_compat_Stow(); - - make_path('../stow/pkg1/bin1'); - make_file('../stow/pkg1/bin1/file1'); - make_link('bin1', '../stow/pkg1/bin1'); - - $stow->plan_unstow('pkg1'); - $stow->process_tasks(); - is($stow->get_conflict_count, 0); - ok(-f '../stow/pkg1/bin1/file1'); - ok(! -e 'bin1' => 'unstow a simple tree'); -}); - -subtest("unstow a simple tree from an existing directory", sub { - plan tests => 3; - my $stow = new_compat_Stow(); - - make_path('lib2'); - make_path('../stow/pkg2/lib2'); - make_file('../stow/pkg2/lib2/file2'); - make_link('lib2/file2', '../../stow/pkg2/lib2/file2'); - $stow->plan_unstow('pkg2'); - $stow->process_tasks(); - is($stow->get_conflict_count, 0); - ok(-f '../stow/pkg2/lib2/file2'); - ok(-d 'lib2' - => 'unstow simple tree from a pre-existing directory' - ); -}); - -subtest("fold tree after unstowing", sub { - plan tests => 3; - my $stow = new_compat_Stow(); - - make_path('bin3'); - - make_path('../stow/pkg3a/bin3'); - make_file('../stow/pkg3a/bin3/file3a'); - make_link('bin3/file3a' => '../../stow/pkg3a/bin3/file3a'); # emulate stow - - make_path('../stow/pkg3b/bin3'); - make_file('../stow/pkg3b/bin3/file3b'); - make_link('bin3/file3b' => '../../stow/pkg3b/bin3/file3b'); # emulate stow - $stow->plan_unstow('pkg3b'); - $stow->process_tasks(); - is($stow->get_conflict_count, 0); - ok(-l 'bin3'); - is(readlink('bin3'), '../stow/pkg3a/bin3' - => 'fold tree after unstowing' - ); -}); - -subtest("existing link is owned by stow but is invalid so it gets removed anyway", sub { - plan tests => 2; - my $stow = new_compat_Stow(); - - make_path('bin4'); - make_path('../stow/pkg4/bin4'); - make_file('../stow/pkg4/bin4/file4'); - make_invalid_link('bin4/file4', '../../stow/pkg4/bin4/does-not-exist'); - - $stow->plan_unstow('pkg4'); - $stow->process_tasks(); - is($stow->get_conflict_count, 0); - ok(! -e 'bin4/file4' - => q(remove invalid link owned by stow) - ); -}); - -subtest("Existing link is not owned by stow", sub { - plan tests => 2; - my $stow = new_compat_Stow(); - - make_path('../stow/pkg5/bin5'); - make_invalid_link('bin5', '../not-stow'); - - $stow->plan_unstow('pkg5'); - # Unlike the corresponding stow_contents.t test, this doesn't - # cause any conflicts. - # - #like( - # $Conflicts[-1], qr(can't unlink.*not owned by stow) - # => q(existing link not owned by stow) - #); - ok(-l 'bin5'); - is( - readlink('bin5'), - '../not-stow' - => q(existing link not owned by stow) - ); -}); - -subtest("Target already exists, is owned by stow, but points to a different package", sub { - plan tests => 3; - my $stow = new_compat_Stow(); - - make_path('bin6'); - make_path('../stow/pkg6a/bin6'); - make_file('../stow/pkg6a/bin6/file6'); - make_link('bin6/file6', '../../stow/pkg6a/bin6/file6'); - - make_path('../stow/pkg6b/bin6'); - make_file('../stow/pkg6b/bin6/file6'); - - $stow->plan_unstow('pkg6b'); - is($stow->get_conflict_count, 0); - ok(-l 'bin6/file6'); - is( - readlink('bin6/file6'), - '../../stow/pkg6a/bin6/file6' - => q(ignore existing link that points to a different package) - ); -}); - -subtest("Don't unlink anything under the stow directory", sub { - plan tests => 5; - make_path('stow'); # make stow dir a subdir of target - my $stow = new_compat_Stow(dir => 'stow'); - - # emulate stowing into ourself (bizarre corner case or accident) - make_path('stow/pkg7a/stow/pkg7b'); - make_file('stow/pkg7a/stow/pkg7b/file7b'); - make_link('stow/pkg7b', '../stow/pkg7a/stow/pkg7b'); - - stderr_like( - sub { $stow->plan_unstow('pkg7b'); }, - qr/WARNING: skipping target which was current stow directory stow/ - => "warn when unstowing from ourself" - ); - is($stow->get_tasks, 0, 'no tasks to process when unstowing pkg7b'); - is($stow->get_conflict_count, 0); - ok(-l 'stow/pkg7b'); - is( - readlink('stow/pkg7b'), - '../stow/pkg7a/stow/pkg7b' - => q(don't unlink any nodes under the stow directory) - ); -}); - -subtest("Don't unlink any nodes under another stow directory", sub { - plan tests => 5; - my $stow = new_compat_Stow(dir => 'stow'); - - make_path('stow2'); # make our alternate stow dir a subdir of target - make_file('stow2/.stow'); - - # emulate stowing into ourself (bizarre corner case or accident) - make_path('stow/pkg8a/stow2/pkg8b'); - make_file('stow/pkg8a/stow2/pkg8b/file8b'); - make_link('stow2/pkg8b', '../stow/pkg8a/stow2/pkg8b'); - - stderr_like( - sub { $stow->plan_unstow('pkg8a'); }, - qr/WARNING: skipping target which was current stow directory stow/ - => "warn when skipping unstowing" - ); - is($stow->get_tasks, 0, 'no tasks to process when unstowing pkg8a'); - is($stow->get_conflict_count, 0); - ok(-l 'stow2/pkg8b'); - is( - readlink('stow2/pkg8b'), - '../stow/pkg8a/stow2/pkg8b' - => q(don't unlink any nodes under another stow directory) - ); -}); - -# This will be used by subsequent tests -sub check_protected_dirs_skipped { - my $coderef = shift; - my $stderr = stderr_from { $coderef->(); }; - for my $dir (qw{stow stow2}) { - like($stderr, - qr/WARNING: skipping marked Stow directory $dir/ - => "warn when skipping marked directory $dir"); - } -} - -subtest("overriding already stowed documentation", sub { - plan tests => 4; - - my $stow = new_compat_Stow(override => ['man9', 'info9']); - make_file('stow/.stow'); - - make_path('../stow/pkg9a/man9/man1'); - make_file('../stow/pkg9a/man9/man1/file9.1'); - make_path('man9/man1'); - make_link('man9/man1/file9.1' => '../../../stow/pkg9a/man9/man1/file9.1'); # emulate stow - - make_path('../stow/pkg9b/man9/man1'); - make_file('../stow/pkg9b/man9/man1/file9.1'); - check_protected_dirs_skipped( - sub { $stow->plan_unstow('pkg9b'); } - ); - $stow->process_tasks(); - is($stow->get_conflict_count, 0); - ok(!-l 'man9/man1/file9.1' - => 'overriding existing documentation files' - ); -}); - -subtest("deferring to already stowed documentation", sub { - plan tests => 5; - my $stow = new_compat_Stow(defer => ['man10', 'info10']); - - make_path('../stow/pkg10a/man10/man1'); - make_file('../stow/pkg10a/man10/man1/file10a.1'); - make_path('man10/man1'); - make_link('man10/man1/file10a.1' => '../../../stow/pkg10a/man10/man1/file10a.1'); - - # need this to block folding - make_path('../stow/pkg10b/man10/man1'); - make_file('../stow/pkg10b/man10/man1/file10b.1'); - make_link('man10/man1/file10b.1' => '../../../stow/pkg10b/man10/man1/file10b.1'); - - make_path('../stow/pkg10c/man10/man1'); - make_file('../stow/pkg10c/man10/man1/file10a.1'); - check_protected_dirs_skipped( - sub { $stow->plan_unstow('pkg10c'); } - ); - is($stow->get_tasks, 0, 'no tasks to process when unstowing pkg10c'); - is($stow->get_conflict_count, 0); - is( - readlink('man10/man1/file10a.1'), - '../../../stow/pkg10a/man10/man1/file10a.1' - => 'defer to existing documentation files' - ); -}); - -subtest("Ignore temp files", sub { - plan tests => 4; - my $stow = new_compat_Stow(ignore => ['~', '\.#.*']); - - make_path('../stow/pkg12/man12/man1'); - make_file('../stow/pkg12/man12/man1/file12.1'); - make_file('../stow/pkg12/man12/man1/file12.1~'); - make_file('../stow/pkg12/man12/man1/.#file12.1'); - make_path('man12/man1'); - make_link('man12/man1/file12.1' => '../../../stow/pkg12/man12/man1/file12.1'); - - check_protected_dirs_skipped( - sub { $stow->plan_unstow('pkg12'); } - ); - $stow->process_tasks(); - is($stow->get_conflict_count, 0); - ok(!-e 'man12/man1/file12.1' => 'ignore temp files'); -}); - -subtest("Unstow an already unstowed package", sub { - plan tests => 4; - my $stow = new_compat_Stow(); - check_protected_dirs_skipped( - sub { $stow->plan_unstow('pkg12'); } - ); - is($stow->get_tasks, 0, 'no tasks to process when unstowing pkg12'); - is( - $stow->get_conflict_count, - 0 - => 'unstow already unstowed package pkg12' - ); -}); - -subtest("Unstow a never stowed package", sub { - plan tests => 4; - - eval { remove_dir("$TEST_DIR/target"); }; - mkdir("$TEST_DIR/target"); - - my $stow = new_compat_Stow(); - check_protected_dirs_skipped( - sub { $stow->plan_unstow('pkg12'); } - ); - is($stow->get_tasks, 0, 'no tasks to process when unstowing pkg12 which was never stowed'); - is( - $stow->get_conflict_count, - 0 - => 'unstow never stowed package pkg12' - ); -}); - -subtest("Unstowing when target contains a real file shouldn't be an issue", sub { - plan tests => 5; - make_file('man12/man1/file12.1'); - - my $stow = new_compat_Stow(); - check_protected_dirs_skipped( - sub { $stow->plan_unstow('pkg12'); } - ); - is($stow->get_tasks, 0, 'no tasks to process when unstowing pkg12 for third time'); - %conflicts = $stow->get_conflicts; - is($stow->get_conflict_count, 1); - like( - $conflicts{unstow}{pkg12}[0], - qr!existing target is neither a link nor a directory: man12/man1/file12\.1! - => 'unstow pkg12 for third time' - ); -}); - -subtest("unstow a simple tree minimally when cwd isn't target", sub { - plan tests => 3; - cd('../..'); - my $stow = new_Stow(dir => "$TEST_DIR/stow", target => "$TEST_DIR/target"); - - make_path("$TEST_DIR/stow/pkg13/bin13"); - make_file("$TEST_DIR/stow/pkg13/bin13/file13"); - make_link("$TEST_DIR/target/bin13", '../stow/pkg13/bin13'); - - $stow->plan_unstow('pkg13'); - $stow->process_tasks(); - is($stow->get_conflict_count, 0); - ok(-f "$TEST_DIR/stow/pkg13/bin13/file13"); - ok(! -e "$TEST_DIR/target/bin13" => 'unstow a simple tree'); -}); - -subtest("unstow a simple tree minimally with absolute stow dir when cwd isn't target", sub { - plan tests => 3; - my $stow = new_Stow(dir => canon_path("$TEST_DIR/stow"), - target => "$TEST_DIR/target"); - - make_path("$TEST_DIR/stow/pkg14/bin14"); - make_file("$TEST_DIR/stow/pkg14/bin14/file14"); - make_link("$TEST_DIR/target/bin14", '../stow/pkg14/bin14'); - - $stow->plan_unstow('pkg14'); - $stow->process_tasks(); - is($stow->get_conflict_count, 0); - ok(-f "$TEST_DIR/stow/pkg14/bin14/file14"); - ok(! -e "$TEST_DIR/target/bin14" - => 'unstow a simple tree with absolute stow dir' - ); -}); - -subtest("unstow a simple tree minimally with absolute stow AND target dirs when cwd isn't target", sub { - plan tests => 3; - my $stow = new_Stow(dir => canon_path("$TEST_DIR/stow"), - target => canon_path("$TEST_DIR/target")); - make_path("$TEST_DIR/stow/pkg15/bin15"); - make_file("$TEST_DIR/stow/pkg15/bin15/file15"); - make_link("$TEST_DIR/target/bin15", '../stow/pkg15/bin15'); - - $stow->plan_unstow('pkg15'); - $stow->process_tasks(); - is($stow->get_conflict_count, 0); - ok(-f "$TEST_DIR/stow/pkg15/bin15/file15"); - ok(! -e "$TEST_DIR/target/bin15" - => 'unstow a simple tree with absolute stow and target dirs' - ); -}); - -# subtest("Test cleaning up subdirs with --paranoid option", sub { -# TODO -# }); From 744ba651f50341a998c97341809eeda4f8e181e0 Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Sun, 7 Apr 2024 13:08:56 +0100 Subject: [PATCH 469/482] unstow_link_node(): don't register conflicts when unstowing unowned links --- lib/Stow.pm.in | 17 ++++------------- t/unstow.t | 41 ++++++----------------------------------- 2 files changed, 10 insertions(+), 48 deletions(-) diff --git a/lib/Stow.pm.in b/lib/Stow.pm.in index 40351bb..7647a42 100755 --- a/lib/Stow.pm.in +++ b/lib/Stow.pm.in @@ -830,19 +830,10 @@ sub unstow_link_node { my ($existing_pkg_path_from_cwd, $existing_stow_path, $existing_package) = $self->find_stowed_path($target_subpath, $link_dest); if (not $existing_pkg_path_from_cwd) { - if ($self->{compat}) { - # We're traversing the target tree not the package tree, - # so we definitely expect to find stuff not owned by stow. - # Therefore we can't flag a conflict. - return; - } - else { - $self->conflict( - 'unstow', - $package, - "existing target is not owned by stow: $target_subpath => $link_dest" - ); - } + # The user is unstowing the package, so they don't want links to it. + # Therefore we should allow them to have a link pointing elsewhere + # which would conflict with the package if they were stowing it. + debug(5, 3, "Ignoring unowned link $target_subpath => $link_dest"); return; } diff --git a/t/unstow.t b/t/unstow.t index 9fd7852..1c7f967 100755 --- a/t/unstow.t +++ b/t/unstow.t @@ -154,46 +154,17 @@ subtests("existing link is owned by stow but is invalid so it gets removed anywa ); }); -subtest("Existing link is not owned by stow", sub { - plan tests => 2; - $ENV{HOME} = $ABS_TEST_DIR; - cd($repo); - cd("$TEST_DIR/target"); - my $stow = new_Stow(); +subtests("Existing invalid link is not owned by stow", sub { + my ($stow) = @_; + plan tests => 3; make_path('../stow/pkg5/bin5'); make_invalid_link('bin5', '../not-stow'); $stow->plan_unstow('pkg5'); - is($stow->get_conflict_count, 1, 'conflict count'); - my %conflicts = $stow->get_conflicts(); - is_deeply( - \%conflicts, - { - 'unstow' => { - 'pkg5' => [ - 'existing target is not owned by stow: bin5 => ../not-stow' - ] - } - } - => "existing link not owned by stow" - ); -}); - -subtest("Existing link is not owned by stow (compat mode)", sub { - plan tests => 2; - $ENV{HOME} = $COMPAT_ABS_TEST_DIR; - cd($repo); - cd("$COMPAT_TEST_DIR/target"); - my $stow = new_compat_Stow(); - - make_path('../stow/pkg5/bin5'); - make_invalid_link('bin5', '../not-stow'); - - $stow->plan_unstow('pkg5'); - # Unlike the non-compat test above, this doesn't cause any conflicts. - ok(-l 'bin5'); - is(readlink('bin5'), '../not-stow' => "existing link not owned by stow"); + is($stow->get_conflict_count, 0, 'conflict count'); + ok(-l 'bin5', 'invalid link not removed'); + is(readlink('bin5'), '../not-stow' => "invalid link not changed"); }); subtests("Target already exists, is owned by stow, but points to a different package", sub { From afa50077c98b6fc0b13530912b2c1ea35603ee32 Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Mon, 1 Apr 2024 22:50:58 +0100 Subject: [PATCH 470/482] dotfiles: switch {un,}stow_{contents,node}() recursion parameters Stow walks the package and target tree hierarchies by using mutually recursive pairs of functions: - `stow_contents()` and `stow_node()` - `unstow_contents()` and `unstow_node()` As Stow runs its planning from the target directory (`plan_*()` both call `within_target_do()`), previously the parameters for these included: - `$target_subpath` (or `$target_subdir` in the `*_node()` functions): the relative path from the target top-level directory to the target subdirectory (initially `.` at the beginning of recursion). For example, this could be `dir1/subdir1/file1`. - `$source`: the relative path from the target _subdirectory_ (N.B. _not_ top-level directory) to the package subdirectory. For example, if the relative path to the Stow directory is `../stow`, this could be `../../../stow/pkg1/dir1/subdir1/file1`. This is used when stowing to construct a new link, or when unstowing to detect whether the link can be unstowed. Each time it descends into a further subdirectory of the target and package, it appends the new path segment onto both of these, and also prefixes `$source` with another `..`. When the `--dotfiles` parameter is enabled, it adjusts `$target_subdir`, performing the `dot-foo` => `.foo` adjustment on all segments of the path in one go. In this case, `$target_subpath` could be something like `.dir1/subdir1/file1`, and the corresponding `$source` could be something like `../../../stow/pkg1/dot-dir1/subdir1/file1`. However this doesn't leave an easy way to obtain the relative path from the target _top-level_ directory to the package subdirectory (i.e. `../stow/pkg1/dot-dir1/subdir1/file1`), which is needed for checking its existence and if necessary iterating over its contents. The current implementation solves this by including an extra `$level` parameter which tracks the recursion depth, and uses that to strip the right number of leading path segments off the front of `$source`. (In the above example, it would remove `../..`.) This implementation isn't the most elegant because: - It involves adding things to `$source` and then removing them again. - It performs the `dot-` => `.` adjustment on every path segment at each level, which is overkill, since when recursing down a level, only adjustment on the final subdirectory is required since the higher segments have already had any required adjustment. This in turn requires `adjust_dotfile` to be more complex than it needs to be. It also prevents a potential future where we might want Stow to optionally start iterating from within a subdirectory of the whole package install image / target tree, avoiding adjustment at higher levels and only doing it at the levels below the starting point. - It requires passing an extra `$level` parameter which can be automatically calculated simply by counting the number of slashes in `$target_subpath`. So change the `$source` recursion parameter to instead track the relative path from the top-level package directory to the package subdirectory or file being considered for (un)stowing, and rename it to avoid the ambiguity caused by the word "source". Also automatically calculate the depth simply by counting the number of slashes, and reconstruct `$source` when needed by combining the relative path to the Stow directory with the package name and `$target_subpath`. Closes #33. --- lib/Stow.pm.in | 255 +++++++++++++++++++++++++++----------------- lib/Stow/Util.pm.in | 14 +-- t/dotfiles.t | 13 +-- 3 files changed, 162 insertions(+), 120 deletions(-) diff --git a/lib/Stow.pm.in b/lib/Stow.pm.in index 7647a42..2c94622 100755 --- a/lib/Stow.pm.in +++ b/lib/Stow.pm.in @@ -284,7 +284,7 @@ sub plan_unstow { $self->unstow_contents( $package, '.', - $pkg_path, + '.', ); debug(2, 0, "Planning unstow of package $package... done"); $self->{action_count}++; @@ -319,8 +319,7 @@ sub plan_stow { $self->{stow_path}, $package, '.', - $pkg_path, # source from target - 0, + '.', ); debug(2, 0, "Planning stow of package $package... done"); $self->{action_count}++; @@ -361,7 +360,7 @@ sub within_target_do { debug(3, 0, "cwd restored to $cwd"); } -=head2 stow_contents($stow_path, $package, $target_subdir, $source) +=head2 stow_contents($stow_path, $package, $pkg_subdir, $target_subdir) Stow the contents of the given directory. @@ -379,55 +378,48 @@ Stow Directories" section of the manual). The package whose contents are being stowed. +=item $pkg_subdir + +Subdirectory of the installation image in the package directory which +needs stowing as a symlink which points to it. This is relative to +the top-level package directory. + =item $target_subdir -Subpath relative to package directory which needs stowing as a symlink -at subpath relative to target directory. - -=item $source - -Relative path from the (sub)dir of target to symlink source. +Subdirectory of the target directory which either needs a symlink to the +corresponding package subdirectory in the installation image, or if +it's an existing directory, it's an unfolded tree which may need to +be folded or recursed into. =back C and C are mutually recursive. -C<$source> and C<$target_subdir> are used for creating the symlink. =cut sub stow_contents { my $self = shift; - my ($stow_path, $package, $target_subdir, $source, $level) = @_; + my ($stow_path, $package, $pkg_subdir, $target_subdir) = @_; + + return if $self->should_skip_target($pkg_subdir); + + my $cwd = getcwd(); + my $msg = "Stowing contents of $stow_path / $package / $pkg_subdir (cwd=$cwd)"; + $msg =~ s!$ENV{HOME}(/|$)!~$1!g; + debug(3, 0, $msg); + debug(4, 1, "target subdir is $target_subdir"); # Calculate the path to the package directory or sub-directory # whose contents need to be stowed, relative to the current # (target directory). This is needed so that we can check it's a # valid directory, and can read its contents to iterate over them. - # - # Note that $source refers to the same package (sub-)directory, - # but instead it's relative to the target directory or - # sub-directory where the symlink will be installed when the plans - # are executed. + my $pkg_path_from_cwd = join_paths($stow_path, $package, $pkg_subdir); - # Remove leading $level times .. from $source - my $n = 0; - my $path = join '/', map { (++$n <= $level) ? ( ) : $_ } (split m{/+}, $source); - - return if $self->should_skip_target($target_subdir); - - my $cwd = getcwd(); - my $msg = "Stowing contents of $path (cwd=$cwd)"; - $msg =~ s!$ENV{HOME}(/|$)!~$1!g; - debug(3, 0, $msg); - debug(4, 1, "=> $source"); - - error("stow_contents() called with non-directory package path: $path") - unless -d $path; error("stow_contents() called with non-directory target: $target_subdir") unless $self->is_a_node($target_subdir); - opendir my $DIR, $path - or error("cannot read directory: $path ($!)"); + opendir my $DIR, $pkg_path_from_cwd + or error("cannot read directory: $pkg_path_from_cwd ($!)"); my @listing = readdir $DIR; closedir $DIR; @@ -435,26 +427,31 @@ sub stow_contents { for my $node (sort @listing) { next NODE if $node eq '.'; next NODE if $node eq '..'; - my $node_target = join_paths($target_subdir, $node); - next NODE if $self->ignore($stow_path, $package, $node_target); + + my $package_node_path = join_paths($pkg_subdir, $node); + my $target_node = $node; if ($self->{dotfiles}) { - my $adj_node_target = adjust_dotfile($node_target); - debug(4, 1, "Adjusting: $node_target => $adj_node_target"); - $node_target = $adj_node_target; + my $adjusted = adjust_dotfile($node); + if ($adjusted ne $node) { + debug(4, 1, "Adjusting: $node => $adjusted"); + $target_node = $adjusted; + } } + my $target_node_path = join_paths($target_subdir, $target_node); + + next NODE if $self->ignore($stow_path, $package, $target_node_path); $self->stow_node( $stow_path, $package, - $node_target, # target, potentially adjusted for dot- prefix - join_paths($source, $node), # source - $level + $package_node_path, + $target_node_path ); } } -=head2 stow_node($stow_path, $package, $target_subpath, $source) +=head2 stow_node($stow_path, $package, $pkg_subpath, $target_subpath) Stow the given node @@ -470,16 +467,20 @@ Stow Directories" section of the manual). =item $package -The package containing the node being stowed +The package containing the node being stowed. + +=item $pkg_subpath + +Subpath of the installation image in the package directory which needs +stowing as a symlink which points to it. This is relative to the +top-level package directory. =item $target_subpath -Subpath relative to package directory of node which needs stowing as a -symlink at subpath relative to target directory. - -=item $source - -Relative path to symlink source from the dir of target. +Subpath of the target directory which either needs a symlink to the +corresponding package subpathectory in the installation image, or if +it's an existing directory, it's an unfolded tree which may need to +be folded or recursed into. =back @@ -489,27 +490,42 @@ C and C are mutually recursive. sub stow_node { my $self = shift; - my ($stow_path, $package, $target_subpath, $source, $level) = @_; + my ($stow_path, $package, $pkg_subpath, $target_subpath) = @_; - my $path = join_paths($stow_path, $package, $target_subpath); - - debug(3, 0, "Stowing entry $stow_path / $package / $target_subpath"); - debug(4, 1, "=> $source"); + debug(3, 0, "Stowing entry $stow_path / $package / $pkg_subpath"); + # Calculate the path to the package directory or sub-directory + # whose contents need to be stowed, relative to the current + # (target directory). This is needed so that we can check it's a + # valid directory, and can read its contents to iterate over them. + my $pkg_path_from_cwd = join_paths($stow_path, $package, $pkg_subpath); # Don't try to stow absolute symlinks (they can't be unstowed) - if (-l $source) { - my $link_dest = $self->read_a_link($source); + if (-l $pkg_path_from_cwd) { + my $link_dest = $self->read_a_link($pkg_path_from_cwd); if ($link_dest =~ m{\A/}) { $self->conflict( 'stow', $package, - "source is an absolute symlink $source => $link_dest" + "source is an absolute symlink $pkg_path_from_cwd => $link_dest" ); debug(3, 0, "Absolute symlinks cannot be unstowed"); return; } } + # How many directories deep are we? + my $level = ($pkg_subpath =~ tr,/,,); + debug(2, 1, "level of $pkg_subpath is $level"); + + # Calculate the destination of the symlink which would need to be + # installed within this directory in the absence of folding. This + # is relative to the target (sub-)directory where the symlink will + # be installed when the plans are executed, so as we descend down + # into the package hierarchy, it will have extra "../" segments + # prefixed to it. + my $link_dest = join_paths('../' x $level, $pkg_path_from_cwd); + debug(4, 1, "link destination $link_dest"); + # Does the target already exist? if ($self->is_a_link($target_subpath)) { # Where is the link pointing? @@ -533,8 +549,8 @@ sub stow_node { # Does the existing $target_subpath actually point to anything? if ($self->is_a_node($existing_pkg_path_from_cwd)) { - if ($existing_link_dest eq $source) { - debug(2, 0, "--- Skipping $target_subpath as it already points to $source"); + if ($existing_link_dest eq $link_dest) { + debug(2, 0, "--- Skipping $target_subpath as it already points to $link_dest"); } elsif ($self->defer($target_subpath)) { debug(2, 0, "--- Deferring installation of: $target_subpath"); @@ -542,10 +558,10 @@ sub stow_node { elsif ($self->override($target_subpath)) { debug(2, 0, "--- Overriding installation of: $target_subpath"); $self->do_unlink($target_subpath); - $self->do_link($source, $target_subpath); + $self->do_link($link_dest, $target_subpath); } elsif ($self->is_a_dir(join_paths(parent($target_subpath), $existing_link_dest)) && - $self->is_a_dir(join_paths(parent($target_subpath), $source))) + $self->is_a_dir(join_paths(parent($target_subpath), $link_dest))) { # If the existing link points to a directory, @@ -558,16 +574,14 @@ sub stow_node { $self->stow_contents( $existing_stow_path, $existing_package, + $pkg_subpath, $target_subpath, - join_paths('..', $existing_link_dest), - $level + 1, ); $self->stow_contents( $self->{stow_path}, $package, + $pkg_subpath, $target_subpath, - join_paths('..', $source), - $level + 1, ); } else { @@ -581,9 +595,9 @@ sub stow_node { } else { # The existing link is invalid, so replace it with a good link - debug(2, 0, "--- replacing invalid link: $path"); + debug(2, 0, "--- replacing invalid link: $target_subpath"); $self->do_unlink($target_subpath); - $self->do_link($source, $target_subpath); + $self->do_link($link_dest, $target_subpath); } } elsif ($self->is_a_node($target_subpath)) { @@ -592,15 +606,14 @@ sub stow_node { $self->stow_contents( $self->{stow_path}, $package, + $pkg_subpath, $target_subpath, - join_paths('..', $source), - $level + 1, ); } else { if ($self->{adopt}) { - $self->do_mv($target_subpath, $path); - $self->do_link($source, $target_subpath); + $self->do_mv($target_subpath, $pkg_path_from_cwd); + $self->do_link($link_dest, $target_subpath); } else { $self->conflict( @@ -611,18 +624,17 @@ sub stow_node { } } } - elsif ($self->{'no-folding'} && -d $path && ! -l $path) { + elsif ($self->{'no-folding'} && -d $pkg_path_from_cwd && ! -l $pkg_path_from_cwd) { $self->do_mkdir($target_subpath); $self->stow_contents( $self->{stow_path}, $package, + $pkg_subpath, $target_subpath, - join_paths('..', $source), - $level + 1, ); } else { - $self->do_link($source, $target_subpath); + $self->do_link($link_dest, $target_subpath); } return; } @@ -684,7 +696,7 @@ sub marked_stow_dir { return 0; } -=head2 unstow_contents($package, $target) +=head2 unstow_contents($package, $pkg_subdir, $target_subdir) Unstow the contents of the given directory @@ -694,9 +706,18 @@ Unstow the contents of the given directory The package whose contents are being unstowed. -=item $target +=item $pkg_subdir -Relative path to symlink target from the current directory. +Subdirectory of the installation image in the package directory which +may need a symlink pointing to it to be unstowed. This is relative to +the top-level package directory. + +=item $target_subdir + +Subdirectory of the target directory which either needs unstowing of a +symlink to the corresponding package subdirectory in the installation +image, or if it's an existing directory, it's an unfolded tree which +may need to be recursed into. =back @@ -707,15 +728,21 @@ Here we traverse the package tree, rather than the target tree. sub unstow_contents { my $self = shift; - my ($package, $target_subdir, $path) = @_; + my ($package, $pkg_subdir, $target_subdir) = @_; return if $self->should_skip_target($target_subdir); my $cwd = getcwd(); - my $msg = "Unstowing from $target_subdir (cwd=$cwd, stow dir=$self->{stow_path})"; + my $msg = "Unstowing contents of $self->{stow_path} / $package / $pkg_subdir (cwd=$cwd" . ($self->{compat} ? ', compat' : '') . ")"; $msg =~ s!$ENV{HOME}/!~/!g; debug(3, 0, $msg); - debug(4, 1, "source path is $path"); + debug(4, 1, "target subdir is $target_subdir"); + + # Calculate the path to the package directory or sub-directory + # whose contents need to be unstowed, relative to the current + # (target directory). This is needed so that we can check it's a + # valid directory, and can read its contents to iterate over them. + my $pkg_path_from_cwd = join_paths($self->{stow_path}, $package, $pkg_subdir); if ($self->{compat}) { # In compat mode we traverse the target tree not the source tree, @@ -725,9 +752,10 @@ sub unstow_contents { unless -d $target_subdir; } else { - # We traverse the source tree not the target tree, so $path must exist. - error("unstow_contents() called with non-directory path: $path") - unless -d $path; + # We traverse the package installation image tree not the + # target tree, so $pkg_path_from_cwd must exist. + error("unstow_contents() called with non-directory path: $pkg_path_from_cwd") + unless -d $pkg_path_from_cwd; # When called at the top level, $target_subdir should exist. And # unstow_node() should only call this via mutual recursion if @@ -736,7 +764,7 @@ sub unstow_contents { unless $self->is_a_node($target_subdir); } - my $dir = $self->{compat} ? $target_subdir : $path; + my $dir = $self->{compat} ? $target_subdir : $pkg_path_from_cwd; opendir my $DIR, $dir or error("cannot read directory: $dir ($!)"); my @listing = readdir $DIR; @@ -746,16 +774,29 @@ sub unstow_contents { for my $node (sort @listing) { next NODE if $node eq '.'; next NODE if $node eq '..'; - my $node_target = join_paths($target_subdir, $node); - next NODE if $self->ignore($self->{stow_path}, $package, $node_target); + + my $package_node = $node; + my $target_node = $node; if ($self->{dotfiles}) { - my $adj_node_target = adjust_dotfile($node_target); - debug(4, 1, "Adjusting: $node_target => $adj_node_target"); - $node_target = $adj_node_target; + # $node is in the package tree, so adjust any dot-* + # files for the target. + my $adjusted = adjust_dotfile($node); + if ($adjusted ne $node) { + debug(4, 1, "Adjusting: $node => $adjusted"); + $target_node = $adjusted; + } } + my $package_node_path = join_paths($pkg_subdir, $package_node); + my $target_node_path = join_paths($target_subdir, $target_node); - $self->unstow_node($package, $node_target, join_paths($path, $node)); + next NODE if $self->ignore($self->{stow_path}, $package, $target_node_path); + + $self->unstow_node( + $package, + $package_node_path, + $target_node_path + ); } if (! $self->{compat} && -d $target_subdir) { @@ -763,7 +804,7 @@ sub unstow_contents { } } -=head2 unstow_node($package, $target_subpath) +=head2 unstow_node($package, $pkg_subpath, $target_subpath) Unstow the given node. @@ -773,9 +814,18 @@ Unstow the given node. The package containing the node being unstowed. +=item $pkg_subpath + +Subpath of the installation image in the package directory which needs +stowing as a symlink which points to it. This is relative to the +top-level package directory. + =item $target_subpath -Relative path to symlink target from the current directory. +Subpath of the target directory which either needs a symlink to the +corresponding package subpathectory in the installation image, or if +it's an existing directory, it's an unfolded tree which may need to +be folded or recursed into. =back @@ -785,17 +835,19 @@ C and C are mutually recursive. sub unstow_node { my $self = shift; - my ($package, $target_subpath, $source) = @_; - - debug(3, 1, "Unstowing $source"); - debug(4, 2, "target is $target_subpath"); + my ($package, $pkg_subpath, $target_subpath) = @_; + debug(3, 0, "Unstowing entry from target: $target_subpath"); + debug(4, 1, "Package entry: $self->{stow_path} / $package / $pkg_subpath"); + # Calculate the path to the package directory or sub-directory + # whose contents need to be unstowed, relative to the current + # (target directory). # Does the target exist? if ($self->is_a_link($target_subpath)) { - $self->unstow_link_node($package, $target_subpath, $source); + $self->unstow_link_node($package, $pkg_subpath, $target_subpath); } elsif (-d $target_subpath) { - $self->unstow_contents($package, $target_subpath, $source); + $self->unstow_contents($package, $pkg_subpath, $target_subpath); # This action may have made the parent directory foldable if (my $parent_in_pkg = $self->foldable($target_subpath)) { @@ -812,7 +864,7 @@ sub unstow_node { sub unstow_link_node { my $self = shift; - my ($package, $target_subpath, $pkg_path_from_cwd) = @_; + my ($package, $pkg_subpath, $target_subpath) = @_; debug(4, 2, "Evaluate existing link: $target_subpath"); # Where is the link pointing? @@ -837,9 +889,12 @@ sub unstow_link_node { return; } + my $pkg_path_from_cwd = join_paths($self->{stow_path}, $package, $pkg_subpath); + # Does the existing $target_subpath actually point to anything? if (-e $existing_pkg_path_from_cwd) { if ($existing_pkg_path_from_cwd eq $pkg_path_from_cwd) { + # It points to the package we're unstowing, so unstow the link. $self->do_unlink($target_subpath); } else { diff --git a/lib/Stow/Util.pm.in b/lib/Stow/Util.pm.in index 3b7dc3e..8ee42f9 100644 --- a/lib/Stow/Util.pm.in +++ b/lib/Stow/Util.pm.in @@ -239,17 +239,9 @@ sub restore_cwd { } sub adjust_dotfile { - my ($link_dest) = @_; - - my @result = (); - for my $part (split m{/+}, $link_dest) { - if (($part ne "dot-") && ($part ne "dot-.")) { - $part =~ s/^dot-/./; - } - push @result, $part; - } - - return join '/', @result; + my ($pkg_node) = @_; + (my $adjusted = $pkg_node) =~ s/^dot-([^.])/.$1/; + return $adjusted; } =head1 BUGS diff --git a/t/dotfiles.t b/t/dotfiles.t index 5719eaa..e954076 100755 --- a/t/dotfiles.t +++ b/t/dotfiles.t @@ -22,7 +22,7 @@ use strict; use warnings; -use Test::More tests => 10; +use Test::More tests => 11; use English qw(-no_match_vars); use Stow::Util qw(adjust_dotfile); @@ -32,17 +32,12 @@ init_test_dirs(); cd("$TEST_DIR/target"); subtest('adjust_dotfile()', sub { - plan tests => 9; + plan tests => 4; my @TESTS = ( ['file'], + ['dot-'], + ['dot-.'], ['dot-file', '.file'], - ['dir1/file'], - ['dir1/dir2/file'], - ['dir1/dir2/dot-file', 'dir1/dir2/.file'], - ['dir1/dot-dir2/file', 'dir1/.dir2/file'], - ['dir1/dot-dir2/dot-file', 'dir1/.dir2/.file'], - ['dot-dir1/dot-dir2/dot-file', '.dir1/.dir2/.file'], - ['dot-dir1/dot-dir2/file', '.dir1/.dir2/file'], ); for my $test (@TESTS) { my ($input, $expected) = @$test; From 8ed799a3a38f9478bd49b134be05787cb9068232 Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Sun, 7 Apr 2024 15:42:06 +0100 Subject: [PATCH 471/482] t/unstow.t: create a bunch of unowned files to make tests more robust This should make it harder for Stow to do the right thing. --- t/unstow.t | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/t/unstow.t b/t/unstow.t index 1c7f967..7eab2d0 100755 --- a/t/unstow.t +++ b/t/unstow.t @@ -43,6 +43,20 @@ sub init_stow2 { make_file('stow2/.stow'); } +sub create_unowned_files { + # Make things harder for Stow to figure out, by adding + # a bunch of alien files unrelated to Stow. + my @UNOWNED_DIRS = ('unowned-dir', '.unowned-dir', 'dot-unowned-dir'); + for my $dir ('.', @UNOWNED_DIRS) { + for my $subdir ('.', @UNOWNED_DIRS) { + make_path("$dir/$subdir"); + make_file("$dir/$subdir/unowned"); + make_file("$dir/$subdir/.unowned"); + make_file("$dir/$subdir/dot-unowned"); + } + } +} + # Run a subtest twice, with compat off then on, in parallel test trees. # # Params: $name[, $setup], $test_code @@ -58,6 +72,7 @@ sub subtests { $ENV{HOME} = $ABS_TEST_DIR; cd($repo); cd("$TEST_DIR/target"); + create_unowned_files(); # cd first to allow setup to cd somewhere else. my $opts = ref($setup) eq 'HASH' ? $setup : $setup->($TEST_DIR); subtest($name, sub { @@ -69,6 +84,7 @@ sub subtests { $ENV{HOME} = $COMPAT_ABS_TEST_DIR; cd($repo); cd("$COMPAT_TEST_DIR/target"); + create_unowned_files(); # cd first to allow setup to cd somewhere else. $opts = ref $setup eq 'HASH' ? $setup : $setup->($COMPAT_TEST_DIR); subtest("$name (compat mode)", sub { From 34421ba5cf34df7265017e6564fa4d7922e37182 Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Tue, 2 Apr 2024 00:06:38 +0100 Subject: [PATCH 472/482] stow_contents: fix bugs and corner cases with type mismatch conflicts If the target directory as a file named X and a package has a directory named X, or vice-versa, then it is impossible for Stow to stow that entry X from the package, even if --adopt is supplied. However we were previously only handling the former case, and not the latter, and the test for the former was actually broken. So fix stow_contents() to handle both cases correctly, fix the broken test, and add a new test for the latter case. --- lib/Stow.pm.in | 40 +++++++++++++++++++++++++++++++--------- t/stow.t | 42 +++++++++++++++++++++++++++++++++++------- 2 files changed, 66 insertions(+), 16 deletions(-) diff --git a/lib/Stow.pm.in b/lib/Stow.pm.in index 2c94622..5a81855 100755 --- a/lib/Stow.pm.in +++ b/lib/Stow.pm.in @@ -603,23 +603,45 @@ sub stow_node { elsif ($self->is_a_node($target_subpath)) { debug(4, 1, "Evaluate existing node: $target_subpath"); if ($self->is_a_dir($target_subpath)) { - $self->stow_contents( - $self->{stow_path}, - $package, - $pkg_subpath, - $target_subpath, - ); + if (! -d $pkg_path_from_cwd) { + # FIXME: why wasn't this ever needed before? + $self->conflict( + 'stow', + $package, + "cannot stow non-directory $pkg_path_from_cwd over existing directory target $target_subpath" + ); + } + else { + $self->stow_contents( + $self->{stow_path}, + $package, + $pkg_subpath, + $target_subpath, + ); + } } else { + # If we're here, $target_subpath is not a current or + # planned directory. + if ($self->{adopt}) { - $self->do_mv($target_subpath, $pkg_path_from_cwd); - $self->do_link($link_dest, $target_subpath); + if (-d $pkg_path_from_cwd) { + $self->conflict( + 'stow', + $package, + "cannot stow directory $pkg_path_from_cwd over existing non-directory target $target_subpath" + ); + } + else { + $self->do_mv($target_subpath, $pkg_path_from_cwd); + $self->do_link($link_dest, $target_subpath); + } } else { $self->conflict( 'stow', $package, - "existing target is neither a link nor a directory: $target_subpath" + "cannot stow $pkg_path_from_cwd over existing target $target_subpath since neither a link nor a directory and --adopt not specified" ); } } diff --git a/t/stow.t b/t/stow.t index 318eb6d..d23e8d6 100755 --- a/t/stow.t +++ b/t/stow.t @@ -22,7 +22,7 @@ use strict; use warnings; -use Test::More tests => 21; +use Test::More tests => 22; use Test::Output; use English qw(-no_match_vars); @@ -103,7 +103,7 @@ subtest("Package dir 'bin4' conflicts with existing non-dir so can't unfold", su is($stow->get_conflict_count, 1); like( $conflicts{stow}{pkg4}[0], - qr/existing target is neither a link nor a directory/ + qr!cannot stow ../stow/pkg4/bin4 over existing target bin4 since neither a link nor a directory and --adopt not specified! => 'link to new dir bin4 conflicts with existing non-directory' ); }); @@ -111,8 +111,7 @@ subtest("Package dir 'bin4' conflicts with existing non-dir so can't unfold", su subtest("Package dir 'bin4a' conflicts with existing non-dir " . "so can't unfold even with --adopt", sub { plan tests => 2; - #my $stow = new_Stow(adopt => 1); - my $stow = new_Stow(); + my $stow = new_Stow(adopt => 1); make_file('bin4a'); # this is a file but named like a directory make_path('../stow/pkg4a/bin4a'); @@ -121,8 +120,9 @@ subtest("Package dir 'bin4a' conflicts with existing non-dir " . $stow->plan_stow('pkg4a'); %conflicts = $stow->get_conflicts(); is($stow->get_conflict_count, 1); - like($conflicts{stow}{pkg4a}[0], - qr/existing target is neither a link nor a directory/ + like( + $conflicts{stow}{pkg4a}[0], + qr!cannot stow directory ../stow/pkg4a/bin4a over existing non-directory target bin4a! => 'link to new dir bin4a conflicts with existing non-directory' ); }); @@ -146,14 +146,42 @@ subtest("Package files 'file4b' and 'bin4b' conflict with existing files", sub { %conflicts = $stow->get_conflicts(); is($stow->get_conflict_count, 2 => 'conflict per file'); for my $i (0, 1) { + my $target = $i ? 'file4b' : 'bin4b/file4b'; like( $conflicts{stow}{pkg4b}[$i], - qr/existing target is neither a link nor a directory/ + qr,cannot stow ../stow/pkg4b/$target over existing target $target since neither a link nor a directory and --adopt not specified, => 'link to file4b conflicts with existing non-directory' ); } }); +subtest("Package files 'file4d' conflicts with existing directories", sub { + plan tests => 3; + my $stow = new_Stow(); + + # Populate target + make_path('file4d'); # this is a directory but named like a file to create the conflict + make_path('bin4d/file4d'); # same here + + # Populate stow package + make_path('../stow/pkg4d'); + make_file('../stow/pkg4d/file4d', 'file4d - version originally in stow package'); + make_path('../stow/pkg4d/bin4d'); + make_file('../stow/pkg4d/bin4d/file4d', 'bin4d/file4d - version originally in stow package'); + + $stow->plan_stow('pkg4d'); + %conflicts = $stow->get_conflicts(); + is($stow->get_conflict_count, 2 => 'conflict per file'); + for my $i (0, 1) { + my $target = $i ? 'file4d' : 'bin4d/file4d'; + like( + $conflicts{stow}{pkg4d}[$i], + qr!cannot stow non-directory ../stow/pkg4d/$target over existing directory target $target! + => 'link to file4d conflicts with existing non-directory' + ); + } +}); + subtest("Package files 'file4c' and 'bin4c' can adopt existing versions", sub { plan tests => 8; my $stow = new_Stow(adopt => 1); From 723ddcf3a4dcc0480585e2c831363652c5bbe5aa Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Sun, 7 Apr 2024 15:57:03 +0100 Subject: [PATCH 473/482] t/dotfiles.t: improve language in test names and assertion messages We use the term "directory" (or "dir" for short) rather than "folder". Also explicitly say whether a test is stowing or unstowing, and fix the odd typo. --- t/dotfiles.t | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/t/dotfiles.t b/t/dotfiles.t index e954076..1c16522 100755 --- a/t/dotfiles.t +++ b/t/dotfiles.t @@ -48,7 +48,7 @@ subtest('adjust_dotfile()', sub { my $stow; -subtest("stow a dotfile marked with 'dot' prefix", sub { +subtest("stow dot-foo as .foo", sub { plan tests => 1; $stow = new_Stow(dir => '../stow', dotfiles => 1); make_path('../stow/dotfiles'); @@ -63,7 +63,7 @@ subtest("stow a dotfile marked with 'dot' prefix", sub { ); }); -subtest("ensure that turning off dotfile processing links files as usual", sub { +subtest("stow dot-foo as dot-foo without --dotfile enabled", sub { plan tests => 1; $stow = new_Stow(dir => '../stow', dotfiles => 0); make_path('../stow/dotfiles'); @@ -76,10 +76,9 @@ subtest("ensure that turning off dotfile processing links files as usual", sub { '../stow/dotfiles/dot-foo', => 'unprocessed dotfile' ); - }); -subtest("stow folder marked with 'dot' prefix", sub { +subtest("stow dot-emacs dir as .emacs", sub { plan tests => 1; $stow = new_Stow(dir => '../stow', dotfiles => 1); @@ -91,11 +90,11 @@ subtest("stow folder marked with 'dot' prefix", sub { is( readlink('.emacs'), '../stow/dotfiles/dot-emacs', - => 'processed dotfile folder' + => 'processed dotfile dir' ); }); -subtest("process folder marked with 'dot' prefix when directory exists is target", sub { +subtest("stow dir marked with 'dot' prefix when directory exists in target", sub { plan tests => 1; $stow = new_Stow(dir => '../stow', dotfiles => 1); @@ -108,11 +107,11 @@ subtest("process folder marked with 'dot' prefix when directory exists is target is( readlink('.emacs.d/init.el'), '../../stow/dotfiles/dot-emacs.d/init.el', - => 'processed dotfile folder when folder exists (1 level)' + => 'processed dotfile dir when dir exists (1 level)' ); }); -subtest("process folder marked with 'dot' prefix when directory exists is target (2 levels)", sub { +subtest("stow dir marked with 'dot' prefix when directory exists in target (2 levels)", sub { plan tests => 1; $stow = new_Stow(dir => '../stow', dotfiles => 1); @@ -125,11 +124,11 @@ subtest("process folder marked with 'dot' prefix when directory exists is target is( readlink('.emacs.d/.emacs.d'), '../../stow/dotfiles/dot-emacs.d/dot-emacs.d', - => 'processed dotfile folder exists (2 levels)' + => 'processed dotfile dir exists (2 levels)' ); }); -subtest("process folder marked with 'dot' prefix when directory exists is target", sub { +subtest("stow dir marked with 'dot' prefix when directory exists in target", sub { plan tests => 1; $stow = new_Stow(dir => '../stow', dotfiles => 1); @@ -142,7 +141,7 @@ subtest("process folder marked with 'dot' prefix when directory exists is target is( readlink('./.one/.two/three'), '../../../stow/dotfiles/dot-one/dot-two/three', - => 'processed dotfile 2 folder exists (2 levels)' + => 'processed dotfile 2 dir exists (2 levels)' ); }); @@ -171,7 +170,7 @@ subtest("dot-. should not have that part expanded.", sub { ); }); -subtest("simple unstow scenario", sub { +subtest("unstow .bar from dot-bar", sub { plan tests => 3; $stow = new_Stow(dir => '../stow', dotfiles => 1); @@ -186,7 +185,7 @@ subtest("simple unstow scenario", sub { ok(! -e '.bar' => 'unstow a simple dotfile'); }); -subtest("unstow process folder marked with 'dot' prefix when directory exists is target", sub { +subtest("unstow dot-emacs.d/init.el when .emacs.d/init.el in target", sub { plan tests => 4; $stow = new_Stow(dir => '../stow', dotfiles => 1); @@ -200,5 +199,5 @@ subtest("unstow process folder marked with 'dot' prefix when directory exists is is($stow->get_conflict_count, 0); ok(-f '../stow/dotfiles/dot-emacs.d/init.el'); ok(! -e '.emacs.d/init.el'); - ok(-d '.emacs.d/' => 'unstow dotfile folder when folder already exists'); + ok(-d '.emacs.d/' => 'unstow dotfile dir when dir already exists'); }); From 93fc195ddb5588a3ebeb4d353909b8e58e45bf0b Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Sun, 7 Apr 2024 17:19:37 +0100 Subject: [PATCH 474/482] Fix unstowing with `--compat --dotfiles` Unstowing with `--dotfiles` didn't work with `--compat`, because when traversing the target tree rather than the package tree, there was no mechanism for mapping a `.foo` file or directory back to its original `dot-foo` and determine whether it should be unstowed. So add a reverse `unadjust_dotfile()` mapping mechanism to support this. --- lib/Stow.pm.in | 27 ++++++++++++++++++++------- lib/Stow/Util.pm.in | 11 ++++++++++- t/dotfiles.t | 42 +++++++++++++++++++++++++++++++++++++----- 3 files changed, 67 insertions(+), 13 deletions(-) diff --git a/lib/Stow.pm.in b/lib/Stow.pm.in index 5a81855..b9b3b30 100755 --- a/lib/Stow.pm.in +++ b/lib/Stow.pm.in @@ -56,7 +56,8 @@ use File::Spec; use POSIX qw(getcwd); use Stow::Util qw(set_debug_level debug error set_test_mode - join_paths restore_cwd canon_path parent adjust_dotfile); + join_paths restore_cwd canon_path parent + adjust_dotfile unadjust_dotfile); our $ProgramName = 'stow'; our $VERSION = '@VERSION@'; @@ -801,12 +802,24 @@ sub unstow_contents { my $target_node = $node; if ($self->{dotfiles}) { - # $node is in the package tree, so adjust any dot-* - # files for the target. - my $adjusted = adjust_dotfile($node); - if ($adjusted ne $node) { - debug(4, 1, "Adjusting: $node => $adjusted"); - $target_node = $adjusted; + if ($self->{compat}) { + # $node is in the target tree, so we need to reverse + # adjust any .* files in case they came from a dot-* + # file. + my $adjusted = unadjust_dotfile($node); + if ($adjusted ne $node) { + debug(4, 1, "Reverse adjusting: $node => $adjusted"); + $package_node = $adjusted; + } + } + else { + # $node is in the package tree, so adjust any dot-* + # files for the target. + my $adjusted = adjust_dotfile($node); + if ($adjusted ne $node) { + debug(4, 1, "Adjusting: $node => $adjusted"); + $target_node = $adjusted; + } } } my $package_node_path = join_paths($pkg_subdir, $package_node); diff --git a/lib/Stow/Util.pm.in b/lib/Stow/Util.pm.in index 8ee42f9..b33fb5a 100644 --- a/lib/Stow/Util.pm.in +++ b/lib/Stow/Util.pm.in @@ -38,7 +38,8 @@ use POSIX qw(getcwd); use base qw(Exporter); our @EXPORT_OK = qw( error debug set_debug_level set_test_mode - join_paths parent canon_path restore_cwd adjust_dotfile + join_paths parent canon_path restore_cwd + adjust_dotfile unadjust_dotfile ); our $ProgramName = 'stow'; @@ -244,6 +245,14 @@ sub adjust_dotfile { return $adjusted; } +# Needed when unstowing with --compat and --dotfiles +sub unadjust_dotfile { + my ($target_node) = @_; + return $target_node if $target_node =~ /^\.\.?$/; + (my $adjusted = $target_node) =~ s/^\./dot-/; + return $adjusted; +} + =head1 BUGS =head1 SEE ALSO diff --git a/t/dotfiles.t b/t/dotfiles.t index 1c16522..643b873 100755 --- a/t/dotfiles.t +++ b/t/dotfiles.t @@ -22,10 +22,10 @@ use strict; use warnings; -use Test::More tests => 11; +use Test::More tests => 12; use English qw(-no_match_vars); -use Stow::Util qw(adjust_dotfile); +use Stow::Util qw(adjust_dotfile unadjust_dotfile); use testutil; init_test_dirs(); @@ -46,6 +46,21 @@ subtest('adjust_dotfile()', sub { } }); +subtest('unadjust_dotfile()', sub { + plan tests => 4; + my @TESTS = ( + ['file'], + ['.'], + ['..'], + ['.file', 'dot-file'], + ); + for my $test (@TESTS) { + my ($input, $expected) = @$test; + $expected ||= $input; + is(unadjust_dotfile($input), $expected); + } +}); + my $stow; subtest("stow dot-foo as .foo", sub { @@ -182,7 +197,7 @@ subtest("unstow .bar from dot-bar", sub { $stow->process_tasks(); is($stow->get_conflict_count, 0); ok(-f '../stow/dotfiles/dot-bar', 'package file untouched'); - ok(! -e '.bar' => 'unstow a simple dotfile'); + ok(! -e '.bar' => '.bar was unstowed'); }); subtest("unstow dot-emacs.d/init.el when .emacs.d/init.el in target", sub { @@ -198,6 +213,23 @@ subtest("unstow dot-emacs.d/init.el when .emacs.d/init.el in target", sub { $stow->process_tasks(); is($stow->get_conflict_count, 0); ok(-f '../stow/dotfiles/dot-emacs.d/init.el'); - ok(! -e '.emacs.d/init.el'); - ok(-d '.emacs.d/' => 'unstow dotfile dir when dir already exists'); + ok(! -e '.emacs.d/init.el', '.emacs.d/init.el unstowed'); + ok(-d '.emacs.d/' => '.emacs.d left behind'); +}); + +subtest("unstow dot-emacs.d/init.el in --compat mode", sub { + plan tests => 4; + $stow = new_compat_Stow(dir => '../stow', dotfiles => 1); + + make_path('../stow/dotfiles/dot-emacs.d'); + make_file('../stow/dotfiles/dot-emacs.d/init.el'); + make_path('.emacs.d'); + make_link('.emacs.d/init.el', '../../stow/dotfiles/dot-emacs.d/init.el'); + + $stow->plan_unstow('dotfiles'); + $stow->process_tasks(); + is($stow->get_conflict_count, 0); + ok(-f '../stow/dotfiles/dot-emacs.d/init.el'); + ok(! -e '.emacs.d/init.el', '.emacs.d/init.el unstowed'); + ok(-d '.emacs.d/' => '.emacs.d left behind'); }); From c0b8890b144bfc0f6e77270452324c643cb750e8 Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Sun, 7 Apr 2024 17:24:13 +0100 Subject: [PATCH 475/482] t/unstow.t: remove superfluous spaces --- t/unstow.t | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/t/unstow.t b/t/unstow.t index 7eab2d0..c0e7639 100755 --- a/t/unstow.t +++ b/t/unstow.t @@ -475,52 +475,52 @@ sub create_and_stow_pkg { my ($id, $pkg) = @_; my $stow_pkg = "../stow/$id-$pkg"; - make_path ($stow_pkg); + make_path($stow_pkg); make_file("$stow_pkg/$id-file-$pkg"); # create a shallow hierarchy specific to this package and stow # via folding - make_path ("$stow_pkg/$id-$pkg-only-folded"); + make_path("$stow_pkg/$id-$pkg-only-folded"); make_file("$stow_pkg/$id-$pkg-only-folded/file-$pkg"); make_link("$id-$pkg-only-folded", "$stow_pkg/$id-$pkg-only-folded"); # create a deeper hierarchy specific to this package and stow # via folding - make_path ("$stow_pkg/$id-$pkg-only-folded2/subdir"); + make_path("$stow_pkg/$id-$pkg-only-folded2/subdir"); make_file("$stow_pkg/$id-$pkg-only-folded2/subdir/file-$pkg"); make_link("$id-$pkg-only-folded2", "$stow_pkg/$id-$pkg-only-folded2"); # create a shallow hierarchy specific to this package and stow # without folding - make_path ("$stow_pkg/$id-$pkg-only-unfolded"); + make_path("$stow_pkg/$id-$pkg-only-unfolded"); make_file("$stow_pkg/$id-$pkg-only-unfolded/file-$pkg"); - make_path ("$id-$pkg-only-unfolded"); + make_path("$id-$pkg-only-unfolded"); make_link("$id-$pkg-only-unfolded/file-$pkg", "../$stow_pkg/$id-$pkg-only-unfolded/file-$pkg"); # create a deeper hierarchy specific to this package and stow # without folding - make_path ("$stow_pkg/$id-$pkg-only-unfolded2/subdir"); + make_path("$stow_pkg/$id-$pkg-only-unfolded2/subdir"); make_file("$stow_pkg/$id-$pkg-only-unfolded2/subdir/file-$pkg"); - make_path ("$id-$pkg-only-unfolded2/subdir"); + make_path("$id-$pkg-only-unfolded2/subdir"); make_link("$id-$pkg-only-unfolded2/subdir/file-$pkg", "../../$stow_pkg/$id-$pkg-only-unfolded2/subdir/file-$pkg"); # create a shallow shared hierarchy which this package uses, and stow # its contents without folding - make_path ("$stow_pkg/$id-shared"); + make_path("$stow_pkg/$id-shared"); make_file("$stow_pkg/$id-shared/file-$pkg"); - make_path ("$id-shared"); + make_path("$id-shared"); make_link("$id-shared/file-$pkg", "../$stow_pkg/$id-shared/file-$pkg"); # create a deeper shared hierarchy which this package uses, and stow # its contents without folding - make_path ("$stow_pkg/$id-shared2/subdir"); + make_path("$stow_pkg/$id-shared2/subdir"); make_file("$stow_pkg/$id-shared2/file-$pkg"); make_file("$stow_pkg/$id-shared2/subdir/file-$pkg"); - make_path ("$id-shared2/subdir"); + make_path("$id-shared2/subdir"); make_link("$id-shared2/file-$pkg", "../$stow_pkg/$id-shared2/file-$pkg"); make_link("$id-shared2/subdir/file-$pkg", From 94ed91646620dbcc71cca1fa1fd20be65ec21d4a Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Sun, 7 Apr 2024 17:44:44 +0100 Subject: [PATCH 476/482] t/unstow.t: move final set of tests into a subtest --- t/unstow.t | 43 ++++++++++++++++++++----------------------- 1 file changed, 20 insertions(+), 23 deletions(-) diff --git a/t/unstow.t b/t/unstow.t index c0e7639..4252694 100755 --- a/t/unstow.t +++ b/t/unstow.t @@ -24,7 +24,7 @@ use warnings; use File::Spec qw(make_path); use POSIX qw(getcwd); -use Test::More tests => 49; +use Test::More tests => 35; use Test::Output; use English qw(-no_match_vars); @@ -465,12 +465,6 @@ subtests("unstow a simple tree minimally with absolute stow AND target dirs when ); }); -# -# unstow a tree with no-folding enabled - -# no refolding should take place -# -cd("$TEST_DIR/target"); - sub create_and_stow_pkg { my ($id, $pkg) = @_; @@ -527,25 +521,28 @@ sub create_and_stow_pkg { "../../$stow_pkg/$id-shared2/subdir/file-$pkg"); } -foreach my $pkg (qw{a b}) { - create_and_stow_pkg('no-folding', $pkg); -} +subtest("unstow a tree with no-folding enabled - no refolding should take place", sub { + cd("$TEST_DIR/target"); + plan tests => 15; -my $stow = new_Stow('no-folding' => 1); -$stow->plan_unstow('no-folding-b'); -is_deeply([ $stow->get_conflicts ], [] => 'no conflicts with --no-folding'); -use Data::Dumper; -#warn Dumper($stow->get_tasks); + foreach my $pkg (qw{a b}) { + create_and_stow_pkg('no-folding', $pkg); + } -$stow->process_tasks(); + my $stow = new_Stow('no-folding' => 1); + $stow->plan_unstow('no-folding-b'); + is_deeply([ $stow->get_conflicts ], [] => 'no conflicts with --no-folding'); -is_nonexistent_path('no-folding-b-only-folded'); -is_nonexistent_path('no-folding-b-only-folded2'); -is_nonexistent_path('no-folding-b-only-unfolded/file-b'); -is_nonexistent_path('no-folding-b-only-unfolded2/subdir/file-b'); -is_dir_not_symlink('no-folding-shared'); -is_dir_not_symlink('no-folding-shared2'); -is_dir_not_symlink('no-folding-shared2/subdir'); + $stow->process_tasks(); + + is_nonexistent_path('no-folding-b-only-folded'); + is_nonexistent_path('no-folding-b-only-folded2'); + is_nonexistent_path('no-folding-b-only-unfolded/file-b'); + is_nonexistent_path('no-folding-b-only-unfolded2/subdir/file-b'); + is_dir_not_symlink('no-folding-shared'); + is_dir_not_symlink('no-folding-shared2'); + is_dir_not_symlink('no-folding-shared2/subdir'); +}); # subtests("Test cleaning up subdirs with --paranoid option", sub { # TODO From cbc12d7a3b4b41e6658bd46f46fbe3c57d9ae748 Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Sun, 7 Apr 2024 18:00:03 +0100 Subject: [PATCH 477/482] stow: remove misleading comment about current dir The current directory is changed by within_target_do() which is called by `plan_stow()`, `plan_unstow()`, and `process_tasks()`. It is not changed when constructing a new `Stow` object, so remove this outdated and misleading comment. Fixes #102. --- bin/stow.in | 1 - 1 file changed, 1 deletion(-) diff --git a/bin/stow.in b/bin/stow.in index 9147fd1..024b152 100755 --- a/bin/stow.in +++ b/bin/stow.in @@ -474,7 +474,6 @@ sub main { my ($options, $pkgs_to_unstow, $pkgs_to_stow) = process_options(); my $stow = new Stow(%$options); - # current dir is now the target directory $stow->plan_unstow(@$pkgs_to_unstow); $stow->plan_stow (@$pkgs_to_stow); From 49aa3458e5c54647ec92554ca3c0fd466c4f1429 Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Sun, 7 Apr 2024 18:22:56 +0100 Subject: [PATCH 478/482] Add details on how to view coverage locally Unfortunately for now, Coveralls reports don't include source due to #84, but this is a good workaround. --- CONTRIBUTING.md | 12 ++++++++++++ Makefile.am | 4 ++++ 2 files changed, 16 insertions(+) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 6f6399c..1752a8e 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -90,6 +90,18 @@ recommended to put them in a subdirectory called `playground/` since this will be automatically ignored by git and the build process, avoiding any undesirable complications. +Test coverage +~~~~~~~~~~~~~ + +To view test coverage reports, first ensure that +[`Devel::Cover`](https://metacpan.org/dist/Devel-Cover) is installed. +Then type `make coverage`. The last lines of the output should +include something like: + + HTML output written to /home/user/path/to/stow/cover_db/coverage.html + +which you can open in a web browser to view the report. + Translating Stow ---------------- diff --git a/Makefile.am b/Makefile.am index 56abbef..96eedb1 100644 --- a/Makefile.am +++ b/Makefile.am @@ -87,6 +87,10 @@ check-TESTS: dir=$(TESTS_DIR); \ $(TESTS_ENVIRONMENT) -MTest::Harness -e 'runtests(@ARGV)' "$${dir#./}"/*.t +coverage: + PERL5OPT=-MDevel::Cover $(MAKE) check-TESTS + cover + $(TESTS_OUT): mkdir -p $@ From fdac519bdfc1df754ffaea4da1e7ce7854b9e89a Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Sun, 7 Apr 2024 18:24:49 +0100 Subject: [PATCH 479/482] Bump version to 2.4.0 --- META.json | 6 +++--- META.yml | 6 +++--- NEWS | 2 +- configure.ac | 2 +- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/META.json b/META.json index 3509018..780a868 100644 --- a/META.json +++ b/META.json @@ -37,11 +37,11 @@ "provides" : { "Stow" : { "file" : "lib/Stow.pm", - "version" : "v2.3.2" + "version" : "v2.4.0" }, "Stow::Util" : { "file" : "lib/Stow/Util.pm", - "version" : "v2.3.2" + "version" : "v2.4.0" } }, "release_status" : "stable", @@ -55,6 +55,6 @@ "url" : "git://git.savannah.gnu.org/stow.git" } }, - "version" : "v2.3.2", + "version" : "v2.4.0", "x_serialization_backend" : "JSON::PP version 4.00" } diff --git a/META.yml b/META.yml index 9385103..7ea1404 100644 --- a/META.yml +++ b/META.yml @@ -18,10 +18,10 @@ name: Stow provides: Stow: file: lib/Stow.pm - version: v2.3.2 + version: v2.4.0 Stow::Util: file: lib/Stow/Util.pm - version: v2.3.2 + version: v2.4.0 requires: Carp: '0' IO::File: '0' @@ -30,5 +30,5 @@ resources: homepage: https://savannah.gnu.org/projects/stow license: http://www.gnu.org/licenses/gpl-2.0.html repository: git://git.savannah.gnu.org/stow.git -version: v2.3.2 +version: v2.4.0 x_serialization_backend: 'CPAN::Meta::YAML version 0.018' diff --git a/NEWS b/NEWS index 6e27494..2ea6523 100644 --- a/NEWS +++ b/NEWS @@ -1,6 +1,6 @@ News file for Stow. -* Changes in version 2.3.2 +* Changes in version 2.4.0 *** Eliminated a spurious warning on unstowing diff --git a/configure.ac b/configure.ac index 27d3b3b..3e16434 100644 --- a/configure.ac +++ b/configure.ac @@ -15,7 +15,7 @@ dnl along with this program. If not, see https://www.gnu.org/licenses/. dnl Process this file with Autoconf to produce configure dnl -AC_INIT([stow], [2.3.2], [bug-stow@gnu.org]) +AC_INIT([stow], [2.4.0], [bug-stow@gnu.org]) AC_PREREQ([2.61]) AC_CONFIG_AUX_DIR([automake]) # Unfortunately we have to disable warnings for overrides, because we From 413278f1785378c0a19641b293eacf00c6e1077f Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Sun, 7 Apr 2024 18:32:51 +0100 Subject: [PATCH 480/482] Update NEWS for v2.4.0 --- NEWS | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/NEWS b/NEWS index 2ea6523..490cb6c 100644 --- a/NEWS +++ b/NEWS @@ -2,6 +2,13 @@ News file for Stow. * Changes in version 2.4.0 +*** --dotfiles now works with directories + + A long-standing bug preventing the --dotfiles option from working + correctly with directories has been fixed. + + It should also works in combination with the --compat option. + *** Eliminated a spurious warning on unstowing 2.3.1 introduced a benign but annoying warning when unstowing @@ -11,6 +18,14 @@ News file for Stow. This was caused by erroneous logic, and has now been fixed. +*** Unstowing logic has been improved in other cases + + Several other improvements have been made internally to the + unstowing logic. These changes should all be either invisible + (except for changes to debug output) or improvements, but if you + encounter any unexpected behaviour, please report it as directed + in the manual. + *** Improved debug output Extra output resulting from use of the -v / --verbose flag From 9985de7c78ca41a9f860fc6b87dd32460ab9cdb0 Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Sun, 7 Apr 2024 18:34:35 +0100 Subject: [PATCH 481/482] HOWTO-RELEASE: THANKS is no longer being updated --- doc/HOWTO-RELEASE | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/doc/HOWTO-RELEASE b/doc/HOWTO-RELEASE index e4a23af..fb72cec 100644 --- a/doc/HOWTO-RELEASE +++ b/doc/HOWTO-RELEASE @@ -21,11 +21,10 @@ Release procedure version=$( tools/get-version ) && echo $version -- Ensure NEWS contains the latest changes, and that any new - contributors have been added to THANKS. If necessary, commit +- Ensure NEWS contains the latest changes. If necessary, commit any additions: - git commit -m "Prepare NEWS and THANKS for $version release" + git commit -m "Prepare NEWS for $version release" - Check CPAN distribution will work via Module::Build: From 20031c0001bdaa229453aee3f423900c6cdc7cf6 Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Sun, 7 Apr 2024 18:38:12 +0100 Subject: [PATCH 482/482] Rebuild META.* --- META.json | 4 ++-- META.yml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/META.json b/META.json index 780a868..a94e94f 100644 --- a/META.json +++ b/META.json @@ -4,7 +4,7 @@ "unknown" ], "dynamic_config" : 1, - "generated_by" : "Module::Build version 0.4224", + "generated_by" : "Module::Build version 0.4234", "license" : [ "gpl_1" ], @@ -56,5 +56,5 @@ } }, "version" : "v2.4.0", - "x_serialization_backend" : "JSON::PP version 4.00" + "x_serialization_backend" : "JSON::PP version 4.16" } diff --git a/META.yml b/META.yml index 7ea1404..f59b25b 100644 --- a/META.yml +++ b/META.yml @@ -9,7 +9,7 @@ build_requires: configure_requires: Module::Build: '0' dynamic_config: 1 -generated_by: 'Module::Build version 0.4224, CPAN::Meta::Converter version 2.150010' +generated_by: 'Module::Build version 0.4234, CPAN::Meta::Converter version 2.150010' license: gpl meta-spec: url: http://module-build.sourceforge.net/META-spec-v1.4.html