« blib/lib/auto/share/dist/Alien-Alien/lib/perl5/Alien/Package/Pkg.pm
↑ Summary
blib/lib/auto/share/dist/Alien-Alien/lib/perl5/Alien/Package/Tgz.pm »
| 1 | #!/usr/bin/perl -w | ||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||
| 3 | =head1 NAME | ||||||||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||||||||
| 5 | Alien::Package::Deb - an object that represents a deb package | ||||||||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||||||||
| 7 | =cut | ||||||||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||||||||
| 9 | package Alien::Package::Deb; | ||||||||||||||||||||||||||||||||||
| 10 | 1 | ▶ | use strict; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 11 | 1 | ▶ | use base qw(Alien::Package); | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 12 | 1 | ▶ | use List::Util qw(first); | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||||||||
| 14 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||||||||
| 16 | This is an object class that represents a deb package. It is derived from | ||||||||||||||||||||||||||||||||||
| 17 | Alien::Package. | ||||||||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||||||||
| 19 | =head1 FIELDS | ||||||||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||||||||
| 21 | =over 4 | ||||||||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||||||||
| 23 | =item have_dpkg_deb | ||||||||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||||||||
| 25 | Set to a true value if dpkg-deb is available. | ||||||||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||||||||
| 27 | =item deb_member_list | ||||||||||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||||||||
| 29 | Set to the list of member names in the deb package. | ||||||||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||||||||
| 31 | =item dirtrans | ||||||||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||||||||
| 33 | After the build stage, set to a hash reference of the directories we moved | ||||||||||||||||||||||||||||||||||
| 34 | files from and to, so these moves can be reverted in the cleantree stage. | ||||||||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||||||||
| 36 | =item fixperms | ||||||||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||||||||
| 38 | If this is set to true, the generated debian/rules will run dh_fixperms. | ||||||||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||||||||
| 40 | =back | ||||||||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||||||||
| 42 | =head1 METHODS | ||||||||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||||||||
| 44 | =over 4 | ||||||||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||||||||
| 46 | =item init | ||||||||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||||||||
| 48 | Sets have_dpkg_deb if dpkg-deb is in the path. I prefer to use dpkg-deb, | ||||||||||||||||||||||||||||||||||
| 49 | if it is available since it is a lot more future-proof. | ||||||||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||||||||
| 51 | =cut | ||||||||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||||||||
| 53 | 0 | ▶ | sub _inpath { | ||||||||||||||||||||||||||||||||
|
Subroutine
_inpath: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||||||||
| 54 | 0 | my $this=shift; | |||||||||||||||||||||||||||||||||
| 55 | 0 | my $program=shift; | |||||||||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||||||||
| 57 | 0 | foreach (split(/:/,$ENV{PATH})) { | |||||||||||||||||||||||||||||||||
| 58 | 0 | ▶ | if (-x "$_/$program") { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 59 | 0 | return 1; | |||||||||||||||||||||||||||||||||
| 60 | } | ||||||||||||||||||||||||||||||||||
| 61 | } | ||||||||||||||||||||||||||||||||||
| 62 | 0 | return ''; | |||||||||||||||||||||||||||||||||
| 63 | } | ||||||||||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||||||||
| 65 | 0 | ▶ | sub init { | ||||||||||||||||||||||||||||||||
|
Subroutine
init: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||
| 66 | 0 | my $this=shift; | |||||||||||||||||||||||||||||||||
| 67 | 0 | $this->SUPER::init(@_); | |||||||||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||||||||
| 69 | 0 | $this->have_dpkg_deb($this->_inpath('dpkg-deb')); | |||||||||||||||||||||||||||||||||
| 70 | } | ||||||||||||||||||||||||||||||||||
| 71 | |||||||||||||||||||||||||||||||||||
| 72 | =item checkfile | ||||||||||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||||||||
| 74 | Detect deb files by their extension. | ||||||||||||||||||||||||||||||||||
| 75 | |||||||||||||||||||||||||||||||||||
| 76 | =cut | ||||||||||||||||||||||||||||||||||
| 77 | |||||||||||||||||||||||||||||||||||
| 78 | 0 | ▶ | sub checkfile { | ||||||||||||||||||||||||||||||||
|
Subroutine
checkfile: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||
| 79 | 0 | my $this=shift; | |||||||||||||||||||||||||||||||||
| 80 | 0 | my $file=shift; | |||||||||||||||||||||||||||||||||
| 81 | |||||||||||||||||||||||||||||||||||
| 82 | 0 | return $file =~ m/.*\.u?deb$/; | |||||||||||||||||||||||||||||||||
| 83 | } | ||||||||||||||||||||||||||||||||||
| 84 | |||||||||||||||||||||||||||||||||||
| 85 | =item install | ||||||||||||||||||||||||||||||||||
| 86 | |||||||||||||||||||||||||||||||||||
| 87 | Install a deb with dpkg. Pass in the filename of the deb to install. | ||||||||||||||||||||||||||||||||||
| 88 | |||||||||||||||||||||||||||||||||||
| 89 | =cut | ||||||||||||||||||||||||||||||||||
| 90 | |||||||||||||||||||||||||||||||||||
| 91 | 0 | ▶ | sub install { | ||||||||||||||||||||||||||||||||
|
Subroutine
install: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||
| 92 | 0 | my $this=shift; | |||||||||||||||||||||||||||||||||
| 93 | 0 | my $deb=shift; | |||||||||||||||||||||||||||||||||
| 94 | |||||||||||||||||||||||||||||||||||
| 95 | 0 | my $v=$Alien::Package::verbose; | |||||||||||||||||||||||||||||||||
| 96 | 0 | $Alien::Package::verbose=2; | |||||||||||||||||||||||||||||||||
| 97 | 0 | ▶ | $this->do("dpkg", "--no-force-overwrite", "-i", $deb) | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 98 | or die "Unable to install"; | ||||||||||||||||||||||||||||||||||
| 99 | 0 | $Alien::Package::verbose=$v; | |||||||||||||||||||||||||||||||||
| 100 | } | ||||||||||||||||||||||||||||||||||
| 101 | |||||||||||||||||||||||||||||||||||
| 102 | =item test | ||||||||||||||||||||||||||||||||||
| 103 | |||||||||||||||||||||||||||||||||||
| 104 | Test a deb with lintian. Pass in the filename of the deb to test. | ||||||||||||||||||||||||||||||||||
| 105 | |||||||||||||||||||||||||||||||||||
| 106 | =cut | ||||||||||||||||||||||||||||||||||
| 107 | |||||||||||||||||||||||||||||||||||
| 108 | 0 | ▶ | sub test { | ||||||||||||||||||||||||||||||||
|
Subroutine
test: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||
| 109 | 0 | my $this=shift; | |||||||||||||||||||||||||||||||||
| 110 | 0 | my $deb=shift; | |||||||||||||||||||||||||||||||||
| 111 | |||||||||||||||||||||||||||||||||||
| 112 | 0 | ▶ | if ($this->_inpath("lintian")) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 113 | # Ignore some lintian warnings that don't matter for | ||||||||||||||||||||||||||||||||||
| 114 | # aliened packages. | ||||||||||||||||||||||||||||||||||
| 115 | 0 | return map { s/\n//; $_ } | |||||||||||||||||||||||||||||||||
| 116 | grep { | ||||||||||||||||||||||||||||||||||
| 117 | 0 | ! /unknown-section alien/ | |||||||||||||||||||||||||||||||||
| 118 | } $this->runpipe(1, "lintian '$deb'"); | ||||||||||||||||||||||||||||||||||
| 119 | } | ||||||||||||||||||||||||||||||||||
| 120 | else { | ||||||||||||||||||||||||||||||||||
| 121 | 0 | return "lintian not available, so not testing"; | |||||||||||||||||||||||||||||||||
| 122 | } | ||||||||||||||||||||||||||||||||||
| 123 | } | ||||||||||||||||||||||||||||||||||
| 124 | |||||||||||||||||||||||||||||||||||
| 125 | =item get_deb_member_list | ||||||||||||||||||||||||||||||||||
| 126 | |||||||||||||||||||||||||||||||||||
| 127 | Helper method. Pass it the name of the deb and it will return the list of | ||||||||||||||||||||||||||||||||||
| 128 | ar members. | ||||||||||||||||||||||||||||||||||
| 129 | |||||||||||||||||||||||||||||||||||
| 130 | =cut | ||||||||||||||||||||||||||||||||||
| 131 | |||||||||||||||||||||||||||||||||||
| 132 | 0 | ▶ | sub get_deb_member_list { | ||||||||||||||||||||||||||||||||
|
Subroutine
get_deb_member_list: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||
| 133 | 0 | my $this=shift; | |||||||||||||||||||||||||||||||||
| 134 | 0 | my $file=$this->filename; | |||||||||||||||||||||||||||||||||
| 135 | 0 | my $members=$this->deb_member_list; | |||||||||||||||||||||||||||||||||
| 136 | |||||||||||||||||||||||||||||||||||
| 137 | 0 | ▶ | unless (defined $members) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 138 | 0 | $members = [ map { chomp; $_ } $this->runpipe(1, "ar -t '$file'") ]; | |||||||||||||||||||||||||||||||||
| 139 | 0 | $this->deb_member_list($members); | |||||||||||||||||||||||||||||||||
| 140 | } | ||||||||||||||||||||||||||||||||||
| 141 | |||||||||||||||||||||||||||||||||||
| 142 | 0 | return @{$members}; | |||||||||||||||||||||||||||||||||
| 143 | } | ||||||||||||||||||||||||||||||||||
| 144 | |||||||||||||||||||||||||||||||||||
| 145 | =item getcontrolfile | ||||||||||||||||||||||||||||||||||
| 146 | |||||||||||||||||||||||||||||||||||
| 147 | Helper method. Pass it the name of a control file, and it will pull it out | ||||||||||||||||||||||||||||||||||
| 148 | of the deb and return it. | ||||||||||||||||||||||||||||||||||
| 149 | |||||||||||||||||||||||||||||||||||
| 150 | =cut | ||||||||||||||||||||||||||||||||||
| 151 | |||||||||||||||||||||||||||||||||||
| 152 | 0 | ▶ | sub getcontrolfile { | ||||||||||||||||||||||||||||||||
|
Subroutine
getcontrolfile: not called CC=6 SCAR=37.4
Pod
documented
| |||||||||||||||||||||||||||||||||||
| 153 | 0 | my $this=shift; | |||||||||||||||||||||||||||||||||
| 154 | 0 | my $controlfile=shift; | |||||||||||||||||||||||||||||||||
| 155 | 0 | my $file=$this->filename; | |||||||||||||||||||||||||||||||||
| 156 | |||||||||||||||||||||||||||||||||||
| 157 | 0 | ▶ | if ($this->have_dpkg_deb) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 158 | 0 | return $this->runpipe(1, "dpkg-deb --info '$file' $controlfile 2>/dev/null"); | |||||||||||||||||||||||||||||||||
| 159 | } | ||||||||||||||||||||||||||||||||||
| 160 | else { | ||||||||||||||||||||||||||||||||||
| 161 | # Solaris tar doesn't support O | ||||||||||||||||||||||||||||||||||
| 162 | 0 | ▶ | sub tar_out { | ||||||||||||||||||||||||||||||||
|
Subroutine
tar_out: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||
| 163 | 0 | my $file = shift; | |||||||||||||||||||||||||||||||||
| 164 | |||||||||||||||||||||||||||||||||||
| 165 | 0 | return "(mkdir /tmp/tar_out.$$ &&". | |||||||||||||||||||||||||||||||||
| 166 | " cd /tmp/tar_out.$$ &&". | ||||||||||||||||||||||||||||||||||
| 167 | " tar xf - './$file' &&". | ||||||||||||||||||||||||||||||||||
| 168 | " cat '$file'; cd /; rm -rf /tmp/tar_out.$$)"; | ||||||||||||||||||||||||||||||||||
| 169 | } | ||||||||||||||||||||||||||||||||||
| 170 | 0 | my $controlcomp; | |||||||||||||||||||||||||||||||||
| 171 | 0 | ▶ | my $controlmember = first { /^control\.tar/ } | ||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||
| 172 | 0 | $this->get_deb_member_list; | |||||||||||||||||||||||||||||||||
| 173 | 0 | ▶ | if (! defined $controlmember) { | ||||||||||||||||||||||||||||||||
|
Branch: 4 branches
| |||||||||||||||||||||||||||||||||||
| 174 | 0 | die 'Cannot find control member!'; | |||||||||||||||||||||||||||||||||
| 175 | } elsif ($controlmember eq 'control.tar.gz') { | ||||||||||||||||||||||||||||||||||
| 176 | 0 | $controlcomp = 'gzip -dc'; | |||||||||||||||||||||||||||||||||
| 177 | } elsif ($controlmember eq 'control.tar.xz') { | ||||||||||||||||||||||||||||||||||
| 178 | 0 | $controlcomp = 'xz -dc'; | |||||||||||||||||||||||||||||||||
| 179 | } elsif ($controlmember eq 'control.tar') { | ||||||||||||||||||||||||||||||||||
| 180 | 0 | $controlcomp = 'cat'; | |||||||||||||||||||||||||||||||||
| 181 | } else { | ||||||||||||||||||||||||||||||||||
| 182 | 0 | die 'Unknown control member!'; | |||||||||||||||||||||||||||||||||
| 183 | } | ||||||||||||||||||||||||||||||||||
| 184 | 0 | my $getcontrol = "ar -p '$file' $controlmember | $controlcomp | ".tar_out($controlfile)." 2>/dev/null"; | |||||||||||||||||||||||||||||||||
| 185 | 0 | return $this->runpipe(1, $getcontrol); | |||||||||||||||||||||||||||||||||
| 186 | } | ||||||||||||||||||||||||||||||||||
| 187 | } | ||||||||||||||||||||||||||||||||||
| 188 | |||||||||||||||||||||||||||||||||||
| 189 | =item get_datamember_cmd | ||||||||||||||||||||||||||||||||||
| 190 | |||||||||||||||||||||||||||||||||||
| 191 | Helper method. Pass it the name of the deb and it will return the raw | ||||||||||||||||||||||||||||||||||
| 192 | command needed to extract the data.tar member. | ||||||||||||||||||||||||||||||||||
| 193 | |||||||||||||||||||||||||||||||||||
| 194 | =cut | ||||||||||||||||||||||||||||||||||
| 195 | |||||||||||||||||||||||||||||||||||
| 196 | 0 | ▶ | sub get_datamember_cmd { | ||||||||||||||||||||||||||||||||
|
Subroutine
get_datamember_cmd: not called CC=7 SCAR=40.3
Pod
documented
| |||||||||||||||||||||||||||||||||||
| 197 | 0 | my $this=shift; | |||||||||||||||||||||||||||||||||
| 198 | 0 | my $file=$this->filename; | |||||||||||||||||||||||||||||||||
| 199 | |||||||||||||||||||||||||||||||||||
| 200 | 0 | my $datacomp; | |||||||||||||||||||||||||||||||||
| 201 | 0 | ▶ | my $datamember = first { /^data\.tar/ } | ||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||
| 202 | 0 | $this->get_deb_member_list; | |||||||||||||||||||||||||||||||||
| 203 | 0 | ▶ | if (! defined $datamember) { | ||||||||||||||||||||||||||||||||
|
Branch: 6 branches
| |||||||||||||||||||||||||||||||||||
| 204 | 0 | die 'Cannot find data member!'; | |||||||||||||||||||||||||||||||||
| 205 | } elsif ($datamember eq 'data.tar.gz') { | ||||||||||||||||||||||||||||||||||
| 206 | 0 | $datacomp = 'gzip -dc'; | |||||||||||||||||||||||||||||||||
| 207 | } elsif ($datamember eq 'data.tar.bz2') { | ||||||||||||||||||||||||||||||||||
| 208 | 0 | $datacomp = 'bzip2 -dc'; | |||||||||||||||||||||||||||||||||
| 209 | } elsif ($datamember eq 'data.tar.xz') { | ||||||||||||||||||||||||||||||||||
| 210 | 0 | $datacomp = 'xz -dc'; | |||||||||||||||||||||||||||||||||
| 211 | } elsif ($datamember eq 'data.tar.lzma') { | ||||||||||||||||||||||||||||||||||
| 212 | 0 | $datacomp = 'xz -dc'; | |||||||||||||||||||||||||||||||||
| 213 | } elsif ($datamember eq 'data.tar') { | ||||||||||||||||||||||||||||||||||
| 214 | 0 | $datacomp = 'cat'; | |||||||||||||||||||||||||||||||||
| 215 | } else { | ||||||||||||||||||||||||||||||||||
| 216 | 0 | die 'Unknown data member!'; | |||||||||||||||||||||||||||||||||
| 217 | } | ||||||||||||||||||||||||||||||||||
| 218 | |||||||||||||||||||||||||||||||||||
| 219 | 0 | return "ar -p '$file' $datamember | $datacomp"; | |||||||||||||||||||||||||||||||||
| 220 | } | ||||||||||||||||||||||||||||||||||
| 221 | |||||||||||||||||||||||||||||||||||
| 222 | =item scan | ||||||||||||||||||||||||||||||||||
| 223 | |||||||||||||||||||||||||||||||||||
| 224 | Implement the scan method to read a deb file. | ||||||||||||||||||||||||||||||||||
| 225 | |||||||||||||||||||||||||||||||||||
| 226 | =cut | ||||||||||||||||||||||||||||||||||
| 227 | |||||||||||||||||||||||||||||||||||
| 228 | 0 | ▶ | sub scan { | ||||||||||||||||||||||||||||||||
|
Subroutine
scan: not called CC=11 SCAR=48.8
Pod
documented
| |||||||||||||||||||||||||||||||||||
| 229 | 0 | my $this=shift; | |||||||||||||||||||||||||||||||||
| 230 | 0 | $this->SUPER::scan(@_); | |||||||||||||||||||||||||||||||||
| 231 | 0 | my $file=$this->filename; | |||||||||||||||||||||||||||||||||
| 232 | |||||||||||||||||||||||||||||||||||
| 233 | 0 | my @control=$this->getcontrolfile('control'); | |||||||||||||||||||||||||||||||||
| 234 | 0 | ▶ | die "Control file couldn't be read!" | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 235 | if @control == 0; | ||||||||||||||||||||||||||||||||||
| 236 | # Parse control file and extract fields. Use a translation table | ||||||||||||||||||||||||||||||||||
| 237 | # to map between the debian names and the internal field names, | ||||||||||||||||||||||||||||||||||
| 238 | # which more closely resemble those used by rpm (for historical | ||||||||||||||||||||||||||||||||||
| 239 | # reasons; TODO: change to deb style names). | ||||||||||||||||||||||||||||||||||
| 240 | 0 | my $description=''; | |||||||||||||||||||||||||||||||||
| 241 | 0 | my $field; | |||||||||||||||||||||||||||||||||
| 242 | 0 | my %fieldtrans=( | |||||||||||||||||||||||||||||||||
| 243 | Package => 'name', | ||||||||||||||||||||||||||||||||||
| 244 | Version => 'version', | ||||||||||||||||||||||||||||||||||
| 245 | Architecture => 'arch', | ||||||||||||||||||||||||||||||||||
| 246 | Maintainer => 'maintainer', | ||||||||||||||||||||||||||||||||||
| 247 | Section => 'group', | ||||||||||||||||||||||||||||||||||
| 248 | Description => 'summary', | ||||||||||||||||||||||||||||||||||
| 249 | ); | ||||||||||||||||||||||||||||||||||
| 250 | 0 | ▶ | for (my $i=0; $i <= $#control; $i++) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 251 | 0 | $_ = $control[$i]; | |||||||||||||||||||||||||||||||||
| 252 | 0 | chomp; | |||||||||||||||||||||||||||||||||
| 253 | 0 | ▶ | if (/^(\w.*?):\s+(.*)/) { | ||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||
| 254 | # Really old debs might have oddly capitalized | ||||||||||||||||||||||||||||||||||
| 255 | # field names. | ||||||||||||||||||||||||||||||||||
| 256 | 0 | $field=ucfirst(lc($1)); | |||||||||||||||||||||||||||||||||
| 257 | 0 | ▶ | if (exists $fieldtrans{$field}) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 258 | 0 | $field=$fieldtrans{$field}; | |||||||||||||||||||||||||||||||||
| 259 | 0 | $this->$field($2); | |||||||||||||||||||||||||||||||||
| 260 | } | ||||||||||||||||||||||||||||||||||
| 261 | } | ||||||||||||||||||||||||||||||||||
| 262 | ▶ | elsif (/^ / && $field eq 'summary') { | |||||||||||||||||||||||||||||||||
|
Condition0%0/3
/^ / and $field eq "summary"
MC/DC0%0/2
/^ / and $field eq "summary"
/^ /
$field eq "summary"
Truth table0%0/3
A and B
A= /^ /B= $field eq "summary"
| |||||||||||||||||||||||||||||||||||
| 263 | # Handle extended description. | ||||||||||||||||||||||||||||||||||
| 264 | 0 | s/^ //g; | |||||||||||||||||||||||||||||||||
| 265 | 0 | ▶ | $_="" if $_ eq "."; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 266 | 0 | $description.="$_\n"; | |||||||||||||||||||||||||||||||||
| 267 | } | ||||||||||||||||||||||||||||||||||
| 268 | } | ||||||||||||||||||||||||||||||||||
| 269 | 0 | $this->description($description); | |||||||||||||||||||||||||||||||||
| 270 | |||||||||||||||||||||||||||||||||||
| 271 | 0 | $this->copyright("see /usr/share/doc/".$this->name."/copyright"); | |||||||||||||||||||||||||||||||||
| 272 | 0 | ▶ | $this->group("unknown") if ! $this->group; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 273 | 0 | $this->distribution("Debian"); | |||||||||||||||||||||||||||||||||
| 274 | 0 | $this->origformat("deb"); | |||||||||||||||||||||||||||||||||
| 275 | 0 | $this->binary_info(scalar $this->getcontrolfile('control')); | |||||||||||||||||||||||||||||||||
| 276 | |||||||||||||||||||||||||||||||||||
| 277 | # Read in the list of conffiles, if any. | ||||||||||||||||||||||||||||||||||
| 278 | 0 | my @conffiles; | |||||||||||||||||||||||||||||||||
| 279 | 0 | @conffiles=map { chomp; $_ } $this->getcontrolfile('conffiles'); | |||||||||||||||||||||||||||||||||
| 280 | 0 | $this->conffiles(\@conffiles); | |||||||||||||||||||||||||||||||||
| 281 | |||||||||||||||||||||||||||||||||||
| 282 | # Read in the list of all files. | ||||||||||||||||||||||||||||||||||
| 283 | # Note that tar doesn't supply a leading '/', so we have to add that. | ||||||||||||||||||||||||||||||||||
| 284 | 0 | my $datamember_cmd; | |||||||||||||||||||||||||||||||||
| 285 | 0 | ▶ | if ($this->have_dpkg_deb) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 286 | 0 | $datamember_cmd = "dpkg-deb --fsys-tarfile '$file'"; | |||||||||||||||||||||||||||||||||
| 287 | } | ||||||||||||||||||||||||||||||||||
| 288 | else { | ||||||||||||||||||||||||||||||||||
| 289 | 0 | $datamember_cmd = $this->get_datamember_cmd($file); | |||||||||||||||||||||||||||||||||
| 290 | } | ||||||||||||||||||||||||||||||||||
| 291 | 0 | my @filelist=map { chomp; s:\./::; "/$_" } | |||||||||||||||||||||||||||||||||
| 292 | $this->runpipe(0, "$datamember_cmd | tar tf -"); | ||||||||||||||||||||||||||||||||||
| 293 | 0 | $this->filelist(\@filelist); | |||||||||||||||||||||||||||||||||
| 294 | |||||||||||||||||||||||||||||||||||
| 295 | # Read in the scripts, if any. | ||||||||||||||||||||||||||||||||||
| 296 | 0 | foreach my $field (qw{postinst postrm preinst prerm}) { | |||||||||||||||||||||||||||||||||
| 297 | 0 | $this->$field(scalar $this->getcontrolfile($field)); | |||||||||||||||||||||||||||||||||
| 298 | } | ||||||||||||||||||||||||||||||||||
| 299 | |||||||||||||||||||||||||||||||||||
| 300 | 0 | return 1; | |||||||||||||||||||||||||||||||||
| 301 | } | ||||||||||||||||||||||||||||||||||
| 302 | |||||||||||||||||||||||||||||||||||
| 303 | =item unpack | ||||||||||||||||||||||||||||||||||
| 304 | |||||||||||||||||||||||||||||||||||
| 305 | Implement the unpack method to unpack a deb file. | ||||||||||||||||||||||||||||||||||
| 306 | |||||||||||||||||||||||||||||||||||
| 307 | =cut | ||||||||||||||||||||||||||||||||||
| 308 | |||||||||||||||||||||||||||||||||||
| 309 | 0 | ▶ | sub unpack { | ||||||||||||||||||||||||||||||||
|
Subroutine
unpack: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||||||||||||||||||||||||
| 310 | 0 | my $this=shift; | |||||||||||||||||||||||||||||||||
| 311 | 0 | $this->SUPER::unpack(@_); | |||||||||||||||||||||||||||||||||
| 312 | 0 | my $file=$this->filename; | |||||||||||||||||||||||||||||||||
| 313 | |||||||||||||||||||||||||||||||||||
| 314 | 0 | ▶ | if ($this->have_dpkg_deb) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 315 | 0 | ▶ | $this->do("dpkg-deb", "-x", $file, $this->unpacked_tree) | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 316 | or die "Unpacking of '$file' failed: $!"; | ||||||||||||||||||||||||||||||||||
| 317 | } | ||||||||||||||||||||||||||||||||||
| 318 | else { | ||||||||||||||||||||||||||||||||||
| 319 | 0 | my $datamember_cmd = $this->get_datamember_cmd($file); | |||||||||||||||||||||||||||||||||
| 320 | |||||||||||||||||||||||||||||||||||
| 321 | 0 | ▶ | $this->do("$datamember_cmd | (cd ".$this->unpacked_tree."; tar xpf -)") | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 322 | or die "Unpacking of '$file' failed: $!"; | ||||||||||||||||||||||||||||||||||
| 323 | } | ||||||||||||||||||||||||||||||||||
| 324 | |||||||||||||||||||||||||||||||||||
| 325 | 0 | return 1; | |||||||||||||||||||||||||||||||||
| 326 | } | ||||||||||||||||||||||||||||||||||
| 327 | |||||||||||||||||||||||||||||||||||
| 328 | =item getpatch | ||||||||||||||||||||||||||||||||||
| 329 | |||||||||||||||||||||||||||||||||||
| 330 | This method tries to find a patch file to use in the prep stage. If it | ||||||||||||||||||||||||||||||||||
| 331 | finds one, it returns it. Pass in a list of directories to search for | ||||||||||||||||||||||||||||||||||
| 332 | patches in. | ||||||||||||||||||||||||||||||||||
| 333 | |||||||||||||||||||||||||||||||||||
| 334 | =cut | ||||||||||||||||||||||||||||||||||
| 335 | |||||||||||||||||||||||||||||||||||
| 336 | 0 | ▶ | sub getpatch { | ||||||||||||||||||||||||||||||||
|
Subroutine
getpatch: not called CC=7 SCAR=36.5
Pod
documented
| |||||||||||||||||||||||||||||||||||
| 337 | 0 | my $this=shift; | |||||||||||||||||||||||||||||||||
| 338 | 0 | my $anypatch=shift; | |||||||||||||||||||||||||||||||||
| 339 | |||||||||||||||||||||||||||||||||||
| 340 | 0 | my @patches; | |||||||||||||||||||||||||||||||||
| 341 | 0 | foreach my $dir (@_) { | |||||||||||||||||||||||||||||||||
| 342 | 0 | ▶ | push @patches, glob("$dir/".$this->name."_".$this->version."-".$this->release."*.diff.gz"); | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.2
| |||||||||||||||||||||||||||||||||||
| 343 | } | ||||||||||||||||||||||||||||||||||
| 344 | 0 | ▶ | if (! @patches) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 345 | # Try not matching the release, see if that helps. | ||||||||||||||||||||||||||||||||||
| 346 | 0 | foreach my $dir (@_) { | |||||||||||||||||||||||||||||||||
| 347 | 0 | push @patches,glob("$dir/".$this->name."_".$this->version."*.diff.gz"); | |||||||||||||||||||||||||||||||||
| 348 | } | ||||||||||||||||||||||||||||||||||
| 349 | 0 | ▶ | if (@patches && $anypatch) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
@patches and $anypatch
MC/DC0%0/2
@patches and $anypatch
@patches
$anypatch
Truth table0%0/3
A and B
A= @patchesB= $anypatch
| |||||||||||||||||||||||||||||||||||
| 350 | # Fallback to anything that matches the name. | ||||||||||||||||||||||||||||||||||
| 351 | 0 | foreach my $dir (@_) { | |||||||||||||||||||||||||||||||||
| 352 | 0 | push @patches,glob("$dir/".$this->name."_*.diff.gz"); | |||||||||||||||||||||||||||||||||
| 353 | } | ||||||||||||||||||||||||||||||||||
| 354 | } | ||||||||||||||||||||||||||||||||||
| 355 | } | ||||||||||||||||||||||||||||||||||
| 356 | |||||||||||||||||||||||||||||||||||
| 357 | # If we ended up with multiple matches, return the first. | ||||||||||||||||||||||||||||||||||
| 358 | 0 | return $patches[0]; | |||||||||||||||||||||||||||||||||
| 359 | } | ||||||||||||||||||||||||||||||||||
| 360 | |||||||||||||||||||||||||||||||||||
| 361 | =item prep | ||||||||||||||||||||||||||||||||||
| 362 | |||||||||||||||||||||||||||||||||||
| 363 | Adds a populated debian directory the unpacked package tree, making it | ||||||||||||||||||||||||||||||||||
| 364 | ready for building. This can either be done automatically, or via a patch | ||||||||||||||||||||||||||||||||||
| 365 | file. | ||||||||||||||||||||||||||||||||||
| 366 | |||||||||||||||||||||||||||||||||||
| 367 | =cut | ||||||||||||||||||||||||||||||||||
| 368 | |||||||||||||||||||||||||||||||||||
| 369 | 0 | ▶ | sub prep { | ||||||||||||||||||||||||||||||||
|
Subroutine
prep: not called CC=25 SCAR=64.8
Pod
documented
| |||||||||||||||||||||||||||||||||||
| 370 | 0 | my $this=shift; | |||||||||||||||||||||||||||||||||
| 371 | 0 | ▶ | my $dir=$this->unpacked_tree || die "The package must be unpacked first!"; | ||||||||||||||||||||||||||||||||
|
Condition0%0/2
$this->unpacked_tree || die('The package must be unpacked first!')
MC/DC0%0/1
$this->unpacked_tree || die('The package must be unpacked first!')
$this->unpacked_tree
Truth table0%0/2
A
A= $this->unpacked_tree
| |||||||||||||||||||||||||||||||||||
| 372 | |||||||||||||||||||||||||||||||||||
| 373 | 0 | ▶ | $this->do("mkdir $dir/debian") || | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 374 | die "mkdir $dir/debian failed: $!"; | ||||||||||||||||||||||||||||||||||
| 375 | |||||||||||||||||||||||||||||||||||
| 376 | # Use a patch file to debianize? | ||||||||||||||||||||||||||||||||||
| 377 | 0 | ▶ | if (defined $this->patchfile) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 378 | # The -f passed to zcat makes it pass uncompressed files | ||||||||||||||||||||||||||||||||||
| 379 | # through without error. | ||||||||||||||||||||||||||||||||||
| 380 | 0 | ▶ | $this->do("zcat -f ".$this->patchfile." | (cd $dir; patch -p1)") | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 381 | or die "patch error: $!"; | ||||||||||||||||||||||||||||||||||
| 382 | # Look for .rej files. | ||||||||||||||||||||||||||||||||||
| 383 | 0 | ▶ | die "patch failed with .rej files; giving up" | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 384 | if $this->runpipe(1, "find '$dir' -name \"*.rej\""); | ||||||||||||||||||||||||||||||||||
| 385 | 0 | $this->do('find', '.', '-name', '*.orig', '-exec', 'rm', '{}', ';'); | |||||||||||||||||||||||||||||||||
| 386 | 0 | $this->do("chmod", 755, "$dir/debian/rules"); | |||||||||||||||||||||||||||||||||
| 387 | |||||||||||||||||||||||||||||||||||
| 388 | # It's possible that the patch file changes the debian | ||||||||||||||||||||||||||||||||||
| 389 | # release or version. Parse changelog to detect that. | ||||||||||||||||||||||||||||||||||
| 390 | 0 | ▶ | open (my $changelog, "<$dir/debian/changelog") || return; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 391 | 0 | my $line=<$changelog>; | |||||||||||||||||||||||||||||||||
| 392 | 0 | ▶ | if ($line=~/^[^ ]+\s+\(([^)]+)\)\s/) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 393 | 0 | my $version=$1; | |||||||||||||||||||||||||||||||||
| 394 | 0 | $version=~s/\s+//; # ensure no whitespace | |||||||||||||||||||||||||||||||||
| 395 | 0 | ▶ | if ($version=~/(.*)-(.*)/) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 396 | 0 | $version=$1; | |||||||||||||||||||||||||||||||||
| 397 | 0 | $this->release($2); | |||||||||||||||||||||||||||||||||
| 398 | } | ||||||||||||||||||||||||||||||||||
| 399 | 0 | $this->version($1); | |||||||||||||||||||||||||||||||||
| 400 | } | ||||||||||||||||||||||||||||||||||
| 401 | 0 | close $changelog; | |||||||||||||||||||||||||||||||||
| 402 | |||||||||||||||||||||||||||||||||||
| 403 | 0 | return; | |||||||||||||||||||||||||||||||||
| 404 | } | ||||||||||||||||||||||||||||||||||
| 405 | |||||||||||||||||||||||||||||||||||
| 406 | # Automatic debianization. | ||||||||||||||||||||||||||||||||||
| 407 | # Changelog file. | ||||||||||||||||||||||||||||||||||
| 408 | 0 | ▶ | open (OUT, ">$dir/debian/changelog") || die "$dir/debian/changelog: $!"; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 409 | 0 | print OUT $this->name." (".$this->version."-".$this->release.") experimental; urgency=low\n"; | |||||||||||||||||||||||||||||||||
| 410 | 0 | print OUT "\n"; | |||||||||||||||||||||||||||||||||
| 411 | 0 | print OUT " * Converted from .".$this->origformat." format to .deb by alien version $Alien::Version\n"; | |||||||||||||||||||||||||||||||||
| 412 | 0 | print OUT " \n"; | |||||||||||||||||||||||||||||||||
| 413 | 0 | ▶ | if (defined $this->changelogtext) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 414 | 0 | my $ct=$this->changelogtext; | |||||||||||||||||||||||||||||||||
| 415 | 0 | $ct=~s/^/ /gm; | |||||||||||||||||||||||||||||||||
| 416 | 0 | print OUT $ct."\n"; | |||||||||||||||||||||||||||||||||
| 417 | } | ||||||||||||||||||||||||||||||||||
| 418 | 0 | print OUT "\n"; | |||||||||||||||||||||||||||||||||
| 419 | 0 | print OUT " -- ".$this->username." <".$this->email."> ".$this->date."\n"; | |||||||||||||||||||||||||||||||||
| 420 | 0 | close OUT; | |||||||||||||||||||||||||||||||||
| 421 | |||||||||||||||||||||||||||||||||||
| 422 | # Control file. | ||||||||||||||||||||||||||||||||||
| 423 | 0 | ▶ | open (OUT, ">$dir/debian/control") || die "$dir/debian/control: $!"; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 424 | 0 | print OUT "Source: ".$this->name."\n"; | |||||||||||||||||||||||||||||||||
| 425 | 0 | print OUT "Section: alien\n"; | |||||||||||||||||||||||||||||||||
| 426 | 0 | print OUT "Priority: extra\n"; | |||||||||||||||||||||||||||||||||
| 427 | 0 | print OUT "Maintainer: ".$this->username." <".$this->email.">\n"; | |||||||||||||||||||||||||||||||||
| 428 | 0 | print OUT "\n"; | |||||||||||||||||||||||||||||||||
| 429 | 0 | print OUT "Package: ".$this->name."\n"; | |||||||||||||||||||||||||||||||||
| 430 | 0 | print OUT "Architecture: ".$this->arch."\n"; | |||||||||||||||||||||||||||||||||
| 431 | 0 | ▶ | if (defined $this->depends) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 432 | 0 | print OUT "Depends: ".join(", ", "\${shlibs:Depends}", $this->depends)."\n"; | |||||||||||||||||||||||||||||||||
| 433 | } | ||||||||||||||||||||||||||||||||||
| 434 | else { | ||||||||||||||||||||||||||||||||||
| 435 | 0 | print OUT "Depends: \${shlibs:Depends}\n"; | |||||||||||||||||||||||||||||||||
| 436 | } | ||||||||||||||||||||||||||||||||||
| 437 | 0 | print OUT "Description: ".$this->summary."\n"; | |||||||||||||||||||||||||||||||||
| 438 | 0 | print OUT $this->description."\n"; | |||||||||||||||||||||||||||||||||
| 439 | 0 | close OUT; | |||||||||||||||||||||||||||||||||
| 440 | |||||||||||||||||||||||||||||||||||
| 441 | # Copyright file. | ||||||||||||||||||||||||||||||||||
| 442 | 0 | ▶ | open (OUT, ">$dir/debian/copyright") || die "$dir/debian/copyright: $!"; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 443 | 0 | print OUT "This package was debianized by the alien program by converting\n"; | |||||||||||||||||||||||||||||||||
| 444 | 0 | print OUT "a binary .".$this->origformat." package on ".$this->date."\n"; | |||||||||||||||||||||||||||||||||
| 445 | 0 | print OUT "\n"; | |||||||||||||||||||||||||||||||||
| 446 | 0 | print OUT "Copyright: ".$this->copyright."\n"; | |||||||||||||||||||||||||||||||||
| 447 | 0 | print OUT "\n"; | |||||||||||||||||||||||||||||||||
| 448 | 0 | print OUT "Information from the binary package:\n"; | |||||||||||||||||||||||||||||||||
| 449 | 0 | print OUT $this->binary_info."\n"; | |||||||||||||||||||||||||||||||||
| 450 | 0 | close OUT; | |||||||||||||||||||||||||||||||||
| 451 | |||||||||||||||||||||||||||||||||||
| 452 | # Conffiles, if any. Note that debhelper takes care of files in /etc. | ||||||||||||||||||||||||||||||||||
| 453 | 0 | my @conffiles=grep { $_ !~ /^\/etc/ } @{$this->conffiles}; | |||||||||||||||||||||||||||||||||
| 454 | 0 | ▶ | if (@conffiles) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 455 | 0 | ▶ | open (OUT, ">$dir/debian/conffiles") || die "$dir/debian/conffiles: $!"; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 456 | 0 | print OUT join("\n", @conffiles)."\n"; | |||||||||||||||||||||||||||||||||
| 457 | 0 | close OUT; | |||||||||||||||||||||||||||||||||
| 458 | } | ||||||||||||||||||||||||||||||||||
| 459 | |||||||||||||||||||||||||||||||||||
| 460 | # Use debhelper v7 | ||||||||||||||||||||||||||||||||||
| 461 | 0 | ▶ | open (OUT, ">$dir/debian/compat") || die "$dir/debian/compat: $!"; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 462 | 0 | print OUT "7\n"; | |||||||||||||||||||||||||||||||||
| 463 | 0 | close OUT; | |||||||||||||||||||||||||||||||||
| 464 | |||||||||||||||||||||||||||||||||||
| 465 | # A minimal rules file. | ||||||||||||||||||||||||||||||||||
| 466 | 0 | ▶ | open (OUT, ">$dir/debian/rules") || die "$dir/debian/rules: $!"; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 467 | 0 | ▶ | my $fixpermscomment = $this->fixperms ? "" : "#"; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 468 | 0 | print OUT << "EOF"; | |||||||||||||||||||||||||||||||||
| 469 | #!/usr/bin/make -f | ||||||||||||||||||||||||||||||||||
| 470 | # debian/rules for alien | ||||||||||||||||||||||||||||||||||
| 471 | |||||||||||||||||||||||||||||||||||
| 472 | PACKAGE=\$(shell dh_listpackages) | ||||||||||||||||||||||||||||||||||
| 473 | |||||||||||||||||||||||||||||||||||
| 474 | build: | ||||||||||||||||||||||||||||||||||
| 475 | dh_testdir | ||||||||||||||||||||||||||||||||||
| 476 | |||||||||||||||||||||||||||||||||||
| 477 | clean: | ||||||||||||||||||||||||||||||||||
| 478 | dh_testdir | ||||||||||||||||||||||||||||||||||
| 479 | dh_testroot | ||||||||||||||||||||||||||||||||||
| 480 | dh_clean -d | ||||||||||||||||||||||||||||||||||
| 481 | |||||||||||||||||||||||||||||||||||
| 482 | binary-indep: build | ||||||||||||||||||||||||||||||||||
| 483 | |||||||||||||||||||||||||||||||||||
| 484 | binary-arch: build | ||||||||||||||||||||||||||||||||||
| 485 | dh_testdir | ||||||||||||||||||||||||||||||||||
| 486 | dh_testroot | ||||||||||||||||||||||||||||||||||
| 487 | dh_prep | ||||||||||||||||||||||||||||||||||
| 488 | dh_installdirs | ||||||||||||||||||||||||||||||||||
| 489 | |||||||||||||||||||||||||||||||||||
| 490 | dh_installdocs | ||||||||||||||||||||||||||||||||||
| 491 | dh_installchangelogs | ||||||||||||||||||||||||||||||||||
| 492 | |||||||||||||||||||||||||||||||||||
| 493 | # Copy the packages's files. | ||||||||||||||||||||||||||||||||||
| 494 | find . -maxdepth 1 -mindepth 1 -not -name debian -print0 | \\ | ||||||||||||||||||||||||||||||||||
| 495 | xargs -0 -r -i cp -a {} debian/\$(PACKAGE) | ||||||||||||||||||||||||||||||||||
| 496 | |||||||||||||||||||||||||||||||||||
| 497 | # | ||||||||||||||||||||||||||||||||||
| 498 | # If you need to move files around in debian/\$(PACKAGE) or do some | ||||||||||||||||||||||||||||||||||
| 499 | # binary patching, do it here | ||||||||||||||||||||||||||||||||||
| 500 | # | ||||||||||||||||||||||||||||||||||
| 501 | |||||||||||||||||||||||||||||||||||
| 502 | |||||||||||||||||||||||||||||||||||
| 503 | # This has been known to break on some wacky binaries. | ||||||||||||||||||||||||||||||||||
| 504 | # dh_strip | ||||||||||||||||||||||||||||||||||
| 505 | dh_compress | ||||||||||||||||||||||||||||||||||
| 506 | $fixpermscomment dh_fixperms | ||||||||||||||||||||||||||||||||||
| 507 | dh_makeshlibs | ||||||||||||||||||||||||||||||||||
| 508 | dh_installdeb | ||||||||||||||||||||||||||||||||||
| 509 | -dh_shlibdeps | ||||||||||||||||||||||||||||||||||
| 510 | dh_gencontrol | ||||||||||||||||||||||||||||||||||
| 511 | dh_md5sums | ||||||||||||||||||||||||||||||||||
| 512 | dh_builddeb | ||||||||||||||||||||||||||||||||||
| 513 | |||||||||||||||||||||||||||||||||||
| 514 | binary: binary-indep binary-arch | ||||||||||||||||||||||||||||||||||
| 515 | .PHONY: build clean binary-indep binary-arch binary | ||||||||||||||||||||||||||||||||||
| 516 | EOF | ||||||||||||||||||||||||||||||||||
| 517 | 0 | close OUT; | |||||||||||||||||||||||||||||||||
| 518 | 0 | $this->do("chmod", 755, "$dir/debian/rules"); | |||||||||||||||||||||||||||||||||
| 519 | |||||||||||||||||||||||||||||||||||
| 520 | 0 | ▶ | if ($this->usescripts) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 521 | 0 | foreach my $script (qw{postinst postrm preinst prerm}) { | |||||||||||||||||||||||||||||||||
| 522 | 0 | $this->savescript($script, $this->$script()); | |||||||||||||||||||||||||||||||||
| 523 | } | ||||||||||||||||||||||||||||||||||
| 524 | } | ||||||||||||||||||||||||||||||||||
| 525 | else { | ||||||||||||||||||||||||||||||||||
| 526 | # There may be a postinst with permissions fixups even when | ||||||||||||||||||||||||||||||||||
| 527 | # scripts are disabled. | ||||||||||||||||||||||||||||||||||
| 528 | 0 | $this->savescript("postinst", undef); | |||||||||||||||||||||||||||||||||
| 529 | } | ||||||||||||||||||||||||||||||||||
| 530 | |||||||||||||||||||||||||||||||||||
| 531 | 0 | my %dirtrans=( # Note: no trailing slashes on these directory names! | |||||||||||||||||||||||||||||||||
| 532 | # Move files to FHS-compliant locations, if possible. | ||||||||||||||||||||||||||||||||||
| 533 | '/usr/man' => '/usr/share/man', | ||||||||||||||||||||||||||||||||||
| 534 | '/usr/info' => '/usr/share/info', | ||||||||||||||||||||||||||||||||||
| 535 | '/usr/doc' => '/usr/share/doc', | ||||||||||||||||||||||||||||||||||
| 536 | ); | ||||||||||||||||||||||||||||||||||
| 537 | 0 | foreach my $olddir (keys %dirtrans) { | |||||||||||||||||||||||||||||||||
| 538 | 0 | ▶ | if (-d "$dir/$olddir" && ! -e "$dir/$dirtrans{$olddir}") { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
-d "$dir/$olddir" and not -e "$dir/$dirtrans{$olddir}"
MC/DC0%0/2
-d "$dir/$olddir" and not -e "$dir/$dirtrans{$olddir}"
-d "$dir/$olddir"
not -e "$dir/$dirtrans{$olddir}"
Truth table0%0/3
A and not(B)
A= -d "$dir/$olddir"B= not -e "$dir/$dirtrans{$olddir}"
| |||||||||||||||||||||||||||||||||||
| 539 | # Ignore failure.. | ||||||||||||||||||||||||||||||||||
| 540 | 0 | my ($dirbase)=$dirtrans{$olddir}=~/(.*)\//; | |||||||||||||||||||||||||||||||||
| 541 | 0 | $this->do("install", "-d", "$dir/$dirbase"); | |||||||||||||||||||||||||||||||||
| 542 | 0 | $this->do("mv", "$dir/$olddir", "$dir/$dirtrans{$olddir}"); | |||||||||||||||||||||||||||||||||
| 543 | 0 | ▶ | if (-d "$dir/$olddir") { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 544 | 0 | $this->do("rmdir", "-p", "$dir/$olddir"); | |||||||||||||||||||||||||||||||||
| 545 | } | ||||||||||||||||||||||||||||||||||
| 546 | } | ||||||||||||||||||||||||||||||||||
| 547 | else { | ||||||||||||||||||||||||||||||||||
| 548 | 0 | delete $dirtrans{$olddir}; | |||||||||||||||||||||||||||||||||
| 549 | } | ||||||||||||||||||||||||||||||||||
| 550 | } | ||||||||||||||||||||||||||||||||||
| 551 | 0 | $this->dirtrans(\%dirtrans); # store for cleantree | |||||||||||||||||||||||||||||||||
| 552 | } | ||||||||||||||||||||||||||||||||||
| 553 | |||||||||||||||||||||||||||||||||||
| 554 | =item build | ||||||||||||||||||||||||||||||||||
| 555 | |||||||||||||||||||||||||||||||||||
| 556 | Build a deb. | ||||||||||||||||||||||||||||||||||
| 557 | |||||||||||||||||||||||||||||||||||
| 558 | =cut | ||||||||||||||||||||||||||||||||||
| 559 | |||||||||||||||||||||||||||||||||||
| 560 | 0 | ▶ | sub build { | ||||||||||||||||||||||||||||||||
|
Subroutine
build: not called CC=5 SCAR=34.0
Pod
documented
| |||||||||||||||||||||||||||||||||||
| 561 | 0 | my $this=shift; | |||||||||||||||||||||||||||||||||
| 562 | |||||||||||||||||||||||||||||||||||
| 563 | # Detect architecture mismatch and abort with a comprehensible | ||||||||||||||||||||||||||||||||||
| 564 | # error message. | ||||||||||||||||||||||||||||||||||
| 565 | 0 | my $arch=$this->arch; | |||||||||||||||||||||||||||||||||
| 566 | 0 | ▶ | if ($arch ne 'all') { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 567 | 0 | my $ret=system("dpkg-architecture", "-i".$arch); | |||||||||||||||||||||||||||||||||
| 568 | 0 | ▶ | if ($ret != 0) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 569 | 0 | die $this->filename." is for architecture ".$this->arch." ; the package cannot be built on this system"."\n"; | |||||||||||||||||||||||||||||||||
| 570 | } | ||||||||||||||||||||||||||||||||||
| 571 | } | ||||||||||||||||||||||||||||||||||
| 572 | |||||||||||||||||||||||||||||||||||
| 573 | 0 | chdir $this->unpacked_tree; | |||||||||||||||||||||||||||||||||
| 574 | 0 | my $log=$this->runpipe(1, "debian/rules binary 2>&1"); | |||||||||||||||||||||||||||||||||
| 575 | 0 | chdir ".."; | |||||||||||||||||||||||||||||||||
| 576 | 0 | my $err=$?; | |||||||||||||||||||||||||||||||||
| 577 | 0 | ▶ | if ($err) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 578 | 0 | ▶ | if (! defined $log) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 579 | 0 | die "Package build failed; could not run generated debian/rules file.\n"; | |||||||||||||||||||||||||||||||||
| 580 | } | ||||||||||||||||||||||||||||||||||
| 581 | 0 | die "Package build failed. Here's the log:\n", $log; | |||||||||||||||||||||||||||||||||
| 582 | } | ||||||||||||||||||||||||||||||||||
| 583 | |||||||||||||||||||||||||||||||||||
| 584 | 0 | return $this->name."_".$this->version."-".$this->release."_".$this->arch.".deb"; | |||||||||||||||||||||||||||||||||
| 585 | } | ||||||||||||||||||||||||||||||||||
| 586 | |||||||||||||||||||||||||||||||||||
| 587 | =item cleantree | ||||||||||||||||||||||||||||||||||
| 588 | |||||||||||||||||||||||||||||||||||
| 589 | Delete the entire debian/ directory. | ||||||||||||||||||||||||||||||||||
| 590 | |||||||||||||||||||||||||||||||||||
| 591 | =cut | ||||||||||||||||||||||||||||||||||
| 592 | |||||||||||||||||||||||||||||||||||
| 593 | 0 | ▶ | sub cleantree { | ||||||||||||||||||||||||||||||||
|
Subroutine
cleantree: not called CC=6 SCAR=37.4
Pod
documented
| |||||||||||||||||||||||||||||||||||
| 594 | 0 | my $this=shift; | |||||||||||||||||||||||||||||||||
| 595 | 0 | ▶ | my $dir=$this->unpacked_tree || die "The package must be unpacked first!"; | ||||||||||||||||||||||||||||||||
|
Condition0%0/2
$this->unpacked_tree || die('The package must be unpacked first!')
MC/DC0%0/1
$this->unpacked_tree || die('The package must be unpacked first!')
$this->unpacked_tree
Truth table0%0/2
A
A= $this->unpacked_tree
| |||||||||||||||||||||||||||||||||||
| 596 | |||||||||||||||||||||||||||||||||||
| 597 | 0 | my %dirtrans=%{$this->dirtrans}; | |||||||||||||||||||||||||||||||||
| 598 | 0 | foreach my $olddir (keys %dirtrans) { | |||||||||||||||||||||||||||||||||
| 599 | 0 | ▶ | if (! -e "$dir/$olddir" && -d "$dir/$dirtrans{$olddir}") { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
not -e "$dir/$olddir" and -d "$dir/$dirtrans{$olddir}"
MC/DC0%0/2
not -e "$dir/$olddir" and -d "$dir/$dirtrans{$olddir}"
not -e "$dir/$olddir"
-d "$dir/$dirtrans{$olddir}"
Truth table0%0/3
not(A) and B
A= not -e "$dir/$olddir"B= -d "$dir/$dirtrans{$olddir}"
| |||||||||||||||||||||||||||||||||||
| 600 | # Ignore failure.. (should I?) | ||||||||||||||||||||||||||||||||||
| 601 | 0 | my ($dirbase)=$dir=~/(.*)\//; | |||||||||||||||||||||||||||||||||
| 602 | 0 | $this->do("install", "-d", "$dir/$dirbase"); | |||||||||||||||||||||||||||||||||
| 603 | 0 | $this->do("mv", "$dir/$dirtrans{$olddir}", "$dir/$olddir"); | |||||||||||||||||||||||||||||||||
| 604 | 0 | ▶ | if (-d "$dir/$dirtrans{$olddir}") { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 605 | 0 | $this->do("rmdir", "-p", "$dir/$dirtrans{$olddir}"); | |||||||||||||||||||||||||||||||||
| 606 | } | ||||||||||||||||||||||||||||||||||
| 607 | } | ||||||||||||||||||||||||||||||||||
| 608 | } | ||||||||||||||||||||||||||||||||||
| 609 | |||||||||||||||||||||||||||||||||||
| 610 | 0 | $this->do("rm", "-rf", "$dir/debian"); | |||||||||||||||||||||||||||||||||
| 611 | } | ||||||||||||||||||||||||||||||||||
| 612 | |||||||||||||||||||||||||||||||||||
| 613 | =item package | ||||||||||||||||||||||||||||||||||
| 614 | |||||||||||||||||||||||||||||||||||
| 615 | Set/get package name. | ||||||||||||||||||||||||||||||||||
| 616 | |||||||||||||||||||||||||||||||||||
| 617 | Always returns the package name in lowercase with all invalid characters | ||||||||||||||||||||||||||||||||||
| 618 | rmoved. The name is however, stored unchanged. | ||||||||||||||||||||||||||||||||||
| 619 | |||||||||||||||||||||||||||||||||||
| 620 | =cut | ||||||||||||||||||||||||||||||||||
| 621 | |||||||||||||||||||||||||||||||||||
| 622 | 0 | ▶ | sub name { | ||||||||||||||||||||||||||||||||
|
Subroutine
name: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||||||||
| 623 | 0 | my $this=shift; | |||||||||||||||||||||||||||||||||
| 624 | |||||||||||||||||||||||||||||||||||
| 625 | # set | ||||||||||||||||||||||||||||||||||
| 626 | 0 | ▶ | $this->{name} = shift if @_; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 627 | 0 | ▶ | return unless defined wantarray; # optimization | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 628 | |||||||||||||||||||||||||||||||||||
| 629 | # get | ||||||||||||||||||||||||||||||||||
| 630 | 0 | $_=lc($this->{name}); | |||||||||||||||||||||||||||||||||
| 631 | 0 | tr/_/-/; | |||||||||||||||||||||||||||||||||
| 632 | 0 | s/[^a-z0-9-\.\+]//g; | |||||||||||||||||||||||||||||||||
| 633 | 0 | return $_; | |||||||||||||||||||||||||||||||||
| 634 | } | ||||||||||||||||||||||||||||||||||
| 635 | |||||||||||||||||||||||||||||||||||
| 636 | =item version | ||||||||||||||||||||||||||||||||||
| 637 | |||||||||||||||||||||||||||||||||||
| 638 | Set/get package version. | ||||||||||||||||||||||||||||||||||
| 639 | |||||||||||||||||||||||||||||||||||
| 640 | When the version is set, it will be stripped of any epoch. If there is a | ||||||||||||||||||||||||||||||||||
| 641 | release, the release will be stripped away and used to set the release | ||||||||||||||||||||||||||||||||||
| 642 | field as a side effect. Otherwise, the release will be set to 1. | ||||||||||||||||||||||||||||||||||
| 643 | |||||||||||||||||||||||||||||||||||
| 644 | More sanitization of the version is done when the field is retrieved, to | ||||||||||||||||||||||||||||||||||
| 645 | make sure it is a valid debian version field. | ||||||||||||||||||||||||||||||||||
| 646 | |||||||||||||||||||||||||||||||||||
| 647 | =cut | ||||||||||||||||||||||||||||||||||
| 648 | |||||||||||||||||||||||||||||||||||
| 649 | 0 | ▶ | sub version { | ||||||||||||||||||||||||||||||||
|
Subroutine
version: not called CC=5 SCAR=34.0
Pod
documented
| |||||||||||||||||||||||||||||||||||
| 650 | 0 | my $this=shift; | |||||||||||||||||||||||||||||||||
| 651 | |||||||||||||||||||||||||||||||||||
| 652 | # set | ||||||||||||||||||||||||||||||||||
| 653 | 0 | ▶ | if (@_) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 654 | 0 | my $version=shift; | |||||||||||||||||||||||||||||||||
| 655 | 0 | ▶ | if ($version =~ /(.+)-(.+)/) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 656 | 0 | $version=$1; | |||||||||||||||||||||||||||||||||
| 657 | 0 | $this->release($2); | |||||||||||||||||||||||||||||||||
| 658 | } | ||||||||||||||||||||||||||||||||||
| 659 | else { | ||||||||||||||||||||||||||||||||||
| 660 | 0 | $this->release(1); | |||||||||||||||||||||||||||||||||
| 661 | } | ||||||||||||||||||||||||||||||||||
| 662 | # Kill epochs. | ||||||||||||||||||||||||||||||||||
| 663 | 0 | $version=~s/^\d+://; | |||||||||||||||||||||||||||||||||
| 664 | |||||||||||||||||||||||||||||||||||
| 665 | 0 | $this->{version}=$version; | |||||||||||||||||||||||||||||||||
| 666 | } | ||||||||||||||||||||||||||||||||||
| 667 | |||||||||||||||||||||||||||||||||||
| 668 | # get | ||||||||||||||||||||||||||||||||||
| 669 | 0 | ▶ | return unless defined wantarray; # optimization | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 670 | 0 | $_=$this->{version}; | |||||||||||||||||||||||||||||||||
| 671 | # Make sure the version contains a digit at the start, as required | ||||||||||||||||||||||||||||||||||
| 672 | # by dpkg-deb. | ||||||||||||||||||||||||||||||||||
| 673 | 0 | ▶ | unless (/^[0-9]/) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 674 | 0 | $_="0".$_; | |||||||||||||||||||||||||||||||||
| 675 | } | ||||||||||||||||||||||||||||||||||
| 676 | # filter out some characters not allowed in debian versions | ||||||||||||||||||||||||||||||||||
| 677 | 0 | s/[^-.+~:A-Za-z0-9]//g; # see lib/dpkg/parsehelp.c parseversion | |||||||||||||||||||||||||||||||||
| 678 | 0 | return $_; | |||||||||||||||||||||||||||||||||
| 679 | } | ||||||||||||||||||||||||||||||||||
| 680 | |||||||||||||||||||||||||||||||||||
| 681 | =item release | ||||||||||||||||||||||||||||||||||
| 682 | |||||||||||||||||||||||||||||||||||
| 683 | Set/get package release. | ||||||||||||||||||||||||||||||||||
| 684 | |||||||||||||||||||||||||||||||||||
| 685 | Always returns a sanitized release version. The release is however, stored | ||||||||||||||||||||||||||||||||||
| 686 | unchanged. | ||||||||||||||||||||||||||||||||||
| 687 | |||||||||||||||||||||||||||||||||||
| 688 | =cut | ||||||||||||||||||||||||||||||||||
| 689 | |||||||||||||||||||||||||||||||||||
| 690 | 0 | ▶ | sub release { | ||||||||||||||||||||||||||||||||
|
Subroutine
release: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||||||||||||||||||||||||
| 691 | 0 | my $this=shift; | |||||||||||||||||||||||||||||||||
| 692 | |||||||||||||||||||||||||||||||||||
| 693 | # set | ||||||||||||||||||||||||||||||||||
| 694 | 0 | ▶ | $this->{release} = shift if @_; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 695 | |||||||||||||||||||||||||||||||||||
| 696 | # get | ||||||||||||||||||||||||||||||||||
| 697 | 0 | ▶ | return unless defined wantarray; # optimization | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 698 | 0 | $_=$this->{release}; | |||||||||||||||||||||||||||||||||
| 699 | # Make sure the release contains digets. | ||||||||||||||||||||||||||||||||||
| 700 | 0 | ▶ | return $_."-1" unless /[0-9]/; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 701 | 0 | return $_; | |||||||||||||||||||||||||||||||||
| 702 | } | ||||||||||||||||||||||||||||||||||
| 703 | |||||||||||||||||||||||||||||||||||
| 704 | =item description | ||||||||||||||||||||||||||||||||||
| 705 | |||||||||||||||||||||||||||||||||||
| 706 | Set/get description | ||||||||||||||||||||||||||||||||||
| 707 | |||||||||||||||||||||||||||||||||||
| 708 | Although the description is stored internally unchanged, this will always | ||||||||||||||||||||||||||||||||||
| 709 | return a sanitized form of it that is compliant with Debian standards. | ||||||||||||||||||||||||||||||||||
| 710 | |||||||||||||||||||||||||||||||||||
| 711 | =cut | ||||||||||||||||||||||||||||||||||
| 712 | |||||||||||||||||||||||||||||||||||
| 713 | 0 | ▶ | sub description { | ||||||||||||||||||||||||||||||||
|
Subroutine
description: not called CC=6 SCAR=37.4
Pod
documented
| |||||||||||||||||||||||||||||||||||
| 714 | 0 | my $this=shift; | |||||||||||||||||||||||||||||||||
| 715 | |||||||||||||||||||||||||||||||||||
| 716 | # set | ||||||||||||||||||||||||||||||||||
| 717 | 0 | ▶ | $this->{description} = shift if @_; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 718 | |||||||||||||||||||||||||||||||||||
| 719 | # get | ||||||||||||||||||||||||||||||||||
| 720 | 0 | ▶ | return unless defined wantarray; # optimization | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 721 | 0 | my $ret=''; | |||||||||||||||||||||||||||||||||
| 722 | 0 | foreach (split /\n/,$this->{description}) { | |||||||||||||||||||||||||||||||||
| 723 | 0 | s/\t/ /g; # change tabs to spaces | |||||||||||||||||||||||||||||||||
| 724 | 0 | s/\s+$//g; # remove trailing whitespace | |||||||||||||||||||||||||||||||||
| 725 | 0 | ▶ | $_="." if $_ eq ''; # empty lines become dots | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 726 | 0 | $ret.=" $_\n"; | |||||||||||||||||||||||||||||||||
| 727 | } | ||||||||||||||||||||||||||||||||||
| 728 | 0 | $ret=~s/^\n+//g; # kill leading blank lines | |||||||||||||||||||||||||||||||||
| 729 | 0 | ▶ | $ret.=" .\n" if length $ret; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 730 | 0 | $ret.=" (Converted from a ".$this->origformat." package by alien version $Alien::Version.)"; | |||||||||||||||||||||||||||||||||
| 731 | 0 | return $ret; | |||||||||||||||||||||||||||||||||
| 732 | } | ||||||||||||||||||||||||||||||||||
| 733 | |||||||||||||||||||||||||||||||||||
| 734 | =item date | ||||||||||||||||||||||||||||||||||
| 735 | |||||||||||||||||||||||||||||||||||
| 736 | Returns the date, in rfc822 format. | ||||||||||||||||||||||||||||||||||
| 737 | |||||||||||||||||||||||||||||||||||
| 738 | =cut | ||||||||||||||||||||||||||||||||||
| 739 | |||||||||||||||||||||||||||||||||||
| 740 | 0 | ▶ | sub date { | ||||||||||||||||||||||||||||||||
|
Subroutine
date: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||
| 741 | 0 | my $this=shift; | |||||||||||||||||||||||||||||||||
| 742 | |||||||||||||||||||||||||||||||||||
| 743 | 0 | my $date=$this->runpipe(1, "date -R"); | |||||||||||||||||||||||||||||||||
| 744 | 0 | chomp $date; | |||||||||||||||||||||||||||||||||
| 745 | 0 | ▶ | if (!$date) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 746 | 0 | die "date -R did not return a valid result."; | |||||||||||||||||||||||||||||||||
| 747 | } | ||||||||||||||||||||||||||||||||||
| 748 | |||||||||||||||||||||||||||||||||||
| 749 | 0 | return $date; | |||||||||||||||||||||||||||||||||
| 750 | } | ||||||||||||||||||||||||||||||||||
| 751 | |||||||||||||||||||||||||||||||||||
| 752 | =item email | ||||||||||||||||||||||||||||||||||
| 753 | |||||||||||||||||||||||||||||||||||
| 754 | Returns an email address for the current user. | ||||||||||||||||||||||||||||||||||
| 755 | |||||||||||||||||||||||||||||||||||
| 756 | =cut | ||||||||||||||||||||||||||||||||||
| 757 | |||||||||||||||||||||||||||||||||||
| 758 | 0 | ▶ | sub email { | ||||||||||||||||||||||||||||||||
|
Subroutine
email: not called CC=7 SCAR=40.3
Pod
documented
| |||||||||||||||||||||||||||||||||||
| 759 | 0 | my $this=shift; | |||||||||||||||||||||||||||||||||
| 760 | |||||||||||||||||||||||||||||||||||
| 761 | 0 | ▶ | return $ENV{EMAIL} if exists $ENV{EMAIL}; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 762 | |||||||||||||||||||||||||||||||||||
| 763 | 0 | ▶ | my $login = getlogin || (getpwuid($<))[0] || $ENV{USER}; | ||||||||||||||||||||||||||||||||
|
Condition0%0/6
getlogin || (getpwuid $<)[0] || $ENV{'USER'}
getlogin or (getpwuid $<)[0]
MC/DC0%0/3
getlogin || (getpwuid $<)[0] || $ENV{'USER'}
getlogin
(getpwuid $<)[0]
$ENV{'USER'}
Truth table0%0/4
A or B || C
A= getloginB= (getpwuid $<)[0]C= $ENV{'USER'}
| |||||||||||||||||||||||||||||||||||
| 764 | 0 | my $mailname=''; | |||||||||||||||||||||||||||||||||
| 765 | 0 | ▶ | if (open (MAILNAME,"</etc/mailname")) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 766 | 0 | $mailname=<MAILNAME>; | |||||||||||||||||||||||||||||||||
| 767 | 0 | ▶ | if (defined $mailname) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 768 | 0 | chomp $mailname; | |||||||||||||||||||||||||||||||||
| 769 | } | ||||||||||||||||||||||||||||||||||
| 770 | 0 | close MAILNAME; | |||||||||||||||||||||||||||||||||
| 771 | } | ||||||||||||||||||||||||||||||||||
| 772 | 0 | ▶ | if (!$mailname) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 773 | 0 | $mailname=$this->runpipe(1, "hostname"); | |||||||||||||||||||||||||||||||||
| 774 | 0 | chomp $mailname; | |||||||||||||||||||||||||||||||||
| 775 | } | ||||||||||||||||||||||||||||||||||
| 776 | 0 | return "$login\@$mailname"; | |||||||||||||||||||||||||||||||||
| 777 | } | ||||||||||||||||||||||||||||||||||
| 778 | |||||||||||||||||||||||||||||||||||
| 779 | =item username | ||||||||||||||||||||||||||||||||||
| 780 | |||||||||||||||||||||||||||||||||||
| 781 | Returns the user name of the real uid. | ||||||||||||||||||||||||||||||||||
| 782 | |||||||||||||||||||||||||||||||||||
| 783 | =cut | ||||||||||||||||||||||||||||||||||
| 784 | |||||||||||||||||||||||||||||||||||
| 785 | 0 | ▶ | sub username { | ||||||||||||||||||||||||||||||||
|
Subroutine
username: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||||||||||||||||||||||||
| 786 | 0 | my $this=shift; | |||||||||||||||||||||||||||||||||
| 787 | |||||||||||||||||||||||||||||||||||
| 788 | 0 | my $username; | |||||||||||||||||||||||||||||||||
| 789 | 0 | ▶ | my $login = getlogin || (getpwuid($<))[0] || $ENV{USER}; | ||||||||||||||||||||||||||||||||
|
Condition0%0/6
getlogin || (getpwuid $<)[0] || $ENV{'USER'}
getlogin or (getpwuid $<)[0]
MC/DC0%0/3
getlogin || (getpwuid $<)[0] || $ENV{'USER'}
getlogin
(getpwuid $<)[0]
$ENV{'USER'}
Truth table0%0/4
A or B || C
A= getloginB= (getpwuid $<)[0]C= $ENV{'USER'}
| |||||||||||||||||||||||||||||||||||
| 790 | 0 | (undef, undef, undef, undef, undef, undef, $username) = getpwnam($login); | |||||||||||||||||||||||||||||||||
| 791 | |||||||||||||||||||||||||||||||||||
| 792 | # Remove GECOS fields from username. | ||||||||||||||||||||||||||||||||||
| 793 | 0 | $username=~s/,.*//g; | |||||||||||||||||||||||||||||||||
| 794 | |||||||||||||||||||||||||||||||||||
| 795 | # The ultimate fallback. | ||||||||||||||||||||||||||||||||||
| 796 | 0 | ▶ | if ($username eq '') { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 797 | 0 | $username=$login; | |||||||||||||||||||||||||||||||||
| 798 | } | ||||||||||||||||||||||||||||||||||
| 799 | |||||||||||||||||||||||||||||||||||
| 800 | 0 | return $username; | |||||||||||||||||||||||||||||||||
| 801 | } | ||||||||||||||||||||||||||||||||||
| 802 | |||||||||||||||||||||||||||||||||||
| 803 | =item savescript | ||||||||||||||||||||||||||||||||||
| 804 | |||||||||||||||||||||||||||||||||||
| 805 | Saves script to debian directory. | ||||||||||||||||||||||||||||||||||
| 806 | |||||||||||||||||||||||||||||||||||
| 807 | =cut | ||||||||||||||||||||||||||||||||||
| 808 | |||||||||||||||||||||||||||||||||||
| 809 | 0 | ▶ | sub savescript { | ||||||||||||||||||||||||||||||||
|
Subroutine
savescript: not called CC=5 SCAR=34.0
Pod
documented
| |||||||||||||||||||||||||||||||||||
| 810 | 0 | my $this=shift; | |||||||||||||||||||||||||||||||||
| 811 | 0 | my $script=shift; | |||||||||||||||||||||||||||||||||
| 812 | 0 | my $data=shift; | |||||||||||||||||||||||||||||||||
| 813 | |||||||||||||||||||||||||||||||||||
| 814 | 0 | ▶ | if ($script eq 'postinst') { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 815 | 0 | $data=$this->gen_postinst($data); | |||||||||||||||||||||||||||||||||
| 816 | } | ||||||||||||||||||||||||||||||||||
| 817 | |||||||||||||||||||||||||||||||||||
| 818 | 0 | my $dir=$this->unpacked_tree; | |||||||||||||||||||||||||||||||||
| 819 | |||||||||||||||||||||||||||||||||||
| 820 | 0 | ▶ | return unless defined $data; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 821 | 0 | ▶ | next if $data =~ m/^\s*$/; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 822 | 0 | ▶ | open (OUT,">$dir/debian/$script") || | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 823 | die "$dir/debian/$script: $!"; | ||||||||||||||||||||||||||||||||||
| 824 | 0 | print OUT $data; | |||||||||||||||||||||||||||||||||
| 825 | 0 | close OUT; | |||||||||||||||||||||||||||||||||
| 826 | } | ||||||||||||||||||||||||||||||||||
| 827 | |||||||||||||||||||||||||||||||||||
| 828 | =item gen_postinst | ||||||||||||||||||||||||||||||||||
| 829 | |||||||||||||||||||||||||||||||||||
| 830 | Modifies or creates a postinst. This may include generated shell code to set | ||||||||||||||||||||||||||||||||||
| 831 | owners and groups from the owninfo field, and update modes from the modeinfo | ||||||||||||||||||||||||||||||||||
| 832 | field. | ||||||||||||||||||||||||||||||||||
| 833 | |||||||||||||||||||||||||||||||||||
| 834 | =cut | ||||||||||||||||||||||||||||||||||
| 835 | |||||||||||||||||||||||||||||||||||
| 836 | 0 | ▶ | sub gen_postinst { | ||||||||||||||||||||||||||||||||
|
Subroutine
gen_postinst: not called CC=8 SCAR=42.8
Pod
documented
| |||||||||||||||||||||||||||||||||||
| 837 | 0 | my $this=shift; | |||||||||||||||||||||||||||||||||
| 838 | 0 | my $postinst=shift; | |||||||||||||||||||||||||||||||||
| 839 | |||||||||||||||||||||||||||||||||||
| 840 | 0 | my $owninfo = $this->owninfo; | |||||||||||||||||||||||||||||||||
| 841 | 0 | my $modeinfo = $this->modeinfo; | |||||||||||||||||||||||||||||||||
| 842 | 0 | ▶ | return $postinst unless ref $owninfo && %$owninfo; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
ref $owninfo and %$owninfo
MC/DC0%0/2
ref $owninfo and %$owninfo
ref $owninfo
%$owninfo
Truth table0%0/3
A and B
A= ref $owninfoB= %$owninfo
| |||||||||||||||||||||||||||||||||||
| 843 | |||||||||||||||||||||||||||||||||||
| 844 | # If there is no postinst, let's make one up.. | ||||||||||||||||||||||||||||||||||
| 845 | 0 | ▶ | $postinst="#!/bin/sh\n" unless defined $postinst && length $postinst; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $postinst and length $postinst
MC/DC0%0/2
defined $postinst and length $postinst
defined $postinst
length $postinst
Truth table0%0/3
A and B
A= defined $postinstB= length $postinst
| |||||||||||||||||||||||||||||||||||
| 846 | |||||||||||||||||||||||||||||||||||
| 847 | 0 | my ($firstline, $rest)=split(/\n/, $postinst, 2); | |||||||||||||||||||||||||||||||||
| 848 | 0 | ▶ | if ($firstline !~ m/^#!\s*\/bin\/(ba)?sh/) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 849 | 0 | print STDERR "warning: unable to add ownership fixup code to postinst as the postinst is not a shell script!\n"; | |||||||||||||||||||||||||||||||||
| 850 | 0 | return $postinst; | |||||||||||||||||||||||||||||||||
| 851 | } | ||||||||||||||||||||||||||||||||||
| 852 | |||||||||||||||||||||||||||||||||||
| 853 | 0 | my $permscript="# alien added permissions fixup code\n"; | |||||||||||||||||||||||||||||||||
| 854 | 0 | foreach my $file (sort keys %$owninfo) { | |||||||||||||||||||||||||||||||||
| 855 | 0 | my $quotedfile=$file; | |||||||||||||||||||||||||||||||||
| 856 | 0 | $quotedfile=~s/'/'"'"'/g; # no single quotes in single quotes.. | |||||||||||||||||||||||||||||||||
| 857 | 0 | $permscript.="chown '".$owninfo->{$file}."' '$quotedfile'\n"; | |||||||||||||||||||||||||||||||||
| 858 | $permscript.="chmod '".$modeinfo->{$file}."' '$quotedfile'\n" | ||||||||||||||||||||||||||||||||||
| 859 | 0 | ▶ | if (defined $modeinfo->{$file}); | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 860 | } | ||||||||||||||||||||||||||||||||||
| 861 | 0 | return "$firstline\n$permscript\n$rest"; | |||||||||||||||||||||||||||||||||
| 862 | } | ||||||||||||||||||||||||||||||||||
| 863 | |||||||||||||||||||||||||||||||||||
| 864 | =back | ||||||||||||||||||||||||||||||||||
| 865 | |||||||||||||||||||||||||||||||||||
| 866 | =head1 AUTHOR | ||||||||||||||||||||||||||||||||||
| 867 | |||||||||||||||||||||||||||||||||||
| 868 | Joey Hess <joey@kitenet.net> | ||||||||||||||||||||||||||||||||||
| 869 | |||||||||||||||||||||||||||||||||||
| 870 | =cut | ||||||||||||||||||||||||||||||||||
| 871 | |||||||||||||||||||||||||||||||||||
| 872 | 1 | 1 | |||||||||||||||||||||||||||||||||