echo -e "${c_error}ERROR: Failed to create directory $c_notice$package$c_error.$c_reset"
fi
- failure=1
+ let failure=1
fi
fi
echo -e "${c_error}ERROR: The build directory $c_notice${path_build}documents$c_error cannot be found or is invalid.$c_reset"
fi
- failure=1
+ let failure=1
fi
if [[ $failure == "" ]] ; then
echo -e "${c_error}ERROR: Failed to copy directory $c_notice${path_build}documents$c_error to $c_notice$package$c_error.$c_reset"
fi
- failure=1
+ let failure=1
fi
fi
echo -e "${c_error}ERROR: Failed to copy directory $c_notice${path_build}licenses$c_error to $c_notice$package$c_error.$c_reset"
fi
- failure=1
+ let failure=1
fi
elif [[ -d ${path_build}../licenses ]] ; then
cp $verbose -R ${path_build}../licenses $package
echo -e "${c_error}ERROR: Failed to copy directory $c_notice${path_build}../licenses$c_error to $c_notice$package$c_error.$c_reset"
fi
- failure=1
+ let failure=1
fi
else
if [[ $verbosity != "quiet" ]] ; then
echo -e "${c_error}ERROR: neither directory $c_notice${path_build}licenses$c_error nor $c_notice${path_build}../licenses$c_error can be found or are invalid.$c_reset"
fi
- failure=1
+ let failure=1
fi
fi
echo -e "${c_error}ERROR: Failed to copy script $c_notice${path_build}bootstrap.sh$c_error to $c_notice$package$c_error.$c_reset"
fi
- failure=1
+ let failure=1
fi
if [[ $failure == "" ]] ; then
echo -e "${c_error}ERROR: Failed to set executable permissions on script $c_notice${package}bootstrap.sh$c_error.$c_reset"
fi
- failure=1
+ let failure=1
fi
fi
echo -e "${c_error}ERROR: Failed to copy script $c_notice${path_build}install.sh$c_error to $c_notice$package$c_error.$c_reset"
fi
- failure=1
+ let failure=1
fi
fi
echo -e "${c_error}ERROR: Failed to set executable permissions on script $c_notice${package}install.sh$c_error.$c_reset"
fi
- failure=1
+ let failure=1
fi
fi
fi
echo -e "${c_error}ERROR: Failed to create directory $c_notice${package}build$c_error.$c_reset"
fi
- failure=1
+ let failure=1
fi
fi
echo -e "${c_error}ERROR: Failed to create directory $c_notice${package}sources$c_error.$c_reset"
fi
- failure=1
+ let failure=1
fi
fi
echo -e "${c_error}ERROR: Failed to create directory $c_notice${package}documents$c_error.$c_reset"
fi
- failure=1
+ let failure=1
fi
fi
echo -e "${c_error}ERROR: Failed to create directory $c_notice${package}licenses$c_error.$c_reset"
fi
- failure=1
+ let failure=1
fi
fi
echo -e "${c_error}ERROR: cannot build dependencies, failed to find $c_notice${directory}/data/build/dependencies$c_error.$c_reset"
fi
- failure=1
+ let failure=1
return
fi
echo -e "${c_error}ERROR: cannot build dependencies for $c_reset$c_notice${name}$c_reset${c_error}, failed to find $c_notice${directory}/data/build/settings$c_error.$c_reset"
fi
- failure=1
+ let failure=1
return
fi
echo -e "${c_error}ERROR: Failed to find dependency data directory $c_notice${path_sources}${level}/${dependency}/data/build/$c_error.$c_reset"
fi
- failure=1
+ let failure=1
return
fi
echo -e "${c_error}ERROR: Failed to find dependency data directory $c_notice${path_sources}${sub_level}/${sub_dependency}/data/build/$c_error.$c_reset"
fi
- failure=1
+ let failure=1
return
fi
echo -e "${c_error}ERROR: Failed to update settings file $c_notice${settings}$c_error.$c_reset"
fi
- failure=1
+ let failure=1
return
fi
echo -e "${c_error}ERROR: Failed to update settings file $c_notice${settings}$c_error.$c_reset"
fi
- failure=1
+ let failure=1
return
fi
fi
echo -e "${c_error}ERROR: Failed to update settings file $c_notice${settings}$c_error.$c_reset"
fi
- failure=1
+ let failure=1
return
fi
echo -e "${c_error}ERROR: Failed to update settings file $c_notice${settings}$c_error.$c_reset"
fi
- failure=1
+ let failure=1
return
fi
fi
echo -e "${c_error}ERROR: Failed to find dependency settings file $c_notice$settings$c_error.$c_reset"
fi
- failure=1
+ let failure=1
return
fi
echo -e "${c_error}ERROR: Failed to find settings file $c_notice$settings$c_error.$c_reset"
fi
- failure=1
+ let failure=1
return
fi
echo -e "${c_error}ERROR: Failed to find settings file $c_notice$settings$c_error.$c_reset"
fi
- failure=1
+ let failure=1
return
fi
echo -e "${c_error}ERROR: Failed to update libraries for settings file $c_notice$settings$c_error.$c_reset"
fi
- failure=1
+ let failure=1
return
fi
echo -e "${c_error}ERROR: Failed to update libraries for settings file $c_notice$settings$c_error.$c_reset"
fi
- failure=1
+ let failure=1
return
fi
echo -e "${c_error}ERROR: Failed to update headers for settings file $c_notice$settings$c_error.$c_reset"
fi
- failure=1
+ let failure=1
return
fi
echo -e "${c_error}ERROR: Failed to update libraries for settings file $c_notice$settings$c_error.$c_reset"
fi
- failure=1
+ let failure=1
return
fi
echo -e "${c_error}ERROR: Failed to update headers for settings file $c_notice$settings$c_error.$c_reset"
fi
- failure=1
+ let failure=1
return
fi
}
echo -e "${c_error}ERROR: Failed to copy the data directory $c_notice${package}sources/data$c_error to $c_notice$package$c_error.$c_reset"
fi
- failure=1
- break
+ let failure=1
+ return $failure
fi
rm $verbose -Rf ${package}sources/data
echo -e "${c_error}ERROR: Failed to remove directory $c_notice${package}sources/data$c_error.$c_reset"
fi
- failure=1
- break
+ let failure=1
+ return $failure
fi
+
+ package_operation_create_config_stubs
fi
if [[ -d ${package}sources/documents/ ]] ; then
echo -e "${c_error}ERROR: Failed to move sources documents directory $c_notice${path_sources}sources/documents$c_error to $c_notice$package$c_error.$c_reset"
fi
- failure=1
- break
+ let failure=1
+ return $failure
fi
rm $verbose -Rf ${package}sources/documents/
echo -e "${c_error}ERROR: Failed to remove sources documents directory $c_notice${path_sources}sources/documents$c_error to $c_notice$package$c_error.$c_reset"
fi
- failure=1
- break
+ let failure=1
+ return $failure
fi
fi
echo -e "${c_error}ERROR: Failed to move sources licenses directory $c_notice${path_sources}sources/licenses$c_error to $c_notice$package$c_error.$c_reset"
fi
- failure=1
- break
+ let failure=1
+ return $failure
fi
rm $verbose -Rf ${package}sources/licenses/
echo -e "${c_error}ERROR: Failed to remove sources licenses directory $c_notice${path_sources}sources/licenses$c_error to $c_notice$package$c_error.$c_reset"
fi
- failure=1
- break
+ let failure=1
+ return $failure
fi
fi
echo -e "${c_error}ERROR: Failed to move sources specifications directory $c_notice${path_sources}sources/specifications$c_error to $c_notice$package$c_error.$c_reset"
fi
- failure=1
- break
+ let failure=1
+ return $failure
fi
rm $verbose -Rf ${package}sources/specifications/
echo -e "${c_error}ERROR: Failed to remove sources specifications directory $c_notice${path_sources}sources/specifications$c_error to $c_notice$package$c_error.$c_reset"
fi
- failure=1
- break
+ let failure=1
+ return $failure
+ fi
+ fi
+}
+
+package_operation_create_config_stubs() {
+ if [[ -f ${package}data/build/settings ]] ; then
+ if [[ $(grep -soP '^\s*\bbuild_language\b\s+c\s*$' ${package}data/build/settings) != "" && ! -f ${package}sources/c/config.c ]] ; then
+ if [[ $(grep -soP '^\s*\bbuild_sources_program\b\s+\S' ${package}data/build/settings) != "" ]] ; then
+ sed -i -E -e "s|^\s*\bbuild_sources_program\s+|&config.c |" ${package}data/build/settings
+
+ if [[ $? -ne 0 ]] ; then
+ if [[ $verbosity != "quiet" ]] ; then
+ echo -e "${c_error}ERROR: Failed to insert the config.c into $c_notice${package}data/build/settings$c_error.$c_reset"
+ fi
+
+ let failure=1
+ return $failure
+ fi
+ elif [[ $(grep -soP '^\s*\bbuild_sources_library\b\s+\S' ${package}data/build/settings) != "" ]] ; then
+ sed -i -E -e "s|^\s*\bbuild_sources_library\s+|&config.c |" ${package}data/build/settings
+
+ if [[ $? -ne 0 ]] ; then
+ if [[ $verbosity != "quiet" ]] ; then
+ echo -e "${c_error}ERROR: Failed to insert the config.c into $c_notice${package}data/build/settings$c_error.$c_reset"
+ fi
+
+ let failure=1
+ return $failure
+ fi
+ fi
+
+ if [[ $(grep -soP '^\s*\bbuild_sources_program\b\s+\S' ${package}data/build/settings) != "" || $(grep -soP '^\s*\bbuild_sources_library\b\s+\S' ${package}data/build/settings) != "" ]] ; then
+ echo > ${package}sources/c/config.c
+
+ if [[ $? -ne 0 ]] ; then
+ if [[ $verbosity != "quiet" ]] ; then
+ echo -e "${c_error}ERROR: Failed to create the config.c at $c_notice${package}sources/c/config.c$c_error.$c_reset"
+ fi
+
+ let failure=1
+ return $failure
+ fi
+ fi
+ elif [[ $(grep -soP '^\s*\bbuild_language\b\s+c\+\+\s*$' ${package}data/build/settings) != "" && ! -f ${package}sources/c/config.cpp ]] ; then
+ if [[ $(grep -soP '^\s*\bbuild_sources_program\b\s+\S' ${package}data/build/settings) != "" ]] ; then
+ sed -i -E -e "s|^\s*\bbuild_sources_program\s+|&config.cpp |" ${package}data/build/settings
+
+ if [[ $? -ne 0 ]] ; then
+ if [[ $verbosity != "quiet" ]] ; then
+ echo -e "${c_error}ERROR: Failed to insert the config.cpp into $c_notice${package}data/build/settings$c_error.$c_reset"
+ fi
+
+ let failure=1
+ return $failure
+ fi
+ elif [[ $(grep -soP '^\s*\bbuild_sources_library\b\s+\S' ${package}data/build/settings) != "" ]] ; then
+ sed -i -E -e "s|^\s*\bbuild_sources_library\s+|&config.cpp |" ${package}data/build/settings
+
+ if [[ $? -ne 0 ]] ; then
+ if [[ $verbosity != "quiet" ]] ; then
+ echo -e "${c_error}ERROR: Failed to insert the config.cpp into $c_notice${package}data/build/settings$c_error.$c_reset"
+ fi
+
+ let failure=1
+ return $failure
+ fi
+ fi
+
+ if [[ $(grep -soP '^\s*\bbuild_sources_program\b\s+\S' ${package}data/build/settings) != "" || $(grep -soP '^\s*\bbuild_sources_library\b\s+\S' ${package}data/build/settings) != "" ]] ; then
+ echo > ${package}sources/c++/config.cpp
+
+ if [[ $? -ne 0 ]] ; then
+ if [[ $verbosity != "quiet" ]] ; then
+ echo -e "${c_error}ERROR: Failed to create the config.cpp at $c_notice${package}sources/c++/config.cpp$c_error.$c_reset"
+ fi
+
+ let failure=1
+ return $failure
+ fi
+ fi
+ fi
+
+ if [[ ( $(grep -soP '^\s*\bbuild_language\b\s+c\s*$' ${package}data/build/settings) != "" && ! -f ${package}sources/c/config.h ) || ( $(grep -soP '^\s*\bbuild_language\b\s+c\+\+\s*$' ${package}data/build/settings) != "" && ! -f ${package}sources/c++/config.h ) ]] ; then
+ if [[ $(grep -soP '^\s*\bbuild_sources_headers\b\s+\S' ${package}data/build/settings) != "" ]] ; then
+ sed -i -E -e "s|^\s*\bbuild_sources_headers\s+|&config.h |" ${package}data/build/settings
+
+ if [[ $? -ne 0 ]] ; then
+ if [[ $verbosity != "quiet" ]] ; then
+ echo -e "${c_error}ERROR: Failed to insert the config.h into $c_notice${package}data/build/settings$c_error.$c_reset"
+ fi
+
+ let failure=1
+ return $failure
+ fi
+
+ if [[ $(grep -soP '^\s*\bbuild_language\b\s+c\s*$' ${package}data/build/settings) != "" ]] ; then
+ echo > ${package}sources/c/config.h
+
+ if [[ $? -ne 0 ]] ; then
+ if [[ $verbosity != "quiet" ]] ; then
+ echo -e "${c_error}ERROR: Failed to create the config.cpp at $c_notice${package}sources/c/config.h$c_error.$c_reset"
+ fi
+
+ let failure=1
+ return $failure
+ fi
+ else
+ echo > ${package}sources/c++/config.h
+
+ if [[ $? -ne 0 ]] ; then
+ if [[ $verbosity != "quiet" ]] ; then
+ echo -e "${c_error}ERROR: Failed to create the config.cpp at $c_notice${package}sources/c++/config.h$c_error.$c_reset"
+ fi
+
+ let failure=1
+ return $failure
+ fi
+ fi
+ fi
fi
fi
}
echo -e "${c_error}ERROR: Failed to copy sources directory $c_notice$directory$c_error to $c_notice${package}sources$c_error.$c_reset"
fi
- failure=1
+ let failure=1
break
fi
echo -e "${c_error}ERROR: build settings directory $c_notice$path_build$level$c_error is invalid or missing.$c_reset"
fi
- failure=1
+ let failure=1
break
fi
echo -e "${c_error}ERROR: Failed to create directory $c_notice${package}data$c_error.$c_reset"
fi
- failure=1
+ let failure=1
break
fi
fi
echo -e "${c_error}ERROR: Failed to move the directory $c_notice$path_build$level$c_error as $c_notice$path_build${level}build$c_error.$c_reset"
fi
- failure=1
+ let failure=1
break
fi
echo -e "${c_error}ERROR: Failed to create directory $c_notice${package}sources$c_error.$c_reset"
fi
- failure=1
+ let failure=1
break
fi
fi
echo -e "${c_error}ERROR: Failed to copy files from sources directory $c_notice$directory$c_error to $c_notice${package}sources$c_error.$c_reset"
fi
- failure=1
+ let failure=1
break
fi
echo -e "${c_error}ERROR: Failed to remove directory $c_notice${package}sources/data/build$c_error.$c_reset"
fi
- failure=1
+ let failure=1
break
fi
echo -e "${c_error}ERROR: Failed to create package data directory $c_notice${package}data/$level$c_error.$c_reset"
fi
- failure=1
+ let failure=1
break
fi
fi
echo -e "${c_error}ERROR: Failed to copy files from data directory $c_notice$subdirectory$c_error to $c_notice${package}sources/data$level$c_error.$c_reset"
fi
- failure=1
+ let failure=1
break
fi
echo -e "${c_error}ERROR: Failed to remove directory $c_notice${package}sources/data/build$c_error.$c_reset"
fi
- failure=1
+ let failure=1
break
fi
echo -e "${c_error}ERROR: Failed to copy the data directory $c_notice${package}sources/data/$level/data$c_error to $c_notice${package}data/$level$c_error.$c_reset"
fi
- failure=1
+ let failure=1
break
fi
fi
echo -e "${c_error}ERROR: Failed to remove directory $c_notice${package}sources/data$c_error.$c_reset"
fi
- failure=1
+ let failure=1
break
fi
elif [[ $pathname == "documents" ]] ; then
echo -e "${c_error}ERROR: Failed to copy files from data directory $c_notice$subdirectory$c_error to $c_notice${package}sources/documents$c_error.$c_reset"
fi
- failure=1
+ let failure=1
break
fi
elif [[ $pathname == "licenses" ]] ; then
echo -e "${c_error}ERROR: Failed to copy files from data directory $c_notice$subdirectory$c_error to $c_notice${package}sources/licenses$c_error.$c_reset"
fi
- failure=1
+ let failure=1
break
fi
elif [[ $pathname == "specifications" ]] ; then
echo -e "${c_error}ERROR: Failed to copy files from data directory $c_notice$subdirectory$c_error to $c_notice${package}sources/specifications$c_error.$c_reset"
fi
- failure=1
+ let failure=1
break
fi
else
echo -e "${c_error}ERROR: Failed to create package sources directory $c_notice${package}sources/$pathname/$level$c_error.$c_reset"
fi
- failure=1
+ let failure=1
break
fi
fi
echo -e "${c_error}ERROR: Failed to copy files from sources directory $c_notice$subdirectory$c_error to $c_notice${package}sources/$pathname/$level$c_error.$c_reset"
fi
- failure=1
+ let failure=1
break
fi
fi
fi
done
+ if [[ $failure == "" ]] ; then
+ package_operation_create_config_stubs
+ fi
+
if [[ $failure != "" ]] ; then
package_cleanup
exit $failure
echo -e "${c_error}ERROR: Failed to copy sources directory $c_notice$directory$c_error to $c_notice${package}sources$c_error.$c_reset"
fi
- failure=1
+ let failure=1
break
fi
unset package_dependencies_monolithic
unset package_operation_clean
unset package_operation_copy_package
+ unset package_operation_create_config_stubs
unset package_operation_individual
unset package_operation_level
unset package_operation_monolithic