File loki_setup-overwrite.diff of Package loki_setup
Index: loki_setup/install.c
===================================================================
--- loki_setup.orig/install.c
+++ loki_setup/install.c
@@ -346,21 +346,29 @@ const char *GetProductCDKey(install_info
return (char *)xmlGetProp(XML_ROOT(info->config), BAD_CAST "cdkey");
}
-int GetProductPromptOverwrite(install_info *info)
+// 0 = don't overwrite, 1 = overwrite, 2 = ask user
+int GetProductOverwriteFiles(install_info *info)
{
- int ret = 1; /* yes */
+ int ret = 2; /* prompt */
int needfree = 0;
char *str = NULL;
- if(getenv("SETUP_NOPROMPTOVERWRITE")) {
- str = getenv("SETUP_NOPROMPTOVERWRITE");
+ if(getenv("SETUP_OVERWRITEFILES")) {
+ str = getenv("SETUP_OVERWRITEFILES");
}
else {
- str = (char *)xmlGetProp(XML_ROOT(info->config), BAD_CAST "nopromptoverwrite");
+ str = (char *)xmlGetProp(XML_ROOT(info->config), BAD_CAST "overwritefiles");
needfree = 1;
}
- if ( str && (!strcasecmp(str, "yes") || !strcasecmp(str, "true"))) {
+ if (!str) {
+ ret = 2; /* prompt */
+ }
+ else if ((!strcasecmp(str, "yes") || !strcasecmp(str, "true"))) {
+ ret = 1; /* yes */
+ }
+ else if ((!strcasecmp(str, "no") || !strcasecmp(str, "false"))) {
ret = 0; /* no */
}
+
if(needfree)
xmlFree(str);
return ret;
Index: loki_setup/install.h
===================================================================
--- loki_setup.orig/install.h
+++ loki_setup/install.h
@@ -270,8 +270,10 @@ extern int GetProductHasManPages
extern int GetProductUseFork(install_info *info);
extern const char *GetProductCDKey(install_info *info);
extern const char *GetProductPostInstallMsg(install_info *info);
-/** whether the user should be prompted when files already exist */
-extern int GetProductPromptOverwrite(install_info *info);
+/** whether to overwrite already existing files
+ * @returns 0 = don't overwrite, 1 = overwrite, 2 = ask user
+ */
+extern int GetProductOverwriteFiles(install_info *info);
/** whether the product should reinstall with _zero_ user interaction. */
int GetProductReinstallFast(install_info *info);
Index: loki_setup/file.c
===================================================================
--- loki_setup.orig/file.c
+++ loki_setup/file.c
@@ -130,16 +130,19 @@ stream *file_fdopen(install_info *info,
return streamp;
}
-static int prompt_overwrite = -1;
+static int overwrite = -1;
stream *file_open_install(install_info *info, const char *path, const char *mode)
{
if ( file_exists(path) ) {
- if( prompt_overwrite == -1 ) {
- prompt_overwrite = GetProductPromptOverwrite(info);
+ if( overwrite == -1 ) {
+ overwrite = GetProductOverwriteFiles(info);
}
- if ( prompt_overwrite ) {
+ if ( overwrite == 0 ) {
+ return NULL;
+ }
+ else if ( overwrite == 2 ) {
char msg[128];
snprintf(msg, sizeof(msg), _("File '%25s' already exists, overwrite?"), loki_basename(path));
if ( UI.prompt(msg, RESPONSE_YES) != RESPONSE_YES ) {
Index: loki_setup/README.xml
===================================================================
--- loki_setup.orig/README.xml
+++ loki_setup/README.xml
@@ -207,8 +207,8 @@ There are several optional attributes of
manpages If set to "yes", then the user will be prompted for the install pages installation path.
Should be used when using the MANPAGE element described below.
- nopromptoverwrite If set to 'yes' existing files will be overwritten without
- prompting the user. This was the default before setup 1.6.4
+ overwritefiles If set to 'yes' existing files will be overwritten without
+ prompting the user. This was the default before setup 1.6.4
nomenuitems If set to 'yes', menu items for Gnome/KDE/etc will not be installed, and the
user will not be prompted about installing them.