Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The git package should not be a dependency to build the Wazuh unattended scripts #2702

Closed
rauldpm opened this issue Dec 18, 2023 · 1 comment · Fixed by #2708
Closed

The git package should not be a dependency to build the Wazuh unattended scripts #2702

rauldpm opened this issue Dec 18, 2023 · 1 comment · Fixed by #2708
Assignees
Labels
level/task Subtask issue type/bug Bug issue

Comments

@rauldpm
Copy link
Member

rauldpm commented Dec 18, 2023

Wazuh version Install type Action performed Platform
4.7.2 Wazuh unattended scripts builder.sh -

In the issue #2697 an error was detected when building the Wazuh indexer package:

+ /root/unattended_installer/builder.sh -c
/root/unattended_installer/builder.sh: line 19: git: command not found
cat: /VERSION: No such file or directory
+ /root/unattended_installer/builder.sh -p
/root/unattended_installer/builder.sh: line 19: git: command not found
cat: /VERSION: No such file or directory
  • After investigation, it has been found that a call to the git command has been incorporated into the assistant through the PR The source_branch variable is set dynamically #2676, this means that to build any unattended script, the system must have the git package.
readonly source_directory="$(git rev-parse --show-toplevel)"
source_branch=`cat ${source_directory}/VERSION`
  • This should be reevaluated since the build of such scripts should not depend on the said package and can significantly impact the user experience or even the current CI processes
  • Additionally, an unwanted behavior has been found when executing the script from a directory other than the location of the repository or scripts, by not correctly obtaining the parent directory, in the following example, it should return /root and not /
bash-4.4# pwd
/build/rpmbuild/BUILD
bash-4.4# git rev-parse --show-toplevel
/
bash-4.4# ls -l /
total 72
lrwxrwxrwx   1 root root    7 Oct 11  2021 bin -> usr/bin
drwxr-xr-x   4 root root 4096 Dec  1 14:31 boot
drwxr-xr-x   4 root root 4096 Dec 18 23:06 build
drwxr-xr-x   5 root root  360 Dec 18 23:06 dev
drwxr-xr-x   1 root root 4096 Dec 18 23:06 etc
drwxr-xr-x   2 root root 4096 Oct 11  2021 home
lrwxrwxrwx   1 root root    7 Oct 11  2021 lib -> usr/lib
lrwxrwxrwx   1 root root    9 Oct 11  2021 lib64 -> usr/lib64
drwx------   2 root root 4096 Nov 14  2021 lost+found
drwxr-xr-x   2 root root 4096 Oct 11  2021 media
drwxr-xr-x   2 root root 4096 Oct 11  2021 mnt
drwxr-xr-x   2 root root 4096 Oct 11  2021 opt
dr-xr-xr-x 613 root root    0 Dec 18 23:06 proc
drwxrwxr-x  26 1000 1000 4096 Dec 18 23:05 root
drwxr-xr-x   1 root root 4096 Dec  1 14:31 run
lrwxrwxrwx   1 root root    8 Oct 11  2021 sbin -> usr/sbin
drwxr-xr-x   2 root root 4096 Oct 11  2021 srv
dr-xr-xr-x  13 root root    0 Dec 18 23:06 sys
drwxr-xr-x   2 root root 4096 Dec 18 23:06 tmp
drwxr-xr-x   1 root root 4096 Nov 14  2021 usr
drwxr-xr-x   1 root root 4096 Nov 14  2021 var
bash-4.4# ls -l /root/
total 120
-rw-rw-r-- 1 1000 1000  5406 Dec 18 20:06 CHANGELOG.md
-rw-rw-r-- 1 1000 1000 18092 Dec 18 20:06 LICENSE
-rw-rw-r-- 1 1000 1000  2627 Dec 18 20:06 README.md
-rw-rw-r-- 1 1000 1000     6 Dec 18 20:06 VERSION
drwxrwxr-x 3 1000 1000  4096 Dec 18 20:06 aix
drwxrwxr-x 4 1000 1000  4096 Dec 18 20:06 alpine
drwxrwxr-x 4 1000 1000  4096 Dec 18 20:06 arch
-rw-rw-r-- 1 1000 1000  8292 Dec 18 20:06 bump_version.py
drwxrwxr-x 4 1000 1000  4096 Dec 18 20:06 debs
drwxrwxr-x 5 1000 1000  4096 Dec 18 20:06 documentation-templates
drwxrwxr-x 2 1000 1000  4096 Dec 18 20:06 hp-ux
drwxrwxr-x 4 1000 1000  4096 Dec 18 20:06 macos
drwxrwxr-x 3 1000 1000  4096 Dec 18 20:06 ova
drwxrwxr-x 3 1000 1000  4096 Dec 18 20:06 puppet_module
drwxrwxr-x 4 1000 1000  4096 Dec 18 20:06 rpms
drwxrwxr-x 6 1000 1000  4096 Dec 18 20:06 solaris
drwxrwxr-x 3 1000 1000  4096 Dec 18 20:06 splunkapp
drwxrwxr-x 4 1000 1000  4096 Dec 18 20:25 stack
drwxrwxr-x 3 1000 1000  4096 Dec 18 20:06 tests
drwxrwxr-x 7 1000 1000  4096 Dec 18 22:20 unattended_installer
drwxrwxr-x 4 1000 1000  4096 Dec 18 20:06 wazuhapp
drwxrwxr-x 2 1000 1000  4096 Dec 18 20:06 windows
drwxrwxr-x 4 1000 1000  4096 Dec 18 20:06 wpk
/root/unattended_installer/builder.sh -c
cat: //VERSION: No such file or directory

