From ca00c5b4584a17a200f814ca6fc1388879bb1486 Mon Sep 17 00:00:00 2001 From: Han-Wen Nienhuys Date: Mon, 19 Dec 2005 01:58:11 +0000 Subject: [PATCH] * stepmake/stepmake/install-targets.make (local-uninstall): idem. * stepmake/stepmake/install-out-targets.make (local-install-outfiles): idem. * stepmake/stepmake/help2man-targets.make (install-help2man): idem. * stepmake/stepmake/generic-vars.make (Module): idem. * stepmake/stepmake/executable-targets.make (default): use it. * stepmake/bin/install.py (create_dir): new file. Replace install-sh. * lily/main.cc (setup_paths): don't inspect $PATH for argv0 with slashes. (prepend_env_path): more verbosity. --- ChangeLog | 12 +++ lily/main.cc | 8 +- stepmake/bin/install.py | 89 ++++++++++++++++++++++ stepmake/stepmake/executable-targets.make | 7 +- stepmake/stepmake/generic-vars.make | 2 + stepmake/stepmake/help2man-targets.make | 5 +- stepmake/stepmake/install-out-targets.make | 11 +-- stepmake/stepmake/install-targets.make | 7 +- 8 files changed, 119 insertions(+), 22 deletions(-) create mode 100644 stepmake/bin/install.py diff --git a/ChangeLog b/ChangeLog index 90bc5a37a4..74d5593628 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,17 @@ 2005-12-19 Han-Wen Nienhuys + * stepmake/stepmake/install-targets.make (local-uninstall): idem. + + * stepmake/stepmake/install-out-targets.make (local-install-outfiles): idem. + + * stepmake/stepmake/help2man-targets.make (install-help2man): idem. + + * stepmake/stepmake/generic-vars.make (Module): idem. + + * stepmake/stepmake/executable-targets.make (default): use it. + + * stepmake/bin/install.py (create_dir): new file. Replace install-sh. + * make/GNUmakefile: don't install make rules. * lily/main.cc (setup_paths): don't inspect $PATH for argv0 with diff --git a/lily/main.cc b/lily/main.cc index bcae55d5ee..14fa300e1f 100644 --- a/lily/main.cc +++ b/lily/main.cc @@ -302,16 +302,16 @@ prepend_env_path (char const *key, String value) { if (is_dir (value)) { + if (be_verbose_global) + progress_indication (_f ("%s=%s\n", key, value.to_str0 ())); + if (char const *cur = getenv (key)) value += to_string (PATHSEP) + cur; - if (be_verbose_global) - progress_indication (_f ("%s=%s", key, value.to_str0 ())); - return sane_putenv (key, value.to_str0 ()); } else if (be_verbose_global) - warning (_f ("no such directory: %s", value)); + warning (_f ("no such directory: %s for %s", value, key)); return -1; } diff --git a/stepmake/bin/install.py b/stepmake/bin/install.py new file mode 100644 index 0000000000..7da9c854ac --- /dev/null +++ b/stepmake/bin/install.py @@ -0,0 +1,89 @@ +#!@PYTHON@ +import string +import getopt +import sys +import os +import shutil +(opts, args) = getopt.getopt (sys.argv[1:], 'b:cdg:m:o:st:', []) +transform_base = None +group = None +owner = None +transform = None +mode = None +copy = False +create_dir = False + +for (o,a) in opts: + if o == '-b': + transform_base = a + elif o == '-c': + copy = True + elif o == '-d': + create_dir = True + elif o == '-g': + group = a + elif o == '-m': + mode = string.atoi (a, 8) + elif o == '-o': + owner = a + elif o == '-s': + strip = True + elif o == '-t': + transform = a + elif o == '-h': + print ''' Usage: $0 [OPTION]... SRCFILE DSTFILE + or: $0 [OPTION]... SRCFILES... DIRECTORY + or: $0 -d DIRECTORIES... + +In the first form, install SRCFILE to DSTFILE, removing SRCFILE by default. +In the second, create the directory path DIR. + +Options: +-b=TRANSFORMBASENAME +-c copy source (using $cpprog) instead of moving (using $mvprog). +-d create directories instead of installing files. +-g GROUP $chgrp installed files to GROUP. +-m MODE $chmod installed files to MODE. +-o USER $chown installed files to USER. +-s strip installed files (using $stripprog). +-t=TRANSFORM +--help display this help and exit. +--version display version info and exit.''' + sys.exit (0) + +if not mode: + if create_dir: + mode = 0755 + else: + mode = 0644 + + +chown_me = [] + +dest = None +if not create_dir: + dest = args.pop() + +for f in args: + if create_dir: + os.makedirs (f, mode=mode) + chown_me.append (f) + else: + if copy: + shutil.copy2 (f, dest) + else: + shutil.move (f, dest) + if os.path.isdir (dest): + chown_me.append (os.path.join (dest, os.path.basename (f))) + else: + chown_me.append (dest) + +for f in chown_me: + os.chmod (f, mode) + if group <> None or owner <> None: + os.chown (f, group, owner) + + + + + diff --git a/stepmake/stepmake/executable-targets.make b/stepmake/stepmake/executable-targets.make index edf282ab0a..7afa1db579 100644 --- a/stepmake/stepmake/executable-targets.make +++ b/stepmake/stepmake/executable-targets.make @@ -7,12 +7,11 @@ local-install: installexe local-uninstall: uninstallexe installexe: all - -$(INSTALL) -d $(DESTDIR)$(bindir) + -$(INSTALLPY) -d $(DESTDIR)$(bindir) $(foreach a, $(EXECUTABLES), \ - $(INSTALL) -m 755 $(outdir)/$(a) \ + $(INSTALLPY) -m 755 $(outdir)/$(a) \ $(DESTDIR)$(bindir)/$(program_prefix)$(a)$(program_suffix) && ) true - $(foreach a, $(SEXECUTABLES), \ - $(INSTALL) -m 755 $(outdir)/$(a) $(DESTDIR)$(bindir) &&) true + $(INSTALLPY) -c -m 755 $(addprefix $(outdir)/, $(SEXECUTABLES)) $(DESTDIR)$(bindir) uninstallexe: $(foreach a, $(EXECUTABLES), rm -f \ diff --git a/stepmake/stepmake/generic-vars.make b/stepmake/stepmake/generic-vars.make index e3fe7c76a8..110c177393 100644 --- a/stepmake/stepmake/generic-vars.make +++ b/stepmake/stepmake/generic-vars.make @@ -38,6 +38,8 @@ step-bindir = $(stepmake)/bin # stepmake package support. DEPTH = $(depth)/$(package-depth) +INSTALLPY=$(PYTHON) $(step-bindir)/install.py -c + group-dir = $(shell cd $(DEPTH);pwd)/.. release-dir = $(group-dir)/releases patch-dir = $(group-dir)/patches diff --git a/stepmake/stepmake/help2man-targets.make b/stepmake/stepmake/help2man-targets.make index 04dada703c..53782b63fc 100644 --- a/stepmake/stepmake/help2man-targets.make +++ b/stepmake/stepmake/help2man-targets.make @@ -3,9 +3,8 @@ default: man local-install: install-help2man install-help2man: man - -$(INSTALL) -d $(DESTDIR)$(mandir)/man1 - $(foreach a, $(HELP2MAN_GROFFS), \ - $(INSTALL) -m 644 $(a) $(DESTDIR)$(mandir)/man1 && ) true + -$(INSTALLPY) -d $(DESTDIR)$(mandir)/man1 + $(INSTALLPY) -c -m 644 $(HELP2MAN_GROFFS) $(DESTDIR)$(mandir)/man1 man: $(HELP2MAN_GROFFS) diff --git a/stepmake/stepmake/install-out-targets.make b/stepmake/stepmake/install-out-targets.make index 2cbe3ebd92..6b987d8463 100644 --- a/stepmake/stepmake/install-out-targets.make +++ b/stepmake/stepmake/install-out-targets.make @@ -5,14 +5,11 @@ local-install-files: # urg, parameterise local-install-outfiles: $(INSTALLATION_OUT_FILES) $(foreach suff, $(INSTALLATION_OUT_SUFFIXES), $(INSTALLATION_OUT_FILES$(suff))) - -$(INSTALL) -d $(DESTDIR)$(INSTALLATION_OUT_DIR) - $(foreach i, $(INSTALLATION_OUT_FILES), \ - $(INSTALL) -m 644 $(i) $(DESTDIR)$(INSTALLATION_OUT_DIR)/ && ) true + -$(INSTALLPY) -d $(DESTDIR)$(INSTALLATION_OUT_DIR) + $(INSTALLPY) -c -m 644 $(INSTALLATION_OUT_FILES) $(DESTDIR)$(INSTALLATION_OUT_DIR)/ $(foreach suff, $(INSTALLATION_OUT_SUFFIXES), \ - ($(INSTALL) -d $(DESTDIR)$(INSTALLATION_OUT_DIR$(suff))/ || true) && \ - $(foreach i, $(INSTALLATION_OUT_FILES$(suff)), \ - $(INSTALL) -m 644 $(i) $(DESTDIR)$(INSTALLATION_OUT_DIR$(suff))/ && ) true && ) true - + ($(INSTALLPY) -d $(DESTDIR)$(INSTALLATION_OUT_DIR$(suff))/ || true) && \ + $(INSTALLPY) -c -m 644 $(INSTALLATION_OUT_FILES$(suff)) $(DESTDIR)$(INSTALLATION_OUT_DIR$(suff))/ && ) true local-uninstall: local-uninstall-outfiles local-uninstall-files diff --git a/stepmake/stepmake/install-targets.make b/stepmake/stepmake/install-targets.make index 9e89eedbf6..394270b3c9 100644 --- a/stepmake/stepmake/install-targets.make +++ b/stepmake/stepmake/install-targets.make @@ -7,12 +7,11 @@ local-install-outfiles: local-install-files: $(INSTALLATION_FILES) $(PRE_INSTALL) -$(INSTALL) -d $(DESTDIR)$(INSTALLATION_DIR) - for i in $(foreach j,$(INSTALLATION_FILES),$(src-dir)/$(j)); do \ - $(INSTALL) -m 644 $$i $(DESTDIR)$(INSTALLATION_DIR)/ ; done + $(INSTALLPY) -m 644 $(addprefix $(src-dir)/,$(INSTALLATION_FILES)) $(DESTDIR)$(INSTALLATION_DIR)/ + $(foreach suff, $(INSTALLATION_SUFFIXES), \ ($(INSTALL) -d $(DESTDIR)$(INSTALLATION_DIR$(suff)) || true) && \ - for i in $(foreach j,INSTALLATION_FILES$(suff), $(src-dir)/$(j)); do \ - $(INSTALL) -m 644 $$i $(DESTDIR)$(INSTALLATION_DIR$(suff))/; done ) + $(INSTALL) -m 644 $(addprefix $(src-dir)/, $(INSTALLATION_FILES$(suff))) $(DESTDIR)$(INSTALLATION_DIR$(suff))/ ) $(POST_INSTALL) local-uninstall: local-uninstall-outfiles local-uninstall-files -- 2.39.2