Skip to content

[Bug]: Debian/Ubuntu repo postrm/postinst scripts might need some love #263

@flingr

Description

@flingr

For your issue to not get closed without review, please confirm that:

  • [ x] This issue does not fit into any of the predefined categories, which is
    why I am making a blank issue from scratch.
  • [x ] I am not reporting a security vulnerability through this issue, because
    I am aware that there is an appropriate channel for that.
  • I understand that I will be permanently banned from interacting with this
    organization if I lied by checking any of these checkboxes.

[your issue text goes here]
Disclaimer: I couldn't find a better/more suitable place to report this.

When using the Debian/Ubuntu repo to install/upgrade helium-bin, I noticed apt complaining about /var/lib/dpkg/info/helium-bin.postrm:

$ sudo apt install helium-bin
[...]
Unpacking helium-bin (0.11.3.2-1) over (0.10.9.1-1) ...
/var/lib/dpkg/info/helium-bin.postrm: 4: [: Illegal number: upgrade
[...]

So I turned to shellcheck to see what that had to report on that file (and on /var/lib/dpkg/info/helium-bin.postinst too for good measure). Looks like there's some non-Posix stuff in there that might be worthwhile looking into.

$ shellcheck /var/lib/dpkg/info/helium-bin.postrm
```
In /var/lib/dpkg/info/helium-bin.postrm line 3:

/usr/bin/update-desktop-database &> /dev/null || :
^----------^ SC3020 (warning): In POSIX sh, &> is undefined.

In /var/lib/dpkg/info/helium-bin.postrm line 4:
if [ $1 -eq 0 ] ; then
^-- SC2086 (info): Double quote to prevent globbing and word splitting.

Did you mean:
if [ "$1" -eq 0 ] ; then

In /var/lib/dpkg/info/helium-bin.postrm line 5:
/bin/touch --no-create /usr/share/icons/hicolor &>/dev/null
^---------^ SC3020 (warning): In POSIX sh, &> is undefined.

In /var/lib/dpkg/info/helium-bin.postrm line 6:
/usr/bin/gtk-update-icon-cache /usr/share/icons/hicolor &>/dev/null || :
^---------^ SC3020 (warning): In POSIX sh, &> is undefined.

For more information:
https://www.shellcheck.net/wiki/SC3020 -- In POSIX sh, &> is undefined.
https://www.shellcheck.net/wiki/SC2086 -- Double quote to prevent globbing ...
```

$ shellcheck /var/lib/dpkg/info/helium-bin.postinst
```
In /var/lib/dpkg/info/helium-bin.postinst line 13:

/usr/bin/update-desktop-database &> /dev/null || :
^----------^ SC3020 (warning): In POSIX sh, &> is undefined.

In /var/lib/dpkg/info/helium-bin.postinst line 14:
/bin/touch --no-create /usr/share/icons/hicolor &>/dev/null || :
^---------^ SC3020 (warning): In POSIX sh, &> is undefined.

In /var/lib/dpkg/info/helium-bin.postinst line 21:
/usr/bin/gtk-update-icon-cache /usr/share/icons/hicolor &>/dev/null || :
^---------^ SC3020 (warning): In POSIX sh, &> is undefined.

For more information:
https://www.shellcheck.net/wiki/SC3020 -- In POSIX sh, &> is undefined.
```

Additionally, IMO, the apparmor profile handling could be improved. The postinst script runs apparmor_parser -r. The debian wiki recommends also using the '-W -T' options.

Regards

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions