Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 23 Mar 1995 21:49:26 +1000
From:      Bruce Evans <bde@zeta.org.au>
To:        hsu@freefall.cdrom.com, rgrimes@gndrsh.aac.dev.com
Cc:        current@freefall.cdrom.com
Subject:   Re: Make World Times and a question about shared libs / make all
Message-ID:  <199503231149.VAA12855@godzilla.zeta.org.au>

next in thread | raw e-mail | index | archive | help
>	The one I really want to clean up is the installation of header
>	files, that causes more things to rebuild than anything to do
>	with the libraries.

>Yes!  Yes!  Yes!  I've been thinking about this too.  It's really
>painful to have to recompile everything just because install is too dumb
>to not update the mtime if the source and target are the same.

A long time ago, I hacked install to be less dumb.  This isn't the right
way to do it, but it sort of works (installation times are much longer...).

Bruce

*** xinstall.c~	Fri May 27 22:33:39 1994
--- xinstall.c	Mon Sep  5 06:55:54 1994
***************
*** 52,57 ****
--- 52,58 ----
  #include <grp.h>
  #include <paths.h>
  #include <pwd.h>
+ #include <utime.h>
  #include <stdio.h>
  #include <stdlib.h>
  #include <string.h>
***************
*** 156,162 ****
--- 157,165 ----
  		if (to_sb.st_flags & NOCHANGEBITS)
  			(void)chflags(to_name,
  			    to_sb.st_flags & ~(NOCHANGEBITS));
+ #if 0 /* no, unlink after utime stuff. */
  		(void)unlink(to_name);
+ #endif
  	}
  	install(*argv, to_name, fset, iflags);
  	exit(0);
***************
*** 173,181 ****
  	u_int flags;
  {
  	struct stat from_sb, to_sb;
! 	int devnull, from_fd, to_fd, serrno;
  	char *p;
  
  	/* If try to install NULL file to a directory, fails. */
  	if (flags & DIRECTORY || strcmp(from_name, _PATH_DEVNULL)) {
  		if (stat(from_name, &from_sb))
--- 176,220 ----
  	u_int flags;
  {
  	struct stat from_sb, to_sb;
! 	struct utimbuf utb;
! 	int cmdstat, devnull, from_fd, to_fd, serrno;
  	char *p;
  
+ 	/*
+ 	 * Check if target is being changed.  Assume that the strip step
+ 	 * always does the same thing, just to make removing the tmp file
+ 	 * easier.
+ 	 */
+ 	cmdstat = stat(to_name, &to_sb);
+ 	if (cmdstat == 0) {
+ 		char *cmdbuf;
+ 		char *f_name;
+ 
+ 		f_name = from_name;
+ 		if (dostrip) {
+ 			f_name = malloc(L_tmpnam);
+ 			(void)tmpnam(f_name);
+ 			cmdbuf = malloc(10 + strlen(from_name)
+ 					+ strlen(f_name));
+ 			sprintf(cmdbuf, "/bin/cp %s %s", from_name, f_name);
+ 			if (system(cmdbuf) == 0)
+ 				strip(f_name);
+ 			else {
+ 				free(f_name);
+ 				f_name = from_name;
+ 			}
+ 			free(cmdbuf);
+ 		}
+ 		cmdbuf = malloc(18 + strlen(f_name) + strlen(to_name));
+ 		sprintf(cmdbuf, "/usr/bin/cmp -s %s %s", f_name, to_name);
+ 		cmdstat = system(cmdbuf);
+ 		free(cmdbuf);
+ 		if (strcmp(f_name, from_name) != 0) {
+ 			(void)unlink(f_name);
+ 			free(f_name);
+ 		}
+ 	}
+ 
  	/* If try to install NULL file to a directory, fails. */
  	if (flags & DIRECTORY || strcmp(from_name, _PATH_DEVNULL)) {
  		if (stat(from_name, &from_sb))
***************
*** 234,239 ****
--- 273,286 ----
  		(void)unlink(to_name);
  		err("%s: chmod: %s", to_name, strerror(serrno));
  	}
+ 	if (cmdstat == 0) {
+ 		utb.actime = to_sb.st_atime;
+ 		utb.modtime = to_sb.st_mtime;
+ 	} else {
+ 		utb.actime = from_sb.st_atime;
+ 		utb.modtime = from_sb.st_mtime;
+ 	}
+ 	(void)utime(to_name, &utb);
  
  	/*
  	 * If provided a set of flags, set them, otherwise, preserve the



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199503231149.VAA12855>