diff options
author | Pierre Schmitz <pierre@archlinux.de> | 2017-04-19 17:23:59 +0200 |
---|---|---|
committer | Pierre Schmitz <pierre@archlinux.de> | 2017-04-19 17:23:59 +0200 |
commit | 59d495b55f52253518fe1a184627e7259034f978 (patch) | |
tree | 66fffd6de59c130bc4babdc452763d76c4cdcc5e | |
parent | 60f0691a945b69b4ede50a18a642c8df1bdc3559 (diff) |
Cache already built packages
-rw-r--r-- | test/Makefile | 6 | ||||
-rw-r--r-- | test/lib/common.bash | 24 |
2 files changed, 23 insertions, 7 deletions
diff --git a/test/Makefile b/test/Makefile index afc3cff..c4cc021 100644 --- a/test/Makefile +++ b/test/Makefile @@ -1,8 +1,10 @@ +PACKAGE_CACHE:=$(shell mktemp -d) + test: - PATH=$(CURDIR)/../:$(CURDIR)/../cron-jobs/:$(PATH) bats test.d + PATH=$(CURDIR)/../:$(CURDIR)/../cron-jobs/:$(PATH) PACKAGE_CACHE=$(PACKAGE_CACHE) bats test.d test-coverage: - PATH=$(CURDIR)/../:$(CURDIR)/../cron-jobs/:$(PATH) kcov \ + PATH=$(CURDIR)/../:$(CURDIR)/../cron-jobs/:$(PATH) PACKAGE_CACHE=$(PACKAGE_CACHE) kcov \ --include-path=$(CURDIR)/../ \ --exclude-path=$(CURDIR)/../test,$(CURDIR)/../cron-jobs/makepkg.conf,$(CURDIR)/../config \ $(COVERAGE_DIR) \ diff --git a/test/lib/common.bash b/test/lib/common.bash index aba3336..187875b 100644 --- a/test/lib/common.bash +++ b/test/lib/common.bash @@ -25,21 +25,30 @@ __updatePKGBUILD() { svn commit -q -m"update pkg to pkgrel=${pkgrel}" } +__getCheckSum() { + local result=($(sha1sum $1)) + echo ${result[0]} +} + __buildPackage() { local arch=$1 local pkgver local pkgname local a local p + local checkSum + + if [[ -n ${PACKAGE_CACHE} ]]; then + checkSum=$(__getCheckSum PKGBUILD) + # TODO: Be more specific + if cp -av ${PACKAGE_CACHE}/${checkSum}/*-${arch}${PKGEXT}{,.sig} .; then + return 0 + fi + fi pkgname=($(. PKGBUILD; echo ${pkgname[@]})) pkgver=$(. PKGBUILD; get_full_version) - # FIXME: Avoid rebuilding of the same package - for p in ${pkgname[@]}; do - [ -f ${p}-${pkgver}-${arch}${PKGEXT} ] && return 0 - done - if [ "${arch}" == 'any' ]; then makepkg -c else @@ -49,6 +58,11 @@ __buildPackage() { for p in ${pkgname[@]}; do gpg --detach-sign --no-armor --use-agent ${p}-${pkgver}-${arch}* done + + if [[ -n ${PACKAGE_CACHE} ]]; then + mkdir -p ${PACKAGE_CACHE}/${checkSum} + cp -av *-${arch}${PKGEXT}{,.sig} ${PACKAGE_CACHE}/${checkSum}/ + fi } setup() { |