From 2a90fb5ba517f8d2515a69226a8f6a0d99ccaf50 Mon Sep 17 00:00:00 2001 From: yenienserrano Date: Mon, 4 Dec 2023 13:25:37 +0100 Subject: [PATCH] Update script build all packages --- .../build-packages/base/generate_base.sh | 4 ++- dev-tools/build-packages/build-packages.sh | 28 +++++++++++++++---- dev-tools/build-packages/deb/launcher.sh | 4 ++- dev-tools/build-packages/rpm/launcher.sh | 5 +++- 4 files changed, 32 insertions(+), 9 deletions(-) diff --git a/dev-tools/build-packages/base/generate_base.sh b/dev-tools/build-packages/base/generate_base.sh index 2ea2ddbed2ba..f89ce2035c53 100755 --- a/dev-tools/build-packages/base/generate_base.sh +++ b/dev-tools/build-packages/base/generate_base.sh @@ -157,7 +157,9 @@ build() { echo Compressing the package... echo cd .. - mkdir -p $out_dir + if [ ! -d "$out_dir" ]; then + mkdir -p $out_dir + fi tar -czvf $out_dir/$working_dir.tar.gz $working_dir echo diff --git a/dev-tools/build-packages/build-packages.sh b/dev-tools/build-packages/build-packages.sh index 4c9f3a9410b3..e7733f0765e0 100644 --- a/dev-tools/build-packages/build-packages.sh +++ b/dev-tools/build-packages/build-packages.sh @@ -16,12 +16,12 @@ current_path="$( cd $(dirname $0) ; pwd -P )" build_tar() { echo "Building tar package..." cd ./base - # bash ./generate_base.sh -a $app -b $base -s $security -v $version -r $revision + bash ./generate_base.sh -a $app -b $base -s $security -v $version -r $revision - name_package_tar = $(ls ./output) + name_package_tar=$(ls ./output) if [ "$tar" == "yes" ]; then - echo $(pwd) + echo "Moving tar package to $output" mv $current_path/base/output/$name_package_tar $output/$name_package_tar fi cd ../ @@ -30,14 +30,19 @@ build_tar() { build_deb() { echo "Building deb package..." cd ./deb - # bash ./launcher.sh -v $version -r $revision -p file://$current_path/base/output/$name_package_tar + bash ./launcher.sh -v $version -r $revision -p file://$output/$name_package_tar + name_package_tar=$(ls ./output) + echo "Moving deb package to $output/deb" + mv $current_path/deb/output $output/deb cd ../ } build_rpm() { echo "Building rpm package..." cd ./rpm - # bash ./launcher.sh -v $version -r $revision -p file://$current_path/base/output/$name_package_tar + bash ./launcher.sh -v $version -r $revision -p file://$output/$name_package_tar + echo "Moving rpm package to $output/rpm" + mv $current_path/rpm/output $output/rpm cd ../ } @@ -46,7 +51,7 @@ build() { name_package_tar="wazuh-dashboard-$version-$revision-linux-x64.tar.gz" if [ ! -d "$output" ]; then - mkdir -p $output + mkdir $output fi if [ "$all_platforms" == "yes" ]; then @@ -67,6 +72,11 @@ build() { echo "Building rpm package..." build_rpm fi + + if [ "$tar" == "no" ]; then + echo "Removing tar package..." + rm -r $current_path/base/output + fi } help() { @@ -164,6 +174,12 @@ main() { done if [ -z "$app" ] | [ -z "$base" ] | [ -z "$security" ] | [ -z "$version" ]; then + echo "You must specify the app, base, security and version." + help 1 + fi + + if [ "$all_platforms" == "no" ] && [ "$deb" == "no" ] && [ "$rpm" == "no" ] && [ "$tar" == "no" ]; then + echo "You must specify at least one package to build." help 1 fi diff --git a/dev-tools/build-packages/deb/launcher.sh b/dev-tools/build-packages/deb/launcher.sh index 8e75a5e25a79..090bcb96a71b 100755 --- a/dev-tools/build-packages/deb/launcher.sh +++ b/dev-tools/build-packages/deb/launcher.sh @@ -96,7 +96,9 @@ build_deb() { fi # Build the Debian package with a Docker container - mkdir -p $out_dir + if [ ! -d "$out_dir" ]; then + mkdir -p $out_dir + fi 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 \ diff --git a/dev-tools/build-packages/rpm/launcher.sh b/dev-tools/build-packages/rpm/launcher.sh index f5555e4bd5a5..ca9a67d4c1c4 100755 --- a/dev-tools/build-packages/rpm/launcher.sh +++ b/dev-tools/build-packages/rpm/launcher.sh @@ -98,7 +98,10 @@ build_rpm() { fi # Build the RPM package with a Docker container - mkdir -p $out_dir + + if [ ! -d "$out_dir" ]; then + mkdir -p $out_dir + fi 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 \