@@ -971,6 +971,8 @@ var platformPackages = map[string]string{
971
971
972
972
func packageAgent (platforms []string , dependenciesVersion string , agentPackaging , agentBinaryTarget mg.Fn ) {
973
973
fmt .Println ("--- Package Elastic-Agent" )
974
+ var manifestResponse tools.Build
975
+ var err error
974
976
975
977
requiredPackages := []string {}
976
978
for _ , p := range platforms {
@@ -980,8 +982,26 @@ func packageAgent(platforms []string, dependenciesVersion string, agentPackaging
980
982
log .Printf ("--- Packaging dependenciesVersion[%s], %+v \n " , dependenciesVersion , requiredPackages )
981
983
}
982
984
985
+ if devtools .PackagingFromManifest {
986
+ if manifestResponse , err = manifest .DownloadManifest (devtools .ManifestURL ); err != nil {
987
+ log .Panicf ("failed to download remote manifest file %s" , err )
988
+ } else {
989
+ if parsedVersion , err := version .ParseVersion (manifestResponse .Version ); err != nil {
990
+ log .Panicf ("the manifest version from manifest is not semver, got %s" , manifestResponse .Version )
991
+ } else {
992
+ // When getting the packageVersion from snapshot we should also update the env of SNAPSHOT=true which is
993
+ // something that we use as an implicit parameter to various functions
994
+ if parsedVersion .IsSnapshot () {
995
+ os .Setenv (snapshotEnv , "true" )
996
+ mage .Snapshot = true
997
+ }
998
+ os .Setenv ("BEAT_VERSION" , parsedVersion .CoreVersion ())
999
+ }
1000
+ }
1001
+ }
1002
+
983
1003
// download/copy all the necessary dependencies for packaging elastic-agent
984
- archivePath , dropPath := collectPackageDependencies (platforms , dependenciesVersion , requiredPackages )
1004
+ archivePath , dropPath := collectPackageDependencies (platforms , dependenciesVersion , requiredPackages , manifestResponse )
985
1005
986
1006
// cleanup after build
987
1007
defer os .RemoveAll (archivePath )
@@ -997,7 +1017,7 @@ func packageAgent(platforms []string, dependenciesVersion string, agentPackaging
997
1017
defer os .RemoveAll (flatPath )
998
1018
999
1019
// extract all dependencies from their archives into flat dir
1000
- flattenDependencies (requiredPackages , dependenciesVersion , archivePath , dropPath , flatPath )
1020
+ flattenDependencies (requiredPackages , dependenciesVersion , archivePath , dropPath , flatPath , manifestResponse )
1001
1021
1002
1022
// package agent
1003
1023
log .Println ("--- Running packaging function" )
@@ -1014,25 +1034,27 @@ func packageAgent(platforms []string, dependenciesVersion string, agentPackaging
1014
1034
// NOTE: after the build is done the caller must:
1015
1035
// - delete archivePath and dropPath contents
1016
1036
// - unset AGENT_DROP_PATH environment variable
1017
- func collectPackageDependencies (platforms []string , packageVersion string , requiredPackages []string ) (archivePath string , dropPath string ) {
1037
+ func collectPackageDependencies (platforms []string , packageVersion string , requiredPackages []string , manifestResponse tools. Build ) (archivePath string , dropPath string ) {
1018
1038
// if we have defined a manifest URL to package Agent from, we should be using the same packageVersion of that manifest
1019
- if devtools .PackagingFromManifest {
1020
- if manifestResponse , err := manifest .DownloadManifest (devtools .ManifestURL ); err != nil {
1021
- log .Panicf ("failed to download remote manifest file %s" , err )
1022
- } else {
1023
- if parsedVersion , err := version .ParseVersion (manifestResponse .Version ); err != nil {
1024
- log .Panicf ("the manifest version from manifest is not semver, got %s" , manifestResponse .Version )
1039
+ /*
1040
+ if devtools.PackagingFromManifest {
1041
+ if manifestResponse, err := manifest.DownloadManifest(devtools.ManifestURL); err != nil {
1042
+ log.Panicf("failed to download remote manifest file %s", err)
1025
1043
} else {
1026
- // When getting the packageVersion from snapshot we should also update the env of SNAPSHOT=true which is
1027
- // something that we use as an implicit parameter to various functions
1028
- if parsedVersion .IsSnapshot () {
1029
- os .Setenv (snapshotEnv , "true" )
1030
- mage .Snapshot = true
1044
+ if parsedVersion, err := version.ParseVersion(manifestResponse.Version); err != nil {
1045
+ log.Panicf("the manifest version from manifest is not semver, got %s", manifestResponse.Version)
1046
+ } else {
1047
+ // When getting the packageVersion from snapshot we should also update the env of SNAPSHOT=true which is
1048
+ // something that we use as an implicit parameter to various functions
1049
+ if parsedVersion.IsSnapshot() {
1050
+ os.Setenv(snapshotEnv, "true")
1051
+ mage.Snapshot = true
1052
+ }
1053
+ os.Setenv("BEAT_VERSION", parsedVersion.CoreVersion())
1031
1054
}
1032
- os .Setenv ("BEAT_VERSION" , parsedVersion .CoreVersion ())
1033
1055
}
1034
1056
}
1035
- }
1057
+ */
1036
1058
1037
1059
dropPath , found := os .LookupEnv (agentDropPath )
1038
1060
@@ -1189,7 +1211,8 @@ func getIndAgentGlobExpr(versionedFlatPath string, packageVersion string) string
1189
1211
1190
1212
// flattenDependencies will extract all the required packages collected in archivePath and dropPath in flatPath and
1191
1213
// regenerate checksums
1192
- func flattenDependencies (requiredPackages []string , packageVersion , archivePath , dropPath , flatPath string ) {
1214
+ func flattenDependencies (requiredPackages []string , packageVersion , archivePath , dropPath , flatPath string , manifestResponse tools.Build ) {
1215
+
1193
1216
for _ , rp := range requiredPackages {
1194
1217
targetPath := filepath .Join (archivePath , rp )
1195
1218
versionedFlatPath := filepath .Join (flatPath , rp )
@@ -1198,6 +1221,8 @@ func flattenDependencies(requiredPackages []string, packageVersion, archivePath,
1198
1221
os .MkdirAll (versionedFlatPath , 0755 )
1199
1222
os .MkdirAll (versionedDropPath , 0755 )
1200
1223
1224
+ log .Printf (">>>>>>>>>>>> XXX flattenDeps: requiredPackage: [%s]" , rp )
1225
+
1201
1226
// untar all
1202
1227
matches , err := filepath .Glob (filepath .Join (targetPath , "*tar.gz" ))
1203
1228
if err != nil {
0 commit comments