This file is indexed.

/usr/share/perl5/DebAux/Util.pm is in debaux 0.1.10-1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
# Util.pm - utility functions for DebAux scripts

# Copyright (C) 2001,2005 Stefan Hornburg  (Racke) <racke@linuxia.de>

# This file is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by the
# Free Software Foundation; either version 2, or (at your option) any
# later version.

# This file is distributed in the hope that it will be
# useful, but WITHOUT ANY WARRANTY; without even the implied warranty
# of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
# General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this file; see the file COPYING.  If not, write to the Free
# Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
# MA 02110-1301 USA.

=head1 NAME

DebAux::Util - utility functions for scripts of the debaux suite

=head1 SYNOPSIS

  use DebAux::Util;

  DebAux::Util::mkdir ('/path/to/a/directory');
  DebAux::Util::remove ('/path/to/a/directory');

  DebAux::Util::architecture ();

=head1 DESCRIPTION

This modules provides utility functions for scripts of the debaux
suite.

=head1 FUNCTIONS

=over 4

=item mkdir I<directory>

Creates I<directory> and any missing parent directories.

=back

=cut

package DebAux::Util;

use strict;
use Cwd;
use File::Find;

sub mkdir {
	my ($directory) = @_;
	my @frags = split (/\/+/, $directory);
	my $path;

	unless (length $frags[0]) {
		shift (@frags);
		$path = '/';
	}
	
	for (@frags) {
		$path .= $_;

		unless (-d $path) {
			mkdir ($path, 0777)
				|| die "$0: Couldn't create directory \"$path\"\n";
		}
		$path .= '/';
	}
}

=over 4

=item remove I<directory>

Removes recursively I<directory> in the way I<rm -rf> would do.

=cut

sub remove {
	my ($directory) = @_;
	
	# proceed only if directory exists
	return unless -d $directory;

	my $sub = sub {
		my $cwd = cwd();

		# ignore special files
		return if $_ =~ /^\.\.?$/;

		if (-d $_ && ! -l $_) {
			# remove directory
			rmdir ($_)
				|| die "$0: Couldn't remove directory: $cwd/$_: $!\n";
		} else {
			# remove file
			unlink ($_)
				|| die "$0: Couldn't remove file: $cwd/$_: $!\n";
		}
	};

	my $cwd = cwd();

	finddepth ($sub, $directory);
	rmdir ($directory)
		|| die "$0: Couldn't remove directory: $cwd/$directory\n";
}

=over 4

=item architecture

Returns current architecture.

=cut

sub architecture {
	my ($arch);

	$arch = `dpkg --print-architecture`;

	if ($@ || !$arch) {
		die "$0: failed to determine current architecture\n";
	}

	# remove trailing blanks
	$arch =~ s/\s+$//;
	
	return $arch;
}

1;

__END__

=head1 AUTHOR

Stefan Hornburg (Racke) <racke@linuxia.de>

=head1 LICENSE

DebAux::Util comes with ABSOLUTELY NO WARRANTY. This is free software, and
you are welcome to redistribute and modify it under the terms of the
GNU General Public License.

=head1 COPYRIGHT

Copyright 2001,2005 Stefan Hornburg (Racke) <racke@linuxia.de>.

=cut