File: make_standalone

package info (click to toggle)
libpostscriptbarcode 20200401-1.1
  • links: PTS
  • area: main
  • in suites: bookworm, bullseye, forky, sid, trixie
  • size: 3,920 kB
  • sloc: ansic: 563; makefile: 304; perl: 277; xml: 243; sh: 107; lisp: 92; java: 73; python: 45; ruby: 21
file content (59 lines) | stat: -rwxr-xr-x 1,195 bytes parent folder | download
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
#!/usr/bin/perl -w

use strict;
use File::Temp;
use File::Basename;

my $abspath=`pwd`;
chomp $abspath;

my $infile=$ARGV[0];
my $outfile=$ARGV[1];

my $encoder=basename($outfile);
$encoder=~s/\.ps$//;

open(VER,'CHANGES') || die 'Unable to open CHANGES';
my $version=<VER>;
close VER;
chomp $version;

open(HEAD,'src/ps.head') || die 'Unable to open ps.head';
my $head=join('',<HEAD>);
close HEAD;
$head=~s/XXXX-XX-XX/$version/;

open(PS,$infile) || die "File not found: $infile";
my $template=join('',<PS>);
close(PS);

open(PS,">$outfile") || die "Failed to write $outfile";
print PS $head;
($_,$_,my $meta,$_)=$template=~/
    ^%\ --BEGIN\ (ENCODER|RENDERER|RESOURCE)\ ($encoder)--$
    (.*?)
    (^[^%].*?)
    ^%\ --END\ \1\ \2--$
/msgx or die 'Encoder unknown';
(my $reqs)=$meta=~/^% --REQUIRES (.*)--$/mg;
$reqs='' unless defined $reqs;
my %reqs=($encoder=>1);
$reqs{$_}=1 foreach split ' ', $reqs;

while ($template=~/
    ^%\ --BEGIN\ (ENCODER|RENDERER|RESOURCE)\ ([\w-]+?)--$
    (.*?)
    (^%%.*?)
    (^[^%].*?)
    ^%\ --END\ \1\ \2--$
/msgx) {
  my $resource=$2;
  my $meta=$3;
  my $dsc=$4;
  my $body=$5;
  next unless $reqs{$resource};
  print PS "$dsc$body\n";
}

close(PS);