sys-boot/udk: Simplify udk installation
authorStéphane Veyret <sveyret@gmail.com>
Sun, 2 Jun 2019 18:23:32 +0000 (20:23 +0200)
committerMichał Górny <mgorny@gentoo.org>
Fri, 5 Jul 2019 20:31:22 +0000 (22:31 +0200)
Signed-off-by: Stéphane VEYRET <sveyret@gmail.com>
Closes: https://bugs.gentoo.org/687222
Package-Manager: Portage-2.3.66, Repoman-2.3.11
Signed-off-by: Michał Górny <mgorny@gentoo.org>
sys-boot/udk/files/udk-workspace.template [new file with mode: 0644]
sys-boot/udk/udk-2018-r1.ebuild [new file with mode: 0644]

diff --git a/sys-boot/udk/files/udk-workspace.template b/sys-boot/udk/files/udk-workspace.template
new file mode 100644 (file)
index 0000000..e119c3a
--- /dev/null
@@ -0,0 +1,63 @@
+#!/bin/bash
+# Copyright 1999-2019 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+SCRIPT_NAME='udk-workspace'
+[ -n "${BASH_SOURCE}" ] && SCRIPT_NAME="${BASH_SOURCE}"
+
+show_usage() {
+       if [ ! -z "${1}" ]; then
+               echo "${1}" >&2
+               echo >&2
+       fi
+       echo "Usage:"
+       echo ". ${SCRIPT_NAME} [folder]"
+       echo "where folder is the workspace folder - current directory is used if unspecified"
+}
+
+create_workspace() {
+       local workspace_dir="${PWD}"
+       if [ ! -z "${1}" ]; then
+               workspace_dir="${1}"
+               if ! mkdir -p "${1}"; then
+                       show_usage "Cannot create directory ${1}"
+                       return 1
+               fi
+       fi
+
+       pushd "${workspace_dir}" >/dev/null
+       if ! mkdir -p Conf; then
+               show_usage "Cannot create configuration directory"
+               return 1
+       fi
+       export WORKSPACE="${PWD}"
+       popd >/dev/null
+}
+
+if [ "${1}" = "-h" ] || [ "${1}" = "--help" ]; then
+       show_usage
+       # Script may have been sourced
+       return 0 2>/dev/null
+       exit 0
+elif [ "${SCRIPT_NAME}" = "${0}" ]; then
+       show_usage "Script must be sourced"
+       exit 1
+elif [ $# -gt 1 ]; then
+       show_usage "Too many arguments"
+       return 1
+fi
+
+if ! create_workspace "${1}"; then
+       return 1
+fi
+unset -f show_usage
+unset -f create_workspace
+shift $#
+
+export EDK_TOOLS_PATH="{EDK_BASE}/BaseTools"
+. "{EDK_BASE}/edksetup.sh"
+
+echo "Do not forget to call this script each time you open a new terminal or work on"
+echo "another workspace."
+echo "For more information, type:"
+echo "${SCRIPT_NAME} --help"
diff --git a/sys-boot/udk/udk-2018-r1.ebuild b/sys-boot/udk/udk-2018-r1.ebuild
new file mode 100644 (file)
index 0000000..89f40f3
--- /dev/null
@@ -0,0 +1,146 @@
+# Copyright 1999-2019 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=7
+
+PYTHON_COMPAT=( python2_7 )
+PYTHON_REQ_USE="sqlite"
+
+inherit multiprocessing python-single-r1 toolchain-funcs
+
+DESCRIPTION="Tianocore UEFI Development kit"
+HOMEPAGE="https://github.com/tianocore/tianocore.github.io/wiki/EDK-II"
+
+if [[ ${PV} == *9999* ]]; then
+       inherit git-r3
+       EGIT_REPO_URI="https://github.com/tianocore/edk2.git"
+       KEYWORDS=""
+else
+       MY_V="${PN^^}${PV}"
+       SRC_URI="https://github.com/tianocore/edk2/archive/v${MY_V}.tar.gz -> ${P}.tar.gz
+               doc? ( https://github.com/tianocore/edk2/releases/download/v${MY_V}/${MY_V}.Documents.zip -> ${P}-docs.zip )"
+       S="${WORKDIR}/edk2-v${MY_V}"
+       KEYWORDS="~amd64 ~x86"
+fi
+
+LICENSE="BSD-2"
+SLOT="0"
+IUSE="doc"
+REQUIRED_USE="${PYTHON_REQUIRED_USE}"
+RESTRICT="strip"
+
+RDEPEND="${PYTHON_DEPS}"
+DEPEND="${RDEPEND}
+       >=dev-lang/nasm-2.14.02
+       >=sys-power/iasl-20160729
+       doc? ( app-arch/unzip )"
+
+DOCDIR="${WORKDIR}/Documents"
+
+# EFI pre-build libs
+QA_PREBUILT="
+       usr/lib/${P}/BeagleBoardPkg/Debugger_scripts/rvi_dummy.axf
+       usr/lib/${P}/ArmPkg/Library/GccLto/*.a
+"
+# GenBiosId is built upstream
+# VfrCompile does not use LDFLAGS but next upsteam version should change this
+QA_FLAGS_IGNORED="
+       usr/lib/udk-2018/BaseTools/Source/C/bin/VfrCompile
+       usr/lib/${P}/Vlv2TbltDevicePkg/GenBiosId
+"
+
+pkg_setup() {
+       if use x86; then
+               EFIARCH=IA32
+       elif use amd64; then
+               EFIARCH=X64
+       fi
+
+       # Select toolchain within predefined ones
+       if tc-is-gcc; then
+               TOOLCHAIN_TAG="GCC5"
+       elif tc-is-clang; then
+               TOOLCHAIN_TAG="CLANG38"
+       else
+               TOOLCHAIN_TAG="ELFGCC"
+       fi
+}
+
+src_unpack() {
+       default
+
+       local doc_name
+       local f
+       if use doc; then
+               pushd "${DOCDIR}" >/dev/null || die
+               rm -f *.chm || die
+               for f in *.zip; do
+                       unpack "${DOCDIR}/${f}"
+                       mv html "${f%.zip}" || die
+               done
+               rm -f *.zip || die
+               popd >/dev/null || die
+       fi
+}
+
+src_configure() {
+       sed -e "s:^\(BUILD_CFLAGS\s*=\).*$:\1 ${CFLAGS} -MD -fshort-wchar -fno-strict-aliasing -nostdlib -c -fPIC:" \
+               -e "s:^\(BUILD_LFLAGS\s*=\).*$:\1 ${LDFLAGS}:" \
+               -e "s:^\(BUILD_CXXFLAGS\s*=\).*$:\1 ${CXXFLAGS} -Wno-unused-result:" \
+               -i "BaseTools/Source/C/Makefiles/header.makefile" \
+               || die "Failed to update makefile header"
+}
+
+src_compile() {
+       local make_flags=(
+               BUILD_CC="$(tc-getBUILD_CC)"
+               BUILD_CXX="$(tc-getBUILD_CXX)"
+               BUILD_AS="$(tc-getBUILD_AS)"
+               BUILD_AR="$(tc-getBUILD_AR)"
+               BUILD_LD="$(tc-getBUILD_LD)"
+       )
+       # Base tools does not like parallel make
+       emake "${make_flags[@]}" -j1 -C BaseTools
+
+       # Update template parameter files
+       sed -e "s:^\(ACTIVE_PLATFORM\s*=\).*$:\1 MdeModulePkg/MdeModulePkg.dsc:" \
+               -e "s:^\(TARGET\s*=\).*$:\1 RELEASE:" \
+               -e "s:^\(TARGET_ARCH\s*=\).*$:\1 ${EFIARCH}:" \
+               -e "s:^\(TOOL_CHAIN_TAG\s*=\).*$:\1 ${TOOLCHAIN_TAG}:" \
+               -e "s:^\(MAX_CONCURRENT_THREAD_NUMBER\s*=\).*$:\1 $(makeopts_jobs):" \
+               -i "BaseTools/Conf/target.template" || die "Failed to configure target file"
+
+       # Clean unneeded files
+       find . -name '*.bat' -o -name '*.exe' -exec rm -f {} \; || die
+       find ./BaseTools/Source/C -mindepth 1 -maxdepth 1 \! -name 'bin' -exec rm -rf {} \; || die
+
+       # Upsteam hack (symbolic link) should only be created if needed
+       rm "${S}/EmulatorPkg/Unix/Host/X11IncludeHack" || die
+
+       # Create workspace script file
+       sed -e "s:{EDK_BASE}:${EPREFIX}/usr/lib/${P}:" \
+               "${FILESDIR}"/udk-workspace.template \
+               > "${T}/udk-workspace" || die "Failed to build udk-workspace"
+}
+
+src_install() {
+       dobin "${T}/udk-workspace"
+
+       # Use mkdir && cp here as doins does not preserve execution bits
+       mkdir -p "${ED}/usr/lib/${P}" || die
+       cp -pR "${S}"/* "${D}/usr/lib/${P}" || die
+       dosym "${P}" "/usr/lib/${PN}"
+
+       local HTML_DOCS
+       use doc && HTML_DOCS=( "${DOCDIR}"/. )
+       einstalldocs
+}
+
+pkg_postinst() {
+       elog "To create a new workspace, execute:"
+       elog "    . udk-workspace [workspace_dir]"
+       elog "You can link appropriate packages to your workspace. For example,"
+       elog "in order to build MdeModulePkg and examples, you can try:"
+       elog "    ln -s \"${EROOT}/usr/lib/${P}/\"Mde{Module,}Pkg ."
+       elog "    build -a ${EFIARCH} all"
+}