Subversion Repositories DevTools

Rev

Rev 3413 | Rev 5272 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 3413 Rev 5253
Line 18... Line 18...
18
($name, $passwd, $buildadm, $buildgid) = getpwnam ('buildadm');
18
($name, $passwd, $buildadm, $buildgid) = getpwnam ('buildadm');
19
$name = '';
19
$name = '';
20
$passwd = '';
20
$passwd = '';
21
 
21
 
22
die "$0: Could not determine uid of builadadm\n"
22
die "$0: Could not determine uid of builadadm\n"
23
	unless ($buildadm && $buildgid);
23
    unless ($buildadm && $buildgid);
24
 
24
 
25
die "$0: Not run as root\n"
25
die "$0: Not run as root\n"
26
        if ( $> );
26
        if ( $> );
27
 
27
 
28
opendir(DPKGARCHIVE, ".") or die "$0: Could not open \"$DIR\": $!\n";
28
opendir(DPKGARCHIVE, ".") or die "$0: Could not open \"$DIR\": $!\n";
Line 33... Line 33...
33
 
33
 
34
    $sb=lstat($pkg);
34
    $sb=lstat($pkg);
35
    $rwx=$sb->mode & 00777;
35
    $rwx=$sb->mode & 00777;
36
    $uid=$sb->uid;
36
    $uid=$sb->uid;
37
 
37
 
-
 
38
    if ( -d $pkg && isEmptyDir($pkg) == 1 )
-
 
39
    {
-
 
40
        system("/usr/bin/logger", "-p", "local0.notice", "-t", $0,
-
 
41
               sprintf("%s/%s: is empty", $DIR, $pkg, $rwx));
-
 
42
        printf STDERR ("%s: %s/%s: is empty\n", $0, $DIR, $pkg, $rwx);
-
 
43
        unless (rmdir($pkg)) {
-
 
44
            printf STDERR "%s: Could not delete empty directiry %s/%s: %s\n", $0, $rwx, $DIR, $pkg, $!;
-
 
45
            next;
-
 
46
        }
-
 
47
    }
-
 
48
 
38
    # Rather than change everything every day, change it only if it's wrong
49
    # Rather than change everything every day, change it only if it's wrong
39
    if ($rwx != 00775) {
50
    if ($rwx != 00775) {
40
        system("/usr/bin/logger", "-p", "local0.notice", "-t", $0,
51
        system("/usr/bin/logger", "-p", "local0.notice", "-t", $0,
41
               sprintf("%s/%s: was chmod %04o", $DIR, $pkg, $rwx));
52
               sprintf("%s/%s: was chmod %04o", $DIR, $pkg, $rwx));
42
        printf STDERR ("%s: %s/%s: was chmod %04o\n", $0, $DIR, $pkg, $rwx);
53
        printf STDERR ("%s: %s/%s: was chmod %04o\n", $0, $DIR, $pkg, $rwx);
Line 55... Line 66...
55
        }
66
        }
56
    }
67
    }
57
}
68
}
58
closedir(DPKGARCHIVE);
69
closedir(DPKGARCHIVE);
59
 
70
 
-
 
71
#-------------------------------------------------------------------------------
-
 
72
# Function        : isEmptyDir 
-
 
73
#
-
 
74
# Description     : Tset for empty directiry
-
 
75
#
-
 
76
# Inputs          : $dir        - Path to directory
-
 
77
#
-
 
78
# Returns         : 0           - Contains stuff
-
 
79
#                   1           - Does not contain stuff
-
 
80
#                  -1           - Does not exist
-
 
81
#
-
 
82
sub isEmptyDir
-
 
83
{
-
 
84
    my ($dir) = @_;
-
 
85
    my $rv = -1;
-
 
86
 
-
 
87
    if (opendir (my $dh, $dir ))
-
 
88
    {
-
 
89
        $rv = 1;
-
 
90
        while (readdir $dh)
-
 
91
        {
-
 
92
            next if ($_ eq '.');
-
 
93
            next if ($_ eq '..');
-
 
94
            $rv = 0;
-
 
95
            last;
-
 
96
        }
-
 
97
        closedir $dh;
-
 
98
    }
-
 
99
    return $rv;
-
 
100
}
-
 
101