From 6fcd69a365365ad828410d0c58970e8bef9112b6 Mon Sep 17 00:00:00 2001 From: Solomon Peachy Date: Tue, 7 Apr 2020 23:55:43 -0400 Subject: hiby_patcher: Mangle the version string in the update payload if necessary Change-Id: I204837f8a0e56fe51b3ee317be7d9f597b89f877 --- tools/hiby_patcher.pl | 34 ++++++++++++++++++++++++++-------- 1 file changed, 26 insertions(+), 8 deletions(-) diff --git a/tools/hiby_patcher.pl b/tools/hiby_patcher.pl index e1aa30733e..9c45ce6dd3 100755 --- a/tools/hiby_patcher.pl +++ b/tools/hiby_patcher.pl @@ -18,8 +18,6 @@ # need '7z', 'mkisofs', 'md5sum', 'mkfs.ubifs' # and https://github.com/jrspruitt/ubi_reader -# Rocker: PEB size 128KiB, I/O 2048, LEBs size: 124KiB, max LEBs 1024 (?) - use strict; use File::Basename; @@ -61,13 +59,20 @@ mkdir($isowork) || die ("Can't create '$isowork'"); @sysargs = ("7z", "x", "-aoa", "-o$isowork", $inname); system(@sysargs); -### figure out the rootfs image filename +### figure out the rootfs image filenames my $updatename; if ( -e "$isowork/UPDATE.TXT") { $updatename = "$isowork/UPDATE.TXT"; } elsif ( -e "$isowork/update.txt") { $updatename = "$isowork/update.txt"; } +my $versionname; +if ( -e "$isowork/VERSION.TXT") { + $versionname = "$isowork/VERSION.TXT"; +} elsif ( -e "$isowork/version.txt") { + $versionname = "$isowork/version.txt"; +} + open UPDATE, $updatename || die ("Can't open update.txt!");; my $rootfs_found = 0; @@ -137,16 +142,14 @@ system("mv $ubinamenew $ubiname"); ### Generate new ISO9660 update image -# Update version string as needed XXX - -open UPDATE, "<$updatename" || die ("Can't open update.txt!");; -open UPDATEO, ">$updatename.new" || die ("Can't open update.txt!");; +# Correct md5sum for new rootfs image +open UPDATE, "<$updatename" || die ("Can't open update.txt!"); +open UPDATEO, ">$updatename.new" || die ("Can't open update.txt!"); $rootfs_found = 0; while () { if ($rootfs_found) { if (s/md5=.*/md5=$md5/) { - print "#### $_ ####\n"; $rootfs_found=0; } } else { @@ -159,6 +162,21 @@ while () { close UPDATE; close UPDATEO; system("mv $updatename.new $updatename"); + +# Fix up version text, if needed (AGPTek Rocker 1.31 beta) + +open UPDATE, "<$versionname" || die ("Can't open version.txt!");; +open UPDATEO, ">$versionname.new" || die ("Can't open version.txt!"); + +while () { + s/ver=1\.0\.0\.0/ver=2018-10-07T00:00:00+08:00/; + print UPDATEO; +} + +close UPDATE; +close UPDATEO; +system("mv $versionname.new $versionname"); + @sysargs = ("mkisofs", "-volid", "CDROM", "-o", $uptnamenew, $isowork); system(@sysargs); -- cgit v1.2.3