pkg/kamailio/alpine: Added function to build package from local git tree
authorSergey Safarov <s.safarov@gmail.com>
Sat, 1 Sep 2018 19:55:32 +0000 (19:55 +0000)
committerSergey Safarov <s.safarov@gmail.com>
Sun, 2 Sep 2018 21:55:56 +0000 (21:55 +0000)
pkg/kamailio/Makefile
pkg/kamailio/README.md
pkg/kamailio/alpine/APKBUILD

index 766c524..86f826a 100644 (file)
@@ -1,10 +1,21 @@
 # Makefile to help building packages
 
+ifneq ("$(wildcard ../../src/config.mak)","")
 include ../../src/Makefile.defs
+else ifneq ($(MAKECMDGOALS),cfg)
+$(error Please start "make cfg" first)
+endif
 
 RPMBUILD_TOP := /tmp/rpmbuild
 DIST_ARCHIVE = ${shell echo "kamailio-$(RELEASE)_src.tar.gz" | sed -e "s/-dev[0-9]//" }
+APK_VERSION = ${shell echo "$(RELEASE)" | grep -o "^[0-9.]*"}
 RPMBUILD_OPT= --define "_topdir $(RPMBUILD_TOP)"
+GIT_TAG = ${shell git rev-parse HEAD 2> /dev/null}
+
+# generate config.mak and modules.lst
+.PHONY: cfg
+cfg:
+       $(MAKE) -C ../../src cfg
 
 # generate the tarball with source tree
 .PHONY: tar
@@ -12,6 +23,16 @@ tar:
        rm -f ../../kamailio*_src.tar.gz
        $(MAKE) -C ../.. tar
 
+# build alpine apk packages
+.PHONY: apk
+apk:
+       echo Building alpine packages using commit ${GIT_TAG}
+       sed -e "s/^_gitcommit=.*/_gitcommit=${GIT_TAG}/" \
+           -e "s/^pkgver=.*/pkgver=${APK_VERSION}/" \
+           -i alpine/APKBUILD
+       cd alpine && abuild snapshot
+       @echo \"abuild\" cannot be start from Makefile please start manualy \"cd alpine \&\& abuild -r\"
+
 # build source rpm package
 .PHONY: src.rpm
 src.rpm: tar
index acf1b93..a2157f9 100644 (file)
@@ -42,7 +42,7 @@ To build RPM packages for CentOS, RHEL, Fedora, OpenSUSE and Oracle linux execut
 make rpm
 ```
 
-When utility is finished, you can see tge directory where compiled RPM files
+When utility is finished, you can see the directory where compiled RPM files
 are located.
 
 Example:
@@ -74,4 +74,16 @@ maintained, being quite old.
 
 ## Solaris ##
 
-Not actively maintained, being quite old.
\ No newline at end of file
+Not actively maintained, being quite old.
+
+## Alpine Linux ##
+
+To build apk packages please execute
+
+```
+make cfg
+make apk
+cd alpine && abuild -r
+```
+
+NOTICE: Now `abuild -r` command is failed when called from `Makefile`. This reason why need to execute command from shell.
\ No newline at end of file
index eebe8d6..4333ad9 100644 (file)
@@ -8,7 +8,7 @@ pkgver=5.1.0
 pkgrel=0
 
 # If building from a git snapshot, specify the gitcommit
-# If building a proper release, leave gitcommit blank
+# If building a proper release, leave gitcommit blank or commented
 _gitcommit=991fe9b28e0e201309048f3b38a135037e40357a
 
 [ ! -z "${_gitcommit}" ] && pkgver="${pkgver}.$(date +%Y%m%d)"
@@ -24,6 +24,7 @@ pkggroups="kamailio"
 arch="all"
 license="GPL2+"
 depends="gawk"
+options="!check"
 makedepends="bison db-dev flex freeradius-client-dev expat-dev lksctp-tools-dev perl-dev postgresql-dev python2-dev pcre-dev mariadb-dev
        libxml2-dev curl-dev unixodbc-dev confuse-dev ncurses-dev sqlite-dev
        lua-dev openldap-dev libressl-dev net-snmp-dev libuuid libev-dev
@@ -250,11 +251,22 @@ source="${pkgname}-${pkgver}${_suffix}.tar.gz::https://github.com/kamailio/$pkgn
        kamailio.initd
        "
 
+get_source_from_local_git(){
+        cd ../../.. && git archive --format=tar.gz --prefix=${pkgname}-${_gitcommit}/ -o "$SRCDEST"/${pkgname}-${pkgver}${_suffix}.tar.gz ${_gitcommit} && cd pkg/kamailio/alpine || return 1
+        echo Created dist archive "$SRCDEST"/${pkgname}-${pkgver}${_suffix}.tar.gz
+}
+
+get_source_from_github(){
+        echo Cannot create archive using local git repo. Trying create source from GutHub.
+        wget -O "$SRCDEST"/${pkgname}-${pkgver}${_suffix}.tar.gz https://github.com/kamailio/$pkgname/archive/${_gitcommit}.tar.gz || return 1
+        echo Created dist archive "$SRCDEST"/${pkgname}-${pkgver}${_suffix}.tar.gz
+}
+
 snapshot() {
         if [ ! -f "$SRCDEST"/${pkgname}-${pkgver}${_suffix}.tar.gz ]; then
-            wget -O "$SRCDEST"/${pkgname}-${pkgver}${_suffix}.tar.gz https://github.com/kamailio/$pkgname/archive/$_gitcommit.tar.gz
+            get_source_from_local_git || get_source_from_github
         fi
-        SHA512SUM=$(sha512sum "$SRCDEST"/${pkgname}-${pkgver}${_suffix}.tar.gz | sed -e "s:$SRCDEST/::")
+        SHA512SUM=$(sha512sum "$SRCDEST"/${pkgname}-${pkgver}${_suffix}.tar.gz | sed -e "s:${SRCDEST}/::")
         sed -i -e "s/^\(sha512sums=.\).*/\1$SHA512SUM/" APKBUILD
 }