diff --git a/src/sonic-frr/Makefile b/src/sonic-frr/Makefile index c7c43ccecc0e..69d62a2e7a82 100644 --- a/src/sonic-frr/Makefile +++ b/src/sonic-frr/Makefile @@ -13,12 +13,19 @@ export DEBEMAIL := sonicproject@googlegroups.com $(addprefix $(DEST)/, $(MAIN_TARGET)): $(DEST)/% : # Build the package pushd ./frr - git checkout -b $(FRR_BRANCH) origin/$(FRR_BRANCH) || git checkout $(FRR_BRANCH) -ifeq ($(CROSS_BUILD_ENVIRON), y) - git reset --hard -endif - stg branch --create $(STG_BRANCH) $(FRR_TAG) + git fetch --all + + oldbranch=$$(git describe --always) + if ! git checkout $(FRR_BRANCH)-sonic; then + git checkout -b $(FRR_BRANCH)-sonic origin/$(FRR_BRANCH) + fi + git clean -xdf + git reset --hard origin/$(FRR_BRANCH) + git branch --list 'stg_temp.*' | sed -e '/^[*] /d' | xargs --no-run-if-empty git branch -D + + stg branch --create $(STG_BRANCH)-sonic $(FRR_TAG) stg import -s ../patch/series + gbp dch --ignore-branch --new-version=$(FRR_VERSION)-sonic-$(FRR_SUBVERSION) --dch-opt="--force-bad-version" --commit --git-author ifeq ($(CROSS_BUILD_ENVIRON), y) @@ -26,16 +33,7 @@ ifeq ($(CROSS_BUILD_ENVIRON), y) else dpkg-buildpackage -rfakeroot -b -us -uc -Ppkg.frr.nortrlib -j$(SONIC_CONFIG_MAKE_JOBS) --admindir $(SONIC_DPKG_ADMINDIR) endif - stg undo || true - git clean -xfdf - git checkout $(FRR_BRANCH) - stg branch --delete --force $(STG_BRANCH) - git rev-parse --short HEAD | xargs git checkout -ifeq ($(CROSS_BUILD_ENVIRON), y) - git reset --hard -endif - git checkout master - git branch -D $(FRR_BRANCH) + git checkout "$$oldbranch" popd mv $(DERIVED_TARGET) $* $(DEST)/