Skip to content

Commit

Permalink
cherry-pick parts of #6583 to permit full-upgrade of v11.0.0 to futur…
Browse files Browse the repository at this point in the history
…e versions
  • Loading branch information
nqb committed Oct 18, 2021
1 parent b9dd213 commit 07ec618
Show file tree
Hide file tree
Showing 21 changed files with 603 additions and 46 deletions.
106 changes: 82 additions & 24 deletions .gitlab-ci.yml
Expand Up @@ -11,7 +11,7 @@ before_script:
################################################################################
stages:
- build_img
- build_pkg
- build_artifacts
- sign
- publish
- test
Expand Down Expand Up @@ -144,6 +144,14 @@ variables:
- if: '$CI_COMMIT_REF_NAME == "devel" && ( $BUILD_PF_IMG_ZEN == "yes" || $CI_COMMIT_MESSAGE =~ /build_pf_img_zen=yes/ )'
- if: '$CI_COMMIT_REF_NAME != "devel" && $CI_COMMIT_REF_NAME !~ /^maintenance\/[[:digit:]]+\.[[:digit:]]+$/ && $CI_COMMIT_TAG == null && $CI_PIPELINE_SOURCE == "web" && ( $BUILD_PF_IMG_ZEN == "yes" || $CI_COMMIT_MESSAGE =~ /build_pf_img_zen=yes/ )'

# run this job on:
# - devel branch with BUILD_ARTIFACTS_WEBSITE variable defined or build_artifacts_website=yes in commit message
# - all branches, except maintenance/X.Y and devel (web) if variable BUILD_ARTIFACTS_WEBSITE sets to yes or if CI_COMMIT_MESSAGE contains "build_artifacts_website=yes".
.build_artifacts_website_devel_and_branches_rules:
rules:
- if: '$CI_COMMIT_REF_NAME == "devel" && ( $BUILD_ARTIFACTS_WEBSITE == "yes" || $CI_COMMIT_MESSAGE =~ /build_artifacts_website=yes/ )'
- if: '$CI_COMMIT_REF_NAME != "devel" && $CI_COMMIT_REF_NAME !~ /^maintenance\/[[:digit:]]+\.[[:digit:]]+$/ && $CI_COMMIT_TAG == null && $CI_PIPELINE_SOURCE == "web" && ( $BUILD_ARTIFACTS_WEBSITE == "yes" || $CI_COMMIT_MESSAGE =~ /build_artifacts_website=yes/ )'

########################################
# JOBS
########################################
Expand All @@ -167,15 +175,26 @@ variables:
- shell
- inverse.ca

