File: update-build-timestamp.pl

package info (click to toggle)
dosbox-x 2025.12.01%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 53,224 kB
  • sloc: cpp: 339,768; ansic: 165,257; sh: 1,455; makefile: 963; perl: 385; python: 106; asm: 57
file content (47 lines) | stat: -rwxr-xr-x 1,312 bytes parent folder | download | duplicates (2)
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
#!/usr/bin/perl

my @t = localtime();
my $sec =  $t[0];
my $min =  $t[1];
my $hour = $t[2];
my $mday = $t[3];
my $mon  = $t[4] + 1;
my $year = $t[5] + 1900;
my $yearn = $year + ($mon == 12 && $mday == 31 ? 1 : 0);

my @months = qw( Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec );

my $tmp = sprintf("%s %u, %u %u:%02u:%02u%s",$months[$mon-1],$mday,$year,(($hour + 11) % 12) + 1,$min,$sec,$hour >= 12 ? "pm" : "am");

my $commit = `git rev-parse --short=7 HEAD`;
chomp($commit);

open(X,">","include/build_timestamp.h") || die;
print X "/*auto-generated*/\n";
print X "#define UPDATED_STR \"$tmp\"\n";
print X "#define GIT_COMMIT_HASH \"$commit\"\n";
print X "#define COPYRIGHT_END_YEAR \"$yearn\"\n";
close(X);

# why perl....
use strict;
use warnings;

my $file = "contrib/linux/com.dosbox_x.DOSBox-X.metainfo.xml.in";
open FILE, $file or die "Can't read from $file!\n";

my @lines;
while (my $line = <FILE>) {
	if ($line =~ /date=/) {
		push @lines, ("          <release version=\"\@PACKAGE_VERSION\@\" date=\"" . $year . "-" . $mon . "-" . $mday . "\"/>\n");
	} elsif ($line =~ /<!-- Copyright/) {
		push @lines, ("<!-- Copyright 2011-$yearn Jonathan Campbell -->\n");
	} else {
		push @lines, $line;
	}
}
close FILE;

open FILE, '>', $file or die "Can't write to $file!\n";
print FILE @lines;
close FILE;