aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorB. Watson <urchlay@slackware.uk>2022-07-05 14:42:09 -0400
committerB. Watson <urchlay@slackware.uk>2022-07-07 00:32:56 -0400
commit02909612d07fc52ce09bf5f2bd3a0c46d7d8340a (patch)
tree54cd1cbbf4851f586a2c7243715076da542b5786
parentfe4080bcbd182c9c8068d4524b205926c31353b6 (diff)
downloadsbo-maintainer-tools-02909612d07fc52ce09bf5f2bd3a0c46d7d8340a.tar.gz
sbofixinfo: handle lowercase keys/md5sums, use color diff
-rwxr-xr-xsbofixinfo35
1 files changed, 24 insertions, 11 deletions
diff --git a/sbofixinfo b/sbofixinfo
index be1cb85..c4ba522 100755
--- a/sbofixinfo
+++ b/sbofixinfo
@@ -9,7 +9,7 @@ $VERSION="0.1";
=head1 NAME
-sbofixinfo - fix common errors in a SlackBuilds.org .info file
+sbofixinfo - fix common errors in SlackBuilds.org .info files
=head1 SYNOPSIS
@@ -17,8 +17,8 @@ B<sbofixinfo> I<file-or-dir> [I<file-or-dir> I<...>]
=head1 DESCRIPTION
-B<sbofixinfo> attempts to fix common errors in a SlackBuilds.org .info
-file. Each argument must be an .info file or a directory containing
+B<sbofixinfo> attempts to fix common errors in SlackBuilds.org .info
+files. Each argument must be an .info file or a directory containing
an .info file. With no arguments, the .info file in the current
directory is checked.
@@ -28,7 +28,7 @@ B<sbofixinfo> attempts to fix the following errors in SBo .info files:
=item -
-Out-of-order keys will be reordered to match order in the template.
+Out-of-order keys will be reordered to match the order in the template.
=item -
@@ -59,7 +59,16 @@ Values quoted with single-quotes will be quoted with double-quotes.
Multi-valued keys (e.g. DOWNLOAD with two URLs) will be split up into
multiple lines, if they're not already. Any missing line-continuation
-backslashes will be added.
+backslashes will be added. Continuation lines will be correctly
+indented.
+
+=item -
+
+Any capitalized hex digits in MD5SUM or MD5SUM_x86_64 will be lowercased.
+
+=item -
+
+Lowercase key names (e.g. md5sum or download) will be uppercased.
=back
@@ -73,7 +82,7 @@ to B<sed>(1).
B<sbofixinfo> keeps a backup of the original file with the
extension I<.bak> appended to the filename. If the backup file already
exists, it will be silently overwritten. After the new file is generated,
-B<diff>(1) (with its B<-u> option) is run on the backup and modified
+B<diff>(1) (with its B<-u> and B<--color> options) is run on the backup and modified
files, and the backup is deleted if the new file is identical. The diff
output also goes to stdout, so the user can see what changes were made.
@@ -84,9 +93,9 @@ files occur, the exit status will be the error count.
=head1 BUGS
-Misspelled key names (e.g. MD5USM or DOWNLAOD) will have their values
-discarded. Not a true bug (it's by design), but it violates the principle
-of least surprise a bit.
+Misspelled key names (e.g. MD5USM or DOWNLAOD) will be discarded. Not
+a true bug (it's by design), but it violates the principle of least
+surprise a bit.
B<sbofixinfo> can't automatically fix every issue B<sbolint> reports.
In particular, missing or extra values (for valid keys) can't
@@ -171,11 +180,15 @@ sub fix_info {
s/^(\w+)\s*=\s*/$1=/; # remove spaces around =
if(/^(\w+)=(.*)$/) {
- $key = $1;
+ $key = uc $1;
$val = $2;
$val =~ s,(?:^['"]|['"]$),,g; # remove quotes around value
$val =~ s,[\s\\]*$,,; # remove any line-continuation backslash
+ if($key =~ /^MD5SUM/) {
+ $val =~ tr/A-Z/a-z/;
+ }
+
# multiple valued keys all on the same line get split up into
# multi-line values. This only applies to download and md5sum
# values (which can't contain spaces anyway).
@@ -218,7 +231,7 @@ sub fix_info {
}
}
- my $result = system("diff $file.bak $file");
+ my $result = system("diff -u --color $file.bak $file");
if($result == 0) {
system("rm $file.bak");
warn "$SELF: no changes to $file\n";