commit:     004d9a56c6b7cc0867735791e54f07a2981c7d93
Author:     Ulrich Müller <ulm <AT> gentoo <DOT> org>
AuthorDate: Sun Mar  5 10:08:34 2023 +0000
Commit:     Ulrich Müller <ulm <AT> gentoo <DOT> org>
CommitDate: Sun Mar  5 10:11:21 2023 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=004d9a56

app-editors/emacs: Workaround for non-idempotent pkg_preinst

Closes: https://bugs.gentoo.org/899648
Signed-off-by: Ulrich Müller <ulm <AT> gentoo.org>

 app-editors/emacs/emacs-18.59-r15.ebuild    | 12 +++++++++---
 app-editors/emacs/emacs-25.3-r16.ebuild     | 10 ++++++++--
 app-editors/emacs/emacs-26.3-r13.ebuild     | 10 ++++++++--
 app-editors/emacs/emacs-27.2-r11.ebuild     | 10 ++++++++--
 app-editors/emacs/emacs-28.2-r6.ebuild      | 10 ++++++++--
 app-editors/emacs/emacs-28.3_rc1.ebuild     | 10 ++++++++--
 app-editors/emacs/emacs-29.0.9999-r1.ebuild | 10 ++++++++--
 app-editors/emacs/emacs-30.0.9999.ebuild    | 10 ++++++++--
 8 files changed, 65 insertions(+), 17 deletions(-)

diff --git a/app-editors/emacs/emacs-18.59-r15.ebuild 
b/app-editors/emacs/emacs-18.59-r15.ebuild
index 6822620a67f8..2c48395d4314 100644
--- a/app-editors/emacs/emacs-18.59-r15.ebuild
+++ b/app-editors/emacs/emacs-18.59-r15.ebuild
@@ -1,4 +1,4 @@
-# Copyright 1999-2022 Gentoo Authors
+# Copyright 1999-2023 Gentoo Authors
 # Distributed under the terms of the GNU General Public License v2
 
 EAPI=8
