# Copyright 1999-2022 Gentoo Authors # Distributed under the terms of the GNU General Public License v2 EAPI=7 PYTHON_COMPAT=( python3_{11..12} ) inherit git-r3 python-r1 udev DESCRIPTION="An Implementation of USB Cryptographic Token for GnuPG" HOMEPAGE="https://www.fsij.org/category/gnuk.html" EGIT_REPO_URI="https://salsa.debian.org/gnuk-team/${PN}/${PN}" EGIT_COMMIT="release/${PV}" LICENSE="GPL-3" SLOT="0" KEYWORDS="~amd64" IUSE="debug doc tools" DEPEND="doc? ( dev-python/sphinx )" RDEPEND="virtual/udev tools? ( ${PYTHON_DEPS} dev-python/pyusb[${PYTHON_USEDEP}] dev-python/colorama[${PYTHON_USEDEP}] )" REQUIRED_USE="${PYTHON_REQUIRED_USE}" PATCHES=( "${FILESDIR}/${PV}-MINOR-Always-get-version-from-the-VERSION-file.patch" "${FILESDIR}/${PV}-build-initilize-empty-MCFLAGS-and-LDFLAGS.patch" "${FILESDIR}/${PV}-build-discard-compiler-default-specs.patch" "${FILESDIR}/${PV}-build-move-nostartfiles-earlier.patch" "${FILESDIR}/${PV}-build-do-not-produce-a-dynamically-linked-position-i.patch" ) pkg_pretend() { if type -p arm-none-eabi-gcc > /dev/null 2>&1 ; then return 0 fi eerror "Before you could build the firmware, you need to install arm-none-eabi toolchain" eerror "Run the following commands:" eerror " emerge -vat crossdev" eerror " crossdev --target arm-none-eabi" die "arm-none-eabi toolchain is needed" } src_prepare () { default mv tool/get_raw_public_key.py "tool/${PN}-get_raw_public_key.py" || die mv tool/gnuk_get_random.py "tool/${PN}-get_random.py" || die mv tool/gnuk_put_binary_libusb.py "tool/${PN}-put_binary_libusb.py" || die mv tool/gnuk_remove_keys_libusb.py "tool/${PN}-remove_keys_libusb.py" || die mv tool/gnuk_upgrade.py "tool/${PN}-upgrade.py" || die mv tool/stlinkv2.py "tool/${PN}-stlinkv2.py" || die mv tool/upgrade_by_passwd.py "tool/${PN}-upgrade_by_passwd.py" || die mv tool/usb_strings.py "tool/${PN}-usb_strings.py" || die } src_configure() { cd "${S}/src" ./configure \ --target=FST_01 \ --vidpid=234b:0000 \ --enable-certdo \ --enable-factory-reset \ --enable-hid-card-change \ $(use_enable debug) \ || die "configure failed" } src_compile() { cd "${S}/src" emake CROSS="arm-none-eabi-" if use doc ; then cd "${S}/doc" emake html emake man fi cd "${S}/regnual" emake TRGT="arm-none-eabi-" } src_install() { insinto "/usr/share/${PN}/firmware" doins "src/build/${PN}.bin" doins "regnual/regnual.bin" udev_dorules "${FILESDIR}/60-${PN}.rules" if use doc ; then HTML_DOCS=( doc/_build/html/* ) doman doc/_build/man/* fi install_example() { local d="$(python_get_scriptdir)" insinto "${d#${EPREFIX}}" doins "${1}" } if use tools ; then python_foreach_impl python_domodule tool/gnuk_token.py python_foreach_impl python_domodule tool/gpg_agent.py python_foreach_impl python_domodule tool/kdf_calc.py python_foreach_impl python_domodule tool/rsa.py python_foreach_impl python_doscript "tool/${PN}-get_random.py" python_foreach_impl python_doscript "tool/${PN}-get_raw_public_key.py" python_foreach_impl python_doscript "tool/${PN}-put_binary_libusb.py" python_foreach_impl python_doscript "tool/${PN}-remove_keys_libusb.py" python_foreach_impl python_doscript "tool/${PN}-stlinkv2.py" python_foreach_impl python_doscript "tool/${PN}-upgrade.py" python_foreach_impl python_doscript "tool/${PN}-upgrade_by_passwd.py" python_foreach_impl python_doscript "tool/${PN}-usb_strings.py" python_foreach_impl install_example tool/rsa_example.key udev_dorules "${FILESDIR}/10-stlink.rules" fi dodoc AUTHORS ChangeLog NEWS README THANKS dodoc -r doc/note }