summaryrefslogtreecommitdiff
path: root/sysutils
diff options
context:
space:
mode:
authorrillig <rillig@pkgsrc.org>2006-08-04 22:46:27 +0000
committerrillig <rillig@pkgsrc.org>2006-08-04 22:46:27 +0000
commite36b6248d63227824c73e72dae2c7585342ff044 (patch)
treeb26bb5452617af16e5a588a3e373b61c9c3f392d /sysutils
parenta18c54cebc675acdf626a05e3ad53e232b8642c0 (diff)
downloadpkgsrc-e36b6248d63227824c73e72dae2c7585342ff044.tar.gz
Updated same to 1.8.
Changes unknown.
Diffstat (limited to 'sysutils')
-rw-r--r--sysutils/same/Makefile17
-rw-r--r--sysutils/same/PLIST3
-rw-r--r--sysutils/same/distinfo10
-rw-r--r--sysutils/same/files/Makefile17
-rw-r--r--sysutils/same/files/same.1180
-rw-r--r--sysutils/same/patches/patch-ab133
-rw-r--r--sysutils/same/patches/patch-ac130
7 files changed, 233 insertions, 257 deletions
diff --git a/sysutils/same/Makefile b/sysutils/same/Makefile
index 68a237dea63..e3d442d83d1 100644
--- a/sysutils/same/Makefile
+++ b/sysutils/same/Makefile
@@ -1,20 +1,23 @@
-# $NetBSD: Makefile,v 1.1.1.1 2004/04/17 13:21:48 minskim Exp $
+# $NetBSD: Makefile,v 1.2 2006/08/04 22:46:27 rillig Exp $
-DISTNAME= same-1.3
+DISTNAME= same-1.8
CATEGORIES= sysutils
MASTER_SITES= ftp://ftp.bitwizard.nl/same/
-MAINTAINER= roland.illig@gmx.de
+MAINTAINER= rillig@NetBSD.org
HOMEPAGE= http://www.bitwizard.nl/
COMMENT= Find identical files and link(2) them to save disk space
PKG_INSTALLATION_TYPES= overwrite pkgviews
-MAKEFILE= ${FILESDIR}/Makefile
+INSTALLATION_DIRS= bin ${PKGMANDIR}/man1
-INSTALLATION_DIRS= bin man/man1
+MAKE_FLAGS+= BINDIR=${PREFIX}/bin
+MAKE_FLAGS+= MANDIR=${PREFIX}/${PKGMANDIR}
+MAKE_FLAGS+= BINOWN=${BINOWN} BINGRP=${BINGRP}
+MAKE_FLAGS+= MANOWN=${MANOWN} MANGRP=${MANGRP}
-post-patch:
- @${CP} ${FILESDIR}/same.1 ${WRKSRC}
+post-extract:
+ cd ${FILESDIR} && cp -f Makefile same.1 ${WRKSRC}
.include "../../mk/bsd.pkg.mk"
diff --git a/sysutils/same/PLIST b/sysutils/same/PLIST
index 9bc7478c798..f4b5824018e 100644
--- a/sysutils/same/PLIST
+++ b/sysutils/same/PLIST
@@ -1,3 +1,4 @@
-@comment $NetBSD: PLIST,v 1.1.1.1 2004/04/17 13:21:48 minskim Exp $
+@comment $NetBSD: PLIST,v 1.2 2006/08/04 22:46:27 rillig Exp $
bin/same
+man/cat1/same.0
man/man1/same.1
diff --git a/sysutils/same/distinfo b/sysutils/same/distinfo
index 41282944e59..ed3fba87415 100644
--- a/sysutils/same/distinfo
+++ b/sysutils/same/distinfo
@@ -1,6 +1,6 @@
-$NetBSD: distinfo,v 1.2 2005/02/24 13:40:57 agc Exp $
+$NetBSD: distinfo,v 1.3 2006/08/04 22:46:27 rillig Exp $
-SHA1 (same-1.3.tar.gz) = 0638d10e53c022470e0ef724679f2c476607ebb2
-RMD160 (same-1.3.tar.gz) = dc0bc8b02a7e02b78f5deae1c3989ac7f92948c4
-Size (same-1.3.tar.gz) = 9119 bytes
-SHA1 (patch-ab) = 7df4a5ee747bf542911c5c2f7208494c68ce9561
+SHA1 (same-1.8.tar.gz) = 39d95e70c09703b5c7525a6ea896c097f744d288
+RMD160 (same-1.8.tar.gz) = 987e6dc1c99258f00ed831af3fa3f034ebe08134
+Size (same-1.8.tar.gz) = 9398 bytes
+SHA1 (patch-ac) = d8b2d46570c54f54b16b0562ae594ad3e23f8257
diff --git a/sysutils/same/files/Makefile b/sysutils/same/files/Makefile
index 0cdc53fba11..1ff9289457a 100644
--- a/sysutils/same/files/Makefile
+++ b/sysutils/same/files/Makefile
@@ -1,15 +1,6 @@
-same_OBJECTS= same.o crc32.o
+# $NetBSD: Makefile,v 1.2 2006/08/04 22:46:27 rillig Exp $
-all: same
+PROG= same
+LDADD= -lz
-install: all
- ${BSD_INSTALL_PROGRAM} same ${PREFIX}/bin/same
- ${BSD_INSTALL_MAN} same.1 ${PREFIX}/man/man1/same.1
-
-.c.o:
- ${CC} ${CPPFLAGS} ${CFLAGS} -c $< -o $@
-
-same: ${same_OBJECTS}
- ${CC} ${LDFLAGS} $(same_OBJECTS) ${LIBS} -o $@
-
-.PHONY: all install
+.include <bsd.prog.mk>
diff --git a/sysutils/same/files/same.1 b/sysutils/same/files/same.1
index 00a358dd9a6..2647befe357 100644
--- a/sysutils/same/files/same.1
+++ b/sysutils/same/files/same.1
@@ -1,114 +1,98 @@
-.TH same 1
-
-.SH NAME
-same \- find identical files and link them to save disk space.
-
-.SH SYNOPSIS
-
-\fBsame\fR [-d | --debug] [-hs \fIn\fR | --hashstart \fIn\fR]
-[-n | --dryrun] [-s] [-t | --timings] [-v | --verbose]
-[-z --nullfiles]
-
-.SH OPTIONS
-
-.TP
-\fB\-d\fR, \fB\-\-debug\fR
-Switch on debugging messages from the program.
-
-.TP
-\fB\-hs\fR \fIn\fR, \fB--hashstart\fR \fIn\fR
-Set the start value of the hash function.
-
-.TP
-\fB\-n\fR, \fB\-\-dryrun\fR
-Do not modify any file on the disk.
-
-.TP
-\fB\-s\fR
-Create symbolic links instead of hard links.
-
-.TP
-\fB\-t\fR, \fB\-\-timings\fR
-At the end of the program, output the time needed.
-
-.TP
-\fB\-v\fR, \fB\-\-verbose\fR
-Output some messages what is done.
-
-.TP
-\fB\-z\fR, \fB\-\-nullfiles\fR
-Even create links for empty files. Normally these files are ignored.
-
-
-.SH INTRODUCTION
-
-This program takes a list of files (e.g. the output of \fBfind . -type f\fR)
-on stdin. Each of the files is compared against each of the
-others. Whenever two files are found that match exactly, the two files
-are linked (soft or hard) together.
-
-
-.SH GOAL
-
+.\" $NetBSD: same.1,v 1.2 2006/08/04 22:46:27 rillig Exp $
+.Dd July 14, 2004
+.Dt SAME 1
+.Sh NAME
+.Nm same
+.Nd link identical files to save disk space
+.Sh SYNOPSIS
+.Nm
+.Fl HVcdhnstuvz
+.Sh DESCRIPTION
+.Nm
+takes a list of files (e.g. the output of find . -type f) on stdin.
+Each of the files is compared against each of the others.
+Whenever two files are found that match exactly, the two files are
+linked (soft or hard) together.
+.Ss Goal
The goal of this program is to conserve disk space when you have
-several different trees of large project on your disk. By creating
-hardlinks or softlinks between the files that are the same, you can
-save lots of disk space. For example, two different versions of the
-Linux kernel only differ in a small number of files. By running this
-program you only need to store the contents of those files once.
+several different trees of large projects on your disk.
+By creating hardlinks or softlinks between the files that are the same,
+you can save lots of disk space.
+For example, two different versions of the Linux kernel only differ in a
+small number of files.
+By running this program you only need to store the contents of those
+files once.
This is especially useful if you have different versions of complete
-trees lying around.
-
-.SH IMPLEMENTATION
-
+trees lying around.
+.Ss Implementation
The filesize of every file is used as an indication of wether two
files can be the same. Whenever the filesizes match, the hashes of
these two files are compared. Whenever these match, the file
contents are compared. For every matching pair one of the two
files is replaced by a hard link to the other file.
-With the \fB-s\fR option a softlink is used.
-
+With the -s option a softlink is used.
+.Pp
To allow you to do this incrementally, the "rm" is done on the file
with the least links. This allows you to "merge" a new tree with
several trees that have already been processed. The new tree has
link count 1, while the old tree has a higher link count for those
files that are likely candidates for linkage.
-
+.Pp
The current implementation keeps the "first" incantation of a file,
and replaces further occurrances of the same file. This is
-significant when using softlinks.
-
-.SH EXAMPLE
-
-.TP
-\fBfind . -type f | same\fR
-
-This links all files together under the current directory that are
-the same.
-
-.SH BUGS
-
-.IP \(bu
-Make sure that you have all the permissions required for
-execution of the commands.
-
-.IP \(bu
-RCS probably allows you to do similar things.
-
-.IP \(bu
+significant when using softlinks.
+.Ss Options
+.Bl -tag -width xxxxxx
+.It Fl H Ar n , Fl -hashstart Ar n
+Start at hash value
+.Ar n
+instead of 0.
+.It Fl V , Fl -version
+Print the version of the program and exit.
+.It Fl c Ar file , Fl -cache Ar file
+Keep a cache between runs in file
+.Ar file .
+.It Fl d , Fl -debug
+Output some debug messages.
+.It Fl h , Fl -help
+Output this page and exit successfully.
+.It Fl n , Fl -dryrun
+Only simulate.
+.It Fl s , Fl -softlinks
+Create soft links instead of hard links.
+.It Fl u , Fl -user
+Don't relink files owned by another user.
+.It Fl v , Fl -verbose
+Output verbose messages.
+.It Fl z , Fl -nullfiles
+Link empty files, too.
+By default, only non-empty files are linked.
+.El
+.Sh EXIT STATUS
+Zero on success, non-zero on failure.
+.Sh EXAMPLES
+.Bd -literal
+find . -type f -print | same
+.Ed
+.Sh SEE ALSO
+.Xr find 1
+.Sh AUTHORS
+.An "Roger E. Wolff" Aq R.E.Wolff@BitWizard.nl ,
+.An "Geert Uytterhoeven" Aq geert@linux-m68k.org ,
+.An "Roland Illig" Aq roland.illig@gmx.de .
+.Sh CAVEATS
+.Bl -bullet
+.It
If your editor does not move the original aside before writing a
new copy, you will change the file in ALL incarnations when
-editing a file. Patch works just fine: it moves the original
-aside before creating a new copy. I'm confident that I could
-learn Emacs to do it this way too. I'm too lazy to figure it out,
-so if you happen to know an easy way how to do this, please Email
-me at R.E.Wolff@BitWizard.nl
-
-.IP \(bu
-There is a 1024 character limit to pathnames when using symlinks.
-
-.SH AUTHOR
-
-This manpage was written by Roland Illig <roland.illig@gmx.de> for the
-pkgsrc distribution. Some sections are taken from the source code of
-`same'.
+editing a file.
+Patch works just fine: it moves the original aside before creating a new
+copy.
+I'm confident that I could learn Emacs to do it this way too.
+I'm too lazy to figure it out, so if you happen to know an easy way how
+to do this, please Email me at
+.Aq R.E.Wolff@BitWizard.nl .
+.It
+There is a 1024 (BUFSIZE) character limit to pathnames when using
+symlinks.
+.El
diff --git a/sysutils/same/patches/patch-ab b/sysutils/same/patches/patch-ab
deleted file mode 100644
index 461ec92bdf2..00000000000
--- a/sysutils/same/patches/patch-ab
+++ /dev/null
@@ -1,133 +0,0 @@
-$NetBSD: patch-ab,v 1.1.1.1 2004/04/17 13:21:48 minskim Exp $
-
---- same.c.orig 2000-10-16 10:04:15.000000000 +0200
-+++ same.c 2004-01-31 20:14:29.000000000 +0100
-@@ -143,6 +143,9 @@
- dev_t device;
- ino_t inode;
- nlink_t nlink;
-+ mode_t mode;
-+ uid_t owner;
-+ gid_t group;
- long crc;
- struct inode_entry *next;
- struct name_entry *names;
-@@ -254,11 +257,19 @@
- fprintf(stderr, "%-60s: %10.2f s\n", "*** Total execution time ***",
- (double)total_time/CLK_TCK);
- fputs("Statistics:\n", stderr);
-- fprintf(stderr, " Merged %lu hard links\n", stat_merge);
-- fprintf(stderr, " Calculated %lu CRCs\n", stat_crc);
-- fprintf(stderr, " Compared %lu files\n", stat_cmp);
-- fprintf(stderr, " Linked %lu names for %lu identical files\n",
-- stat_link_name, stat_link_inode);
-+ if (o_dryrun) {
-+ fprintf(stderr, " Would have merged %lu hard links\n", stat_merge);
-+ fprintf(stderr, " Calculated %lu CRCs\n", stat_crc);
-+ fprintf(stderr, " Compared %lu files\n", stat_cmp);
-+ fprintf(stderr, " Would have linked %lu names for %lu identical files\n",
-+ stat_link_name, stat_link_inode);
-+ } else {
-+ fprintf(stderr, " Merged %lu hard links\n", stat_merge);
-+ fprintf(stderr, " Calculated %lu CRCs\n", stat_crc);
-+ fprintf(stderr, " Compared %lu files\n", stat_cmp);
-+ fprintf(stderr, " Linked %lu names for %lu identical files\n",
-+ stat_link_name, stat_link_inode);
-+ }
- }
-
- static void progress(int percent)
-@@ -292,10 +303,10 @@
- {
- struct name_entry *names;
-
-- printf("%sentry %p size %ld device %lx inode %lx nlink %d crc %08lx\n",
-+ printf("%sentry %p size %ld device %lx inode %lx nlink %d mode %06o owner %d group %d crc %08lx\n",
- indent, entry, (unsigned long)entry->size,
- (unsigned long)entry->device, (unsigned long)entry->inode,
-- entry->nlink, entry->crc);
-+ entry->nlink, entry->mode, entry->owner, entry->group, entry->crc);
- for (names = entry->names; names; names = names->next)
- printf("%s %s\n", indent, names->name);
- }
-@@ -435,6 +446,9 @@
- entry1 = entry0->next;
- while (!stop && entry1) {
- if ((entry0->size == entry1->size) &&
-+ (entry0->mode == entry1->mode) &&
-+ (entry0->owner == entry1->owner) &&
-+ (entry0->group == entry1->group) &&
- (entry0->size != 0 || o_nullfiles)) {
- if (entry0->crc == -1)
- calc_crc(entry0);
-@@ -474,10 +488,16 @@
- {
- int res = 0;
-
-- if (o_debug > 0)
-- printf("unlink %s\n", name);
-- if (!o_dryrun && ((res = unlink(name)) == -1))
-+ if (o_debug > 0) {
-+ if (o_dryrun) {
-+ printf("would unlink %s\n", name);
-+ } else {
-+ printf("unlink %s\n", name);
-+ }
-+ }
-+ if (!o_dryrun && ((res = unlink(name)) == -1)) {
- fprintf(stderr, "unlink %s: %s\n", name, strerror(errno));
-+ }
- return res;
- }
-
-@@ -485,8 +505,13 @@
- {
- int res = 0;
-
-- if (o_debug > 0)
-- printf("link %s %s\n", master, slave);
-+ if (o_debug > 0) {
-+ if (o_dryrun) {
-+ printf("would link %s %s\n", master, slave);
-+ } else {
-+ printf("link %s %s\n", master, slave);
-+ }
-+ }
- if (!o_dryrun && ((res = link(master, slave)) == -1))
- fprintf(stderr, "link %s %s: %s\n", master, slave, strerror(errno));
- return res;
-@@ -496,8 +521,13 @@
- {
- int res = 0;
-
-- if (o_debug > 0)
-- printf("symlink %s %s\n", master, slave);
-+ if (o_debug > 0) {
-+ if (o_dryrun) {
-+ printf("would symlink %s %s\n", master, slave);
-+ } else {
-+ printf("symlink %s %s\n", master, slave);
-+ }
-+ }
- if (!o_dryrun && ((res = symlink(master, slave)) == -1))
- fprintf(stderr, "symlink %s %s: %s\n", master, slave, strerror(errno));
- return res;
-@@ -618,7 +648,7 @@
- return NULL;
- buf[strlen(buf)-1] = '\0';
- if (lstat(buf, &sb) < 0) {
-- fprintf(stderr, "stat %s: %s", buf, strerror(errno));
-+ fprintf(stderr, "stat %s: %s\n", buf, strerror(errno));
- exit (1);
- }
- } while (!S_ISREG(sb.st_mode));
-@@ -630,6 +660,9 @@
- entry->device = sb.st_dev;
- entry->inode = sb.st_ino;
- entry->nlink = sb.st_nlink;
-+ entry->mode = sb.st_mode;
-+ entry->owner = sb.st_uid;
-+ entry->group = sb.st_gid;
- entry->crc = -1;
-
- return entry;
diff --git a/sysutils/same/patches/patch-ac b/sysutils/same/patches/patch-ac
new file mode 100644
index 00000000000..7c204bedeae
--- /dev/null
+++ b/sysutils/same/patches/patch-ac
@@ -0,0 +1,130 @@
+$NetBSD: patch-ac,v 1.1 2006/08/04 22:46:27 rillig Exp $
+
+--- same.c.orig 2004-07-16 19:30:01.000000000 +0200
++++ same.c 2006-08-05 00:17:54.000000000 +0200
+@@ -106,10 +106,9 @@
+ * - There is a 1024 (BUFSIZE) character limit to pathnames when using
+ * symlinks.
+ *
+- * - The same source is not exactly 32kbytes long. However this comment
+- * seems to fix that.
+ * */
+
++#define _FILE_OFFSET_BITS 64
+
+ #include <assert.h>
+ #include <stdio.h>
+@@ -123,16 +122,8 @@
+ #include <sys/times.h>
+ #include <zlib.h>
+ #include <limits.h>
+-
+-#define __USE_LARGEFILE64
+ #include <sys/stat.h>
+
+-#if 1
+-/* Why the *&^#$ doesn't sys/stat define this??? */
+-extern int lstat64 (__const char *__restrict __file,
+- struct stat64 *__restrict __buf) __THROW;
+-#endif
+-
+ #ifdef __linux__
+ #include <asm/page.h>
+ #else /* !__linux__ */
+@@ -184,7 +175,7 @@ static const char *o_cache;
+
+ struct name_entry {
+ struct name_entry *next;
+- char name[0];
++ char name[1];
+ };
+
+ #define F_CRC_VALID (1 << 0)
+@@ -196,7 +187,7 @@ struct inode_entry {
+ struct name_entry *names;
+ int flags; /* See F_* definitions above */
+ /* The two fields below may have been read from the cache */
+- loff_t size;
++ off_t size;
+ unsigned int crc; /* valid if flags & F_CRC_VALID only */
+ /* The four fields below are valid if flags & F_STAT_VALID only */
+ dev_t device;
+@@ -288,7 +279,7 @@ static void read_list(void);
+ static const char *get_fname(void);
+ static struct inode_entry *get_entry(void);
+ static int __get_stat(struct inode_entry *entry);
+-static unsigned int calc_hash(const struct stat64 *sb);
++static unsigned int calc_hash(const struct stat *sb);
+ static int __get_crc(struct inode_entry *entry);
+ static int cmp(const struct inode_entry *entry1,
+ const struct inode_entry *entry2);
+@@ -379,7 +370,7 @@ static void dump_inode_entry(const struc
+
+ printf("%sentry %p size %lu crc %08x device %lx inode %lx nlink %d uid "
+ "%lx\n",
+- indent, entry, (unsigned long)entry->size, entry->crc,
++ indent, (void *)entry, (unsigned long)entry->size, entry->crc,
+ (unsigned long)entry->device, (unsigned long)entry->inode,
+ entry->nlink, (unsigned long)entry->uid);
+ for (names = entry->names; names; names = names->next)
+@@ -429,7 +420,7 @@ static void load_cache(void)
+ gzFile *in;
+ unsigned long line = 0;
+ char *s;
+- loff_t size;
++ off_t size;
+ unsigned int crc;
+ const char *name;
+ unsigned int hash = 0;
+@@ -1168,7 +1159,7 @@ static struct inode_entry *get_entry(voi
+ {
+ const char *buf;
+ struct inode_entry *entry;
+- struct stat64 sb;
++ struct stat sb;
+ unsigned int hash;
+
+ do {
+@@ -1176,7 +1167,7 @@ static struct inode_entry *get_entry(voi
+ if (buf == NULL)
+ return NULL;
+ stat_stat++;
+- if (lstat64(buf, &sb) < 0) {
++ if (lstat(buf, &sb) < 0) {
+ fprintf(stderr, "stat %s: %s\n", buf, strerror(errno));
+ exit(1);
+ }
+@@ -1204,13 +1195,13 @@ static struct inode_entry *get_entry(voi
+
+ static int __get_stat(struct inode_entry *entry)
+ {
+- struct stat64 sb;
++ struct stat sb;
+ struct name_entry *name;
+
+ /* Loop until we find a file that does exist */
+ while ((name = entry->names) != 0) {
+ stat_stat++;
+- if (lstat64(name->name, &sb) < 0)
++ if (lstat(name->name, &sb) < 0)
+ fprintf(stderr, "stat %s: %s\n", name->name, strerror(errno));
+ else if (S_ISREG(sb.st_mode)) {
+ entry->device = sb.st_dev;
+@@ -1231,7 +1222,7 @@ static int __get_stat(struct inode_entry
+ * Calculate the Hash Value for an Inode Entry
+ */
+
+-static unsigned int calc_hash(const struct stat64 *sb)
++static unsigned int calc_hash(const struct stat *sb)
+ {
+ return (sb->st_size) % MAXHASH;
+ }
+@@ -1256,7 +1247,7 @@ static int __get_crc(struct inode_entry
+ }
+
+ while ((n = read(f1, b1, BUFSIZE)) > 0)
+- crc = crc32(crc, b1, n);
++ crc = crc32(crc, (void *)b1, n);
+ close(f1);
+ if (n < 0) {
+ fprintf(stderr, "read %s: %s\n", entry->names->name, strerror(errno));