@@ -147,8 +147,14 @@ src_install() {
 
 pkg_preinst() {
        # move Info dir file to correct name
-       if [[ -d "${D}"/usr/share/info ]]; then
-               mv "${D}"/usr/share/info/emacs-${SLOT}/dir{.orig,} || die
+       local infodir="${ED}/usr/share/info/emacs-${SLOT}"
+       if [[ -f ${infodir}/dir.orig ]]; then
+               mv "${infodir}"/dir{.orig,} || die
+       elif [[ -d ${infodir} ]]; then
+               # this can happen when preinst is run twice, e.g. when
+               # installing a binpkg that was created with quickpkg #899648
+               ewarn "Unexpected \"dir\" file in ${infodir} - preinst run 
twice?"
+               [[ ${MERGE_TYPE} == binary && -f ${infodir}/dir ]] || die
        fi
 }
 

diff --git a/app-editors/emacs/emacs-25.3-r16.ebuild 
b/app-editors/emacs/emacs-25.3-r16.ebuild
index 1e7a6cd64d8b..723f51cc2df7 100644
--- a/app-editors/emacs/emacs-25.3-r16.ebuild
+++ b/app-editors/emacs/emacs-25.3-r16.ebuild
@@ -331,8 +331,14 @@ src_install() {
 
 pkg_preinst() {
        # move Info dir file to correct name
-       if [[ -d ${ED}/usr/share/info ]]; then
-               mv "${ED}"/usr/share/info/${EMACS_SUFFIX}/dir{.orig,} || die
+       local infodir="${ED}/usr/share/info/${EMACS_SUFFIX}"
+       if [[ -f ${infodir}/dir.orig ]]; then
+               mv "${infodir}"/dir{.orig,} || die
+       elif [[ -d ${infodir} ]]; then
+               # this can happen when preinst is run twice, e.g. when
+               # installing a binpkg that was created with quickpkg #899648
+               ewarn "Unexpected \"dir\" file in ${infodir} - preinst run 
twice?"
+               [[ ${MERGE_TYPE} == binary && -f ${infodir}/dir ]] || die
        fi
 }
 

diff --git a/app-editors/emacs/emacs-26.3-r13.ebuild 
b/app-editors/emacs/emacs-26.3-r13.ebuild
index 10482650084c..40ac01cbd10b 100644
--- a/app-editors/emacs/emacs-26.3-r13.ebuild
+++ b/app-editors/emacs/emacs-26.3-r13.ebuild
@@ -351,8 +351,14 @@ src_install() {
 
 pkg_preinst() {
        # move Info dir file to correct name
-       if [[ -d ${ED}/usr/share/info ]]; then
-               mv "${ED}"/usr/share/info/${EMACS_SUFFIX}/dir{.orig,} || die
+       local infodir="${ED}/usr/share/info/${EMACS_SUFFIX}"
+       if [[ -f ${infodir}/dir.orig ]]; then
+               mv "${infodir}"/dir{.orig,} || die
+       elif [[ -d ${infodir} ]]; then
+               # this can happen when preinst is run twice, e.g. when
+               # installing a binpkg that was created with quickpkg #899648
+               ewarn "Unexpected \"dir\" file in ${infodir} - preinst run 
twice?"
+               [[ ${MERGE_TYPE} == binary && -f ${infodir}/dir ]] || die
        fi
 }
 

diff --git a/app-editors/emacs/emacs-27.2-r11.ebuild 
b/app-editors/emacs/emacs-27.2-r11.ebuild
index bbe0dd17f23d..b11a6adb956f 100644
--- a/app-editors/emacs/emacs-27.2-r11.ebuild
+++ b/app-editors/emacs/emacs-27.2-r11.ebuild
@@ -414,8 +414,14 @@ src_install() {
 
 pkg_preinst() {
        # move Info dir file to correct name
-       if [[ -d ${ED}/usr/share/info ]]; then
-               mv "${ED}"/usr/share/info/${EMACS_SUFFIX}/dir{.orig,} || die
+       local infodir="${ED}/usr/share/info/${EMACS_SUFFIX}"
+       if [[ -f ${infodir}/dir.orig ]]; then
+               mv "${infodir}"/dir{.orig,} || die
+       elif [[ -d ${infodir} ]]; then
+               # this can happen when preinst is run twice, e.g. when
+               # installing a binpkg that was created with quickpkg #899648
+               ewarn "Unexpected \"dir\" file in ${infodir} - preinst run 
twice?"
+               [[ ${MERGE_TYPE} == binary && -f ${infodir}/dir ]] || die
        fi
 }
 

diff --git a/app-editors/emacs/emacs-28.2-r6.ebuild 
b/app-editors/emacs/emacs-28.2-r6.ebuild
index 31ef2328e4a8..8d359a6ae141 100644
--- a/app-editors/emacs/emacs-28.2-r6.ebuild
+++ b/app-editors/emacs/emacs-28.2-r6.ebuild
@@ -493,8 +493,14 @@ src_install() {
 
 pkg_preinst() {
        # move Info dir file to correct name
-       if [[ -d ${ED}/usr/share/info ]]; then
-               mv "${ED}"/usr/share/info/${EMACS_SUFFIX}/dir{.orig,} || die
+       local infodir="${ED}/usr/share/info/${EMACS_SUFFIX}"
+       if [[ -f ${infodir}/dir.orig ]]; then
+               mv "${infodir}"/dir{.orig,} || die
+       elif [[ -d ${infodir} ]]; then
+               # this can happen when preinst is run twice, e.g. when
+               # installing a binpkg that was created with quickpkg #899648
+               ewarn "Unexpected \"dir\" file in ${infodir} - preinst run 
twice?"
+               [[ ${MERGE_TYPE} == binary && -f ${infodir}/dir ]] || die
        fi
 }
 

diff --git a/app-editors/emacs/emacs-28.3_rc1.ebuild 
b/app-editors/emacs/emacs-28.3_rc1.ebuild
index 0a3be1463dbd..d38c159725f9 100644
--- a/app-editors/emacs/emacs-28.3_rc1.ebuild
+++ b/app-editors/emacs/emacs-28.3_rc1.ebuild
@@ -510,8 +510,14 @@ src_install() {
 
 pkg_preinst() {
        # move Info dir file to correct name
-       if [[ -d ${ED}/usr/share/info ]]; then
-               mv "${ED}"/usr/share/info/${EMACS_SUFFIX}/dir{.orig,} || die
+       local infodir="${ED}/usr/share/info/${EMACS_SUFFIX}"
+       if [[ -f ${infodir}/dir.orig ]]; then
+               mv "${infodir}"/dir{.orig,} || die
+       elif [[ -d ${infodir} ]]; then
+               # this can happen when preinst is run twice, e.g. when
+               # installing a binpkg that was created with quickpkg #899648
+               ewarn "Unexpected \"dir\" file in ${infodir} - preinst run 
twice?"
+               [[ ${MERGE_TYPE} == binary && -f ${infodir}/dir ]] || die
        fi
 }
 

diff --git a/app-editors/emacs/emacs-29.0.9999-r1.ebuild 
b/app-editors/emacs/emacs-29.0.9999-r1.ebuild
index b06274d3a565..198c02ddd567 100644
--- a/app-editors/emacs/emacs-29.0.9999-r1.ebuild
+++ b/app-editors/emacs/emacs-29.0.9999-r1.ebuild
@@ -540,8 +540,14 @@ src_install() {
 
 pkg_preinst() {
        # move Info dir file to correct name
-       if [[ -d ${ED}/usr/share/info ]]; then
-               mv "${ED}"/usr/share/info/${EMACS_SUFFIX}/dir{.orig,} || die
+       local infodir="${ED}/usr/share/info/${EMACS_SUFFIX}"
+       if [[ -f ${infodir}/dir.orig ]]; then
+               mv "${infodir}"/dir{.orig,} || die
+       elif [[ -d ${infodir} ]]; then
+               # this can happen when preinst is run twice, e.g. when
+               # installing a binpkg that was created with quickpkg #899648
+               ewarn "Unexpected \"dir\" file in ${infodir} - preinst run 
twice?"
+               [[ ${MERGE_TYPE} == binary && -f ${infodir}/dir ]] || die
        fi
 }
 

diff --git a/app-editors/emacs/emacs-30.0.9999.ebuild 
b/app-editors/emacs/emacs-30.0.9999.ebuild
index 0a03ca0c6d54..a1fdc765f4c4 100644
--- a/app-editors/emacs/emacs-30.0.9999.ebuild
+++ b/app-editors/emacs/emacs-30.0.9999.ebuild
@@ -540,8 +540,14 @@ src_install() {
 
 pkg_preinst() {
        # move Info dir file to correct name
-       if [[ -d ${ED}/usr/share/info ]]; then
-               mv "${ED}"/usr/share/info/${EMACS_SUFFIX}/dir{.orig,} || die
+       local infodir="${ED}/usr/share/info/${EMACS_SUFFIX}"
+       if [[ -f ${infodir}/dir.orig ]]; then
+               mv "${infodir}"/dir{.orig,} || die
+       elif [[ -d ${infodir} ]]; then
+               # this can happen when preinst is run twice, e.g. when
+               # installing a binpkg that was created with quickpkg #899648
+               ewarn "Unexpected \"dir\" file in ${infodir} - preinst run 
twice?"
+               [[ ${MERGE_TYPE} == binary && -f ${infodir}/dir ]] || die
        fi
 }
 

Reply via email to