From c59ba65732eab2cd7982cc9273b646c177d4d698 Mon Sep 17 00:00:00 2001 From: Scott Willeke Date: Mon, 20 Jun 2022 19:30:28 -0700 Subject: [PATCH] onlykey-agent 1.1.14 (new formula) - fix test - Update Formula/onlykey-agent.rb - addresses feedback in PR Homebrew/homebrew-core#104096 - addresses brew style violations - fix linux build by replacing hidapi pypi resource with "depends_on" to fix linux bottle build - audit & style violation fixes - fix "fatal error: libusb.h: No such file or directory" when building hidapi on linux with explicit libusb include path - fix: remove wheel resource - wheel is included in brew python formula per discussion at https://github.com/Homebrew/homebrew-core/pull/104096#discussion_r914171487 - style per PR review - use append_to_cflags per PR review - remove unnecessary regex for test per PR feedback - fix: force cython-hidapi to use homebrew's copy of hidapi per advice from @cho-m and @carlocab at https://github.com/Homebrew/homebrew-core/pull/104096#discussion_r914373865 - add entry to pypi_formula_mappings.json to avoid six being added by brew [bump|bump-formula-pr] per thread at https://github.com/Homebrew/homebrew-core/pull/104096#discussion_r931710459 Closes #104096. Co-authored-by: Sean Molenaar Co-authored-by: Carlo Cabrera <30379873+carlocab@users.noreply.github.com> Signed-off-by: Carlo Cabrera <30379873+carlocab@users.noreply.github.com> Signed-off-by: BrewTestBot <1589480+BrewTestBot@users.noreply.github.com> --- Formula/onlykey-agent.rb | 219 +++++++++++++++++++++++++++++++++++++ pypi_formula_mappings.json | 3 + 2 files changed, 222 insertions(+) create mode 100644 Formula/onlykey-agent.rb diff --git a/Formula/onlykey-agent.rb b/Formula/onlykey-agent.rb new file mode 100644 index 00000000000..bbe551a93fc --- /dev/null +++ b/Formula/onlykey-agent.rb @@ -0,0 +1,219 @@ +class OnlykeyAgent < Formula + include Language::Python::Virtualenv + + desc "Middleware that lets you use OnlyKey as a hardware SSH/GPG device" + homepage "https://docs.crp.to/onlykey-agent.html" + url "https://files.pythonhosted.org/packages/02/c1/27c6cfbc5ee63fca91e37915d0182c0bfb988ca12362f01bcd5451e0ee10/onlykey-agent-1.1.14.tar.gz" + sha256 "096f20580ae112f57c1b9b279ed17728dc8e6f0fca301be586b9d976177f1523" + license "LGPL-3.0-only" + + # https://docs.crp.to/onlykey-agent.html#installation + depends_on "rust" => :build # for cryptography + depends_on "gnupg" + depends_on "hidapi" + depends_on "libcython" + depends_on "libusb" + depends_on "openssl@1.1" # for cryptography + depends_on "python@3.10" + depends_on "six" + + resource "aenum" do + url "https://files.pythonhosted.org/packages/63/6c/a71e18de7c651f384b328be6bccadbbd472aca62f547c1a307b9388d03ca/aenum-3.1.11.tar.gz" + sha256 "aed2c273547ae72a0d5ee869719c02a643da16bf507c80958faadc7e038e3f73" + end + + resource "hidapi" do + url "https://files.pythonhosted.org/packages/ef/72/54273f701c737ae5f42d9c0adf641912d20eb955c75433f1093fa509bcc7/hidapi-0.12.0.post2.tar.gz" + sha256 "8ebb2117be8b27af5c780936030148e1971b6b7fda06e0581ff0bfb15e94ed76" + end + + resource "backports.shutil_which" do + url "https://files.pythonhosted.org/packages/a0/22/51b896a4539f1bff6a7ab8514eb031b9f43f12bff23f75a4c3f4e9a666e5/backports.shutil_which-3.5.2.tar.gz" + sha256 "fe39f567cbe4fad89e8ac4dbeb23f87ef80f7fe8e829669d0221ecdb0437c133" + end + + resource "bech32" do + url "https://files.pythonhosted.org/packages/ab/fe/b67ac9b123e25a3c1b8fc3f3c92648804516ab44215adb165284e024c43f/bech32-1.2.0.tar.gz" + sha256 "7d6db8214603bd7871fcfa6c0826ef68b85b0abd90fa21c285a9c5e21d2bd899" + end + + resource "certifi" do + url "https://files.pythonhosted.org/packages/cc/85/319a8a684e8ac6d87a1193090e06b6bbb302717496380e225ee10487c888/certifi-2022.6.15.tar.gz" + sha256 "84c85a9078b11105f04f3036a9482ae10e4621616db313fe045dd24743a0820d" + end + + resource "cffi" do + url "https://files.pythonhosted.org/packages/00/9e/92de7e1217ccc3d5f352ba21e52398372525765b2e0c4530e6eb2ba9282a/cffi-1.15.0.tar.gz" + sha256 "920f0d66a896c2d99f0adbb391f990a84091179542c205fa53ce5787aff87954" + end + + resource "charset-normalizer" do + url "https://files.pythonhosted.org/packages/56/31/7bcaf657fafb3c6db8c787a865434290b726653c912085fbd371e9b92e1c/charset-normalizer-2.0.12.tar.gz" + sha256 "2857e29ff0d34db842cd7ca3230549d1a697f96ee6d3fb071cfa6c7393832597" + end + + resource "click" do + url "https://files.pythonhosted.org/packages/59/87/84326af34517fca8c58418d148f2403df25303e02736832403587318e9e8/click-8.1.3.tar.gz" + sha256 "7682dc8afb30297001674575ea00d1814d808d6a36af415a82bd481d37ba7b8e" + end + + resource "ConfigArgParse" do + url "https://files.pythonhosted.org/packages/16/05/385451bc8d20a3aa1d8934b32bd65847c100849ebba397dbf6c74566b237/ConfigArgParse-1.5.3.tar.gz" + sha256 "1b0b3cbf664ab59dada57123c81eff3d9737e0d11d8cf79e3d6eb10823f1739f" + end + + resource "cryptography" do + url "https://files.pythonhosted.org/packages/51/05/bb2b681f6a77276fc423d04187c39dafdb65b799c8d87b62ca82659f9ead/cryptography-37.0.2.tar.gz" + sha256 "f224ad253cc9cea7568f49077007d2263efa57396a2f2f78114066fd54b5c68e" + end + + resource "docutils" do + url "https://files.pythonhosted.org/packages/57/b1/b880503681ea1b64df05106fc7e3c4e3801736cf63deffc6fa7fc5404cf5/docutils-0.18.1.tar.gz" + sha256 "679987caf361a7539d76e584cbeddc311e3aee937877c87346f31debc63e9d06" + end + + resource "ecdsa" do + url "https://files.pythonhosted.org/packages/bf/3d/3d909532ad541651390bf1321e097404cbd39d1d89c2046f42a460220fb3/ecdsa-0.17.0.tar.gz" + sha256 "b9f500bb439e4153d0330610f5d26baaf18d17b8ced1bc54410d189385ea68aa" + end + + resource "fido2" do + url "https://files.pythonhosted.org/packages/cd/69/1af41955530255ca2337bab370a75b3dbbb8be8707f6280c9efedfb77a85/fido2-1.0.0.tar.gz" + sha256 "2509a4958b666d747fd5754dfa9357da2d81b52edc0ecff75b68cea939154c02" + end + + resource "idna" do + url "https://files.pythonhosted.org/packages/62/08/e3fc7c8161090f742f504f40b1bccbfc544d4a4e09eb774bf40aafce5436/idna-3.3.tar.gz" + sha256 "9d643ff0a55b762d5cdb124b8eaa99c66322e2157b69160bc32796e824360e6d" + end + + resource "intelhex" do + url "https://files.pythonhosted.org/packages/66/37/1e7522494557d342a24cb236e2aec5d078fac8ed03ad4b61372586406b01/intelhex-2.3.0.tar.gz" + sha256 "892b7361a719f4945237da8ccf754e9513db32f5628852785aea108dcd250093" + end + + resource "lib-agent" do + url "https://files.pythonhosted.org/packages/3c/0b/d084adec9efa8170b200e2a98d311e5703b3986a6bb049d871402dfc9607/lib-agent-1.0.5.tar.gz" + sha256 "63d281afb997d3fe5b660dbff998f015b8e40bffee24855063008ab8e7f4deff" + end + + resource "lockfile" do + url "https://files.pythonhosted.org/packages/17/47/72cb04a58a35ec495f96984dddb48232b551aafb95bde614605b754fe6f7/lockfile-0.12.2.tar.gz" + sha256 "6aed02de03cba24efabcd600b30540140634fc06cfa603822d508d5361e9f799" + end + + resource "mnemonic" do + url "https://files.pythonhosted.org/packages/f8/8d/d4dc2b2bddfeb57cab4404a41749b577f578f71140ab754da9afa8f5c599/mnemonic-0.20.tar.gz" + sha256 "7c6fb5639d779388027a77944680aee4870f0fcd09b1e42a5525ee2ce4c625f6" + end + + resource "onlykey" do + url "https://files.pythonhosted.org/packages/95/27/5bf7048f6d9de97610b6252b392a6d2d7e929dcd82809b973aebf1727114/onlykey-1.2.10.tar.gz" + sha256 "666427c99c7d625208c4c31d674536cdbf9000d7dcc2bb46ee24752e98339814" + end + + resource "onlykey-solo-python" do + url "https://files.pythonhosted.org/packages/6f/50/a9783484aafacd9f529ef6afa95fa77998a89fda5c3b28351efaf74f034c/onlykey-solo-python-0.0.31.tar.gz" + sha256 "cb539795d6892826317a3696792b9ae04a37909e80d85a0d9ca8a463e2964e1b" + end + + resource "prompt-toolkit" do + url "https://files.pythonhosted.org/packages/59/68/4d80f22e889ea34f20483ae3d4ca3f8d15f15264bcfb75e52b90fb5aefa5/prompt_toolkit-3.0.29.tar.gz" + sha256 "bd640f60e8cecd74f0dc249713d433ace2ddc62b65ee07f96d358e0b152b6ea7" + end + + resource "pycparser" do + url "https://files.pythonhosted.org/packages/5e/0b/95d387f5f4433cb0f53ff7ad859bd2c6051051cebbb564f139a999ab46de/pycparser-2.21.tar.gz" + sha256 "e644fdec12f7872f86c58ff790da456218b10f863970249516d60a5eaca77206" + end + + resource "pycryptodome" do + url "https://files.pythonhosted.org/packages/32/09/41ea2633fea5b973dac9829de871b417ff3ce2963d07fd92e3f2d2a9ee9b/pycryptodome-3.14.1.tar.gz" + sha256 "e04e40a7f8c1669195536a37979dd87da2c32dbdc73d6fe35f0077b0c17c803b" + end + + resource "PyMsgBox" do + url "https://files.pythonhosted.org/packages/7d/ff/4c6f31a4f08979f12a663f2aeb6c8b765d3bd592e66eaaac445f547bb875/PyMsgBox-1.0.9.tar.gz" + sha256 "2194227de8bff7a3d6da541848705a155dcbb2a06ee120d9f280a1d7f51263ff" + end + + resource "PyNaCl" do + url "https://files.pythonhosted.org/packages/a7/22/27582568be639dfe22ddb3902225f91f2f17ceff88ce80e4db396c8986da/PyNaCl-1.5.0.tar.gz" + sha256 "8ac7448f09ab85811607bdd21ec2464495ac8b7c66d146bf545b0f08fb9220ba" + end + + resource "pyserial" do + url "https://files.pythonhosted.org/packages/1e/7d/ae3f0a63f41e4d2f6cb66a5b57197850f919f59e558159a4dd3a818f5082/pyserial-3.5.tar.gz" + sha256 "3c77e014170dfffbd816e6ffc205e9842efb10be9f58ec16d3e8675b4925cddb" + end + + resource "python-daemon" do + url "https://files.pythonhosted.org/packages/d6/2d/f5e9a44e76777ca5c20765d92eb2d2cb89b6cfa5e921c808fdd57c90cae7/python-daemon-2.3.0.tar.gz" + sha256 "bda993f1623b1197699716d68d983bb580043cf2b8a66a01274d9b8297b0aeaf" + end + + resource "pyusb" do + url "https://files.pythonhosted.org/packages/d9/6e/433a5614132576289b8643fe598dd5d51b16e130fd591564be952e15bb45/pyusb-1.2.1.tar.gz" + sha256 "a4cc7404a203144754164b8b40994e2849fde1cfff06b08492f12fff9d9de7b9" + end + + resource "requests" do + url "https://files.pythonhosted.org/packages/e9/23/384d9953bb968731212dc37af87cb75a885dc48e0615bd6a303577c4dc4b/requests-2.28.0.tar.gz" + sha256 "d568723a7ebd25875d8d1eaf5dfa068cd2fc8194b2e483d7b1f7c81918dbec6b" + end + + resource "semver" do + url "https://files.pythonhosted.org/packages/31/a9/b61190916030ee9af83de342e101f192bbb436c59be20a4cb0cdb7256ece/semver-2.13.0.tar.gz" + sha256 "fa0fe2722ee1c3f57eac478820c3a5ae2f624af8264cbdf9000c980ff7f75e3f" + end + + resource "Unidecode" do + url "https://files.pythonhosted.org/packages/41/16/ee78864c2c2ba9bddba3978baa378f83270c8b7810eb7900f84e62a9ffac/Unidecode-1.3.4.tar.gz" + sha256 "8e4352fb93d5a735c788110d2e7ac8e8031eb06ccbfe8d324ab71735015f9342" + end + + resource "urllib3" do + url "https://files.pythonhosted.org/packages/1b/a5/4eab74853625505725cefdf168f48661b2cd04e7843ab836f3f63abf81da/urllib3-1.26.9.tar.gz" + sha256 "aabaf16477806a5e1dd19aa41f8c2b7950dd3c746362d7e3223dbe6de6ac448e" + end + + resource "wcwidth" do + url "https://files.pythonhosted.org/packages/89/38/459b727c381504f361832b9e5ace19966de1a235d73cdbdea91c771a1155/wcwidth-0.2.5.tar.gz" + sha256 "c4d647b99872929fdb7bdcaa4fbe7f01413ed3d98077df798530e5b04f116c83" + end + + def install + # prevent "fatal error: libusb.h: No such file or directory" when building hidapi on linux + ENV.append_to_cflags "-I#{Formula["libusb"].include}/libusb-1.0" + # replacement for virtualenv_install_with_resources per https://docs.brew.sh/Python-for-Formula-Authors + venv = virtualenv_create(libexec, "python3") + # build hidapi + resource("hidapi").stage do + # monkey patch hidapi's include paths to be the homebrew-installed path instead + # TODO: Fix this with an upstream patch to support `--with-system-hidapi=/foo/bar/hidapi` + # per https://github.com/Homebrew/homebrew-core/pull/104096#discussion_r919469723 + inreplace "setup.py" do |s| + s.gsub! "/usr/include/libusb-1.0", "#{Formula["libusb"].opt_include}/libusb-1.0" + s.gsub! "/usr/include/hidapi", "#{Formula["hidapi"].opt_include}/hidapi" + end + system libexec/"bin/python3", *Language::Python.setup_install_args(libexec), "--with-system-hidapi" + end + # now have pip build other resources except hidapi: + venv.pip_install resources.reject { |r| r.name == "hidapi" } + venv.pip_install_and_link buildpath + + # add path configuration file to find cython + site_packages = Language::Python.site_packages("python3") + pth_contents = <<~EOS + import site; site.addsitedir('#{Formula["libcython"].opt_libexec/site_packages}') + EOS + (libexec/site_packages/"homebrew-onlykey-agent.pth").write pth_contents + end + + test do + # the device mut not be plugged in to get the expected message + # since CI is the foremost user of `brew test` we assume that there is no device + output = shell_output("#{bin}/onlykey-agent test@example.com 2>&1", 1) + assert_match("try unplugging and replugging your device", output) + end +end diff --git a/pypi_formula_mappings.json b/pypi_formula_mappings.json index 32ae49e3809..4beffe7da8d 100644 --- a/pypi_formula_mappings.json +++ b/pypi_formula_mappings.json @@ -274,6 +274,9 @@ "ocrmypdf": { "exclude_packages": ["pillow"] }, + "onlykey-agent": { + "exclude_packages": ["six", "Cython"] + }, "openstackclient": { "extra_packages": ["python-heatclient", "python-octaviaclient"], "exclude_packages": ["six"]