Skip to content

Commit

Permalink
[pkg] build sources using tar in place of git archive
Browse files Browse the repository at this point in the history
It allow us to add any file which are not tracked in source (like git_commit_id).
Using config.mk, we limit which top level directories are included in tar archive.
Using dist_ignore file, we can exclude specific files (like .git files)

conf/.gitignore is removed because this file is overriden by conf/.gitignore.example during packaging.

rpm/source and sub-directories are not necessary anymore
  • Loading branch information
nqb committed Jun 28, 2021
1 parent 8e214fd commit 03c8031
Show file tree
Hide file tree
Showing 12 changed files with 64 additions and 120 deletions.
32 changes: 30 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -224,9 +224,10 @@ rpm/.rpmmacros:
echo "%pf_minor_release $(PF_MINOR_RELEASE)" >> $(SRC_RPMDIR)/.rpmmacros

.PHONY: build_rpm
build_rpm: conf/git_commit_id rpm/.rpmmacros
build_rpm: conf/git_commit_id rpm/.rpmmacros dist
cp $(SRC_RPMDIR)/.rpmmacros $(HOME)
ci-build-pkg $(SRC_RPMDIR)
ci-build-pkg $(SRC_RPMDIR)/packetfence-release.spec
ci-build-pkg $(SRC_RPMDIR)/packetfence.spec

.PHONY: build_deb
build_deb: conf/git_commit_id
Expand All @@ -237,3 +238,30 @@ build_deb: conf/git_commit_id
.PHONY: patch_release
patch_release:
$(SRC_CIDIR)/lib/release/prep-release.sh

.PHONY: distclean
distclean: go_clean vagrant_clean npm_clean clean
rm -rf packetfence-$(PF_PATCH_RELEASE).tar

.PHONY: go_clean
go_clean:
$(MAKE) -C $(SRC_GODIR) clean

# to remove Ansible files from addons/vagrant/
.PHONY: vagrant_clean
vagrant_clean:
$(MAKE) -C $(SRC_CI_TESTDIR) delete

.PHONY: npm_clean
npm_clean:
$(MAKE) -C $(SRC_HTML_COMMONDIR) clean
$(MAKE) -C $(SRC_HTML_PFAPPDIR_ROOT) clean

.PHONY: dist
dist: distclean
mkdir -p packetfence-$(PF_PATCH_RELEASE)
# preserve, recursive and symlinks
cp -pRH $(files_to_include) packetfence-$(PF_PATCH_RELEASE)
tar c --exclude-from=$(SRC_ROOT_DIR)/dist_ignore \
-f packetfence-$(PF_PATCH_RELEASE).tar packetfence-$(PF_PATCH_RELEASE)
rm -rf packetfence-$(PF_PATCH_RELEASE)
5 changes: 0 additions & 5 deletions ci/lib/release/prep-release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ source ${FUNCTIONS_FILE}
get_pf_release

RPM_SPEC=${PF_SRC_DIR}/rpm/packetfence.spec
RPM_SOURCE=${PF_SRC_DIR}/rpm/source
DEB_DIR=${PF_SRC_DIR}/debian
DEB_CHLOG=${DEB_DIR}/changelog

Expand All @@ -33,10 +32,6 @@ update_pf_version() {
sed -i -e "s/^PacketFence .*/PacketFence ${new_release}/" "${PF_RELEASE_PATH}"
head -n1 ${PF_RELEASE_PATH}

log_subsection "${RPM_SOURCE}"
sed -i -e "s/${cur_release}/${new_release}/" "${RPM_SOURCE}"
head -n2 ${RPM_SOURCE}

log_subsection "${RPM_SPEC}"
sed -i -e "s/^\(Version:[^0-9]*\).*/\1${new_release}/" "${RPM_SPEC}"
grep "^Version:" ${RPM_SPEC}
Expand Down
4 changes: 4 additions & 0 deletions ci/lib/test/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ halt:
clean:
./vagrant-wrapper.sh teardown

.PHONY: delete
delete:
./vagrant-wrapper.sh delete

.PHONY: get-public
get-public:
./get_public_from_gitlab.sh
Expand Down
1 change: 1 addition & 0 deletions ci/lib/test/vagrant-wrapper.sh
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ configure_and_check
case $1 in
run) run ;;
halt) halt ${PF_VM_NAME} ${INT_TEST_VM_NAMES} ;;
delete) delete_ansible_files ;;
teardown) teardown ;;
*) die "Wrong argument"
esac
110 changes: 0 additions & 110 deletions conf/.gitignore

This file was deleted.

14 changes: 14 additions & 0 deletions config.mk
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ SRC_ROOT_DIR = $(realpath $(dir $(abspath $(lastword $(MAKEFILE_LIST)))))
SRC_RPMDIR = $(SRC_ROOT_DIR)/rpm
SRC_DEBDIR = $(SRC_ROOT_DIR)/debian
SRC_CIDIR = $(SRC_ROOT_DIR)/ci
SRC_CI_TESTDIR = $(SRC_CIDIR)/lib/test
SRC_GODIR = $(SRC_ROOT_DIR)/go
SRC_TESTDIR= $(SRC_ROOT_DIR)/t

#
# Golang
Expand Down Expand Up @@ -84,3 +87,14 @@ pfapp_alt_files = $(shell find $(SRC_HTML_PFAPPDIR_ROOT) \
symlink_files = $(shell find $(SRC_HTML_PFAPPDIR) \
-type l \
-not -path "$(SRC_HTML_PFAPPDIR_ROOT)/node_modules/*")

# all directories and files necessary to build PacketFence package
# $(SRC_ROOT_DIR)/* to exclude SRC_ROOT_DIR himself
files_to_include = $(shell find $(SRC_ROOT_DIR)/* \
-maxdepth 0 \
-not -path "$(SRC_CIDIR)" \
-not -path "$(SRC_DEBDIR)" \
-not -path "$(SRC_ROOT_DIR)/packetfence-$(PF_PATCH_RELEASE)" \
-not -path "$(SRC_ROOT_DIR)/public" \
-not -path "$(SRC_RPMDIR)" \
-not -path "$(SRC_TESTDIR)" )
6 changes: 6 additions & 0 deletions dist_ignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
dist_ignore
*.gitignore
*.gitattributes
*.git
ChangeLog.old

3 changes: 3 additions & 0 deletions html/common/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,6 @@ dist:

light-dist:
grunt --stack dist

clean:
rm -rf ./node_modules
2 changes: 2 additions & 0 deletions html/pfappserver/root/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,5 @@ dist:
light-dist:
npm run build

clean:
rm -rf ./node_modules
File renamed without changes.
5 changes: 4 additions & 1 deletion rpm/packetfence.spec
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
#==============================================================================
Name: packetfence
Version: 11.0.0
Release: 1%{?dist}
Release: 2%{?dist}
Summary: PacketFence network registration / worm mitigation system
Packager: Inverse inc. <[email protected]>
Group: System Environment/Daemons
Expand Down Expand Up @@ -1248,6 +1248,9 @@ fi
# Changelog
#==============================================================================
%changelog
* Mon Jun 28 2021 Inverse <[email protected]> - 11.0.0-2
- Build Source using Makefile in place of git archive

* Fri Jun 11 2021 Inverse <[email protected]> - 11.0.0-1
- Prepare new PacketFence release

Expand Down
2 changes: 0 additions & 2 deletions rpm/source

This file was deleted.

0 comments on commit 03c8031

Please sign in to comment.