From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id D54D213835A for ; Sat, 19 Dec 2020 21:36:46 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id F40A1E093D; Sat, 19 Dec 2020 21:36:45 +0000 (UTC) Received: from smtp.gentoo.org (woodpecker.gentoo.org [IPv6:2001:470:ea4a:1:5054:ff:fec7:86e4]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id D0926E093D for ; Sat, 19 Dec 2020 21:36:45 +0000 (UTC) Received: from oystercatcher.gentoo.org (oystercatcher.gentoo.org [148.251.78.52]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 368EE3410EA for ; Sat, 19 Dec 2020 21:36:44 +0000 (UTC) Received: from localhost.localdomain (localhost [IPv6:::1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id 98CC34A for ; Sat, 19 Dec 2020 21:36:42 +0000 (UTC) From: "Aisha Tammy" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Aisha Tammy" Message-ID: <1608389598.58fa9b589bcdae2c7e9bdaa7ac34a0a32a18f631.epsilon-0@gentoo> Subject: [gentoo-commits] proj/sci:master commit in: eclass/ X-VCS-Repository: proj/sci X-VCS-Files: eclass/rpm-extended.eclass X-VCS-Directories: eclass/ X-VCS-Committer: epsilon-0 X-VCS-Committer-Name: Aisha Tammy X-VCS-Revision: 58fa9b589bcdae2c7e9bdaa7ac34a0a32a18f631 X-VCS-Branch: master Date: Sat, 19 Dec 2020 21:36:42 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply X-Archives-Salt: 33f5b018-bbbd-4a15-944b-f64b11115058 X-Archives-Hash: 782531f6df42ba067d7e17e7c4502f63 commit: 58fa9b589bcdae2c7e9bdaa7ac34a0a32a18f631 Author: Andrew Ammerlaan riseup net> AuthorDate: Wed Dec 16 12:38:35 2020 +0000 Commit: Aisha Tammy aisha cc> CommitDate: Sat Dec 19 14:53:18 2020 +0000 URL: https://gitweb.gentoo.org/proj/sci.git/commit/?id=58fa9b58 eclass/rpm-extended: add eclass Package-Manager: Portage-3.0.12, Repoman-3.0.2 Signed-off-by: Andrew Ammerlaan riseup.net> Closes: https://github.com/gentoo/sci/pull/996 Signed-off-by: Aisha Tammy aisha.cc> eclass/rpm-extended.eclass | 131 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 131 insertions(+) diff --git a/eclass/rpm-extended.eclass b/eclass/rpm-extended.eclass new file mode 100644 index 000000000..a4e334fd7 --- /dev/null +++ b/eclass/rpm-extended.eclass @@ -0,0 +1,131 @@ +# Copyright 1999-2020 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 + +# @ECLASS: rpm-extended.eclass +# @MAINTAINER: +# Andrew Ammerlaan +# @AUTHOR: +# Andrew Ammerlaan +# Extension of the rpm.eclass by Alastair Tse +# @SUPPORTED_EAPIS: 6 7 +# @BLURB: An eclass that helps automating the creation of ebuilds for software only distributed through rpm +# @DESCRIPTION: +# This extends the rpm eclass to also installs *all* files in the rpm, +# and extracts post/pre(un)install scripts and runs them. +# +# This is mostly useful when creating ebuilds for rpm files in bulk. +# In cases when it is not doable to write a Gentoo specific src_install +# and pkg_post/pre/install/rm functions for each ebuild. + +# The rpm eclass provides the pkg_unpack function we need +inherit rpm + +case "${EAPI:-0}" in + 0|1|2|3|4|5) + die "Unsupported EAPI=${EAPI:-0} (too old) for ${ECLASS}" + ;; + 6|7) + ;; + *) + die "Unsupported EAPI=${EAPI} (unknown) for ${ECLASS}" + ;; +esac + +# Need rpm to extract scripts +if [[ ${EAPI} == [7] ]]; then + BDEPEND="app-arch/rpm" +else + DEPEND="app-arch/rpm" +fi + +# Otherwise we get the S does not exist error +S="${WORKDIR}" +# Everything in the rpm is prebuilt +QA_PREBUILT="*" + +# @FUNCTION: rpm-extended_src_compile +# @DESCRIPTION: +# As everything in the rpm file is prebuilt +# we do not need to compile anything, therefore +# we add an empty src_compile function to avoid +# errors. +rpm-extended_src_compile() { + # Nothing to do here + return +} + +# @FUNCTION: rpm-extended_src_install +# @DESCRIPTION: +# The rpm has been extracted by the pkg_unpack +# function from rpm.eclass. Now we just copy +# everything over to the image directory, while +# preserving permissions. If something is installed +# to /usr/share/doc we move everything in there to +# the correct Gentoo specific location: /usr/share/doc/${PF} +rpm-extended_src_install() { + cp -a "${S}"/* "${ED}" + if [ -d "${ED}/usr/share/doc/" ]; then + # If this package contains docs, move to gentoo specific dir + mkdir "${ED}/usr/share/doc/${PF}" || die + for file in "${ED}/usr/share/doc"/* ; do + if [[ "${file}" == "${ED}/usr/share/doc/${PF}" ]]; then + continue + fi + mv "${file}" "${ED}/usr/share/doc/${PF}" || die + done + fi +} + +# @FUNCTION: rpm-extended_pkg_preinst +# @DESCRIPTION: +# Some rpm files contain a preinstall script, +# we extract this script, write it to a file +# and execute it in the correct phase +rpm-extended_pkg_preinst() { + for x in ${A}; do + rpm -qp --scripts "${DISTDIR}/${x}" | sed -n '/preinstall scriptlet (using \/bin\/sh):/,/scriptlet (using \/bin\/sh)/{//!p;}' > "preinst-${x}.sh" + chmod +x "preinst-${x}.sh" + bash "preinst-${x}.sh" + done +} + +# @FUNCTION: rpm-extended_pkg_postinst +# @DESCRIPTION: +# Some rpm files contain a postinstall script, +# we extract this script, write it to a file +# and execute it in the correct phase +rpm-extended_pkg_postinst() { + for x in ${A}; do + rpm -qp --scripts "${DISTDIR}/${x}" | sed -n '/postinstall scriptlet (using \/bin\/sh):/,/scriptlet (using \/bin\/sh)/{//!p;}' > "postinst-${x}.sh" + chmod +x "postinst-${x}.sh" + bash "postinst-${x}.sh" + done +} + +# @FUNCTION: rpm-extended_pkg_prerm +# @DESCRIPTION: +# Some rpm files contain a preuninstall script, +# we extract this script, write it to a file +# and execute it in the correct phase +rpm-extended_pkg_prerm() { + for x in ${A}; do + rpm -qp --scripts "${DISTDIR}/${x}" | sed -n '/preuninstall scriptlet (using \/bin\/sh):/,/scriptlet (using \/bin\/sh)/{//!p;}' > "prerm-${x}.sh" + chmod +x "prerm-${x}.sh" + bash "prerm-${x}.sh" + done +} + +# @FUNCTION: rpm-extended_pkg_postrm +# @DESCRIPTION: +# Some rpm files contain a postuninstall script, +# we extract this script, write it to a file +# and execute it in the correct phase +rpm-extended_pkg_postrm() { + for x in ${A}; do + rpm -qp --scripts "${DISTDIR}/${x}" | sed -n '/postuninstall scriptlet (using \/bin\/sh):/,/scriptlet (using \/bin\/sh)/{//!p;}' > "postrm-${x}.sh" + chmod +x "postrm-${x}.sh" + bash "postrm-${x}.sh" + done +} + +EXPORT_FUNCTIONS src_compile src_install pkg_preinst pkg_postinst pkg_prerm pkg_postrm