Dependency on gawk should be dropped

Bug #1092539 reported by Sergey Romanov
10
This bug affects 1 person
Affects Status Importance Assigned to Milestone
dpkg-awk (Debian)
New
Undecided
Unassigned
dpkg-awk (Ubuntu)
Fix Released
Undecided
Unassigned

Bug Description

The only feature used by dpkg-awk beyond those required by POSIX is 'delete array'. This extension is supported by all awk variants currently in Debian, i.e. by gawk, mawk, and original-awk. Attached diff drops dependency on gawk. The first version of the patch replaced dependency on gawk with dependency on virtual package awk provided by all of the above awk packages, but packages shouldn't depend on awk according to Debian policy: awk is essential albeit virtual, the only package that depends on it is base-files.

Note however that unsetting environment variable POSIXLY_CORRECT in /usr/bin/dpkg-awk is still needed because otherwise if gawk is configured as default awk it treats 'delete array' as an error (see debbugs #170375).

Note also that debbugs #64146 and #64358 aroused out of a mistake: the previous Debian maintainer of dpkg-awk forgot to replace gawk with awk in /usr/bin/dpkg-awk when trying to drop dependency on gawk in dpkg-awk 1.0.0.

Actually, 'delete array' is also supported by busybox awk, and even by Plan 9 awk that gets installed by package 9base as /usr/lib/plan9/bin/awk and doesn't provide awk in Debian. Moreover, 'delete array' has recently been accepted for inclusion into POSIX: http://austingroupbugs.net/view.php?id=544

Because of that, not yet released gawk 4.1 will support 'delete array' even with POSIXLY_CORRECT set.

But if compatibility with POSIX before 2012 must be retained by all means, the following patch could also be applied. It replaces 'delete array' with 'split("",array)'. In this case, 'unset POSIXLY_CORRECT' in /usr/bin/dpkg-awk obviously isn't needed anymore.

----------------------------------------
diff --git a/dpkg-awk.awk b/dpkg-awk.awk
index 7669c40..cf00c43 100644
--- a/dpkg-awk.awk
+++ b/dpkg-awk.awk
@@ -86,7 +86,7 @@ BEGIN {

  if (options["debug"] >= 1)
   print "ARGV[0]='" ARGV[0] "'\n"
- delete ARGV
+ split("", ARGV)
  if (options["debug"] >= 1)
   for (a in options)
    print "options[" a "]='" options[a] "'\n"
@@ -99,8 +99,8 @@ function my_split(input, output,
  a, b, fields, save0)

 {
- delete output
- delete fields
+ split("", output)
+ split("", fields)
  save0 = $0
  $0 = input
  num_fields = split(input, fields, "\n")
----------------------------------------

However, to make dpkg-awk work with very old gawk (<= 3.0.3) or with some other ancient awk variants like nawk from the Heirloom Toolchest (http://heirloom.sourceforge.net/tools.html) which is derived from original Unix code released by Caldera (http://unixtools.sourceforge.net) this patch still isn't enough. Those awk variants don't like regular expressions starting with '='. If required I can also provide a patch that fixes it.

Revision history for this message
Sergey Romanov (sml-uni) wrote :

Previous version of this patch replaced dependency on gawk with awk, but one of the packages providing awk, mawk has priority 'required' and that makes this dependency unneeded.

summary: - Should depend on awk, not on gawk
+ Dependency on gawk should be dropped
Sergey Romanov (sml-uni)
description: updated
description: updated
Sergey Romanov (sml-uni)
description: updated
Sergey Romanov (sml-uni)
description: updated
Sergey Romanov (sml-uni)
description: updated
Revision history for this message
Ubuntu Foundations Team Bug Bot (crichton) wrote :

The attachment "drop dependency on gawk" of this bug report has been identified as being a patch. The ubuntu-reviewers team has been subscribed to the bug report so that they can review the patch. In the event that this is in fact not a patch you can resolve this situation by removing the tag 'patch' from the bug report and editing the attachment so that it is not flagged as a patch. Additionally, if you are member of the ubuntu-reviewers team please also unsubscribe the team from this bug report.

[This is an automated message performed by a Launchpad user owned by Brian Murray. Please contact him regarding any issues with the action taken in this bug report.]

Sergey Romanov (sml-uni)
description: updated
Sergey Romanov (sml-uni)
description: updated
Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package dpkg-awk - 1.2+nmu1

---------------
dpkg-awk (1.2+nmu1) unstable; urgency=medium

  * Non-maintainer upload.
  * Mark the package as M-A: foreign. Closes: #842525.
  * Fix sorting (-s option). LP: #1093674. Closes: #556651.
  * Enable two-letter short option -rs. LP: #1093672. Closes: #586040.
  * Drop dependency on gawk. The only feature used by dpkg-awk beyond those
    required by POSIX is 'delete array'. This extension is supported by all
    awk variants currently in Debian. LP: #1092539.
  * Bump standards version.

 -- Matthias Klose <email address hidden> Wed, 15 Nov 2017 08:23:19 +0100

Changed in dpkg-awk (Ubuntu):
status: New → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.