From ee3047ee163d0ec2b0c416c2bb11f29ecb1b7552 Mon Sep 17 00:00:00 2001 From: nbd Date: Thu, 20 Apr 2006 00:25:17 +0000 Subject: add timestamp check script git-svn-id: svn://svn.openwrt.org/openwrt/branches/buildroot-ng/openwrt@3677 3c298f89-4303-0410-b956-a3cf2f4a3e73 --- scripts/timestamp.pl | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100755 scripts/timestamp.pl (limited to 'scripts/timestamp.pl') diff --git a/scripts/timestamp.pl b/scripts/timestamp.pl new file mode 100755 index 000000000..f6b06bc7f --- /dev/null +++ b/scripts/timestamp.pl @@ -0,0 +1,40 @@ +#!/usr/bin/perl +use strict; + +sub get_ts($) { + my $path = shift; + my $ts = 0; + open FIND, "find $path -not -path \\*.svn\\* -and -not -path \\*CVS\\* |"; + while () { + open FILE, "<$_"; + my @stat = stat FILE; + close FILE; + $ts = $stat[9] if ($stat[9] > $ts); + } + close FIND; + return $ts; +} + +(@ARGV > 0) or push @ARGV, "."; +my $ts = 0; +my $n = "."; +my %options; +foreach my $path (@ARGV) { + if ($path =~ /^-/) { + $options{$path} = 1; + } else { + my $tmp = get_ts($path); + if ($tmp > $ts) { + $n = $path; + $ts = $tmp; + } + } +} + +if ($options{"-p"}) { + print "$n\n"; +} elsif ($options{"-t"}) { + print "$ts\n"; +} else { + print "$n\t$ts\n"; +} -- cgit v1.2.3 From 61ad8a56f8a015d3d9a673eca98971677135935d Mon Sep 17 00:00:00 2001 From: nbd Date: Thu, 20 Apr 2006 00:33:40 +0000 Subject: redirect find stderr to /dev/null in timestamp.pl git-svn-id: svn://svn.openwrt.org/openwrt/branches/buildroot-ng/openwrt@3678 3c298f89-4303-0410-b956-a3cf2f4a3e73 --- scripts/timestamp.pl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'scripts/timestamp.pl') diff --git a/scripts/timestamp.pl b/scripts/timestamp.pl index f6b06bc7f..108922191 100755 --- a/scripts/timestamp.pl +++ b/scripts/timestamp.pl @@ -4,7 +4,7 @@ use strict; sub get_ts($) { my $path = shift; my $ts = 0; - open FIND, "find $path -not -path \\*.svn\\* -and -not -path \\*CVS\\* |"; + open FIND, "find $path -not -path \\*.svn\\* -and -not -path \\*CVS\\* 2>/dev/null |"; while () { open FILE, "<$_"; my @stat = stat FILE; -- cgit v1.2.3 From ae5ab94ef5f0660d381a3c7076e144be5bf37eef Mon Sep 17 00:00:00 2001 From: nbd Date: Thu, 20 Apr 2006 03:45:03 +0000 Subject: add proper package dependency handling git-svn-id: svn://svn.openwrt.org/openwrt/branches/buildroot-ng/openwrt@3679 3c298f89-4303-0410-b956-a3cf2f4a3e73 --- scripts/timestamp.pl | 34 +++++++++++++++++++++++++--------- 1 file changed, 25 insertions(+), 9 deletions(-) (limited to 'scripts/timestamp.pl') diff --git a/scripts/timestamp.pl b/scripts/timestamp.pl index 108922191..a4bb7ecda 100755 --- a/scripts/timestamp.pl +++ b/scripts/timestamp.pl @@ -1,31 +1,47 @@ #!/usr/bin/perl use strict; -sub get_ts($) { +sub get_ts($$) { my $path = shift; + my $options = shift; my $ts = 0; - open FIND, "find $path -not -path \\*.svn\\* -and -not -path \\*CVS\\* 2>/dev/null |"; + my $fn = ""; + -d "$path" and $path .= "/*"; + open FIND, "find $path -not -path \\*.svn\\* -and -not -path \\*CVS\\* $options 2>/dev/null |"; while () { - open FILE, "<$_"; + chomp; + my $file = $_; + open FILE, "<$file"; my @stat = stat FILE; close FILE; - $ts = $stat[9] if ($stat[9] > $ts); + if ($stat[9] > $ts) { + $ts = $stat[9]; + $fn = $file; + } } close FIND; - return $ts; + return ($ts, $fn); } (@ARGV > 0) or push @ARGV, "."; my $ts = 0; my $n = "."; my %options; -foreach my $path (@ARGV) { - if ($path =~ /^-/) { +while (@ARGV > 0) { + my $path = shift @ARGV; + if ($path =~ /^-x/) { + my $str = shift @ARGV; + $options{"-x"} .= " -and -not -path \\*".$str."\\*" + } elsif ($path =~ /^-/) { $options{$path} = 1; } else { - my $tmp = get_ts($path); + my ($tmp, $fname) = get_ts($path, $options{"-x"}); if ($tmp > $ts) { - $n = $path; + if ($options{'-f'}) { + $n = $fname; + } else { + $n = $path; + } $ts = $tmp; } } -- cgit v1.2.3 From 1fbef95525ace333d4cef5e217d2293cdc891eaf Mon Sep 17 00:00:00 2001 From: nbd Date: Fri, 21 Apr 2006 02:19:38 +0000 Subject: fix detection of removed packages git-svn-id: svn://svn.openwrt.org/openwrt/branches/buildroot-ng/openwrt@3688 3c298f89-4303-0410-b956-a3cf2f4a3e73 --- scripts/timestamp.pl | 1 - 1 file changed, 1 deletion(-) (limited to 'scripts/timestamp.pl') diff --git a/scripts/timestamp.pl b/scripts/timestamp.pl index a4bb7ecda..dc47e24aa 100755 --- a/scripts/timestamp.pl +++ b/scripts/timestamp.pl @@ -6,7 +6,6 @@ sub get_ts($$) { my $options = shift; my $ts = 0; my $fn = ""; - -d "$path" and $path .= "/*"; open FIND, "find $path -not -path \\*.svn\\* -and -not -path \\*CVS\\* $options 2>/dev/null |"; while () { chomp; -- cgit v1.2.3 From 7eceaccf8379b7558fd6b3fac52ec6d985033f0b Mon Sep 17 00:00:00 2001 From: mbm Date: Mon, 15 May 2006 22:42:04 +0000 Subject: replace find call with perl code git-svn-id: svn://svn.openwrt.org/openwrt/branches/buildroot-ng/openwrt@3782 3c298f89-4303-0410-b956-a3cf2f4a3e73 --- scripts/timestamp.pl | 33 ++++++++++++++++++++++----------- 1 file changed, 22 insertions(+), 11 deletions(-) (limited to 'scripts/timestamp.pl') diff --git a/scripts/timestamp.pl b/scripts/timestamp.pl index dc47e24aa..9735dd61e 100755 --- a/scripts/timestamp.pl +++ b/scripts/timestamp.pl @@ -1,24 +1,35 @@ #!/usr/bin/perl use strict; +use File::stat; + +sub crawl($$) { + my $path = shift; + my $options = shift; + my @results = $path; + opendir(DIR,$path); + foreach my $file (readdir(DIR)) { + if ($file !~m/^(\.(svn|\.?)|CVS$options)$/) { + push @results, crawl("$path/$file",$options); + } + } + closedir(DIR); + return @results; +} sub get_ts($$) { my $path = shift; my $options = shift; my $ts = 0; my $fn = ""; - open FIND, "find $path -not -path \\*.svn\\* -and -not -path \\*CVS\\* $options 2>/dev/null |"; - while () { - chomp; - my $file = $_; - open FILE, "<$file"; - my @stat = stat FILE; - close FILE; - if ($stat[9] > $ts) { - $ts = $stat[9]; + my @search = crawl($path,$options); + while (@search) { + my $file = shift @search; + my $mtime = stat($file)->mtime; + if ($mtime > $ts) { + $ts = $mtime; $fn = $file; } } - close FIND; return ($ts, $fn); } @@ -30,7 +41,7 @@ while (@ARGV > 0) { my $path = shift @ARGV; if ($path =~ /^-x/) { my $str = shift @ARGV; - $options{"-x"} .= " -and -not -path \\*".$str."\\*" + $options{"-x"} .= "|".$str; } elsif ($path =~ /^-/) { $options{$path} = 1; } else { -- cgit v1.2.3 From d75c4b82131d175cbd37789f8cdd7efb5cf59b30 Mon Sep 17 00:00:00 2001 From: mbm Date: Mon, 15 May 2006 23:04:02 +0000 Subject: revert; perl version was entirely too slow git-svn-id: svn://svn.openwrt.org/openwrt/branches/buildroot-ng/openwrt@3783 3c298f89-4303-0410-b956-a3cf2f4a3e73 --- scripts/timestamp.pl | 33 +++++++++++---------------------- 1 file changed, 11 insertions(+), 22 deletions(-) (limited to 'scripts/timestamp.pl') diff --git a/scripts/timestamp.pl b/scripts/timestamp.pl index 9735dd61e..dc47e24aa 100755 --- a/scripts/timestamp.pl +++ b/scripts/timestamp.pl @@ -1,35 +1,24 @@ #!/usr/bin/perl use strict; -use File::stat; - -sub crawl($$) { - my $path = shift; - my $options = shift; - my @results = $path; - opendir(DIR,$path); - foreach my $file (readdir(DIR)) { - if ($file !~m/^(\.(svn|\.?)|CVS$options)$/) { - push @results, crawl("$path/$file",$options); - } - } - closedir(DIR); - return @results; -} sub get_ts($$) { my $path = shift; my $options = shift; my $ts = 0; my $fn = ""; - my @search = crawl($path,$options); - while (@search) { - my $file = shift @search; - my $mtime = stat($file)->mtime; - if ($mtime > $ts) { - $ts = $mtime; + open FIND, "find $path -not -path \\*.svn\\* -and -not -path \\*CVS\\* $options 2>/dev/null |"; + while () { + chomp; + my $file = $_; + open FILE, "<$file"; + my @stat = stat FILE; + close FILE; + if ($stat[9] > $ts) { + $ts = $stat[9]; $fn = $file; } } + close FIND; return ($ts, $fn); } @@ -41,7 +30,7 @@ while (@ARGV > 0) { my $path = shift @ARGV; if ($path =~ /^-x/) { my $str = shift @ARGV; - $options{"-x"} .= "|".$str; + $options{"-x"} .= " -and -not -path \\*".$str."\\*" } elsif ($path =~ /^-/) { $options{$path} = 1; } else { -- cgit v1.2.3 From 02cdebbb91a33d8e24da1c94a9d93ac39be168a7 Mon Sep 17 00:00:00 2001 From: mbm Date: Tue, 27 Jun 2006 00:35:46 +0000 Subject: credit where credit is due git-svn-id: svn://svn.openwrt.org/openwrt/branches/buildroot-ng/openwrt@4091 3c298f89-4303-0410-b956-a3cf2f4a3e73 --- scripts/timestamp.pl | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'scripts/timestamp.pl') diff --git a/scripts/timestamp.pl b/scripts/timestamp.pl index dc47e24aa..093ced993 100755 --- a/scripts/timestamp.pl +++ b/scripts/timestamp.pl @@ -1,4 +1,11 @@ #!/usr/bin/perl +# +# Copyright (C) 2006 OpenWrt.org +# +# This is free software, licensed under the GNU General Public License v2. +# See /LICENSE for more information. +# + use strict; sub get_ts($$) { -- cgit v1.2.3 From 503788e306fdadeedba5392959bcdf31ccd74dd8 Mon Sep 17 00:00:00 2001 From: nbd Date: Fri, 4 Aug 2006 21:42:29 +0000 Subject: add -f option to timestamp.pl (follow symlinks) git-svn-id: svn://svn.openwrt.org/openwrt/branches/buildroot-ng/openwrt@4457 3c298f89-4303-0410-b956-a3cf2f4a3e73 --- scripts/timestamp.pl | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'scripts/timestamp.pl') diff --git a/scripts/timestamp.pl b/scripts/timestamp.pl index 093ced993..a3aa50cb0 100755 --- a/scripts/timestamp.pl +++ b/scripts/timestamp.pl @@ -37,11 +37,13 @@ while (@ARGV > 0) { my $path = shift @ARGV; if ($path =~ /^-x/) { my $str = shift @ARGV; - $options{"-x"} .= " -and -not -path \\*".$str."\\*" + $options{"findopts"} .= " -and -not -path \\*".$str."\\*" + } elsif ($path =~ /^-f/) { + $options{"findopts"} .= " -follow"; } elsif ($path =~ /^-/) { $options{$path} = 1; } else { - my ($tmp, $fname) = get_ts($path, $options{"-x"}); + my ($tmp, $fname) = get_ts($path, $options{"findopts"}); if ($tmp > $ts) { if ($options{'-f'}) { $n = $fname; -- cgit v1.2.3