Skip to content

Commit

Permalink
Merge pull request #1637 from sergey-safarov/spec_update
Browse files Browse the repository at this point in the history
[5.1] pkg/docker: Updated submodule
  • Loading branch information
miconda committed Sep 6, 2018
2 parents e747a53 + 6783a66 commit 216f8de
Show file tree
Hide file tree
Showing 4 changed files with 159 additions and 4 deletions.
2 changes: 1 addition & 1 deletion pkg/docker
54 changes: 54 additions & 0 deletions pkg/kamailio/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# 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
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
mkdir -p ${RPMBUILD_TOP}/SOURCES
mv ../../kamailio-$(RELEASE)_src.tar.gz ${RPMBUILD_TOP}/SOURCES/${DIST_ARCHIVE}
sed -i -e 's/setup -n %{name}-%{ver}/setup -n kamailio-$(RELEASE)/' obs/kamailio.spec
rpmbuild ${RPMBUILD_OPT} -bs obs/kamailio.spec
mv ${RPMBUILD_TOP}/SRPMS/kamailio-$(RELEASE).*.src.rpm ../..
rm -Rf ${RPMBUILD_TOP}

# build rpm packages
.PHONY: rpm
rpm: src.rpm
mock ../../kamailio-$(RELEASE).*.src.rpm

# build debian packages
.PHONY: deb
deb:
$(MAKE) -C ../.. deb
89 changes: 89 additions & 0 deletions pkg/kamailio/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
# Kamailio Packaging #

The `pkg/kamailio/` directory contains packaging specs for several operation systems.

Currently the DEB and RPM specs are actively maintained, the rest are still kept
in case someone wants to pick up and update.

## DEBS ##

DEB packages can be generated for several flavours of Debian and Ubuntu
operating systems.

To generate deb packages, run:

```
make deb
```

This is using a generic Debian spec. To select a specific Debian or Ubuntu, go
to root folder of Kamailio source tree, create a `debian` symlink to the
desired distro from `pkg/kamailio/deb/` and run `make deb`. For example,
on a Debian Stretch (9.x), do:

```
ln -s pkg/kamailio/deb/stretch debian
make deb
```

The DEB files are generated in the parent folder.

## RPMS ##

There are couple of variants of RPM specs. The most actual one is stored in `obs/`
subfolder and has conditional options to build for many operating systems that
use RPM for packages (e.g., CenOS, RedHat, Fedora, OpenSuse). The folders with
the name reflecting an operating system might be older, some not really
maintained.

To build RPM packages for CentOS, RHEL, Fedora, OpenSUSE and Oracle linux execute

```
make rpm
```

When utility is finished, you can see the directory where compiled RPM files
are located.

Example:

```
Finish: rpmbuild kamailio-5.2.0-dev1.0.fc25.src.rpm
Finish: build phase for kamailio-5.2.0-dev1.0.fc25.src.rpm
INFO: Done(../../kamailio-5.2.0-dev1.0.fc25.src.rpm) Config(default) 8 minutes 30 seconds
INFO: Results and/or logs in: /var/lib/mock/fedora-25-x86_64/result
Finish: run
```

The `obs` folder aims at using it also in OpenSuse Build Service.

* https://build.opensuse.org

Kamailio build project on OBS is at:

* https://build.opensuse.org/project/show/home:kamailio

## Gentoo ##

Not actively mentained, still fairly recent updated.

## BSD ##

There are specs for FreeBSD, NetBST and OpenBSD. They are not actively
maintained, being quite old.

## Solaris ##

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.
18 changes: 15 additions & 3 deletions pkg/kamailio/alpine/APKBUILD
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ pkgver=5.1.5
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)"
Expand All @@ -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
Expand Down Expand Up @@ -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
}

Expand Down

0 comments on commit 216f8de

Please sign in to comment.