8000 Adjusting Makefile.one and btfhub.sh with fixes and improvements. by rafaeldtinoco · Pull Request #1276 · aquasecurity/tracee · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Adjusting Makefile.one and btfhub.sh with fixes and improvements. #1276

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

Merged
merged 6 commits into from
Jan 10, 2022
Merged

Adjusting Makefile.one and btfhub.sh with fixes and improvements. #1276

merged 6 commits into from
Jan 10, 2022

Conversation

rafaeldtinoco
Copy link
Contributor
@rafaeldtinoco rafaeldtinoco commented Dec 16, 2021

bbf7da2 Makefile.one: build dependencies fixes
a8b8507 btfhub.sh: improvement and fixes
bcf796e tracee-make: fix dockerfiles sudoers and dependencies
6ffbad3 Makefile.one: default parallel jobs for libbpf build only

@rafaeldtinoco rafaeldtinoco changed the title Adjusting Makefile.one with fixes and improvements. Adjusting Makefile.one and btfhub.sh with fixes and improvements. Dec 16, 2021
@rafaeldtinoco rafaeldtinoco requested a review from itaysk December 16, 2021 19:48
@rafaeldtinoco rafaeldtinoco marked this pull request as ready for review December 16, 2021 19:48
@rafaeldtinoco
Copy link
Contributor Author

@yanivagman this PR contain fixes to Makefile.one logic recently merged. Feel free to merge this, if you agree, or to steal this PR and do any adjustments it might need, as I'll be off for couple of weeks.

Copy link
Collaborator
@itaysk itaysk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMO it's a bit too much that every recipe needs to declare all the commands it will use

This was causing issues such as:

    make[1]: warning: -j24 forced in makefile: resetting jobserver mode.

So its better to use $(PARALLEL) whenever we would like builds to be
parallel by default (or to rely in user providing -jX to make as an
argument).
Now, with a customized /etc/sudoers file, we're able to dictate which
environment variables are automatically passed through "sudo". With
that, the feature:

    $ sudo make -f builder/Makefile.docker alpine-shell (or ubuntu-shell)

Automatically sets LIBBPFGO_OSRELEASE_FILE environment variable AND it
is automatically passwed through sudo as well.

This way, user is able to compile tracee-ebpf on the host (or inside
tracee-make container):

    $ STATIC=1 BTFHUB=1 sudo make -f Makefile.one tracee-ebpf

Spin up a tracee-make container (if not inside already):

    $ make -f builder/Makefile.docker alpine-prepare
    $ make -f builder/Makefile.docker alpine-shell

And run tracee-ebpf with embedded BTF files identified correctly
(reading /etc/os-release-host file, instead of /etc/os-release file).

    tracee@9b17259fe526[/tracee]$ sudo ./dist/tracee-ebpf --debug --trace 'event!=sched*' --output none
    KConfig: warning: could not check enabled kconfig features
    (could not read /boot/config-5.13.0-22-generic: stat ...)
    KConfig: warning: assuming kconfig values, might have unexpected behavior
    OSInfo: ID: ubuntu
    OSInfo: ID_LIKE: debian
    OSInfo: KERNEL_RELEASE: 5.13.0-22-generic
    OSInfo: ARCH: x86_64
    OSInfo: PRETTY_NAME: "Ubuntu 21.10"
    OSInfo: VERSION_ID: "21.10"
    OSInfo: VERSION: "21.10 (Impish Indri)"
    OSInfo: VERSION_CODENAME: impish
    BTF: bpfenv = false, btfenv = false, vmlinux = true
    BPF: using embedded BPF object
    unpacked CO:RE bpf object file into memory
    KConfig: warning: assuming kconfig values, might have unexpected behavior
    ...

Note: This commit also adds rsync dependency to tracee-make containers,
so they can execute:

    $ STATIC=1 BTFHUB=1 sudo make -f Makefile.one tracee-ebpf

correctly.
1. execute shell with -e
2. check for command requirements
3. document excluded BTF files
1. Fix the target dependency checks (per target so requirements are
   checked to each build target, based on its needs).

2. Keep a temporary (and gitignore'd) file that correspond to each of
   the requirement test being done. This is needed so the build targets
   are not rebuilt each time you call make for them (by keeping an
   unmodified file there is no need to re-run the build requirement).

3. Cover tooling versioning. There is not a check for Go and Clang
   versions so we can exit the build if requirements aren't met:

   - clang >= 12
   - golang 1.16 or 1.17

4. Format style: keep ordered check requirements, so they're evaluated
   before the real build requirements. Keep each requirement in a
   different line to facilitate maintenance (patches adding and removing
   requirements and build flags).
@rafaeldtinoco
Copy link
Contributor Author

IMO it's a bit too much that every recipe needs to declare all the commands it will use

Okay. I can remove checks for basic commands (such as CMD_RM, CMD_MKDIR, CMD_TOUCH, CMD_GREP, CMD_CAT). I'll keep the others, though, as they aren't "installed by default" such as those basic commands.

@rafaeldtinoco
Copy link
Contributor Author

@itaysk I have removed the basic checks now.

@rafaeldtinoco rafaeldtinoco requested a review from itaysk January 6, 2022 13:25
@rafaeldtinoco
Copy link
Contributor Author

@itaysk mind giving me a +1 on this one (if you think its good) ? Its blocking PR: #1273 for me (because of rebasing need).

@itaysk
Copy link
Collaborator
itaysk commented Jan 7, 2022

Could someone else please take a look? Don't let me block you

@rafaeldtinoco
Copy link
Contributor Author

@yanivagman could you, please, review this one ? It's a bunch of needed fixes to Makefile.one and I would like to move on with it so I can generate the container images with the new Makefile and, finally, get rid of current building files.

Thanks.

@itaysk
Copy link
Collaborator
itaysk commented Jan 10, 2022

@grantseltzer @danielpacak PTAL
(or @mtcherni95 if you have time)

Copy link
Collaborator
@yanivagman yanivagman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM
Please only check about go backwards compatibility

- improve go version detection: go => 1.16 now
- improve clang version detection error message
@rafaeldtinoco rafaeldtinoco merged commit 3e1969b into aquasecurity:main Jan 10, 2022
@rafaeldtinoco rafaeldtinoco deleted the makefileadjusts branch January 10, 2022 17:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants
0