From a5dfc62be80b8606c12ccdfd2628de54fd39701e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Duval?= Date: Sat, 22 Mar 2025 10:29:43 +0100 Subject: [PATCH] freeciv: fix settings directory creation in make_dir() --- .../additional-files/freeciv-postinstall.sh | 21 --- games-strategy/freeciv/freeciv-3.1.4.recipe | 8 +- .../freeciv/patches/freeciv-3.1.4.patchset | 164 +++--------------- 3 files changed, 24 insertions(+), 169 deletions(-) delete mode 100644 games-strategy/freeciv/additional-files/freeciv-postinstall.sh diff --git a/games-strategy/freeciv/additional-files/freeciv-postinstall.sh b/games-strategy/freeciv/additional-files/freeciv-postinstall.sh deleted file mode 100644 index 71b157f8d..000000000 --- a/games-strategy/freeciv/additional-files/freeciv-postinstall.sh +++ /dev/null @@ -1,21 +0,0 @@ -#!/bin/bash - -SETTINGS_PATH=$(finddir B_USER_SETTINGS_DIRECTORY)/freeciv -DATA_PATH=$(finddir B_USER_SETTINGS_DIRECTORY)/freeciv/data -SAVE_PATH=$(finddir B_USER_SETTINGS_DIRECTORY)/freeciv/saves -SCENARIO_PATH=$(finddir B_USER_SETTINGS_DIRECTORY)/freeciv/scenarios - -if [ ! -e $SETTINGS_PATH ]; then - mkdir -p $SETTINGS_PATH -fi -if [ ! -e $DATA_PATH ]; then - mkdir -p $DATA_PATH -fi - -if [ ! -e $SAVE_PATH ]; then - mkdir -p $SAVE_PATH -fi - -if [ ! -e $SCENARIO_PATH ]; then - mkdir -p $SCENARIO_PATH -fi diff --git a/games-strategy/freeciv/freeciv-3.1.4.recipe b/games-strategy/freeciv/freeciv-3.1.4.recipe index 710078623..b993b2f50 100644 --- a/games-strategy/freeciv/freeciv-3.1.4.recipe +++ b/games-strategy/freeciv/freeciv-3.1.4.recipe @@ -11,13 +11,12 @@ you do not need to own Civilization to play Freeciv." HOMEPAGE="http://www.freeciv.org/" COPYRIGHT="1996-2025 The Freeciv Team" LICENSE="GNU GPL v2" -REVISION="1" +REVISION="2" SOURCE_URI="https://downloads.sourceforge.net/sourceforge/freeciv/freeciv-$portVersion.tar.xz" CHECKSUM_SHA256="14999bb903c4507cc287d5a8dd1b89eee623bb41b4e01e0836567fb5f13296e4" PATCHES="freeciv-$portVersion.patchset" ADDITIONAL_FILES=" freeciv.rdef.in - freeciv-postinstall.sh " POST_INSTALL_SCRIPTS="$relativePostInstallDir/freeciv-postinstall.sh" @@ -124,11 +123,6 @@ INSTALL() -e "s|@INTERNAL@|$INTERNAL|" \ $portDir/additional-files/freeciv.rdef.in > freeciv.rdef - # Setup post-install script (to prevent issues with save and config paths) - mkdir -p $postInstallDir - cp $portDir/additional-files/freeciv-postinstall.sh $postInstallDir - chmod +x $postInstallDir/freeciv-postinstall.sh - addResourcesToBinaries freeciv.rdef $appsDir/Freeciv addAppDeskbarSymlink $appsDir/Freeciv diff --git a/games-strategy/freeciv/patches/freeciv-3.1.4.patchset b/games-strategy/freeciv/patches/freeciv-3.1.4.patchset index 982b43eb3..6390eb311 100644 --- a/games-strategy/freeciv/patches/freeciv-3.1.4.patchset +++ b/games-strategy/freeciv/patches/freeciv-3.1.4.patchset @@ -1,149 +1,31 @@ -From a51c9aed56ae66001f0bfbba12d7c203877fe8a3 Mon Sep 17 00:00:00 2001 -From: Peppersawce -Date: Thu, 20 Mar 2025 13:40:40 +0100 -Subject: Fix settings dir usage. +From d779aae5d04834660ea77fd69061c215f1edd900 Mon Sep 17 00:00:00 2001 +From: Jerome Duval +Date: Sat, 22 Mar 2025 10:26:26 +0100 +Subject: Fix make_dir. -diff --git a/client/connectdlg_common.c b/client/connectdlg_common.c -index ce7bb04..4612a55 100644 ---- a/client/connectdlg_common.c -+++ b/client/connectdlg_common.c -@@ -22,6 +22,7 @@ - #include /* SIGTERM and kill */ - #include - #include -+#include - - #ifdef FREECIV_MSWINDOWS - #include -@@ -681,7 +682,7 @@ void send_client_wants_hack(const char *filename) - return; - } - -- if (!make_dir(sdir)) { -+ if (!make_dir(sdir) && errno != EEXIST && errno != EROFS) { - log_error("Couldn't create storage directory for token."); - return; - } -diff --git a/client/options.c b/client/options.c -index 6aafa8b..a7a416d 100644 ---- a/client/options.c -+++ b/client/options.c -@@ -19,6 +19,7 @@ - #include - #include - #include -+#include - - /* utility */ - #include "deprecations.h" -@@ -6138,7 +6139,7 @@ void options_save(option_save_log_callback log_cb) - - if (i > 0) { - dir_name[i] = '\0'; -- if (!make_dir(dir_name)) { -+ if (!make_dir(dir_name) && errno != EEXIST && errno != EROFS) { - log_cb(LOG_ERROR, _("Saving options failed, cannot create directory %s"), - dir_name); - secfile_destroy(sf); -diff --git a/common/mapimg.c b/common/mapimg.c -index 018f2bf..2f3f15a 100644 ---- a/common/mapimg.c -+++ b/common/mapimg.c -@@ -16,6 +16,7 @@ - #endif - - #include -+#include - - #ifdef HAVE_MAPIMG_MAGICKWAND - #ifdef FREECIV_MWAND7 -@@ -2051,7 +2052,7 @@ static bool img_save(const struct img *pimg, const char *mapimgfile, - } - - if (!path_is_absolute(mapimgfile) && path != NULL && path[0] != '\0') { -- if (!make_dir(path)) { -+ if (!make_dir(path) && errno != EEXIST && errno != EROFS) { - MAPIMG_LOG(_("can't create directory")); - return FALSE; - } -diff --git a/server/savegame/savemain.c b/server/savegame/savemain.c -index 6207dc7..3993c37 100644 ---- a/server/savegame/savemain.c -+++ b/server/savegame/savemain.c -@@ -15,6 +15,7 @@ - #include - #endif - -+#include - /* utility */ - #include "log.h" - #include "mem.h" -@@ -259,7 +260,7 @@ void save_game(const char *orig_filename, const char *save_reason, - if (!scenario) { - /* Ensure the saves directory exists. */ - if (srvarg.saves_pathname[0] != '\0' -- && !make_dir(srvarg.saves_pathname)) { -+ && !make_dir(srvarg.saves_pathname) && errno != EEXIST && errno != EROFS) { - log_error(_("Can't create saves directory %s!"), - srvarg.saves_pathname); - /* Don't tell server paths to clients */ -@@ -277,7 +278,7 @@ void save_game(const char *orig_filename, const char *save_reason, - } else { - /* Make sure scenario directory exist */ - if (srvarg.scenarios_pathname[0] != '\0' -- && !make_dir(srvarg.scenarios_pathname)) { -+ && !make_dir(srvarg.scenarios_pathname) && errno != EEXIST && errno != EROFS) { - log_error(_("Can't create scenario saves directory %s!"), - srvarg.scenarios_pathname); - /* Don't tell server paths to clients */ -diff --git a/tools/fcmp/download.c b/tools/fcmp/download.c -index 965f430..d994774 100644 ---- a/tools/fcmp/download.c -+++ b/tools/fcmp/download.c -@@ -348,7 +348,7 @@ static const char *download_modpack_recursive(const char *URL, - free(dest_name_copy); - #endif /* DIR_SEPARATOR_IS_DEFAULT */ - -- if (!make_dir_for_file(local_name)) { -+ if (!make_dir_for_file(local_name) && errno != EEXIST && errno != EROFS) { - secfile_destroy(control); - return _("Cannot create required directories"); - } -diff --git a/tools/fcmp/mpdb.c b/tools/fcmp/mpdb.c -index be88914..e824d6e 100644 ---- a/tools/fcmp/mpdb.c -+++ b/tools/fcmp/mpdb.c -@@ -16,6 +16,7 @@ - #endif - - #include -+#include - - /* utility */ - #include "capability.h" -@@ -144,7 +145,7 @@ void create_mpdb(const char *filename, bool scenario_db) - /* Nothing */ - } - local_name[i] = '\0'; -- if (!make_dir(local_name)) { -+ if (!make_dir(local_name) && errno != EEXIST && errno != EROFS) { - log_error(_("Can't create directory \"%s\" for modpack database."), local_name); - return; - } diff --git a/utility/shared.c b/utility/shared.c -index 3883c1c..1c30e86 100644 +index 3883c1c..7c37018 100644 --- a/utility/shared.c +++ b/utility/shared.c -@@ -1859,7 +1859,7 @@ bool make_dir_for_file(char *filename) - filename[i] = '\0'; - log_debug("Create directory \"%s\"", filename); +@@ -1826,10 +1826,13 @@ bool make_dir(const char *pathname) + } + #endif /* HAVE__MKDIR */ + #else /* FREECIV_MSWINDOWS */ +- if (mkdir(path, 0755) == -1 +- && fc_get_errno() != EEXIST) { +- free(path); +- return FALSE; ++ { ++ struct stat buf; ++ if (stat(path, &buf) != 0 && mkdir(path, 0755) == -1 ++ && fc_get_errno() != EEXIST) { ++ free(path); ++ return FALSE; ++ } + } + #endif /* FREECIV_MSWINDOWS */ -- if (!make_dir(filename)) { -+ if (!make_dir(filename) && errno != EEXIST && errno != EROFS) { - return FALSE; - } - filename[i] = DIR_SEPARATOR_CHAR; -- -2.48.1 +2.45.2