Skip to content

Commit

Permalink
feat: make version parser easier
Browse files Browse the repository at this point in the history
Change-Id: I30870bd384d19c2911a380a42bc46300ab70d3c5
  • Loading branch information
leaeasy committed Jan 16, 2018
1 parent 0e582ee commit 6d3b4ea
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions debian/rules
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,24 @@ export QT_SELECT = qt5

DEB_HOST_MULTIARCH ?= $(shell dpkg-architecture -qDEB_HOST_MULTIARCH)

export _VER=$(shell if [ ! -f .git/config ];then dpkg-parsechangelog -ldebian/changelog -SVersion | awk -F'-' '{print $$1}'; fi)
export _MAJ_VER=$(shell echo $$_VER|awk '{split($$0,vs,"."); if (length(vs[1]) == 0) print 0; else print int(vs[1]);}')
export _MIN_VER=$(shell echo $$_VER|awk '{split($$0,vs,"."); if (length(vs[2]) == 0) print 0; else print int(vs[2]);}')
export _PAT_VER=$(shell echo $$_VER|awk '{split($$0,vs,"."); if (length(vs[3]) == 0) print 0; else print int(vs[3]);}')
export _BUILD_VER=$(shell echo $$_VER|awk '{split($$0,vs,"."); if (length(vs[4]) != 0) print vs[4]; else { split(vs[3], pvs,/\+r/); if (length(pvs[2]) != 0) print int(pvs[2]); else print 0;}}')
VERSION ?= $(shell echo $$_VER|awk '{ if (length($$0)!=0) printf "%s.%s.%s.%s",${_MAJ_VER},${_MIN_VER},${_PAT_VER},${_BUILD_VER}; else printf ""; }')
ifneq (,$(wildcard .git/config))
CONFIG_VERSION=
else
VERSION = $(shell dpkg-parsechangelog -ldebian/changelog -SVersion)
_PACK_VER = $(shell echo $(VERSION) | awk -F'[+_~-]' '{print $$1}')
_BUILD_VER = $(shell echo $(VERSION) | awk -F'[+_~-]' '{print $$2}' | sed 's/[^0-9]//g')
ifeq ($(_BUILD_VER),)
CONFIG_VERSION = $(_PACK_VER)
else
CONFIG_VERSION = $(_PACK_VER).$(_BUILD_VER)
endif
endif

%:
dh $@ --parallel

override_dh_auto_configure:
dh_auto_configure -- LIB_INSTALL_DIR=/usr/lib/$(DEB_HOST_MULTIARCH) VERSION=$(VERSION)
dh_auto_configure -- LIB_INSTALL_DIR=/usr/lib/$(DEB_HOST_MULTIARCH) VERSION=$(CONFIG_VERSION)

override_dh_auto_test:
echo "skip auto test"
Expand Down

0 comments on commit 6d3b4ea

Please sign in to comment.