From 932602082430397bfb08cc95925f5ee1e4e05605 Mon Sep 17 00:00:00 2001 From: Elliott Mitchell Date: Tue, 19 Mar 2024 11:55:43 -0700 Subject: [PATCH] scripts: add partial update functionality to configuration upgrade script This matches the way this has been handled in the past. This could also help devices which were skipped due to abandoned plans to drop. Signed-off-by: Elliott Mitchell --- scripts/kernel_upgrade.pl | 41 +++++++++++++++++++++++++++++++-------- 1 file changed, 33 insertions(+), 8 deletions(-) diff --git a/scripts/kernel_upgrade.pl b/scripts/kernel_upgrade.pl index 5514a18e0d05d4..d4943743d15a60 100755 --- a/scripts/kernel_upgrade.pl +++ b/scripts/kernel_upgrade.pl @@ -37,14 +37,14 @@ () return $_; } -sub getlistmatch($$$) +sub getlistmatch($$@) { - my ($commit, $from, $target)=@_; + my ($commit, $from, @target)=@_; my $ret=[]; local $/="\0"; open(my $fd, '-| :raw :bytes', 'git', 'ls-tree', '-trz', '--full-tree', -'--name-only', $commit.':', '--', $target)||die("failed to read git tree"); +'--name-only', $commit.':', '--', @target)||die("failed to read git tree"); while(<$fd>) { chop($_); @@ -52,6 +52,21 @@ ($$$) if(index($_, $from, length($_)-length($from))>0); } + check: foreach my $entr (@target) { + my ($lo, $hi)=(0, scalar(@$ret)); + while($lo!=$hi) { + $_=substr($ret->[($lo+$hi)>>1], 0, length($entr)) cmp $entr; + if($_<0) { + $lo=(($lo+$hi)>>1)+1; + } elsif($_>0) { + $hi=($lo+$hi)>>1; + } else { + next check; + } + } + die("no files matching \"$from\" found in $entr"); + } + @$ret=sort({length($b)-length($a)} @$ret); return $ret; @@ -211,8 +226,8 @@ () } # end of interface to git fast-import -die(<<"__USAGE__") if(@ARGV!=2); -Usage: $0 +die(<<"__USAGE__") if(@ARGV<2); +Usage: $0 [] Copies all kernel configuration files and patches from the old version to the new version. Git history is preserved on the copies by using a @@ -227,6 +242,12 @@ () Note, the two strings are non-optional, but completely free-form. There are no limitations besides whether they can be used in a file-name (\\0 is the only invalid character). + +One or more boards can be specified to update a subset of boards. This +can include "generic", this can also include a subdirectory for a device. + +The end merge commit /can/ be amended to remove files which should not +be included during an update. __USAGE__ my $from=shift(@ARGV); @@ -240,9 +261,13 @@ () die('git failed, likely not inside OpenWRT git repository?') unless($start|| ($0=~m/^(.*)\// and chdir($1) and $start=gethead())); -my $list=getlistmatch('HEAD', $from, $target); - -die("no files matching \"$from\" found") unless(@$list); +my $list; +unless(@ARGV) { + $list=getlistmatch('HEAD', $from, $target); +} else { + $_=$target.$_ foreach(@ARGV); + $list=getlistmatch('HEAD', $from, @ARGV); +} my $git=GitImporter->new();