diff options
author | V3n3RiX <venerix@redcorelinux.org> | 2020-09-02 14:09:07 +0100 |
---|---|---|
committer | V3n3RiX <venerix@redcorelinux.org> | 2020-09-02 14:09:07 +0100 |
commit | b17a3ef12038de50228bade1f05502c74e135321 (patch) | |
tree | 9026dffec53f92cba48ca9a500a4f778e6304380 /eclass | |
parent | 3cf7c3ef441822c889356fd1812ebf2944a59851 (diff) |
gentoo resync : 02.09.2020
Diffstat (limited to 'eclass')
-rw-r--r-- | eclass/Manifest.gz | bin | 35934 -> 35940 bytes | |||
-rw-r--r-- | eclass/cmake.eclass | 37 | ||||
-rw-r--r-- | eclass/git-r3.eclass | 2 | ||||
-rw-r--r-- | eclass/gnuconfig.eclass | 10 | ||||
-rw-r--r-- | eclass/java-pkg-simple.eclass | 379 | ||||
-rw-r--r-- | eclass/java-utils-2.eclass | 38 | ||||
-rw-r--r-- | eclass/kde.org.eclass | 2 | ||||
-rw-r--r-- | eclass/kernel-build.eclass | 3 | ||||
-rw-r--r-- | eclass/kernel-install.eclass | 124 | ||||
-rw-r--r-- | eclass/toolchain.eclass | 2 |
10 files changed, 527 insertions, 70 deletions
diff --git a/eclass/Manifest.gz b/eclass/Manifest.gz Binary files differindex 9fec9cae23f3..589bed4dc60e 100644 --- a/eclass/Manifest.gz +++ b/eclass/Manifest.gz diff --git a/eclass/cmake.eclass b/eclass/cmake.eclass index f43d5af0f7ab..ddee554d429f 100644 --- a/eclass/cmake.eclass +++ b/eclass/cmake.eclass @@ -147,22 +147,39 @@ _cmake_check_build_dir() { einfo "Working in BUILD_DIR: \"$BUILD_DIR\"" } +# @FUNCTION: cmake_run_in +# @USAGE: <working dir> <run command> +# @DESCRIPTION: +# Set the desired working dir for a function or command. +cmake_run_in() { + if [[ -z ${2} ]]; then + die "${FUNCNAME[0]} must be passed at least two arguments" + fi + + [[ -e ${1} ]] || die "${FUNCNAME[0]}: Nonexistent path: ${1}" + + pushd ${1} > /dev/null || die + "${@:2}" + popd > /dev/null || die +} + # @FUNCTION: cmake_comment_add_subdirectory # @USAGE: <subdirectory> # @DESCRIPTION: # Comment out one or more add_subdirectory calls in CMakeLists.txt in the current directory cmake_comment_add_subdirectory() { if [[ -z ${1} ]]; then - die "comment_add_subdirectory must be passed at least one directory name to comment" + die "${FUNCNAME[0]} must be passed at least one directory name to comment" fi - if [[ -e "CMakeLists.txt" ]]; then - local d - for d in $@; do - sed -e "/add_subdirectory[[:space:]]*([[:space:]]*${d//\//\\/}[[:space:]]*)/I s/^/#DONOTCOMPILE /" \ - -i CMakeLists.txt || die "failed to comment add_subdirectory(${d})" - done - fi + [[ -e "CMakeLists.txt" ]] || return + + local d + for d in $@; do + d=${d//\//\\/} + sed -e "/add_subdirectory[[:space:]]*([[:space:]]*${d}[[:space:]]*)/I s/^/#DONOTCOMPILE /" \ + -i CMakeLists.txt || die "failed to comment add_subdirectory(${d})" + done } # @FUNCTION: comment_add_subdirectory @@ -472,6 +489,10 @@ cmake_src_configure() { SET (BUILD_SHARED_LIBS ON CACHE BOOL "") _EOF_ + if [[ -n ${_ECM_ECLASS} ]]; then + echo 'SET (ECM_DISABLE_QMLPLUGINDUMP ON CACHE BOOL "")' >> "${common_config}" || die + fi + # See bug 689410 if [[ "${ARCH}" == riscv ]]; then echo 'SET (CMAKE_FIND_LIBRARY_CUSTOM_LIB_SUFFIX '"${libdir#lib}"' CACHE STRING "library search suffix" FORCE)' >> "${common_config}" || die diff --git a/eclass/git-r3.eclass b/eclass/git-r3.eclass index 6c75d11218ce..cda7ac161e92 100644 --- a/eclass/git-r3.eclass +++ b/eclass/git-r3.eclass @@ -683,6 +683,8 @@ git-r3_fetch() { "+refs/tags/*:refs/tags/*" # notes in case something needs them "+refs/notes/*:refs/notes/*" + # pullrequest refs are useful for testing incoming changes + "+refs/pull/*/head:refs/pull/*" # and HEAD in case we need the default branch # (we keep it in refs/git-r3 since otherwise --prune interferes) "+HEAD:refs/git-r3/HEAD" diff --git a/eclass/gnuconfig.eclass b/eclass/gnuconfig.eclass index f43647ef6fd9..3433837787c2 100644 --- a/eclass/gnuconfig.eclass +++ b/eclass/gnuconfig.eclass @@ -1,8 +1,6 @@ -# Copyright 1999-2012 Gentoo Foundation +# Copyright 1999-2020 Gentoo Authors # Distributed under the terms of the GNU General Public License v2 # -# THIS ECLASS IS DEAD: It has been integrated into portage -# # Author: Will Woods <wwoods@gentoo.org> # # This eclass is used to automatically update files that typically come with @@ -26,12 +24,6 @@ DEPEND="sys-devel/gnuconfig" # config.sub and config.guess (old default behavior), otherwise update the # named files. gnuconfig_update() { - -# hmm some packages (like binutils gcc glibc) still use this ... -# echo -# ewarn "QA Notice: Please stop using me, portage updates files for you." -# echo - local startdir # declared here ... used in gnuconfig_do_update if [[ $1 == /* ]] ; then diff --git a/eclass/java-pkg-simple.eclass b/eclass/java-pkg-simple.eclass index 0b16cd5d40f3..560db83d77bc 100644 --- a/eclass/java-pkg-simple.eclass +++ b/eclass/java-pkg-simple.eclass @@ -22,11 +22,30 @@ if ! has java-pkg-2 ${INHERITED}; then eerror "java-pkg-simple eclass can only be inherited AFTER java-pkg-2" fi -EXPORT_FUNCTIONS src_compile src_install +EXPORT_FUNCTIONS src_compile src_install src_test # We are only interested in finding all java source files, wherever they may be. S="${WORKDIR}" +# handle dependencies for testing frameworks +if has test ${JAVA_PKG_IUSE}; then + local test_deps + for framework in ${JAVA_TESTING_FRAMEWORKS}; do + case ${framework} in + junit) + test_deps+=" dev-java/junit:0";; + junit-4) + test_deps+=" dev-java/junit:4";; + pkgdiff) + test_deps+=" amd64? ( dev-util/pkgdiff + dev-util/japi-compliance-checker )";; + testng) + test_deps+=" dev-java/testng:0";; + esac + done + [[ ${test_deps} ]] && DEPEND="test? ( ${test_deps} )" +fi + # @ECLASS-VARIABLE: JAVA_GENTOO_CLASSPATH # @DEFAULT_UNSET # @DESCRIPTION: @@ -45,17 +64,46 @@ S="${WORKDIR}" # Extra list of colon separated path elements to be put on the # classpath when compiling sources. +# @ECLASS-VARIABLE: JAVA_CLASSPATH_EXTRA +# @DEFAULT_UNSET +# @DESCRIPTION: +# An extra comma or space separated list of java packages +# that are needed only during compiling sources. + +# @ECLASS-VARIABLE: JAVA_NEEDS_TOOLS +# @DEFAULT_UNSET +# @DESCRIPTION: +# add tools.jar to the gentoo.classpath. Should only be used +# for build-time purposes, the dependency is not recorded to +# package.env. + # @ECLASS-VARIABLE: JAVA_SRC_DIR # @DEFAULT_UNSET # @DESCRIPTION: -# Directories relative to ${S} which contain the sources of the -# application. The default of "" will be treated mostly as ${S} -# itself. For the generated source package (if source is listed in +# An array of directories relative to ${S} which contain the sources +# of the application. If you set ${JAVA_SRC_DIR} to a string it works +# as well. The default value "" means it will get all source files +# inside ${S}. +# For the generated source package (if source is listed in # ${JAVA_PKG_IUSE}), it is important that these directories are # actually the roots of the corresponding source trees. # # @CODE -# JAVA_SRC_DIR="src/java/org/gentoo" +# JAVA_SRC_DIR=( "impl/src/main/java/" +# "arquillian/weld-ee-container/src/main/java/" +# ) +# @CODE + +# @DESCRIPTION: +# @ECLASS-VARIABLE: JAVA_RESOURCE_DIRS +# @DEFAULT_UNSET +# @DESCRIPTION: +# An array of directories relative to ${S} which contain the +# resources of the application. If you do not set the variable, +# there will be no resources added to the compiled jar file. +# +# @CODE +# JAVA_RESOURCE_DIRS=("src/java/resources/") # @CODE # @ECLASS-VARIABLE: JAVA_ENCODING @@ -68,6 +116,17 @@ S="${WORKDIR}" # @DESCRIPTION: # Additional arguments to be passed to javac. +# @ECLASS-VARIABLE: JAVA_MAIN_CLASS +# @DEFAULT_UNSET +# @DESCRIPTION: +# If the java has a main class, you are going to set the +# variable so that we can generate a proper MANIFEST.MF +# and create a launcher. +# +# @CODE +# JAVA_MAIN_CLASS="org.gentoo.java.ebuilder.Main" +# @CODE + # @ECLASS-VARIABLE: JAVADOC_ARGS # @DEFAULT_UNSET # @DESCRIPTION: @@ -78,34 +137,217 @@ S="${WORKDIR}" # The name of the jar file to create and install. : ${JAVA_JAR_FILENAME:=${PN}.jar} +# @ECLASS-VARIABLE: JAVA_BINJAR_FILENAME +# @DEFAULT_UNSET +# @DESCRIPTION: +# The name of the binary jar file to be installed if +# USE FLAG 'binary' is set. + +# @ECLASS-VARIABLE: JAVA_LAUNCHER_FILENAME +# @DESCRIPTION: +# If ${JAVA_MAIN_CLASS} is set, we will create a launcher to +# execute the jar, and ${JAVA_LAUNCHER_FILENAME} will be the +# name of the script. +: ${JAVA_LAUNCHER_FILENAME:=${PN}-${SLOT}} + +# @ECLASS-VARIABLE: JAVA_TESTING_FRAMEWORKS +# @DEFAULT_UNSET +# @DESCRIPTION: +# A space separated list that defines which tests it should launch +# during src_test. +# +# @CODE +# JAVA_TESTING_FRAMEWORKS="junit pkgdiff" +# @CODE + +# @ECLASS-VARIABLE: JAVA_TEST_EXCLUDES +# @DEFAULT_UNSET +# @DESCRIPTION: +# A array of classes that should not be executed during src_test(). +# +# @CODE +# JAVA_TEST_EXCLUDES=( "net.sf.cglib.CodeGenTestCase" "net.sf.cglib.TestAll" ) +# @CODE + +# @ECLASS-VARIABLE: JAVA_TEST_GENTOO_CLASSPATH +# @DEFAULT_UNSET +# @DESCRIPTION: +# The extra classpath we need while compiling and running the +# source code for testing. + +# @ECLASS-VARIABLE: JAVA_TEST_SRC_DIR +# @DEFAULT_UNSET +# @DESCRIPTION: +# An array of directories relative to ${S} which contain the +# sources for testing. It is almost equivalent to +# ${JAVA_SRC_DIR} in src_test. + +# @ECLASS-VARIABLE: JAVA_TEST_RESOURCE_DIRS +# @DEFAULT_UNSET +# @DESCRIPTION: +# It is almost equivalent to ${JAVA_RESOURCE_DIRS} in src_test. + +# @FUNCTION: java-pkg-simple_getclasspath +# @USAGE: java-pkg-simple_getclasspath [--runtime-only] +# @INTERNAL +# @DESCRIPTION: +# Get proper ${classpath} from ${JAVA_GENTOO_CLASSPATH_EXTRA}, +# ${JAVA_NEEDS_TOOLS}, ${JAVA_CLASSPATH_EXTRA} and +# ${JAVA_GENTOO_CLASSPATH}. We use it inside +# java-pkg-simple_src_compile and java-pkg-simple_src_test. +# +# Note that if you need to define a "classpath" variable before +# calling this function. +java-pkg-simple_getclasspath() { + debug-print-function ${FUNCNAME} $* + + local denpendency + local deep_jars="--with-dependencies" + local buildonly_jars="--build-only" + + # the extra classes that are not installed by portage + classpath+=":${JAVA_GENTOO_CLASSPATH_EXTRA}" + + # whether we need tools.jar + [[ ${JAVA_NEEDS_TOOLS} ]] && classpath+=":$(java-config --tools)" + + # the extra classes that are installed by portage + for dependency in ${JAVA_CLASSPATH_EXTRA}; do + classpath="${classpath}:$(java-pkg_getjars ${buildonly_jars}\ + ${deep_jars} ${dependency})" + done + + # add test dependencies if USE FLAG 'test' is set + if has test ${JAVA_PKG_IUSE} && use test; then + for dependency in ${JAVA_TEST_GENTOO_CLASSPATH}; do + classpath="${classpath}:$(java-pkg_getjars ${buildonly_jars}\ + ${deep_jars} ${dependency})" + done + fi + + # add the RUNTIME dependencies + for dependency in ${JAVA_GENTOO_CLASSPATH}; do + classpath="${classpath}:$(java-pkg_getjars ${deep_jars} ${dependency})" + done + + # purify classpath + while [[ $classpath = *::* ]]; do classpath="${classpath//::/:}"; done + classpath=${classpath%:} + classpath=${classpath#:} + + debug-print "CLASSPATH=${classpath}" +} + +# @FUNCTION: java-pkg-simple_test_with_pkgdiff_ +# @INTERNAL +# @DESCRIPTION: +# use japi-compliance-checker the ensure the compabitily of \*.class files, +# Besides, use pkgdiff to ensure the compabilty of resources. +java-pkg-simple_test_with_pkgdiff_() { + debug-print-function ${FUNCNAME} $* + + if [[ ! ${ARCH} == "amd64" ]]; then + elog "For architectures other than amd64, "\ + "the pkgdiff test is currently unavailable "\ + "because 'dev-util/japi-compliance-checker "\ + "and 'dev-util/pkgdiff' do not support those architectures." + return + fi + + local report1=${PN}-japi-compliance-checker.html + local report2=${PN}-pkgdiff.html + + # pkgdiff test + if [[ -f "${DISTDIR}/${JAVA_BINJAR_FILENAME}" ]]; then + # pkgdiff cannot deal with symlinks, so this is a workaround + cp "${DISTDIR}/${JAVA_BINJAR_FILENAME}" ./ \ + || die "Cannot copy binjar file to ${S}." + + # japi-compliance-checker + japi-compliance-checker ${JAVA_BINJAR_FILENAME} ${JAVA_JAR_FILENAME}\ + --lib=${PN} -v1 ${PV}-bin -v2 ${PV} -report-path ${report1}\ + --binary\ + || die "japi-compliance-checker returns $?,"\ + "check the report in ${S}/${report1}" + + # ignore META-INF since it does not matter + # ignore classes because japi-compilance checker will take care of it + pkgdiff ${JAVA_BINJAR_FILENAME} ${JAVA_JAR_FILENAME}\ + -vnum1 ${PV}-bin -vnum2 ${PV}\ + -skip-pattern "META-INF|.class$"\ + -name ${PN} -report-path ${report2}\ + || die "pkgdiff returns $?, check the report in ${S}/${report2}" + fi +} + +# @FUNCTION: java-pkg-simple_prepend_resources +# @USAGE: java-pkg-simple_prepend-resources <${classes}> <"${RESOURCE_DIRS[@]}"> +# @INTERNAL +# @DESCRIPTION: +# Copy things under "${JAVA_RESOURCE_DIRS[@]}" or "${JAVA_TEST_RESOURCE_DIRS[@]}" +# to ${classes}, so that `jar` will package resources together with classes. +# +# Note that you need to define a "classes" variable before calling +# this function. +java-pkg-simple_prepend_resources() { + debug-print-function ${FUNCNAME} $* + + local destination="${1}" + shift 1 + + # return if there is no resource dirs defined + [[ "$@" ]] || return + local resources=("${@}") + + # add resources directory to classpath + for resource in "${resources[@]}"; do + cp -rT "${resource:-.}" "${destination}"\ + || die "Could not copy resources from ${resource:-.} to ${destination}" + done +} + # @FUNCTION: java-pkg-simple_src_compile # @DESCRIPTION: # src_compile for simple bare source java packages. Finds all *.java # sources in ${JAVA_SRC_DIR}, compiles them with the classpath # calculated from ${JAVA_GENTOO_CLASSPATH}, and packages the resulting -# classes to ${JAVA_JAR_FILENAME}. +# classes to a single ${JAVA_JAR_FILENAME}. If the file +# target/META-INF/MANIFEST.MF exists, it is used as the manifest of the +# created jar. +# +# If USE FLAG 'binary' exists and is set, it will just copy +# ${JAVA_BINJAR_FILENAME} to ${S} and skip the rest of src_compile. java-pkg-simple_src_compile() { local sources=sources.lst classes=target/classes apidoc=target/api # auto generate classpath java-pkg_gen-cp JAVA_GENTOO_CLASSPATH + # do not compile if we decide to install binary jar + if has binary ${JAVA_PKG_IUSE} && use binary; then + # register the runtime dependencies + for dependency in ${JAVA_GENTOO_CLASSPATH//,/ }; do + java-pkg_record-jar_ ${dependency} + done + + cp "${DISTDIR}"/${JAVA_BINJAR_FILENAME} ${JAVA_JAR_FILENAME}\ + || die "Could not copy the binary jar file to ${S}" + return 0 + fi + # gather sources - find ${JAVA_SRC_DIR:-*} -name \*.java > ${sources} + find "${JAVA_SRC_DIR[@]}" -name \*.java > ${sources} + + # create the target directory mkdir -p ${classes} || die "Could not create target directory" # compile - local classpath="${JAVA_GENTOO_CLASSPATH_EXTRA}" dependency - for dependency in ${JAVA_GENTOO_CLASSPATH}; do - classpath="${classpath}:$(java-pkg_getjars ${dependency})" \ - || die "getjars failed for ${dependency}" - done - while [[ $classpath = *::* ]]; do classpath="${classpath//::/:}"; done - classpath=${classpath%:} - classpath=${classpath#:} - debug-print "CLASSPATH=${classpath}" - ejavac -d ${classes} -encoding ${JAVA_ENCODING} \ - ${classpath:+-classpath ${classpath}} ${JAVAC_ARGS} \ + local classpath="" + java-pkg-simple_getclasspath + java-pkg-simple_prepend_resources ${classes} "${JAVA_RESOURCE_DIRS[@]}" + + ejavac -d ${classes} -encoding ${JAVA_ENCODING}\ + ${classpath:+-classpath ${classpath}} ${JAVAC_ARGS}\ @${sources} # javadoc @@ -118,25 +360,33 @@ java-pkg-simple_src_compile() { fi # package - local jar_args="cf ${JAVA_JAR_FILENAME}" + local jar_args if [[ -e ${classes}/META-INF/MANIFEST.MF ]]; then jar_args="cfm ${JAVA_JAR_FILENAME} ${classes}/META-INF/MANIFEST.MF" + elif [[ ${JAVA_MAIN_CLASS} ]]; then + jar_args="cfe ${JAVA_JAR_FILENAME} ${JAVA_MAIN_CLASS}" + else + jar_args="cf ${JAVA_JAR_FILENAME}" fi jar ${jar_args} -C ${classes} . || die "jar failed" } # @FUNCTION: java-pkg-simple_src_install # @DESCRIPTION: -# src_install for simple single jar java packages. Simply packages the -# contents from the target directory and installs it as -# ${JAVA_JAR_FILENAME}. If the file target/META-INF/MANIFEST.MF exists, -# it is used as the manifest of the created jar. +# src_install for simple single jar java packages. Simply installs +# ${JAVA_JAR_FILENAME}. It will also install a launcher if +# ${JAVA_MAIN_CLASS} is set. java-pkg-simple_src_install() { local sources=sources.lst classes=target/classes apidoc=target/api - # main jar + # install the jar file that we need java-pkg_dojar ${JAVA_JAR_FILENAME} + # install a wrapper if ${JAVA_MAIN_CLASS} is defined + if [[ ${JAVA_MAIN_CLASS} ]]; then + java-pkg_dolauncher "${JAVA_LAUNCHER_FILENAME}" --main ${JAVA_MAIN_CLASS} + fi + # javadoc if has doc ${JAVA_PKG_IUSE} && use doc; then java-pkg_dojavadoc ${apidoc} @@ -145,12 +395,10 @@ java-pkg-simple_src_install() { # dosrc if has source ${JAVA_PKG_IUSE} && use source; then local srcdirs="" - if [[ ${JAVA_SRC_DIR} ]]; then + if [[ "${JAVA_SRC_DIR[@]}" ]]; then local parent child - for parent in ${JAVA_SRC_DIR}; do - for child in ${parent}/*; do - srcdirs="${srcdirs} ${child}" - done + for parent in "${JAVA_SRC_DIR[@]}"; do + srcdirs="${srcdirs} ${parent}" done else # take all directories actually containing any sources @@ -159,3 +407,76 @@ java-pkg-simple_src_install() { java-pkg_dosrc ${srcdirs} fi } + +# @FUNCTION: java-pkg-simple_src_test +# @DESCRIPTION: +# src_test for simple single java jar file. +# It will perform test with frameworks that are defined in +# ${JAVA_TESTING_FRAMEWORKS}. +java-pkg-simple_src_test() { + local test_sources=test_sources.lst classes=target/test-classes + local tests_to_run classpath + + # do not continue if the USE FLAG 'test' is explicitly unset + # or no ${JAVA_TESTING_FRSerializingCAMEWORKS} specified + if ! has test ${JAVA_PKG_IUSE}; then + return + elif ! use test; then + return + elif [[ ! "${JAVA_TESTING_FRAMEWORKS}" ]]; then + return + fi + + # create the target directory + mkdir -p ${classes} || die "Could not create target directory for testing" + + # get classpath + classpath="${classes}:${JAVA_JAR_FILENAME}" + java-pkg-simple_getclasspath + java-pkg-simple_prepend_resources ${classes} "${JAVA_TEST_RESOURCE_DIRS[@]}" + + # gathering sources for testing + find "${JAVA_TEST_SRC_DIR[@]}" -name \*.java > ${test_sources} + + # compile + [[ -s ${test_sources} ]] && ejavac -d ${classes} ${JAVAC_ARGS} \ + -encoding ${JAVA_ENCODING} ${classpath:+-classpath ${classpath}} \ + @${test_sources} + + # grab a set of tests that testing framework will run + tests_to_run=$(find "${classes}" -type f\ + \( -name "*Test.class"\ + -o -name "Test*.class"\ + -o -name "*Tests.class"\ + -o -name "*TestCase.class" \)\ + ! -name "*Abstract*"\ + ! -name "*BaseTest*"\ + ! -name "*TestTypes*"\ + ! -name "*TestUtils*"\ + ! -name "*\$*") + tests_to_run=${tests_to_run//"${classes}"\/} + tests_to_run=${tests_to_run//.class} + tests_to_run=${tests_to_run//\//.} + + # exclude extra test classes, usually corner cases + # that the code above cannot handle + for class in "${JAVA_TEST_EXCLUDES[@]}"; do + tests_to_run=${tests_to_run//${class}} + done + + # launch test + for framework in ${JAVA_TESTING_FRAMEWORKS}; do + case ${framework} in + junit) + ejunit -classpath "${classpath}" ${tests_to_run};; + junit-4) + ejunit4 -classpath "${classpath}" ${tests_to_run};; + pkgdiff) + java-pkg-simple_test_with_pkgdiff_;; + testng) + etestng -classpath "${classpath}" ${tests_to_run};; + *) + elog "No suitable function found for framework ${framework}" + esac + done +} diff --git a/eclass/java-utils-2.eclass b/eclass/java-utils-2.eclass index 29f13e031f48..a33962f114de 100644 --- a/eclass/java-utils-2.eclass +++ b/eclass/java-utils-2.eclass @@ -1861,6 +1861,44 @@ ejunit4() { ejunit_ "junit-4" "${@}" } +# @FUNCTION: etestng +# @USAGE: etestng_ [-cp $classpath] <test classes> +# @INTERNAL +# @DESCRIPTION: +# Testng wrapper function. Makes it easier to run the tests. +# Launches the tests using org.testng.TestNG. +# +# @CODE +# $1 - -cp or -classpath +# $2 - the classpath passed to it +# $@ - test classes for testng to run. +# @CODE +etestng() { + debug-print-function ${FUNCNAME} $* + + local runner=org.testng.TestNG + local cp=$(java-pkg_getjars --with-dependencies testng) + local tests + + if [[ ${1} = -cp || ${1} = -classpath ]]; then + cp="${cp}:${2}" + shift 2 + else + cp="${cp}:." + fi + + for test in ${@}; do + tests+="${test}," + done + + debug-print "java -cp \"${cp}\" -Djava.io.tmpdir=\"${T}\""\ + "-Djava.awt.headless=true ${runner}"\ + "-usedefaultlisteners false -testclass ${tests}" + java -cp "${cp}" -Djava.io.tmpdir=\"${T}\" -Djava.awt.headless=true\ + ${runner} -usedefaultlisteners false -testclass ${tests}\ + || die "Running TestNG failed." +} + # @FUNCTION: java-utils-2_src_prepare # @DESCRIPTION: # src_prepare Searches for bundled jars diff --git a/eclass/kde.org.eclass b/eclass/kde.org.eclass index 37a631499e14..d099b128918c 100644 --- a/eclass/kde.org.eclass +++ b/eclass/kde.org.eclass @@ -192,7 +192,7 @@ _kde.org_calculate_live_repo() { # @DESCRIPTION: # This variable allows overriding of default repository # name. Specify only if this differs from PN and KDE_ORG_NAME. - EGIT_REPO_URI="${EGIT_MIRROR}/${EGIT_REPONAME:=$KDE_ORG_NAME}" + EGIT_REPO_URI="${EGIT_MIRROR}/${EGIT_REPONAME:=$KDE_ORG_NAME}.git" } case ${KDE_BUILD_TYPE} in diff --git a/eclass/kernel-build.eclass b/eclass/kernel-build.eclass index 47b0db349561..048d0c9b016c 100644 --- a/eclass/kernel-build.eclass +++ b/eclass/kernel-build.eclass @@ -176,6 +176,9 @@ kernel-build_src_install() { local image_path=$(kernel-install_get_image_path) cp -p "build/${image_path}" "${ED}/usr/src/linux-${ver}/${image_path}" || die + # building modules fails with 'vmlinux has no symtab?' if stripped + use ppc64 && dostrip -x "/usr/src/linux-${ver}/${image_path}" + # strip empty directories find "${D}" -type d -empty -exec rmdir {} + || die diff --git a/eclass/kernel-install.eclass b/eclass/kernel-install.eclass index 558e4979168d..e826626e13f2 100644 --- a/eclass/kernel-install.eclass +++ b/eclass/kernel-install.eclass @@ -40,18 +40,7 @@ case "${EAPI:-0}" in ;; esac -inherit mount-boot - -TCL_VER=10.1 -SRC_URI+=" - test? ( - amd64? ( - https://dev.gentoo.org/~mgorny/dist/tinycorelinux-${TCL_VER}-amd64.qcow2 - ) - x86? ( - https://dev.gentoo.org/~mgorny/dist/tinycorelinux-${TCL_VER}-x86.qcow2 - ) - )" +inherit mount-boot toolchain-funcs SLOT="${PV}" IUSE="+initramfs test" @@ -59,7 +48,7 @@ RESTRICT+=" !test? ( test ) test? ( userpriv ) arm? ( test ) - arm64? ( test )" +" # install-DEPEND actually # note: we need installkernel with initramfs support! @@ -72,8 +61,12 @@ RDEPEND=" BDEPEND=" test? ( dev-tcltk/expect + sys-apps/coreutils sys-kernel/dracut + sys-fs/e2fsprogs amd64? ( app-emulation/qemu[qemu_softmmu_targets_x86_64] ) + arm64? ( app-emulation/qemu[qemu_softmmu_targets_aarch64] ) + ppc64? ( app-emulation/qemu[qemu_softmmu_targets_ppc64] ) x86? ( app-emulation/qemu[qemu_softmmu_targets_i386] ) )" @@ -109,6 +102,11 @@ kernel-install_get_image_path() { arm) echo arch/arm/boot/zImage ;; + ppc64) + # ./ is required because of ${image_path%/*} + # substitutions in the code + echo ./vmlinux + ;; *) die "${FUNCNAME}: unsupported ARCH=${ARCH}" ;; @@ -199,12 +197,68 @@ kernel-install_get_qemu_arch() { arm64) echo aarch64 ;; + ppc64) + echo ppc64 + ;; *) die "${FUNCNAME}: unsupported ARCH=${ARCH}" ;; esac } +# @FUNCTION: kernel-install_create_init +# @USAGE: <filename> +# @DESCRIPTION: +# Create minimal /sbin/init +kernel-install_create_init() { + debug-print-function ${FUNCNAME} "${@}" + + [[ ${#} -eq 1 ]] || die "${FUNCNAME}: invalid arguments" + [[ -z ${1} ]] && die "${FUNCNAME}: empty argument specified" + + local output="${1}" + [[ -f ${output} ]] && die "${FUNCNAME}: ${output} already exists" + + cat <<-_EOF_ >"${T}/init.c" || die + #include <stdio.h> + int main() { + printf("Hello, World!\n"); + return 0; + } + _EOF_ + + $(tc-getBUILD_CC) -Os -static "${T}/init.c" -o "${output}" || die + $(tc-getBUILD_STRIP) "${output}" || die +} + +# @FUNCTION: kernel-install_create_qemu_image +# @USAGE: <filename> +# @DESCRIPTION: +# Create minimal qemu raw image +kernel-install_create_qemu_image() { + debug-print-function ${FUNCNAME} "${@}" + + [[ ${#} -eq 1 ]] || die "${FUNCNAME}: invalid arguments" + [[ -z ${1} ]] && die "${FUNCNAME}: empty argument specified" + + local image="${1}" + [[ -f ${image} ]] && die "${FUNCNAME}: ${image} already exists" + + local imageroot="${T}/imageroot" + [[ -d ${imageroot} ]] && die "${FUNCNAME}: ${imageroot} already exists" + mkdir "${imageroot}" || die + + # some layout needed to pass dracut's usable_root() validation + mkdir -p "${imageroot}"/{bin,dev,etc,lib,proc,root,sbin,sys} || die + touch "${imageroot}/lib/ld-fake.so" || die + + kernel-install_create_init "${imageroot}/sbin/init" + + # image may be smaller if needed + truncate -s 4M "${image}" || die + mkfs.ext4 -v -d "${imageroot}" -L groot "${image}" || die +} + # @FUNCTION: kernel-install_test # @USAGE: <version> <image> <modules> # @DESCRIPTION: @@ -227,25 +281,43 @@ kernel-install_test() { --no-hostonly \ --kmoddir "${modules}" \ "${T}/initrd" "${version}" || die - # get a read-write copy of the disk image - cp "${DISTDIR}/tinycorelinux-${TCL_VER}-${ARCH}.qcow2" \ - "${T}/fs.qcow2" || die + + kernel-install_create_qemu_image "${T}/fs.img" cd "${T}" || die + local qemu_extra_args= - [[ ${qemu_arch} == x86_64 ]] && qemu_extra_args='-cpu max' + local qemu_extra_append= + + case ${qemu_arch} in + aarch64) + qemu_extra_args="-M virt -cpu cortex-a57 -smp 1" + qemu_extra_append="console=ttyAMA0" + ;; + i386|x86_64) + qemu_extra_args="-cpu max" + qemu_extra_append="console=ttyS0,115200n8" + ;; + ppc64) + qemu_extra_args="-nodefaults" + ;; + *) + : + ;; + esac + cat > run.sh <<-EOF || die #!/bin/sh exec qemu-system-${qemu_arch} \ ${qemu_extra_args} \ - -m 256M \ - -display none \ + -m 512M \ + -nographic \ -no-reboot \ -kernel '${image}' \ -initrd '${T}/initrd' \ -serial mon:stdio \ - -hda '${T}/fs.qcow2' \ - -append 'root=/dev/sda console=ttyS0,115200n8' + -drive file=fs.img,format=raw,index=0,media=disk \ + -append 'root=LABEL=groot ${qemu_extra_append}' EOF chmod +x run.sh || die # TODO: initramfs does not let core finish starting on some systems, @@ -254,6 +326,14 @@ kernel-install_test() { set timeout 900 spawn ./run.sh expect { + "terminating on signal" { + send_error "\n* Qemu killed" + exit 1 + } + "OS terminated" { + send_error "\n* Qemu terminated OS" + exit 1 + } "Kernel panic" { send_error "\n* Kernel panic" exit 1 @@ -262,7 +342,7 @@ kernel-install_test() { send_error "\n* Initramfs failed to start the system" exit 1 } - "Core 10.1" { + "Hello, World!" { send_error "\n* Booted successfully" exit 0 } diff --git a/eclass/toolchain.eclass b/eclass/toolchain.eclass index 5bbf46ecd3d5..6fb3eb941a2c 100644 --- a/eclass/toolchain.eclass +++ b/eclass/toolchain.eclass @@ -1520,7 +1520,7 @@ gcc-abi-map() { local map=() case ${CTARGET} in mips*) map=("o32 32" "n32 n32" "n64 64") ;; - riscv*) map=("lp64d lp64d" "lp64 lp64") ;; + riscv*) map=("lp64d lp64d" "lp64 lp64" "ilp32d ilp32d" "ilp32 ilp32") ;; x86_64*) map=("amd64 m64" "x86 m32" "x32 mx32") ;; esac |