diff --git a/dev-tools/build-packages/rpm/build_package.sh b/dev-tools/build-packages/rpm/launcher.sh similarity index 87% rename from dev-tools/build-packages/rpm/build_package.sh rename to dev-tools/build-packages/rpm/launcher.sh index 5b6c5d5ae729..ad88bfb2c86b 100755 --- a/dev-tools/build-packages/rpm/build_package.sh +++ b/dev-tools/build-packages/rpm/launcher.sh @@ -8,8 +8,6 @@ # License (version 2) as published by the FSF - Free Software # Foundation. -current_path="$( cd $(dirname $0) ; pwd -P )" -outdir="${current_path}/output" revision="1" architecture="x86_64" build_docker="yes" @@ -19,6 +17,13 @@ build_base="yes" package="" version="" +# Paths +current_path="$( cd $(dirname $0) ; pwd -P )" +config_path=$(realpath $current_path/../config) + +# Folders +out_dir="${current_path}/output" +tmp_dir="${current_path}/tmp" trap ctrl_c INT @@ -28,10 +33,12 @@ clean() { echo "Cleaning temporary files..." echo # Clean the files - rm -rf ${dockerfile_path}/{*.sh,*.tar.gz,wazuh-*,*.tar.gz,*.zip} wazuh-dashboard.tar.gz wazuh-dashboard-base + rm -r $tmp_dir + rm $current_path/docker/x86_64/*.sh if [ $exit_code != 0 ]; then - rm -rf $output/* + rm $out_dir/* + rmdir $out_dir fi exit ${exit_code} @@ -51,6 +58,10 @@ build_rpm() { echo echo "Downloading files..." echo + + mkdir -p $tmp_dir + cd $tmp_dir + if [[ $package =~ $valid_url ]];then if ! curl --output wazuh-dashboard.tar.gz --silent --fail "${package}"; then echo "The given URL or Path to the Wazuh Dashboard package is not working: ${package}" @@ -72,7 +83,7 @@ build_rpm() { rm wazuh-dashboard.tar.gz mv $directory_name wazuh-dashboard-base mkdir -p wazuh-dashboard-base/etc/services - cp ../config/* wazuh-dashboard-base/etc/services + cp $config_path/* wazuh-dashboard-base/etc/services echo ${version} > wazuh-dashboard-base/VERSION tar -czf ./wazuh-dashboard.tar.gz wazuh-dashboard-base @@ -84,15 +95,17 @@ build_rpm() { if [[ ${build_docker} == "yes" ]]; then docker build -t ${container_name} ${dockerfile_path} || return 1 fi + # Build the RPM package with a Docker container - volumes="-v ${outdir}/:/tmp:Z -v ${current_path}/wazuh-dashboard.tar.gz:/opt/wazuh-dashboard.tar.gz" + mkdir -p $out_dir + volumes="-v ${out_dir}/:/tmp:Z -v ${tmp_dir}/wazuh-dashboard.tar.gz:/opt/wazuh-dashboard.tar.gz" docker run -t --rm ${volumes} \ -v ${current_path}/../..:/root:Z \ ${container_name} ${architecture} \ ${revision} ${version} || return 1 - echo "Package $(ls -Art ${outdir} | tail -n 1) added to ${outdir}." + echo "Package $(ls -Art ${out_dir} | tail -n 1) added to ${out_dir}." echo echo DONE! @@ -103,7 +116,7 @@ build_rpm() { build() { build_name="${rpm_x86_builder}" - file_path="${rpm_builder_dockerfile}/${architecture}" + file_path="../${rpm_builder_dockerfile}/${architecture}" build_rpm ${build_name} ${file_path} || return 1 return 0 }