diff options
author | Viorel Munteanu <ceamac@gentoo.org> | 2024-10-08 08:11:20 +0300 |
---|---|---|
committer | Viorel Munteanu <ceamac@gentoo.org> | 2024-10-08 08:12:06 +0300 |
commit | df5d68b75f3e03ed0463d73665b6cc0bf6614c0a (patch) | |
tree | 0a3729a968c82e8b1d796d07369820b732ef4f7f /app-misc | |
parent | dev-qt/qtwebview: add 6.8.0 (diff) | |
download | gentoo-df5d68b75f3e03ed0463d73665b6cc0bf6614c0a.tar.gz gentoo-df5d68b75f3e03ed0463d73665b6cc0bf6614c0a.tar.bz2 gentoo-df5d68b75f3e03ed0463d73665b6cc0bf6614c0a.zip |
app-misc/mc: fix exiting to latest working directory
This was a regression in 4.8.32, fixed after the release.
Closes: https://bugs.gentoo.org/941099
Signed-off-by: Viorel Munteanu <ceamac@gentoo.org>
Diffstat (limited to 'app-misc')
-rw-r--r-- | app-misc/mc/files/mc-4.8.32-fix-chdir.patch | 129 | ||||
-rw-r--r-- | app-misc/mc/mc-4.8.32-r1.ebuild | 140 |
2 files changed, 269 insertions, 0 deletions
diff --git a/app-misc/mc/files/mc-4.8.32-fix-chdir.patch b/app-misc/mc/files/mc-4.8.32-fix-chdir.patch new file mode 100644 index 000000000000..9b74da211f73 --- /dev/null +++ b/app-misc/mc/files/mc-4.8.32-fix-chdir.patch @@ -0,0 +1,129 @@ +https://github.com/MidnightCommander/mc/commit/7a3a763f0ea07a825ca2af4642e31f9e358a9fd0 +https://bugs.gentoo.org/941099 +https://midnight-commander.org/ticket/4535 + +From e2d96fa802abebf888dcc2cc938cfd06abca8eb0 Mon Sep 17 00:00:00 2001 +From: "Yury V. Zaytsev" <yury@shurup.com> +Date: Sun, 1 Sep 2024 12:01:37 +0200 +Subject: [PATCH 1/3] Ticket #4575: adjust mc-wrapper to fit changes in #4535. + +Signed-off-by: Yury V. Zaytsev <yury@shurup.com> +--- a/contrib/mc-wrapper.csh.in ++++ b/contrib/mc-wrapper.csh.in +@@ -1,9 +1,9 @@ +-set MC_USER=`whoami` +- +-if ($?TMPDIR) then +- setenv MC_PWD_FILE $TMPDIR/mc-$MC_USER/mc.pwd.$$ ++if ($?MC_TMPDIR) then ++ setenv MC_PWD_FILE "`mktemp '$MC_TMPDIR/mc.pwd.XXXXXX'`" ++else if ($?TMPDIR) then ++ setenv MC_PWD_FILE "`mktemp '$TMPDIR/mc.pwd.XXXXXX'`" + else +- setenv MC_PWD_FILE /tmp/mc-$MC_USER/mc.pwd.$$ ++ setenv MC_PWD_FILE "`mktemp '/tmp/mc.pwd.XXXXXX'`" + endif + + @bindir@/mc -P "$MC_PWD_FILE" $* +@@ -11,11 +11,10 @@ endif + if (-r "$MC_PWD_FILE") then + setenv MC_PWD "`cat '$MC_PWD_FILE'`" + if ("$MC_PWD" != "$cwd" && -d "$MC_PWD") then +- cd "$MC_PWD" ++ cd "$MC_PWD" || true + endif + unsetenv MC_PWD + endif + + rm -f "$MC_PWD_FILE" + unsetenv MC_PWD_FILE +-unsetenv MC_USER +--- a/contrib/mc-wrapper.sh.in ++++ b/contrib/mc-wrapper.sh.in +@@ -1,15 +1,20 @@ +-MC_USER=`whoami` +-MC_PWD_FILE="${TMPDIR-/tmp}/mc-$MC_USER/mc.pwd.$$" ++if test -n "$MC_TMPDIR"; then ++ MC_PWD_FILE="`mktemp "${MC_TMPDIR}/mc.pwd.XXXXXX"`" ++elif test -n "$TMPDIR"; then ++ MC_PWD_FILE="`mktemp "${TMPDIR}/mc.pwd.XXXXXX"`" ++else ++ MC_PWD_FILE="`mktemp "/tmp/mc.pwd.XXXXXX"`" ++fi ++ + @bindir@/mc -P "$MC_PWD_FILE" "$@" + + if test -r "$MC_PWD_FILE"; then + MC_PWD="`cat "$MC_PWD_FILE"`" + if test -n "$MC_PWD" && test "$MC_PWD" != "$PWD" && test -d "$MC_PWD"; then +- cd "$MC_PWD" ++ cd "$MC_PWD" || true + fi + unset MC_PWD + fi + + rm -f "$MC_PWD_FILE" + unset MC_PWD_FILE +-unset MC_USER + +From a3ce493ae25f35f29919332d4794c17109f56901 Mon Sep 17 00:00:00 2001 +From: "Yury V. Zaytsev" <yury@shurup.com> +Date: Thu, 29 Aug 2024 12:13:40 +0200 +Subject: [PATCH 2/3] vfs: fix tempdir path building to account for trailing + slash on macOS + +Signed-off-by: Yury V. Zaytsev <yury@shurup.com> +--- a/lib/vfs/interface.c ++++ b/lib/vfs/interface.c +@@ -775,6 +775,7 @@ mc_tmpdir (void) + static const char *tmpdir = NULL; + const char *sys_tmp; + struct stat st; ++ gchar *template; + + /* Check if already correctly initialized */ + if (tmpdir != NULL && lstat (tmpdir, &st) == 0 && S_ISDIR (st.st_mode) && +@@ -789,7 +790,10 @@ mc_tmpdir (void) + sys_tmp = TMPDIR_DEFAULT; + } + +- g_snprintf (buffer, sizeof (buffer), "%s/mc-XXXXXX", sys_tmp); ++ template = g_build_filename (sys_tmp, "mc-XXXXXX", (char *) NULL); ++ g_strlcpy (buffer, template, sizeof (buffer)); ++ g_free (template); ++ + tmpdir = g_mkdtemp (buffer); + if (tmpdir != NULL) + g_setenv ("MC_TMPDIR", tmpdir, TRUE); +--- a/tests/lib/vfs/tempdir.c ++++ b/tests/lib/vfs/tempdir.c +@@ -45,6 +45,9 @@ + static void + setup (void) + { ++ /* Ensure that tests behave consistently irrespectively of the environment */ ++ g_unsetenv ("MC_TMPDIR"); ++ + str_init_strings (NULL); + + vfs_init (); + +From d081bc68aa6ad3ded515ea490118b0a38a1ec204 Mon Sep 17 00:00:00 2001 +From: "Yury V. Zaytsev" <yury@shurup.com> +Date: Mon, 2 Sep 2024 16:51:17 +0200 +Subject: [PATCH 3/3] main: remove `O_EXCL` for wd-file since creation is now + managed by wrapper + +Signed-off-by: Yury V. Zaytsev <yury@shurup.com> +--- a/src/main.c ++++ b/src/main.c +@@ -509,8 +509,7 @@ main (int argc, char *argv[]) + { + int last_wd_fd; + +- last_wd_fd = open (mc_args__last_wd_file, O_WRONLY | O_CREAT | O_TRUNC | O_EXCL, +- S_IRUSR | S_IWUSR); ++ last_wd_fd = open (mc_args__last_wd_file, O_WRONLY | O_CREAT | O_TRUNC, S_IRUSR | S_IWUSR); + if (last_wd_fd != -1) + { + ssize_t ret1; diff --git a/app-misc/mc/mc-4.8.32-r1.ebuild b/app-misc/mc/mc-4.8.32-r1.ebuild new file mode 100644 index 000000000000..4be0fffe14c4 --- /dev/null +++ b/app-misc/mc/mc-4.8.32-r1.ebuild @@ -0,0 +1,140 @@ +# Copyright 1999-2024 Gentoo Authors +# Distributed under the terms of the GNU General Public License v2 + +EAPI=8 + +inherit autotools flag-o-matic + +MY_P="${P/_/-}" +DESCRIPTION="GNU Midnight Commander is a text based file manager" +HOMEPAGE="https://midnight-commander.org" +SRC_URI="http://ftp.midnight-commander.org/${MY_P}.tar.xz" +S="${WORKDIR}/${MY_P}" + +LICENSE="GPL-3" +SLOT="0" +KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~mips ~ppc ~ppc64 ~riscv ~s390 ~sparc ~x86 ~amd64-linux ~ppc-macos ~x64-macos" +IUSE="+edit gpm nls sftp +slang spell test unicode X" + +REQUIRED_USE="spell? ( edit )" +RESTRICT="!test? ( test )" + +COMMON_DEPEND=" + >=dev-libs/glib-2.30.0:2 + gpm? ( sys-libs/gpm ) + kernel_linux? ( sys-fs/e2fsprogs[tools(+)] ) + sftp? ( net-libs/libssh2 ) + slang? ( >=sys-libs/slang-2 ) + !slang? ( sys-libs/ncurses:=[unicode(+)?] ) + spell? ( app-text/aspell ) + X? ( + x11-libs/libICE + x11-libs/libSM + x11-libs/libX11 + ) +" + +DEPEND=" + ${COMMON_DEPEND} + X? ( x11-base/xorg-proto ) +" + +RDEPEND=" + ${DEPEND} + spell? ( app-dicts/aspell-en ) +" + +BDEPEND=" + app-arch/xz-utils + virtual/pkgconfig + nls? ( sys-devel/gettext ) + test? ( dev-libs/check ) +" + +PATCHES=( + "${FILESDIR}"/${PN}-4.8.26-ncurses-mouse.patch + "${FILESDIR}"/${PN}-4.8.29-gentoo-tools.patch + "${FILESDIR}"/${P}-fix-chdir.patch +) + +# This is a check for AIX, on Linux mc uses statvfs() regardless of whether +# LFS64 interfaces are available in libc or not. +QA_CONFIG_IMPL_DECL_SKIP=( + statvfs64 +) + +src_prepare() { + default + + # Bug #906194, #922483 + if use elibc_musl; then + eapply "${FILESDIR}"/${PN}-4.8.30-musl-tests.patch + eapply "${FILESDIR}"/${PN}-4.8.31-musl-tests.patch + fi + + eautoreconf +} + +src_configure() { + [[ ${CHOST} == *-solaris* ]] && append-ldflags "-lnsl -lsocket" + + local myeconfargs=( + --enable-charset + --enable-vfs + --with-screen=$(usex slang 'slang' "ncurses$(usex unicode 'w' '')") + $(use_enable kernel_linux vfs-undelfs) + # Today mclib does not expose any headers and is linked to + # single 'mc' binary. Thus there is no advantage of having + # a library. Let's avoid shared library altogether + # as it also conflicts with sci-libs/mc: bug #685938 + --disable-mclib + $(use_enable nls) + $(use_enable sftp vfs-sftp) + $(use_enable spell aspell) + $(use_enable test tests) + $(use_with gpm gpm-mouse) + $(use_with X x) + $(use_with edit internal-edit) + ) + econf "${myeconfargs[@]}" +} + +src_test() { + # Bug #759466 + if [[ ${EUID} == 0 ]] ; then + ewarn "You are emerging ${PN} as root with 'userpriv' disabled." + ewarn "Expect some test failures, or emerge with 'FEATURES=userpriv'!" + fi + + # CK_FORK=no to avoid using fork() in check library + # as mc mocks fork() itself: bug #644462. + # + # VERBOSE=1 to make test failures contain detailed + # information. + CK_FORK=no emake check VERBOSE=1 +} + +src_install() { + emake DESTDIR="${D}" install + dodoc AUTHORS NEWS README + + # fix bug #334383 + if use kernel_linux && [[ ${EUID} == 0 ]] ; then + fowners root:tty /usr/libexec/mc/cons.saver + fperms g+s /usr/libexec/mc/cons.saver + fi +} + +pkg_postinst() { + elog "${PN} extension scripts depend on many external tools, install them as needed" + elog + if use spell && ! has_version app-dicts/aspell-en ; then + elog "'spell' USE flag is enabled however app-dicts/aspell-en is not installed." + elog "You should manually set 'spell_language' in the Misc section of ~/.config/mc/ini" + elog "It has to be set to one of your installed aspell dictionaries or 'NONE'" + elog + fi + elog "To enable exiting to latest working directory," + elog "put this into your ~/.bashrc:" + elog ". ${EPREFIX}/usr/libexec/mc/mc.sh" +} |