Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

usbutils: patch hashbang of lsusb.py #51312

Merged
merged 1 commit into from Feb 17, 2019
Merged

Conversation

oxzi
Copy link
Member

@oxzi oxzi commented Dec 1, 2018

Motivation for this change

The lsusb.py script in the usbutils package is written in the Python3 programming language and requires python3 being available in the PATH. If one does not have python3 installed, the script could not be executed.
This PR changes the hashbang/shebang of this script to point to the python3 interpreter.

Things done
  • Tested using sandboxing (nix.useSandbox on NixOS, or option sandbox in nix.conf on non-NixOS)
  • Built on platform(s)
    • NixOS
    • macOS
    • other Linux distributions
  • Tested via one or more NixOS test(s) if existing and applicable for the change (look inside nixos/tests)
  • Tested compilation of all pkgs that depend on this change using nix-shell -p nox --run "nox-review wip"
  • Tested execution of all binary files (usually in ./result/bin/)
  • Determined the impact on package closure size (by running nix path-info -S before and after)
  • Assured whether relevant documentation is up to date
  • Fits CONTRIBUTING.md.

@Mic92
Copy link
Member

Mic92 commented Dec 1, 2018

That might have been intentionally left out to not depend on python in our installation image.

@oxzi
Copy link
Member Author

oxzi commented Dec 1, 2018

This sounds reasonable. However, is a separation between the system builds possible? Otherwise this program is kind of broken on most installations.

@Mic92
Copy link
Member

Mic92 commented Dec 1, 2018

There could be a python output where this script could be moved to.

@oxzi
Copy link
Member Author

oxzi commented Dec 1, 2018

I updated the PR based on @jtojnar's changes and added an optional pythonSupport flag, defaulting to false. I also introduced a new usbutilsFull package, which sets this flag to true and installs the usbutils with Python3 support. This solution is inspired by @Mic92's proposal.

@oxzi
Copy link
Member Author

oxzi commented Jan 15, 2019

Any updates?

@Mic92
Copy link
Member

Mic92 commented Jan 16, 2019

I would prefer splitting the output instead of having yet another build:

diff --git a/pkgs/os-specific/linux/usbutils/default.nix b/pkgs/os-specific/linux/usbutils/default.nix
index d58c5a7e67c..1d6736b71fe 100644
--- a/pkgs/os-specific/linux/usbutils/default.nix
+++ b/pkgs/os-specific/linux/usbutils/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchurl, substituteAll, autoreconfHook, pkgconfig, libusb1, hwdata }:
+{ stdenv, fetchurl, substituteAll, autoreconfHook, pkgconfig, libusb1, hwdata, python3 }:
 
 stdenv.mkDerivation rec {
   name = "usbutils-010";
@@ -16,7 +16,12 @@ stdenv.mkDerivation rec {
   ];
 
   nativeBuildInputs = [ autoreconfHook pkgconfig ];
-  buildInputs = [ libusb1 ];
+  buildInputs = [ libusb1 python3 ];
+  outputs = [ "out" "man" "python" ];
+
+  postInstall = ''
+    moveToOutput "bin/lsusb.py" "$python"
+  '';
 
   meta = with stdenv.lib; {
     homepage = http://www.linux-usb.org/;

@danbst
Copy link
Contributor

danbst commented Jan 23, 2019

agree with @Mic92 , but maybe name output lsusb?

@Mic92
Copy link
Member

Mic92 commented Jan 24, 2019

The other binary is also called lsusb but without .py extension. That would be a bit confusing.

@oxzi
Copy link
Member Author

oxzi commented Feb 16, 2019

@Mic92: Please excuse my very long delay. I just updated this PR after read the multiple-output packages' section in the manual.

@Mic92 Mic92 merged commit fdc9cbb into NixOS:master Feb 17, 2019
@oxzi oxzi deleted the usbutils-lsusbpy branch March 5, 2019 13:13
@oxzi oxzi restored the usbutils-lsusbpy branch March 10, 2019 21:32
@oxzi oxzi deleted the usbutils-lsusbpy branch March 10, 2019 21:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants