diff --git a/README.en.md b/README.en.md deleted file mode 100644 index 95a3350..0000000 --- a/README.en.md +++ /dev/null @@ -1,36 +0,0 @@ -# fdupes - -#### Description -{**When you're done, you can delete the content in this README and update the file with details for others getting started with your repository**} - -#### Software Architecture -Software architecture description - -#### Installation - -1. xxxx -2. xxxx -3. xxxx - -#### Instructions - -1. xxxx -2. xxxx -3. xxxx - -#### Contribution - -1. Fork the repository -2. Create Feat_xxx branch -3. Commit your code -4. Create Pull Request - - -#### Gitee Feature - -1. You can use Readme\_XXX.md to support different languages, such as Readme\_en.md, Readme\_zh.md -2. Gitee blog [blog.gitee.com](https://blog.gitee.com) -3. Explore open source project [https://gitee.com/explore](https://gitee.com/explore) -4. The most valuable open source project [GVP](https://gitee.com/gvp) -5. The manual of Gitee [https://gitee.com/help](https://gitee.com/help) -6. The most popular members [https://gitee.com/gitee-stars/](https://gitee.com/gitee-stars/) diff --git a/README.md b/README.md deleted file mode 100644 index c695c9d..0000000 --- a/README.md +++ /dev/null @@ -1,39 +0,0 @@ -# fdupes - -#### 介绍 -{**以下是码云平台说明,您可以替换此简介** -码云是 OSCHINA 推出的基于 Git 的代码托管平台(同时支持 SVN)。专为开发者提供稳定、高效、安全的云端软件开发协作平台 -无论是个人、团队、或是企业,都能够用码云实现代码托管、项目管理、协作开发。企业项目请看 [https://gitee.com/enterprises](https://gitee.com/enterprises)} - -#### 软件架构 -软件架构说明 - - -#### 安装教程 - -1. xxxx -2. xxxx -3. xxxx - -#### 使用说明 - -1. xxxx -2. xxxx -3. xxxx - -#### 参与贡献 - -1. Fork 本仓库 -2. 新建 Feat_xxx 分支 -3. 提交代码 -4. 新建 Pull Request - - -#### 码云特技 - -1. 使用 Readme\_XXX.md 来支持不同的语言,例如 Readme\_en.md, Readme\_zh.md -2. 码云官方博客 [blog.gitee.com](https://blog.gitee.com) -3. 你可以 [https://gitee.com/explore](https://gitee.com/explore) 这个地址来了解码云上的优秀开源项目 -4. [GVP](https://gitee.com/gvp) 全称是码云最有价值开源项目,是码云综合评定出的优秀开源项目 -5. 码云官方提供的使用手册 [https://gitee.com/help](https://gitee.com/help) -6. 码云封面人物是一档用来展示码云会员风采的栏目 [https://gitee.com/gitee-stars/](https://gitee.com/gitee-stars/) diff --git a/fdupes-1.6.1-allow_a_instead_of_all.patch b/fdupes-1.6.1-allow_a_instead_of_all.patch new file mode 100644 index 0000000..89115e0 --- /dev/null +++ b/fdupes-1.6.1-allow_a_instead_of_all.patch @@ -0,0 +1,24 @@ +From 88f3d2dd31fbef7e539b2523724221e8e8e5a9f0 Mon Sep 17 00:00:00 2001 +From: Falk +Date: Thu, 27 Oct 2016 18:10:48 +0200 +Subject: [PATCH] allow to type just a instead of all + +Typing all many times can be boring/annoying, So I propose to allow people to type just a for all. +(sometimes there can be very large duplicate sets) +--- + fdupes.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/fdupes.c b/fdupes.c +index 7eee165..7a8a6ed 100644 +--- a/fdupes.c ++++ b/fdupes.c +@@ -886,7 +886,7 @@ void deletefiles(file_t *files, int prompt, FILE *tty) + token = strtok(preservestr, " ,\n"); + + while (token != NULL) { +- if (strcasecmp(token, "all") == 0) ++ if (strcasecmp(token, "all") == 0 || strcasecmp(token, "a") == 0) + for (x = 0; x <= counter; x++) preserve[x] = 1; + + number = 0; diff --git a/fdupes-1.6.1-delete_old_TODO.patch b/fdupes-1.6.1-delete_old_TODO.patch new file mode 100644 index 0000000..ac9ad2d --- /dev/null +++ b/fdupes-1.6.1-delete_old_TODO.patch @@ -0,0 +1,88 @@ +From 315f6702f1cc37036d9f826314245b44a781c387 Mon Sep 17 00:00:00 2001 +From: Adrian Lopez +Date: Sun, 21 Aug 2016 02:04:15 -0400 +Subject: [PATCH] Delete old TODO file. + +--- + TODO | 72 -------------------------------------------------------------------- + 1 file changed, 72 deletions(-) + delete mode 100644 TODO + +diff --git a/TODO b/TODO +deleted file mode 100644 +index f7f77c4..0000000 +--- a/TODO ++++ /dev/null +@@ -1,72 +0,0 @@ +-- A bug with -S shows wrong results. +- +-- A bug causes the following behavior: +- +- $ fdupes --symlinks testdir +- testdir/with spaces b +- testdir/with spaces a +- +- testdir/zero_b +- testdir/zero_a +- +- testdir/symlink_two +- testdir/twice_one +- +- $ cp testdir/two testdir/two_again +- $ fdupes --symlinks testdir +- testdir/two_again +- testdir/two +- testdir/twice_one +- testdir/symlink_two +- +- testdir/with spaces b +- testdir/with spaces a +- +- testdir/zero_b +- testdir/zero_a +- +- ** This is not the desired behavior. Likewise: +- +- $ fdupes testdir +- testdir/with spaces b +- testdir/with spaces a +- +- testdir/zero_b +- testdir/zero_a +- +- testdir/twice_one +- testdir/two +- +- $ fdupes --symlinks testdir +- testdir/with spaces b +- testdir/with spaces a +- +- testdir/zero_b +- testdir/zero_a +- +- testdir/symlink_two +- testdir/twice_one +- +-- Don't assume that stat always works. +- +-- Add partial checksumming where instead of MD5ing whole +- files we MD5 and compare every so many bytes, caching +- these partial results for subsequent comparisons. +- +-- Option -R should not have to be separated from the rest, +- such that "fdupes -dR testdir", "fdupes -d -R testdir", +- "fdupes -Rd testdir", etc., all yield the same results. +- +-- Add option to highlight or identify symlinked files (suggest +- using --classify to identify symlinks with @ suffix... when +- specified, files containing @ are listed using \@). +- +-- Consider autodeletion option without user intervention. +- +-- Consider option to match only to files in specific directory. +- +-- Do a little commenting, to avoid rolling eyes and/or snickering. +- +-- Fix problem where MD5 collisions will result in one of the +- files not being registered (causing it to be ignored). +- diff --git a/fdupes-1.6.1-option_sort_by_ctime.patch b/fdupes-1.6.1-option_sort_by_ctime.patch new file mode 100644 index 0000000..8529323 --- /dev/null +++ b/fdupes-1.6.1-option_sort_by_ctime.patch @@ -0,0 +1,167 @@ +From e95ec42dc178eff0410880c3dc4c0dac3df442df Mon Sep 17 00:00:00 2001 +From: Adrian Lopez +Date: Tue, 23 Aug 2016 18:21:18 -0400 +Subject: [PATCH] Add an option to sort duplicate files by ctime. + +--- + README | 5 +++-- + fdupes.1 | 2 +- + fdupes.c | 49 +++++++++++++++++++++++++++++++++++++------------ + 3 files changed, 41 insertions(+), 15 deletions(-) + +diff --git a/README b/README +index c748d05..c27f043 100644 +--- a/README ++++ b/README +@@ -37,8 +37,9 @@ Usage: fdupes [options] DIRECTORY... + grouping into sets; implies --noprompt + -p --permissions don't consider files with different owner/group or + permission bits as duplicates +- -o --order=BY select sort order for output, linking and deleting; by +- mtime (BY='time'; default) or filename (BY='name') ++ -o --order=BY select sort order for output and deleting; by file ++ modification time (BY='time'; default), status ++ change time (BY='ctime'), or filename (BY='name') + -i --reverse reverse order while sorting + -v --version display fdupes version + -h --help display this help message +diff --git a/fdupes.1 b/fdupes.1 +index 5ddad87..969a5d8 100644 +--- a/fdupes.1 ++++ b/fdupes.1 +@@ -72,7 +72,7 @@ don't consider files with different owner/group or permission bits as duplicates + .TP + .B -o --order\fR=\fIWORD\fR + order files according to WORD: +-time - sort by mtime, name - sort by filename ++time - sort by modification time, ctime - sort by status change time, name - sort by filename + .TP + .B -i --reverse + reverse order while sorting +diff --git a/fdupes.c b/fdupes.c +index ef64c45..7eee165 100644 +--- a/fdupes.c ++++ b/fdupes.c +@@ -56,7 +56,8 @@ + #define F_IMMEDIATE 0x8000 + + typedef enum { +- ORDER_TIME = 0, ++ ORDER_MTIME = 0, ++ ORDER_CTIME, + ORDER_NAME + } ordertype_t; + +@@ -64,6 +65,8 @@ char *program_name; + + unsigned long flags = 0; + ++ordertype_t ordertype = ORDER_MTIME; ++ + #define CHUNK_SIZE 8192 + + #define INPUT_SIZE 256 +@@ -97,7 +100,7 @@ typedef struct _file { + md5_byte_t *crcsignature; + dev_t device; + ino_t inode; +- time_t mtime; ++ time_t sorttime; + int hasdupes; /* true only if file is first on duplicate chain */ + struct _file *duplicates; + struct _file *next; +@@ -183,6 +186,14 @@ time_t getmtime(char *filename) { + return s.st_mtime; + } + ++time_t getctime(char *filename) { ++ struct stat s; ++ ++ if (stat(filename, &s) != 0) return 0; ++ ++ return s.st_ctime; ++} ++ + char **cloneargs(int argc, char **argv) + { + int x; +@@ -435,7 +446,17 @@ void getfilestats(file_t *file) + file->size = filesize(file->d_name); + file->inode = getinode(file->d_name); + file->device = getdevice(file->d_name); +- file->mtime = getmtime(file->d_name); ++ ++ switch (ordertype) ++ { ++ case ORDER_CTIME: ++ file->sorttime = getctime(file->d_name); ++ break; ++ case ORDER_MTIME: ++ default: ++ file->sorttime = getmtime(file->d_name); ++ break; ++ } + } + + int registerfile(filetree_t **branch, file_t *file) +@@ -911,11 +932,11 @@ int sort_pairs_by_arrival(file_t *f1, file_t *f2) + return !ISFLAG(flags, F_REVERSE) ? -1 : 1; + } + +-int sort_pairs_by_mtime(file_t *f1, file_t *f2) ++int sort_pairs_by_time(file_t *f1, file_t *f2) + { +- if (f1->mtime < f2->mtime) ++ if (f1->sorttime < f2->sorttime) + return !ISFLAG(flags, F_REVERSE) ? -1 : 1; +- else if (f1->mtime > f2->mtime) ++ else if (f1->sorttime > f2->sorttime) + return !ISFLAG(flags, F_REVERSE) ? 1 : -1; + + return 0; +@@ -1038,8 +1059,9 @@ void help_text() + printf(" \tgrouping into sets; implies --noprompt\n"); + printf(" -p --permissions \tdon't consider files with different owner/group or\n"); + printf(" \tpermission bits as duplicates\n"); +- printf(" -o --order=BY \tselect sort order for output, linking and deleting; by\n"); +- printf(" \tmtime (BY='time'; default) or filename (BY='name')\n"); ++ printf(" -o --order=BY \tselect sort order for output and deleting; by file\n"); ++ printf(" \tmodification time (BY='time'; default), status\n"); ++ printf(" \tchange time (BY='ctime'), or filename (BY='name')\n"); + printf(" -i --reverse \treverse order while sorting\n"); + printf(" -v --version \tdisplay fdupes version\n"); + printf(" -h --help \tdisplay this help message\n\n"); +@@ -1061,7 +1083,6 @@ int main(int argc, char **argv) { + int progress = 0; + char **oldargv; + int firstrecurse; +- ordertype_t ordertype = ORDER_TIME; + + #ifndef OMIT_GETOPT_LONG + static struct option long_options[] = +@@ -1161,7 +1182,9 @@ int main(int argc, char **argv) { + if (!strcasecmp("name", optarg)) { + ordertype = ORDER_NAME; + } else if (!strcasecmp("time", optarg)) { +- ordertype = ORDER_TIME; ++ ordertype = ORDER_MTIME; ++ } else if (!strcasecmp("ctime", optarg)) { ++ ordertype = ORDER_CTIME; + } else { + errormsg("invalid value for --order: '%s'\n", optarg); + exit(1); +@@ -1247,10 +1270,12 @@ int main(int argc, char **argv) { + if (confirmmatch(file1, file2)) { + if (ISFLAG(flags, F_DELETEFILES) && ISFLAG(flags, F_IMMEDIATE)) + deletesuccessor(match, curfile, +- (ordertype == ORDER_TIME) ? sort_pairs_by_mtime : sort_pairs_by_filename ); ++ (ordertype == ORDER_MTIME || ++ ordertype == ORDER_CTIME) ? sort_pairs_by_time : sort_pairs_by_filename ); + else + registerpair(match, curfile, +- (ordertype == ORDER_TIME) ? sort_pairs_by_mtime : sort_pairs_by_filename ); ++ (ordertype == ORDER_MTIME || ++ ordertype == ORDER_CTIME) ? sort_pairs_by_time : sort_pairs_by_filename ); + } + + fclose(file1); diff --git a/fdupes-1.6.1.tar.gz b/fdupes-1.6.1.tar.gz new file mode 100644 index 0000000..7763ef8 Binary files /dev/null and b/fdupes-1.6.1.tar.gz differ diff --git a/fdupes.spec b/fdupes.spec new file mode 100644 index 0000000..be05342 --- /dev/null +++ b/fdupes.spec @@ -0,0 +1,84 @@ +%global macrosdir %(d=%{_rpmconfigdir}/macros.d; [ -d $d ] || d=%{_sysconfdir}/rpm; /bin/echo $d) +%global macrosname macros.%{name} +%global nameversion %{name}-%{version} + +Name: fdupes +Epoch: 1 +Version: 1.6.1 +Release: 6 +Summary: Identifying duplicate files residing within specified directories + +License: MIT +URL: https://github.com/adrianlopezroche/%{name} +Source0: %{url}/archive/v%{version}.tar.gz#/%{nameversion}.tar.gz +Source1: %{macrosname} + +BuildRequires: gcc + +Patch0: %{nameversion}-delete_old_TODO.patch +Patch1: %{nameversion}-option_sort_by_ctime.patch +Patch2: %{nameversion}-allow_a_instead_of_all.patch + +%description +FDUPES is a program for identifying duplicate files residing within specified +directories. + +%package_help + + +%prep +%autosetup -p 1 + +# From README. +%{__cat} << EOF > LICENSE +FDUPES Copyright (c) 1999 Adrian Lopez + +Permission is hereby granted, free of charge, to any person +obtaining a copy of this software and associated documentation files +(the "Software"), to deal in the Software without restriction, +including without limitation the rights to use, copy, modify, merge, +publish, distribute, sublicense, and/or sell copies of the Software, +and to permit persons to whom the Software is furnished to do so, +subject to the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +EOF + + +%build +%make_build COMPILER_OPTIONS="%{?optflags}" LDFLAGS="%{?__global_ldflags}" + + +%install +%make_install BIN_DIR=%{_bindir} MAN_BASE_DIR=%{_mandir} +install -Dpm 0644 %{SOURCE1} %{buildroot}%{macrosdir}/%{macrosname} + + +%check +./%{name} testdir +./%{name} --omitfirst testdir +./%{name} --recurse testdir +./%{name} --size testdir + + +%files +%license CONTRIBUTORS LICENSE +%{_bindir}/%{name} +%{macrosdir}/%{macrosname} + +%files help +%doc CHANGES README +%doc %{_mandir}/man1/%{name}.1* + +%changelog +* Tue Dec 3 2019 mengxian - 1:1.6.1-6 +- Package init diff --git a/macros.fdupes b/macros.fdupes new file mode 100644 index 0000000..d01d65c --- /dev/null +++ b/macros.fdupes @@ -0,0 +1,21 @@ +%fdupes(s) \ + _target=""; \ + _symlinks=0; \ + %{-s:_symlinks=1;} \ + fdupes -q -n -r -p %1 | \ + while read _file; do \ + if test -z "$_target" ; then \ + _target="$_file"; \ + else \ + if test -z "$_file" ; then \ + _target=""; \ + continue ; \ + fi ; \ + if test "$_symlinks" = 1; then \ + ln -sf "${_target#%{buildroot}}" "$_file"; \ + else \ + ln -f "$_target" "$_file"; \ + fi ;\ + fi ; \ + done \ +%{nil}