File: platform-subst

package info (click to toggle)
grub2 2.02~beta2-22
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 54,604 kB
  • ctags: 64,764
  • sloc: ansic: 370,672; asm: 16,177; sh: 12,946; cpp: 1,993; python: 1,438; makefile: 1,357; lex: 393; sed: 271; yacc: 268; lisp: 50; awk: 48; perl: 31
file content (38 lines) | stat: -rwxr-xr-x 816 bytes parent folder | download | duplicates (15)
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
#! /usr/bin/perl
use warnings;
use strict;

my %subst = ();
while ($ARGV[0] =~ /(.*?)=(.*)/) {
	$subst{$1} = $2;
	shift;
}

die "no package specified\n" unless exists $subst{PACKAGE};
(my $package = $subst{PACKAGE}) =~ s/-(?:bin|dbg)$//;

my $grub_dir_path = "debian/tmp-$package/usr/lib/grub";
opendir my $grub_dir, $grub_dir_path or die "can't opendir $grub_dir_path: $!";
my @cpu_platforms = grep { !/^\./ } readdir $grub_dir;
closedir $grub_dir;

$subst{FIRST_CPU_PLATFORM} = $cpu_platforms[0];

sub emit ($) {
	my $line = shift;
	while (my ($key, $value) = each %subst) {
		$line =~ s/\@$key\@/$value/g;
	}
	print $line;
}

while (<>) {
	if (/\@CPU_PLATFORM\@/) {
		for my $cpu_platform (@cpu_platforms) {
			(my $line = $_) =~ s/\@CPU_PLATFORM\@/$cpu_platform/g;
			emit($line);
		}
	} else {
		emit($_);
	}
}