.build_pkg_job:
stage: build_pkg
.build_artifacts_pkg_job:
stage: build_artifacts
artifacts:
expire_in: 1 day
paths:
- result/*
tags:
- docker-inverse

.build_artifacts_website_job:
stage: build_artifacts
script:
- make -e website
artifacts:
expire_in: 1 day
paths:
- website/*
tags:
- docker-inverse

.publish_job:
stage: publish
environment:
Expand Down Expand Up @@ -263,6 +282,19 @@ variables:
tags:
- shell

.deploy_website_artifacts_job:
stage: deploy
dependencies:
- build_artifacts_website_devel_and_branches
- build_artifacts_website_release
variables:
DEPLOY_USER: reposync
DEPLOY_HOST: web.inverse.ca
script:
- ./${UPLOAD_DIR}/deploy-artifacts.sh website
tags:
- shell

.build_pf_img_zen_job:
stage: build_pf_img
environment:
Expand Down Expand Up @@ -369,54 +401,69 @@ build_img_vagrant_devel_and_branches_debian_bullseye:
BOX_NAME: pfdeb11dev

########################################
# BUILD_PKG JOBS
# BUILD_ARTIFACTS JOBS
########################################
# build_pkg jobs for development
build_pkg_devel_and_branches_centos_8:
# build_artifacts_pkg jobs for development
build_artifacts_pkg_devel_and_branches_centos_8:
image: ${PFBUILD_CENTOS_8_IMG}:${PFBUILD_DEFAULT_DEV_TAG}
extends:
- .build_pkg_job
- .build_artifacts_pkg_job
- .rpm_script_job
- .devel_and_branches_rules

build_pkg_devel_and_branches_debian_bullseye:
build_artifacts_pkg_devel_and_branches_debian_bullseye:
image: ${PFBUILD_DEB_BULLSEYE_IMG}:${PFBUILD_DEFAULT_DEV_TAG}
extends:
- .build_pkg_job
- .build_artifacts_pkg_job
- .deb_script_job
- .devel_and_branches_rules

# build_pkg jobs for release
# build_artifacts_pkg jobs for release
# CI_COMMIT_TAG contains vX.Y.X
build_pkg_release_centos_8:
build_artifacts_pkg_release_centos_8:
image: ${PFBUILD_CENTOS_8_IMG}:${CI_COMMIT_TAG}
extends:
- .build_pkg_job
- .build_artifacts_pkg_job
- .rpm_script_job
- .release_only_rules

build_pkg_release_debian_bullseye:
build_artifacts_pkg_release_debian_bullseye:
image: ${PFBUILD_DEB_BULLSEYE_IMG}:${CI_COMMIT_TAG}
extends:
- .build_pkg_job
- .build_artifacts_pkg_job
- .deb_script_job
- .release_only_rules

# CI_COMMIT_REF_SLUG contains maintenance-X-Y
build_pkg_maintenance_centos_8:
build_artifacts_pkg_maintenance_centos_8:
image: ${PFBUILD_CENTOS_8_IMG}:${CI_COMMIT_REF_SLUG}
extends:
- .build_pkg_job
- .build_artifacts_pkg_job
- .rpm_script_job
- .maintenance_only_rules

build_pkg_maintenance_debian_bullseye:
build_artifacts_pkg_maintenance_debian_bullseye:
image: ${PFBUILD_DEB_BULLSEYE_IMG}:${CI_COMMIT_REF_SLUG}
extends:
- .build_pkg_job
- .build_artifacts_pkg_job
- .deb_script_job
- .maintenance_only_rules

# build_artifacts_website jobs for development
build_artifacts_website_devel_and_branches:
image: ${PFBUILD_DEB_BULLSEYE_IMG}:${PFBUILD_DEFAULT_DEV_TAG}
extends:
- .build_artifacts_website_job
- .build_artifacts_website_devel_and_branches_rules

# build_artifacts_website job for release
# CI_COMMIT_TAG contains vX.Y.X
build_artifacts_website_release:
image: ${PFBUILD_DEB_BULLSEYE_IMG}:${CI_COMMIT_TAG}
extends:
- .build_artifacts_website_job
- .release_only_rules

########################################
# SIGN JOBS
########################################
Expand All @@ -428,12 +475,12 @@ sign_devel_release_branches_and_maintenance:
script:
- ci-sign-pkg
dependencies:
- build_pkg_devel_and_branches_centos_8
- build_pkg_devel_and_branches_debian_bullseye
- build_pkg_release_centos_8
- build_pkg_release_debian_bullseye
- build_pkg_maintenance_centos_8
- build_pkg_maintenance_debian_bullseye
- build_artifacts_pkg_devel_and_branches_centos_8
- build_artifacts_pkg_devel_and_branches_debian_bullseye
- build_artifacts_pkg_release_centos_8
- build_artifacts_pkg_release_debian_bullseye
- build_artifacts_pkg_maintenance_centos_8
- build_artifacts_pkg_maintenance_debian_bullseye
artifacts:
expire_in: 1 day
paths:
Expand Down Expand Up @@ -652,6 +699,17 @@ deploy_maintenance_pkg_friendly_names:
#PF_EXPORT_RPM_DEST_NAME
#PF_EXPORT_DEB_DEST_NAME

# website artifacts
deploy_devel_and_branches_website_artifacts:
extends:
- .deploy_website_artifacts_job
- .build_artifacts_website_devel_and_branches_rules

deploy_release_website_artifacts:
extends:
- .deploy_website_artifacts_job
- .release_only_rules

########################################
# BUILD_PF_IMG JOBS
########################################
Expand Down
21 changes: 20 additions & 1 deletion Makefile
Expand Up @@ -239,13 +239,14 @@ rpm/.rpmmacros:
echo "%pf_minor_release $(PF_MINOR_RELEASE)" >> $(SRC_RPMDIR)/.rpmmacros

.PHONY: build_rpm
build_rpm: conf/git_commit_id rpm/.rpmmacros dist-packetfence-test dist-packetfence-export dist
build_rpm: conf/git_commit_id rpm/.rpmmacros dist-packetfence-test dist-packetfence-export dist-packetfence-upgrade dist
cp $(SRC_RPMDIR)/.rpmmacros $(HOME)
ci-build-pkg $(SRC_RPMDIR)/packetfence.spec
# no need to build other packages if packetfence build failed
ci-build-pkg $(SRC_RPMDIR)/packetfence-release.spec
ci-build-pkg $(SRC_RPMDIR)/packetfence-test.spec
ci-build-pkg $(SRC_RPMDIR)/packetfence-export.spec
ci-build-pkg $(SRC_RPMDIR)/packetfence-upgrade.spec

.PHONY: build_deb
build_deb: conf/git_commit_id
Expand Down Expand Up @@ -328,3 +329,21 @@ dist-packetfence-export: distclean-packetfence-export
cp -pRH $(pf_export_files_to_include) packetfence-export-$(PF_PATCH_RELEASE)
tar c -f packetfence-export-$(PF_PATCH_RELEASE).tar packetfence-export-$(PF_PATCH_RELEASE)
rm -rf packetfence-export-$(PF_PATCH_RELEASE)

# packetfence-upgrade package
.PHONY: distclean-packetfence-upgrade
distclean-packetfence-upgrade:
rm -rf packetfence-upgrade-$(PF_PATCH_RELEASE).tar

.PHONY: dist-packetfence-upgrade
dist-packetfence-upgrade: distclean-packetfence-upgrade
mkdir -p packetfence-upgrade-$(PF_PATCH_RELEASE)
# preserve, recursive and symlinks
cp -pRH $(pf_upgrade_files_to_include) packetfence-upgrade-$(PF_PATCH_RELEASE)
tar c -f packetfence-upgrade-$(PF_PATCH_RELEASE).tar packetfence-upgrade-$(PF_PATCH_RELEASE)
rm -rf packetfence-upgrade-$(PF_PATCH_RELEASE)

.PHONY: website
website:
$(SRC_CIDIR)/lib/release/publish-to-website.sh

15 changes: 12 additions & 3 deletions addons/full-import/Makefile
@@ -1,13 +1,22 @@
# This Makefile is only used to build packetfence-export package

FULL_IMPORT_DIR = /usr/local/pf/addons/full-import
EXPORT_FILES_LIST = 'export.sh find-extra-files.pl helpers.functions database.functions'
FUNCTIONS_DIR = /usr/local/pf/addons/functions
SRC_ADDONS_DIR=$(shell dirname $(CURDIR))
SRC_FULLIMPORT_DIR=$(SRC_ADDONS_DIR)/full-import
SRC_FUNCTIONS_DIR=$(SRC_ADDONS_DIR)/functions
EXPORT_FILES_LIST = 'export.sh find-extra-files.pl'

install:
@echo "create directory $(DESTDIR)$(FULL_IMPORT_DIR)"
@echo "create directories"
install -d -m0755 $(DESTDIR)$(FULL_IMPORT_DIR)
install -d -m0755 $(DESTDIR)$(FUNCTIONS_DIR)

@echo "install full import files"
for file in $(EXPORT_FILES_LIST); do \
install -v -m 0644 $$file -D $(DESTDIR)$(FULL_IMPORT_DIR) ; \
done

@echo "install functions files"
for file in `find $(SRC_FUNCTIONS_DIR) -type f -name "*.functions"` ; do \
install -v -m 0644 $$file -D $(DESTDIR)$(FUNCTIONS_DIR) ; \
done
4 changes: 2 additions & 2 deletions addons/full-import/export.sh
Expand Up @@ -15,8 +15,8 @@ fi

set -o nounset -o pipefail -o errexit

source /usr/local/pf/addons/full-import/helpers.functions
source /usr/local/pf/addons/full-import/database.functions
source /usr/local/pf/addons/functions/helpers.functions
source /usr/local/pf/addons/functions/database.functions

output="$1"

Expand Down
8 changes: 4 additions & 4 deletions addons/full-import/import.sh
Expand Up @@ -2,9 +2,9 @@

set -o nounset -o pipefail -o errexit

source /usr/local/pf/addons/full-import/helpers.functions
source /usr/local/pf/addons/full-import/database.functions
source /usr/local/pf/addons/full-import/configuration.functions
source /usr/local/pf/addons/functions/helpers.functions
source /usr/local/pf/addons/functions/database.functions
source /usr/local/pf/addons/functions/configuration.functions

dump_path="$1"

Expand Down Expand Up @@ -95,7 +95,7 @@ restore_profile_templates
check_code $?

main_splitter
upgrade_configuration
upgrade_imported_configuration
check_code $?

main_splitter
Expand Down
25 changes: 25 additions & 0 deletions addons/full-upgrade/Makefile
@@ -0,0 +1,25 @@
FULL_UPGRADE_DIR = /usr/local/pf/addons/full-upgrade
SRC_ADDONS_DIR=$(shell dirname $(CURDIR))
SRC_FULLUPGRADE_DIR=$(SRC_ADDONS_DIR)/full-upgrade
SRC_FUNCTIONS_DIR=$(SRC_ADDONS_DIR)/functions

# full-upgrade dir is automatically created by install command
install:
@echo "install subdirectories and files inside it"
# /* to exclude directory himself
for subdir in `find $(SRC_FULLUPGRADE_DIR)/* -type d -printf "%f\n"` ; do \
install -d -m0755 $(DESTDIR)$(FULL_UPGRADE_DIR)/$$subdir ; \
for file in `find $$subdir -type f`; do \
install -v -m0644 $$file $(DESTDIR)$(FULL_UPGRADE_DIR)/$$subdir ; \
done \
done

@echo "install top level $(SRC_FULLUPGRADE_DIR) files"
for file in `find $(SRC_FULLUPGRADE_DIR) -maxdepth 1 -type f -not -name "Makefile"`; do \
install -v -m 0644 $$file -D $(DESTDIR)$(FULL_UPGRADE_DIR) ; \
done

@echo "install functions files"
for file in `find $(SRC_FUNCTIONS_DIR) -type f -name "*.functions"` ; do \
install -v -m 0644 $$file -D $(DESTDIR)$(FULL_UPGRADE_DIR) ; \
done
Empty file.

0 comments on commit 07ec618

Please sign in to comment.