當前位置:
首頁 > 知識 > 如何在 Linux 中不安裝軟體測試一個軟體包

如何在 Linux 中不安裝軟體測試一個軟體包

如何在 Linux 中不安裝軟體測試一個軟體包


編譯自: https://www.ostechnix.com/how-to-test-a-package-without-installing-it-in-linux/

作者: Sk

譯者: geekpi

出於某種原因,你可能需要在將軟體包安裝到你的 Linux 系統之前對其進行測試。如果是這樣,你很幸運!今天,我將向你展示如何在 Linux 中使用 Nix 包管理器來實現。Nix 包管理器的一個顯著特性是它允許用戶測試軟體包而無需先安裝它們。當你想要臨時使用特定的程序時,這會很有幫助。

測試一個軟體包而不在 Linux 中安裝它

確保你先安裝了 Nix 包管理器。如果尚未安裝,請參閱以下指南。

例如,假設你想測試你的 C++ 代碼。你不必安裝 GCC。只需運行以下命令:


$ nix-shell -p gcc

該命令會構建或下載 gcc 軟體包及其依賴項,然後將其放入一個存在 gcc 命令的 Bash shell 中,所有這些都不會影響正常環境。


LANGUAGE = (unset),

LC_ALL = (unset),

LANG = "en_US.UTF-8"

are supported and installed on your system.

perl: warning: Falling back to the standard locale ("C").

download-using-manifests.pl: perl: warning: Setting locale failed.

download-using-manifests.pl: perl: warning: Please check that your locale settings:

download-using-manifests.pl: LANGUAGE = (unset),

download-using-manifests.pl: LC_ALL = (unset),

download-using-manifests.pl: LANG = "en_US.UTF-8"

download-using-manifests.pl: are supported and installed on your system.

download-using-manifests.pl: perl: warning: Falling back to the standard locale ("C").

download-from-binary-cache.pl: perl: warning: Setting locale failed.

download-from-binary-cache.pl: perl: warning: Please check that your locale settings:

download-from-binary-cache.pl: LANGUAGE = (unset),

download-from-binary-cache.pl: LC_ALL = (unset),

download-from-binary-cache.pl: LANG = "en_US.UTF-8"

[...]

fetching path 『/nix/store/6mk1s81va81dl4jfbhww86cwkl4gyf4j-stdenv』...

perl: warning: Setting locale failed.

perl: warning: Please check that your locale settings:

LANGUAGE = (unset),

LC_ALL = (unset),

LANG = "en_US.UTF-8"

are supported and installed on your system.

perl: warning: Falling back to the standard locale ("C").

*** Downloading 『https://cache.nixos.org/nar/0aznfg1g17a8jdzvnp3pqszs9rq2wiwf2rcgczyg5b3k6d0iricl.nar.xz』 to 『/nix/store/6mk1s81va81dl4jfbhww86cwkl4gyf4j-stdenv』...

% Total % Received % Xferd Average Speed Time Time Time Current

Dload Upload Total Spent Left Speed

100 8324 100 8324 0 0 6353 0 0:00:01 0:00:01 --:--:-- 6373

[nix-shell:~]$

檢查GCC版本:


[nix-shell:~]$ gcc -v

Using built-in specs.

COLLECT_GCC=/nix/store/dyj2k6ch35r1ips4vr97md2i0yvl4r5c-gcc-5.4.0/bin/gcc

COLLECT_LTO_WRAPPER=/nix/store/dyj2k6ch35r1ips4vr97md2i0yvl4r5c-gcc-5.4.0/libexec/gcc/x86_64-unknown-linux-gnu/5.4.0/lto-wrapper

Target: x86_64-unknown-linux-gnu

Configured with:

Thread model: posix

gcc version 5.4.0 (GCC)

現在,繼續並測試代碼。完成後,輸入 exit 返回到控制台。


[nix-shell:~]$ exit

exit

一旦你從 nix-shell 中退出,你就不能使用 GCC。

這是另一個例子。


$ nix-shell -p hello

這會構建或下載 GNU Hello 和它的依賴關係,然後將其放入 hello 命令所在的 Bash shell 中,所有這些都不會影響你的正常環境:


[nix-shell:~]$ hello

Hello, world!

輸入 exit 返回到控制台。


[nix-shell:~]$ exit

現在測試你的 hello 程序是否可用。


$ hello

hello: command not found

有關 Nix 包管理器的更多詳細信息,請參閱以下指南。

希望本篇對你有幫助!還會有更好的東西。敬請關注!!

乾杯!



via: https://www.ostechnix.com/how-to-test-a-package-without-installing-it-in-linux/

作者: SK 選題: lujun9972 譯者: geekpi 校對: wxy

本文由 LCTT 原創編譯, Linux中國 榮譽推出

點擊「了解更多」可訪問文內鏈接

喜歡這篇文章嗎?立刻分享出去讓更多人知道吧!

本站內容充實豐富,博大精深,小編精選每日熱門資訊,隨時更新,點擊「搶先收到最新資訊」瀏覽吧!


請您繼續閱讀更多來自 Linux技術 的精彩文章:

大學生對開源的反思

TAG:Linux技術 |