Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 19 Sep 2020 22:04:32 +0000 (UTC)
From:      Alexey Dokuchaev <danfe@FreeBSD.org>
To:        ports-committers@freebsd.org, svn-ports-all@freebsd.org, svn-ports-head@freebsd.org
Subject:   svn commit: r549074 - in head/benchmarks/linux-gputest: . files
Message-ID:  <202009192204.08JM4WMg030340@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: danfe
Date: Sat Sep 19 22:04:32 2020
New Revision: 549074
URL: https://svnweb.freebsd.org/changeset/ports/549074

Log:
  To support optional FreeBSD branding in the future, switch to binary patch
  instead of sed(1) when adjusting log file location.  No functional changes.

Added:
  head/benchmarks/linux-gputest/files/apply-binary-patch.pl   (contents, props changed)
  head/benchmarks/linux-gputest/files/fix-logfile-path.crk   (contents, props changed)
Modified:
  head/benchmarks/linux-gputest/Makefile

Modified: head/benchmarks/linux-gputest/Makefile
==============================================================================
--- head/benchmarks/linux-gputest/Makefile	Sat Sep 19 22:00:43 2020	(r549073)
+++ head/benchmarks/linux-gputest/Makefile	Sat Sep 19 22:04:32 2020	(r549074)
@@ -21,8 +21,11 @@ LICENSE_PERMS=	dist-mirror pkg-mirror auto-accept
 
 ONLY_FOR_ARCHS=	amd64
 
-USES=		linux zip
+PATCH_DEPENDS=	p5-Sys-Mmap>0:devel/p5-Sys-Mmap
+
+USES=		linux perl5 zip
 USE_LINUX=	dri libglvnd xorglibs
+USE_PERL5=	patch
 NO_BUILD=	yes
 
 OPTIONS_DEFINE=	DOCS GUI
@@ -36,10 +39,8 @@ GUI_USES=	python:run
 post-patch:
 	@${REINPLACE_CMD} -e '1s,bash,sh,' ${WRKSRC}/start_*.sh
 	@${RM} ${WRKSRC}/data/.DS_Store
-# Save log file in writable location instead of ${PREFIX}/lib/${PORTNAME}
-	@${REINPLACE_CMD} -e \
-	    's,_geeks3d_gputest_log\.txt,/tmp/geeks3d_gputest.log,' \
-		${WRKSRC}/GpuTest
+	@cd ${WRKSRC} && ${PERL} ${FILESDIR}/apply-binary-patch.pl < \
+		${FILESDIR}/fix-logfile-path.crk
 
 # We cannot just embed shebang line in the patch because 210:fix-shebang
 # happens before 500:do-patch :(

Added: head/benchmarks/linux-gputest/files/apply-binary-patch.pl
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/benchmarks/linux-gputest/files/apply-binary-patch.pl	Sat Sep 19 22:04:32 2020	(r549074)
@@ -0,0 +1,33 @@
+#!/usr/bin/env perl
+
+use strict;
+use warnings;
+use Sys::Mmap;
+
+my $fh;
+my $flen;
+my $fdata;
+
+sub commit {
+	return unless $fh;
+	munmap $fdata or die "munmap: $!";
+	close $fh or die "close: $!";
+}
+
+while (<>) {
+	chomp;
+	if (/^([0-9A-F]{8}):? ([0-9A-F]{2}) ([0-9A-F]{2})$/i) {
+		my ($offset, $old, $new) = map hex, $1, $2, $3;
+		next unless $fdata;
+		next unless $offset < $flen;
+		next if ord substr($fdata, $offset, 1) != $old;
+		substr($fdata, $offset, 1) = chr $new;
+	} elsif (-e) {
+		commit;
+		open $fh, '+<', $_ or die "open: $!";
+		mmap $fdata, 0, PROT_READ | PROT_WRITE, MAP_SHARED, $fh
+		or die "mmap: $!";
+		$flen = -s;
+	}
+}
+commit;

Added: head/benchmarks/linux-gputest/files/fix-logfile-path.crk
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/benchmarks/linux-gputest/files/fix-logfile-path.crk	Sat Sep 19 22:04:32 2020	(r549074)
@@ -0,0 +1,95 @@
+; GpuTest is not cwd-agnostic and must be run in ${PREFIX}/lib/${PORTNAME}
+; where it looks for resources and writes its logfile.  Change the logfile
+; location to user-writable directory (/tmp) and shift a couple of strings
+; to make the room for other changes.
+
+GpuTest
+
+00036FE0: 5F 2F
+00036FE1: 67 74
+00036FE2: 65 6D
+00036FE3: 65 70
+00036FE4: 6B 2F
+00036FE5: 73 5F
+00036FE6: 33 67
+00036FE7: 64 65
+00036FE8: 5F 65
+00036FE9: 67 6B
+00036FEA: 70 73
+00036FEB: 75 33
+00036FEC: 74 64
+00036FED: 65 5F
+00036FEE: 73 67
+00036FEF: 74 70
+00036FF0: 5F 75
+00036FF1: 6C 74
+00036FF2: 6F 65
+00036FF3: 67 73
+00036FF4: 2E 74
+00036FF5: 74 2E
+00036FF6: 78 6C
+00036FF7: 74 6F
+00036FF8: 00 67
+
+; "Linux x%d" moves +1 byte (1 reference)
+; 424bbb:	be f9 6f 43 00		mov	$0x436ff9,%esi
+00024BBC: F9 FA
+
+00036FF9: 4C 00
+00036FFA: 69 4C
+00036FFB: 6E 69
+00036FFC: 75 6E
+00036FFD: 78 75
+00036FFE: 20 78
+00036FFF: 78 20
+00037000: 25 78
+00037001: 64 25
+00037002: 00 64
+
+; "GpuTest" moves +3 bytes (3 references)
+; 424c4b:	be 03 70 43 00		mov	$0x437003,%esi
+; 424dba:	b9 03 70 43 00		mov	$0x437003,%ecx
+; 425040:	ba 03 70 43 00		mov	$0x437003,%edx
+00024C4C: 03 06
+00024DBB: 03 06
+00025041: 03 06
+
+00037003: 47 00
+00037004: 70 00
+00037005: 75 00
+00037006: 54 47
+00037007: 65 70
+00037008: 73 75
+00037009: 74 54
+0003700A: 00 65
+
+; "%s (%s) is starting up..." moves +3 bytes (1 reference)
+; 424d9c:	ba 0b 70 43 00		mov	$0x43700b,%edx
+00024D9D: 0B 0E
+
+0003700B: 25 73
+0003700C: 73 74
+0003700D: 20 00
+0003700E: 28 25
+0003700F: 25 73
+00037010: 73 20
+00037011: 29 28
+00037012: 20 25
+00037013: 69 73
+00037014: 73 29
+00037016: 73 69
+00037017: 74 73
+00037018: 61 20
+00037019: 72 73
+0003701B: 69 61
+0003701C: 6E 72
+0003701D: 67 74
+0003701E: 20 69
+0003701F: 75 6E
+00037020: 70 67
+00037021: 2E 20
+00037022: 2E 75
+00037023: 2E 70
+00037024: 00 2E
+00037025: 00 2E
+00037026: 00 2E



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202009192204.08JM4WMg030340>