~ubuntu-branches/ubuntu/intrepid/equivs/intrepid

« back to all changes in this revision

Viewing changes to usr/bin/equivs-build

  • Committer: Bazaar Package Importer
  • Author(s): Stefano Zacchiroli
  • Date: 2008-01-22 12:26:38 UTC
  • Revision ID: james.westby@ubuntu.com-20080122122638-c7tfr3zbqj0dnhe5
Tags: 2.0.7-0.1
* Non-maintainer upload.
* equivs-build: add support for adding arbitrary extra files to a package.
  Thanks to Anthony Towns for the patch (closes: #449542)
* equivs-build.pod: document the new "Files:" and "File:" fields
* debian/control: bump Standards-Version to 3.7.3, no changes needed
* debian/control: move debhelper dependency to Build-Depends, so that it is
  available upon clean

Show diffs side-by-side

added added

removed removed

Lines of Context:
61
61
# Copy any additional files
62
62
 
63
63
my @extra_files = split ",", $control{'Extra-Files'} || "";
 
64
my %install_files = ();
 
65
for (split "\n", $control{'Files'} || "") {
 
66
    $install_files{$2} = $1 if m/^\s*(\S+)\s+(\S+)\s*$/;
 
67
}
 
68
my %create_files = ();
 
69
for (@{$control{'File'} || []}) {
 
70
  if (m/^\s*(\S+)\n(.*)$/s) {
 
71
    my ($f,$b) = ($1,$2);
 
72
    $b =~ s/^ //mg;
 
73
    $b =~ s/^[.]([.]*)$/$1/mg;
 
74
    $create_files{$f} = $b;
 
75
  }
 
76
}
 
77
 
 
78
mkdir "$builddir/install", 0755;
 
79
open INSTALL, '>', "$builddir/debian/install" or
 
80
  die "Cannot open $builddir/debian/installfor writing: $!\n";
 
81
foreach my $target (keys %install_files, keys %create_files) {
 
82
  $target =~ s/ +//g;
 
83
  my $destination;
 
84
  my $cnt = 0;
 
85
  if ($target =~ m/^(preinst|postinst|prerm|postrm)$/) {
 
86
    $destination = "debian/$target";
 
87
  } else {
 
88
  do {
 
89
      $destination = "install/$cnt";
 
90
      mkdir "$builddir/$destination" unless -d "$builddir/$destination";
 
91
      $destination .= "/" . basename($target);
 
92
      $cnt++;
 
93
  } while ( -e "$builddir/$destination" );
 
94
    print INSTALL "$destination " . dirname($target) . "\n";
 
95
  }
 
96
  if (defined $install_files{$target}) {
 
97
    my $file = $install_files{$target};
 
98
  copy $file, "$builddir/$destination" or
 
99
    die "Cannot copy $file to $builddir/$destination: $!\n";
 
100
  } else {
 
101
    open CREATE, ">", "$builddir/$destination" or
 
102
      die "Cannot create file $builddir/$destination: $!\n";
 
103
    print CREATE $create_files{$target};
 
104
    print CREATE "\n";
 
105
    close CREATE;
 
106
  } 
 
107
}
 
108
close INSTALL;
64
109
 
65
110
mkdir "$builddir/docs", 0755;
66
111
open DOCS, '>', "$builddir/debian/docs" or
82
127
      die "Cannot copy $script to $builddir/debian/$destination: $!\n";
83
128
}
84
129
 
85
 
 
86
130
write_control_file($builddir, \%control);
87
131
 
88
132
if ($control{'Changelog'}) {
132
176
 
133
177
sub read_control_file {
134
178
  my ($builddir, $control, $specific_arch, $file) = @_;
 
179
  my @control = ();
135
180
  my $in;
136
181
 
137
182
  open($in, "$builddir/debian/control.in") or
138
183
    die "Cannot open control file: $!\n";
139
 
  read_control_file_section($in, $control) or
 
184
  read_control_file_section($in, \@control) or
140
185
    die "error: empty control file\n";
141
186
  close $in;
142
187
 
150
195
 
151
196
  chomp($systemname = qx(hostname --fqdn));
152
197
 
 
198
  %{$control} = @control;
 
199
 
153
200
  $control->{'Maintainer'} = "$fullname <$username\@$systemname>";
154
201
 
155
202
  $control->{'Architecture'} = $specific_arch ? 'any' : 'all';
157
204
  open($in, $file) or
158
205
    die "Cannot open control file $file: $!\n";
159
206
 
160
 
  read_control_file_section($in, $control) or
 
207
  @control = ();
 
208
  read_control_file_section($in, \@control) or
161
209
    die "error: empty control file\n";
162
210
  close $in;
163
211
 
 
212
  for (my $i = 0; $i < $#control; $i += 2) {
 
213
    my $k = $control[$i];
 
214
    my $v = $control[$i+1];
 
215
    if ($k eq "File") {
 
216
      my $vv = [];
 
217
      $vv = $control->{$k} if defined $control->{$k};
 
218
      push @{$vv}, $v;
 
219
      $control->{$k} = $vv;
 
220
    } else {
 
221
      $control->{$k} = $v;
 
222
    }
 
223
  }
 
224
 
164
225
  # Fix Source: entry
165
226
  $control->{'Source'} = $control->{'Package'};
166
227
 
177
238
  my ($cf,$v);
178
239
  while (<$fh>) {
179
240
    chomp;
180
 
    next if (m/^\s*$/ or m/^\s*#/);
 
241
    next if (m/^\s*$/ or m/^#/);
181
242
 
182
243
    # new field?
183
244
    if (/^(\S+)\s*:\s*(.*?)\s*$/) {
184
245
      ($cf,$v) = (ucfirst lc $1, $2);
185
246
      $cf =~ s/(?<=-)([a-z])/uc $1/eg;
186
 
      $pfields->{$cf} = $v;
 
247
      push @{$pfields}, $cf, $v;
187
248
    } elsif (/^(\s+\S.*)$/) {
188
249
      $v = $1;
189
250
      defined($cf) or die "syntax error in control file: no field specified\n";
190
 
      $pfields->{$cf} .= "\n$v";
 
251
      $pfields->[-1] .= "\n$v";
191
252
    } else {
192
253
      die "syntax error in control file: $_\n";
193
254
    }
243
304
 
244
305
sub make_changelog {
245
306
  my ($builddir, $control) = @_;
246
 
  my ($version, $date);
 
307
  my ($version, $suite, $date);
247
308
 
248
309
  $version = $control->{'Version'} || "1.0";
249
 
  chomp ($date = qx(822-date));
 
310
  $suite = $control->{'Suite'} || "unstable";
 
311
  chomp ($date = qx(date -R));
250
312
 
251
313
  open OUT, '>', "$builddir/debian/changelog" or
252
314
    die "Couldn't write changelog: $!\n";
253
315
  print OUT <<EOINPUT;
254
 
$control->{Package} ($version) unstable; urgency=low
 
316
$control->{Package} ($version) $suite; urgency=low
255
317
 
256
318
  * First version
257
319