include .pkginfo in image builder
[openwrt.git] / scripts / timestamp.pl
1 #!/usr/bin/perl
2 #
3 # Copyright (C) 2006 OpenWrt.org
4 #
5 # This is free software, licensed under the GNU General Public License v2.
6 # See /LICENSE for more information.
7 #
8
9 use strict;
10
11 sub get_ts($$) {
12 my $path = shift;
13 my $options = shift;
14 my $ts = 0;
15 my $fn = "";
16 open FIND, "find $path -not -path \\*.svn\\* -and -not -path \\*CVS\\* $options 2>/dev/null |";
17 while (<FIND>) {
18 chomp;
19 my $file = $_;
20 next if -l $file;
21 my @stat = stat $file;
22 if ($stat[9] > $ts) {
23 $ts = $stat[9];
24 $fn = $file;
25 }
26 }
27 close FIND;
28 return ($ts, $fn);
29 }
30
31 (@ARGV > 0) or push @ARGV, ".";
32 my $ts = 0;
33 my $n = ".";
34 my %options;
35 while (@ARGV > 0) {
36 my $path = shift @ARGV;
37 if ($path =~ /^-x/) {
38 my $str = shift @ARGV;
39 $options{"findopts"} .= " -and -not -path \\*".$str."\\*"
40 } elsif ($path =~ /^-f/) {
41 $options{"findopts"} .= " -follow";
42 } elsif ($path =~ /^-/) {
43 $options{$path} = 1;
44 } else {
45 my ($tmp, $fname) = get_ts($path, $options{"findopts"});
46 if ($tmp > $ts) {
47 if ($options{'-f'}) {
48 $n = $fname;
49 } else {
50 $n = $path;
51 }
52 $ts = $tmp;
53 }
54 }
55 }
56
57 if ($options{"-p"}) {
58 print "$n\n";
59 } elsif ($options{"-t"}) {
60 print "$ts\n";
61 } else {
62 print "$n\t$ts\n";
63 }
This page took 0.05377 seconds and 5 git commands to generate.