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

Make version generation consistent across build targets #3497

Merged
merged 1 commit into from
Dec 1, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 10 additions & 9 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ static:
./scripts/build

static-with-pause:
./scripts/build true "" false true
./scripts/build true "" true true

# Cross-platform build target for static checks
xplatform-build:
Expand Down Expand Up @@ -381,7 +381,7 @@ amazon-linux-sources.tgz:

.amazon-linux-rpm-integrated-done: amazon-linux-sources.tgz
test -e SOURCES || ln -s . SOURCES
rpmbuild --define "%_topdir $(PWD)" -bb ecs-init.spec
rpmbuild --define "%_topdir $(PWD)" -bb ecs-agent.spec
Copy link
Contributor

Choose a reason for hiding this comment

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

how was this working before if ecs-init.spec doesn't exist?

Copy link
Member Author

@fierlion fierlion Nov 30, 2022

Choose a reason for hiding this comment

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

actually that's a good point -- this was working because koji doesn't actually use this Makefile so this target is more a reference to approximate what koji builds rather than the mechanism koji uses to build.

find RPMS/ -type f -exec cp {} . \;
touch .amazon-linux-rpm-integrated-done

Expand All @@ -404,8 +404,8 @@ generic-rpm-integrated: .generic-rpm-integrated-done
VERSION = $(shell cat ecs-init/ECSVERSION)

.generic-deb-integrated-done: get-cni-sources
mkdir -p BUILDROOT
./scripts/update-version.sh
mkdir -p BUILDROOT
tar -czf ./amazon-ecs-init_${VERSION}.orig.tar.gz ecs-init scripts README.md
cp -r packaging/generic-deb-integrated/debian Makefile ecs-init scripts misc agent agent-container amazon-ecs-cni-plugins amazon-vpc-cni-plugins README.md VERSION GO_VERSION BUILDROOT
cd BUILDROOT && dpkg-buildpackage -uc -b
Expand Down Expand Up @@ -459,16 +459,17 @@ generic-rpm: .generic-rpm-done
deb: .deb-done

clean:
rm -f misc/certs/host-certs.crt &> /dev/null
rm -rf misc/pause-container/image/
rm -rf misc/pause-container/rootfs/
rm -rf misc/plugins/
rm -rf out/
rm -rf rootfs/
-rm -f misc/certs/host-certs.crt &> /dev/null
-rm -rf misc/pause-container/image/
-rm -rf misc/pause-container/rootfs/
-rm -rf misc/plugins/
-rm -rf out/
-rm -rf rootfs/
-$(MAKE) -C $(ECS_CNI_REPOSITORY_SRC_DIR) clean
-rm -f .get-deps-stamp
-rm -f .builder-image-stamp
-rm -f .out-stamp
-rm -f ecs-agent.spec
-rm -rf $(PWD)/bin
-rm -rf cover.out
-rm -rf coverprofile.out
Expand Down
4 changes: 1 addition & 3 deletions agent/version/formatting.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,7 @@ func String() string {
return ret + GitShortHash + ")"
}

// Don't prepend the dirty (*) in pathwriter path
func GitHashString() string {
if GitDirty {
return "*" + GitShortHash
}
return GitShortHash
}
12 changes: 0 additions & 12 deletions buildspecs/merge-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -71,18 +71,6 @@ phases:

# Build agent tar and rpm
- GO111MODULE=auto

# Update version.go file
- ./scripts/update-version.sh
- git add agent/version/version.go

# Dummy git config to create a commit
- git config user.email "[email protected]"
- git config user.name "Your Name"

# Commit required to build agent with updated files
- git commit -m "update version"

- make dockerfree-agent-image
- make generic-rpm-integrated
- ls
Expand Down
12 changes: 0 additions & 12 deletions buildspecs/pr-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,18 +60,6 @@ phases:

# Building agent tars
- GO111MODULE=auto

# Update version.go file
- ./scripts/update-version.sh | tee -a $BUILD_LOG
- git add agent/version/version.go | tee -a $BUILD_LOG

# Dummy git config to create a commit
- git config user.email "[email protected]" | tee -a $BUILD_LOG
- git config user.name "Your Name" | tee -a $BUILD_LOG

# Commit required to build agent with updated files
- git commit -m "update version" | tee -a $BUILD_LOG

- make dockerfree-agent-image 2>&1 | tee -a $BUILD_LOG
- make generic-rpm-integrated 2>&1 | tee -a $BUILD_LOG
- ls
Expand Down
2 changes: 1 addition & 1 deletion packaging/amazon-linux-ami-integrated/ecs-agent.spec
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ required routes among its preparation steps.
# each of these should build for arm and amd arch
./scripts/get-host-certs
./scripts/build-cni-plugins
./scripts/build-integrated true "" false true
./scripts/build-integrated true "" true true
./scripts/build-agent-image
./scripts/gobuild.sh %{gobuild_tag}

Expand Down
2 changes: 1 addition & 1 deletion packaging/generic-rpm-integrated/amazon-ecs-init.spec
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ required routes among its preparation steps.
%build
./scripts/get-host-certs
./scripts/build-cni-plugins
./scripts/build-integrated true "" false true
./scripts/build-integrated true "" true true
./scripts/build-agent-image
./scripts/gobuild.sh %{gobuild_tag}

Expand Down
6 changes: 3 additions & 3 deletions scripts/build-integrated
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,10 @@ cd "${SRCPATH}/agent"
if [[ "${version_gen}" == "true" ]]; then
# Versioning stuff. We run the generator to setup the version and then always
# restore ourselves to a clean state
cp agent/version/version.go agent/version/_version.go
trap "cd \"${ROOT}\"; mv agent/version/_version.go agent/version/version.go" EXIT SIGHUP SIGINT SIGTERM
cp ${ROOT}/agent/version/version.go ${ROOT}/agent/version/_version.go
trap "cd \"${ROOT}\"; mv ${ROOT}/agent/version/_version.go ${ROOT}/agent/version/version.go" EXIT SIGHUP SIGINT SIGTERM

cd ./agent/version/
cd ${ROOT}/agent/version/
# Turn off go module here because version-gen.go is a separate program (i.e. "package main")
# and no dependency needed to be fetched (but if go mod is on it will try to fetch dependency causing
# this script to fail when we run it in a container with network mode "none").
Expand Down