From owner-freebsd-hackers Mon Mar 13 15:53:16 1995 Return-Path: hackers-owner Received: (from majordom@localhost) by freefall.cdrom.com (8.6.10/8.6.6) id PAA02148 for hackers-outgoing; Mon, 13 Mar 1995 15:53:16 -0800 Received: from troutmask.apl.washington.edu (troutmask.apl.washington.edu [128.95.97.216]) by freefall.cdrom.com (8.6.10/8.6.6) with ESMTP id PAA02142; Mon, 13 Mar 1995 15:53:13 -0800 Received: (from kargl@localhost) by troutmask.apl.washington.edu (8.6.10/8.6.9) id PAA15798; Mon, 13 Mar 1995 15:46:36 -0800 From: Steven G Kargl Message-Id: <199503132346.PAA15798@troutmask.apl.washington.edu> Subject: install compressed binary patch To: phk@freefall.cdrom.com, freebsd-hackers@freefall.cdrom.com (FreeBSD) Date: Mon, 13 Mar 1995 15:46:36 -0800 (PST) X-Mailer: ELM [version 2.4 PL24] Content-Type: text Content-Length: 5646 Sender: hackers-owner@FreeBSD.org Precedence: bulk Poul, Hackers, I have added a `-z' option to install. It will tell install to execute gzip to compress a binary and create a sym link. I have tested my addition, and it appears to work correctly. This might be useful for a `make world' on a machine with limited disk space. You obviously do not want to blindly compress all binaries during a `make world':-) Of course, your kernel must be compiled to run gzipped binaries. This is with -current sources. I hope I got `diff -c'right. -- Steven G. Kargl | Phone: 206-685-4677 | Applied Physics Laboratory | Fax: 206-543-6785 | University of Washington |---------------------| 1013 NE 40th St | FreeBSD 2.1-current | Seattle, WA 98105 |---------------------| *** /usr/src/usr.bin/xinstall/install.1 Fri May 27 05:33:39 1994 --- ./install.1 Mon Mar 13 14:24:04 1995 *************** *** 39,52 **** .Nd install binaries .Sh SYNOPSIS .Nm install ! .Op Fl cs .Op Fl f Ar flags .Op Fl g Ar group .Op Fl m Ar mode .Op Fl o Ar owner .Ar file1 file2 .Nm install ! .Op Fl cs .Op Fl f Ar flags .Op Fl g Ar group .Op Fl m Ar mode --- 39,52 ---- .Nd install binaries .Sh SYNOPSIS .Nm install ! .Op Fl csz .Op Fl f Ar flags .Op Fl g Ar group .Op Fl m Ar mode .Op Fl o Ar owner .Ar file1 file2 .Nm install ! .Op Fl csz .Op Fl f Ar flags .Op Fl g Ar group .Op Fl m Ar mode *************** *** 93,98 **** --- 93,103 ---- .Xr strip 1 to strip binaries so that install can be portable over a large number of systems and binary types. + .It Fl z + .Nm Install + exec's the command + .Xr gzip 1 + to compress the binaries and create the necessary symbolic links. .El .Pp By default, Only in /usr/src/usr.bin/xinstall: obj Only in .: patch.txt diff -c /usr/src/usr.bin/xinstall/pathnames.h ./pathnames.h *** /usr/src/usr.bin/xinstall/pathnames.h Fri May 27 05:33:38 1994 --- ./pathnames.h Mon Mar 13 15:11:57 1995 *************** *** 34,36 **** --- 34,38 ---- */ #define _PATH_STRIP "/usr/bin/strip" + #define _PATH_GZIP "/usr/bin/gzip" + #define _PATH_LN "/bin/ln" diff -c /usr/src/usr.bin/xinstall/xinstall.c ./xinstall.c *** /usr/src/usr.bin/xinstall/xinstall.c Fri May 27 05:33:39 1994 --- ./xinstall.c Mon Mar 13 15:20:19 1995 *************** *** 61,67 **** struct passwd *pp; struct group *gp; ! int docopy, dostrip; int mode = S_IRWXU|S_IRGRP|S_IXGRP|S_IROTH|S_IXOTH; char *group, *owner, pathbuf[MAXPATHLEN]; --- 61,67 ---- struct passwd *pp; struct group *gp; ! int docopy, dostrip, dogzip; int mode = S_IRWXU|S_IRGRP|S_IXGRP|S_IROTH|S_IXOTH; char *group, *owner, pathbuf[MAXPATHLEN]; *************** *** 73,78 **** --- 73,79 ---- void install __P((char *, char *, u_long, u_int)); u_long string_to_flags __P((char **, u_long *, u_long *)); void strip __P((char *)); + void gzip __P((char *)); void usage __P((void)); int *************** *** 88,94 **** char *flags, *to_name; iflags = 0; ! while ((ch = getopt(argc, argv, "cf:g:m:o:s")) != EOF) switch((char)ch) { case 'c': docopy = 1; --- 89,95 ---- char *flags, *to_name; iflags = 0; ! while ((ch = getopt(argc, argv, "cf:g:m:o:sz")) != EOF) switch((char)ch) { case 'c': docopy = 1; *************** *** 113,118 **** --- 114,122 ---- case 's': dostrip = 1; break; + case 'z': + dogzip = 1; + break; case '?': default: usage(); *************** *** 246,251 **** --- 250,261 ---- err("%s: chflags: %s", to_name, strerror(serrno)); } + /* + * The file has been installed. We now compress and create sym link + */ + if (dogzip) + gzip(to_name); + (void)close(to_fd); if (!docopy && !devnull && unlink(from_name)) err("%s: %s", from_name, strerror(errno)); *************** *** 317,322 **** --- 327,388 ---- } /* + * gzip -- + * use gzip(1) to compress target file, then create a sym link + */ + void + gzip(to_name) + char *to_name; + { + char gz_name[MAXPATHLEN]; + int serrno, status; + + /* + * Fork a child process to compress file. Note: gzip is executed + * with the `-f' option to force installation over existing files. + */ + switch (vfork()) { + case -1: + serrno = errno; + (void)unlink(to_name); + err("forks: %s", strerror(errno)); + case 0: + execl(_PATH_GZIP, "gzip", "-f", to_name, NULL); + err("%s: %s", _PATH_STRIP, strerror(errno)); + default: + if (wait(&status) == -1 || status) + (void)unlink(to_name); + } + + /* + * Compression must have been successful, if we get here. + * So, build a filename for the gzipped file + */ + if (strlen(to_name) < MAXPATHLEN - 3) + strcpy(gz_name, to_name); + strcat(gz_name, ".gz"); + + /* + * Fork a child to create sym link + */ + switch (vfork()) { + case -1: + serrno = errno; + (void)unlink(to_name); + (void)unlink(gz_name); + err("forks: %s", strerror(errno)); + case 0: + execl(_PATH_LN, "ln", "-s", gz_name, to_name, NULL); + err("%s: %s", _PATH_LN, strerror(errno)); + default: + if (wait(&status) == -1 || status) { + (void)unlink(to_name); + (void)unlink(gz_name); + } + } + } + + /* * usage -- * print a usage message and die */ *************** *** 324,330 **** usage() { (void)fprintf(stderr, ! "usage: install [-cs] [-f flags] [-g group] [-m mode] [-o owner] file1 file2;\n\tor file1 ... fileN directory\n"); exit(1); } --- 390,396 ---- usage() { (void)fprintf(stderr, ! "usage: install [-csz] [-f flags] [-g group] [-m mode] [-o owner] file1 file2;\n\tor file1 ... fileN directory\n"); exit(1); }