aboutsummaryrefslogtreecommitdiff
path: root/nuttx/tools
diff options
context:
space:
mode:
Diffstat (limited to 'nuttx/tools')
-rw-r--r--nuttx/tools/configure.c22
-rwxr-xr-xnuttx/tools/configure.sh21
2 files changed, 14 insertions, 29 deletions
diff --git a/nuttx/tools/configure.c b/nuttx/tools/configure.c
index f189f5b98..eb8268f19 100644
--- a/nuttx/tools/configure.c
+++ b/nuttx/tools/configure.c
@@ -549,7 +549,7 @@ static void check_configuration(void)
}
}
-static void copy_file(const char *srcpath, const char *destpath)
+static void copy_file(const char *srcpath, const char *destpath, mode_t mode)
{
int nbytesread;
int nbyteswritten;
@@ -567,7 +567,7 @@ static void copy_file(const char *srcpath, const char *destpath)
/* Now open the destination for writing*/
- wrfd = open(destpath, O_WRONLY|O_CREAT|O_TRUNC, 0666);
+ wrfd = open(destpath, O_WRONLY|O_CREAT|O_TRUNC, mode);
if (wrfd < 0)
{
fprintf(stderr, "ERROR: Failed to open %s for writing: %s\n", destpath, strerror(errno));
@@ -638,13 +638,13 @@ static void configure(void)
snprintf(g_buffer, BUFFER_SIZE, "%s%c.config", g_topdir, g_delim);
destconfig = strdup(g_buffer);
debug("configure: Copying from %s to %s\n", g_srcdefconfig, destconfig);
- copy_file(g_srcdefconfig, destconfig);
+ copy_file(g_srcdefconfig, destconfig, 0644);
/* Copy the Make.defs file as Make.defs */
snprintf(g_buffer, BUFFER_SIZE, "%s%cMake.defs", g_topdir, g_delim);
debug("configure: Copying from %s to %s\n", g_srcmakedefs, g_buffer);
- copy_file(g_srcmakedefs, g_buffer);
+ copy_file(g_srcmakedefs, g_buffer, 0644);
/* Copy the setenv.sh file if have one and need one */
@@ -652,15 +652,7 @@ static void configure(void)
{
snprintf(g_buffer, BUFFER_SIZE, "%s%csetenv.sh", g_topdir, g_delim);
debug("configure: Copying from %s to %s\n", g_srcsetenvsh, g_buffer);
- copy_file(g_srcsetenvsh, g_buffer);
-
- /* Mark the file executable */
-
- if (chmod(g_buffer, 0777) != 0)
- {
- fprintf(stderr, "ERROR: Failed to make setenv.sh executable: %s\n", strerror(errno));
- exit(EXIT_FAILURE);
- }
+ copy_file(g_srcsetenvsh, g_buffer, 0755);
}
/* Copy the setenv.bat file if have one and need one */
@@ -669,7 +661,7 @@ static void configure(void)
{
snprintf(g_buffer, BUFFER_SIZE, "%s%csetenv.bat", g_topdir, g_delim);
debug("configure: Copying from %s to %s\n", g_srcsetenvbat, g_buffer);
- copy_file(g_srcsetenvbat, g_buffer);
+ copy_file(g_srcsetenvbat, g_buffer, 0644);
}
/* Copy the appconfig file to ../apps/.config if have one and need one */
@@ -678,7 +670,7 @@ static void configure(void)
{
snprintf(g_buffer, BUFFER_SIZE, "%s%c.config", g_apppath, g_delim);
debug("configure: Copying from %s to %s\n", g_srcappconfig, g_buffer);
- copy_file(g_srcappconfig, g_buffer);
+ copy_file(g_srcappconfig, g_buffer, 0644);
}
/* If we did not use the CONFIG_APPS_DIR that was in the defconfig config file,
diff --git a/nuttx/tools/configure.sh b/nuttx/tools/configure.sh
index ffa997178..89f2e2fbc 100755
--- a/nuttx/tools/configure.sh
+++ b/nuttx/tools/configure.sh
@@ -125,7 +125,6 @@ else
fi
src_config="${configpath}/defconfig"
-tmp_config="${TOPDIR}/.configX"
dest_config="${TOPDIR}/.config"
if [ ! -r "${src_config}" ]; then
@@ -201,7 +200,7 @@ if [ "X${have_setenv}" = "Xy" ]; then
{ echo "Failed to copy ${src_setenv}" ; exit 8 ; }
chmod 755 "${dest_setenv}"
fi
-install "${src_config}" "${tmp_config}" || \
+install "${src_config}" "${dest_config}" || \
{ echo "Failed to copy \"${src_config}\"" ; exit 9 ; }
# If we did not use the CONFIG_APPS_DIR that was in the defconfig config file,
@@ -209,14 +208,14 @@ install "${src_config}" "${tmp_config}" || \
# file
if [ "X${defappdir}" = "Xy" ]; then
- sed -i -e "/^CONFIG_APPS_DIR/d" "${tmp_config}"
- echo "" >> "${tmp_config}"
- echo "# Application configuration" >> "${tmp_config}"
- echo "" >> "${tmp_config}"
+ sed -i -e "/^CONFIG_APPS_DIR/d" "${dest_config}"
+ echo "" >> "${dest_config}"
+ echo "# Application configuration" >> "${dest_config}"
+ echo "" >> "${dest_config}"
if [ "X${winnative}" = "Xy" ]; then
- echo "CONFIG_APPS_DIR=\"$winappdir\"" >> "${tmp_config}"
+ echo "CONFIG_APPS_DIR=\"$winappdir\"" >> "${dest_config}"
else
- echo "CONFIG_APPS_DIR=\"$posappdir\"" >> "${tmp_config}"
+ echo "CONFIG_APPS_DIR=\"$posappdir\"" >> "${dest_config}"
fi
fi
@@ -232,9 +231,3 @@ if [ ! -z "${appdir}" -a "X${newconfig}" != "Xy" ]; then
{ echo "Failed to copy ${configpath}/appconfig" ; exit 10 ; }
fi
fi
-
-# install the final .configX only if it differs from any existing
-# .config file.
-
-install "${tmp_config}" "${dest_config}"
-rm -f "${tmp_config}"