-
Notifications
You must be signed in to change notification settings - Fork 5k
Add RPM packaging #9092
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
Closed
Closed
Add RPM packaging #9092
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
932ced8
Add RPM package info to Auditbeat
tsg eadda46
Added size and install time
tsg 37229cc
Cache dlopen results
tsg c4d3bf8
Add license headers
tsg cf1ae9a
Added librpm as a dep in the packaging
tsg 0d090ba
Addressed comments
tsg 4579eb4
Renamed rpm_common to rpm_common_test because it's no longer needed i…
tsg File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
67 changes: 67 additions & 0 deletions
67
x-pack/auditbeat/module/system/packages/rpm_common_test.go
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,67 @@ | ||
| // Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
| // or more contributor license agreements. Licensed under the Elastic License; | ||
| // you may not use this file except in compliance with the Elastic License. | ||
|
|
||
| package packages | ||
|
|
||
| import ( | ||
| "fmt" | ||
| "os/exec" | ||
| "strconv" | ||
| "strings" | ||
| "time" | ||
| ) | ||
|
|
||
| func rpmPackagesByExec() ([]*Package, error) { | ||
| format := "%{NAME}|%{VERSION}|%{RELEASE}|%{ARCH}|%{LICENSE}|%{INSTALLTIME}|%{SIZE}|%{URL}|%{SUMMARY}\\n" | ||
| out, err := exec.Command("/usr/bin/rpm", "--qf", format, "-qa").Output() | ||
| if err != nil { | ||
| return nil, fmt.Errorf("Error running rpm -qa command: %v", err) | ||
| } | ||
|
|
||
| lines := strings.Split(string(out), "\n") | ||
| var packages []*Package | ||
| for _, line := range lines { | ||
| if len(strings.TrimSpace(line)) == 0 { | ||
| continue | ||
| } | ||
| words := strings.SplitN(line, "|", 9) | ||
| if len(words) < 9 { | ||
| return nil, fmt.Errorf("line '%s' doesn't have enough elements", line) | ||
| } | ||
| pkg := Package{ | ||
| Name: words[0], | ||
| Version: words[1], | ||
| Release: words[2], | ||
| Arch: words[3], | ||
| License: words[4], | ||
| // install time - 5 | ||
| // size - 6 | ||
| URL: words[7], | ||
| Summary: words[8], | ||
| } | ||
| ts, err := strconv.ParseInt(words[5], 10, 64) | ||
| if err != nil { | ||
| return nil, fmt.Errorf("error converting %s to string: %v", words[5], err) | ||
| } | ||
| pkg.InstallTime = time.Unix(ts, 0) | ||
|
|
||
| pkg.Size, err = strconv.ParseUint(words[6], 10, 64) | ||
| if err != nil { | ||
| return nil, fmt.Errorf("error converting %s to string: %v", words[6], err) | ||
| } | ||
|
|
||
| // Avoid "(none)" in favor of empty strings | ||
| if pkg.URL == "(none)" { | ||
| pkg.URL = "" | ||
| } | ||
| if pkg.Arch == "(none)" { | ||
| pkg.Arch = "" | ||
| } | ||
|
|
||
| packages = append(packages, &pkg) | ||
|
|
||
| } | ||
|
|
||
| return packages, nil | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A few lines up in
init()add a filter to preventmage packagefrom attempting to build these targets.mage.Platforms = mage.Platforms.Filter("!linux/ppc64 !linux/mips64")This is similar to what journalbeat has but with the
linuxselector.beats/journalbeat/magefile.go
Lines 35 to 38 in 1411852