From owner-freebsd-current Thu Mar 23 03:53:10 1995 Return-Path: current-owner Received: (from majordom@localhost) by freefall.cdrom.com (8.6.10/8.6.6) id DAA08791 for current-outgoing; Thu, 23 Mar 1995 03:53:10 -0800 Received: from godzilla.zeta.org.au (godzilla.zeta.org.au [203.2.228.34]) by freefall.cdrom.com (8.6.10/8.6.6) with ESMTP id DAA08785; Thu, 23 Mar 1995 03:52:54 -0800 Received: (from bde@localhost) by godzilla.zeta.org.au (8.6.9/8.6.9) id VAA12855; Thu, 23 Mar 1995 21:49:26 +1000 Date: Thu, 23 Mar 1995 21:49:26 +1000 From: Bruce Evans Message-Id: <199503231149.VAA12855@godzilla.zeta.org.au> To: hsu@freefall.cdrom.com, rgrimes@gndrsh.aac.dev.com Subject: Re: Make World Times and a question about shared libs / make all Cc: current@freefall.cdrom.com Sender: current-owner@FreeBSD.org Precedence: bulk > 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 #include #include + #include #include #include #include *************** *** 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