Proposed alternative

readonly source_directory="$( cd $(dirname $0) ; pwd -P )"
source_branch=$(cat ${current_path}/../VERSION)
@rauldpm rauldpm added level/task Subtask issue type/bug Bug issue labels Dec 18, 2023
@wazuhci wazuhci moved this to Backlog in Release 4.7.2 Dec 19, 2023
@davidcr01 davidcr01 self-assigned this Dec 19, 2023
@davidcr01 davidcr01 moved this from Backlog to In progress in Release 4.7.2 Dec 19, 2023
@davidcr01
Copy link
Contributor

Update Report

Development

The following code has been added:

readonly source_directory="$( cd $(dirname $0) ; pwd -P )"
source_branch=$(cat ${source_directory}/../VERSION)

Testing

It has been tested that the source_branch variable is correctly fetched and the WIA is built:

From wazuh-ppackages/unattended_installer:

 ~/Wazuh/packages/unattended_installer > bash builder.sh -i -d pre-release
+++ dirname builder.sh
++ cd .
++ pwd -P
+ readonly source_directory=/home/davidcr01/Wazuh/packages/unattended_installer
+ source_directory=/home/davidcr01/Wazuh/packages/unattended_installer
++ cat /home/davidcr01/Wazuh/packages/unattended_installer/../VERSION
+ source_branch=4.7.2
+ set +x

From Wazuh (personal parent directory):

 ~/Wazuh > bash packages/unattended_installer/builder.sh -i -d staging
+++ dirname packages/unattended_installer/builder.sh
++ cd packages/unattended_installer
++ pwd -P
+ readonly source_directory=/home/davidcr01/Wazuh/packages/unattended_installer
+ source_directory=/home/davidcr01/Wazuh/packages/unattended_installer
++ cat /home/davidcr01/Wazuh/packages/unattended_installer/../VERSION
+ source_branch=4.7.2
+ set +x

From wazuh-packages/unattended_installer/install_functions:

 ~/Wazuh/packages/unattended_installer/install_functions > bash ../builder.sh -i -d pre-release
+++ dirname ../builder.sh
++ cd ..
++ pwd -P
+ readonly source_directory=/home/davidcr01/Wazuh/packages/unattended_installer
+ source_directory=/home/davidcr01/Wazuh/packages/unattended_installer
++ cat /home/davidcr01/Wazuh/packages/unattended_installer/../VERSION
+ source_branch=4.7.2
+ set +x

@davidcr01 davidcr01 moved this from In progress to Pending review in Release 4.7.2 Dec 19, 2023
@davidcr01 davidcr01 linked a pull request Dec 19, 2023 that will close this issue
@wazuhci wazuhci moved this from Pending review to Pending final review in Release 4.7.2 Dec 20, 2023
@github-project-automation github-project-automation bot moved this from Pending final review to Done in Release 4.7.2 Dec 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
level/task Subtask issue type/bug Bug issue
Projects
No open projects
Status: Done
3 participants