File PKGBUILD of Package linphone

# Get some information about the machine we are building on:
# Fix for error: bsdtar: Failed to set default locale
# LANG=en_US.UTF-8 #not available, use C or POSIX
LANG=C
LC_ALL=${LANG}
# End fix for bsdtar locale error
_numberOfProcessorsOnMachine=$(nproc)
_wantedJobs=$(echo "1.25*${_numberOfProcessorsOnMachine}" | bc -l)
_jobsIget=$(echo ${_wantedJobs} | awk '{print int($1+0.5)}')
_TOTAL_DISK=$(df -h --total | awk 'END{print $2}')
_FREEMEM=$(free --mega)
_TOTAL_MEM=$(free --total --mega | xargs | awk '{print $19"MB"}')
_TOTAL_RAM=$(free --total --mega | xargs | awk '{print $8"MB"}')
_TOTAL_SWAP=$(free --total --mega | xargs | awk '{print $15"MB"}')
_LinphoneCoreVersion=5.3.1
pkgname=liblinphone
_pkgname=liblinphone
_patchfileprefix=linphone
pkgver=5.3.1
pkgrel=1
pkgdesc='A high-level SIP library'
arch=(x86_64 i686)
url='http://www.linphone.org'
license=('GPL')
#'belcard>=$pkgver'
depends=('belcard>=5.3.5' 'belle-sip>=5.3.5' 'mediastreamer2>=5.3.1' 'lime>=5.3.5'
  'xerces-c' 'jsoncpp')
makedepends=(cmake doxygen graphviz python-pystache python-six python-sphinx xsd
  'bctoolbox>=5.3.5' 'belle-sip>=5.3.5' 'belcard>=5.3.5' 'mediastreamer2>=5.3.1'
  'ortp>=5.3.5' 'bzrtp>=5.3.5' 'lime>=5.3.5' 'belr>=5.3.5' 'broadvoice16>=1.2'
  'bcmatroska2>=5.3.5' 'bcg729>=5.3.0'
  "liboqs>=0.7.1" "postquantumcryptoengine>=5.3.0"
  soci boost sqlite3 ffmpeg jsoncpp libdecaf libebml 'procps-ng' 'bc' 'gzip' 'zxing-cpp')
#source=("$pkgname-$pkgver.tar.bz2"
#  linphone-00-fix-pkgconfig.patch
#  linphone-05-fix-jsoncpp_static.patch
#  linphone-06-fix-LinphoneCore_version.patch
#  linphone-fix-Archlinux-compilation.patch)
source=("$pkgname-$pkgver.tar.bz2")
sha1sums=(SKIP)
_uploaddir=/usr/src/packages/SOURCES
_sourcedir=/usr/src/packages/BUILD/${pkgname}/src/${pkgname}-${pkgver}
# srcdir is already defined as
# ${srcdir}=/usr/src/packages/BUILD/${pkgname}/src
_builddir=/usr/src/packages/BUILD/${pkgname}/build
_pkgdir=/usr/src/packages/BUILD/${pkgname}/pkg/${pkgname}
_installToDir=${_pkgdir}/usr


prepare() {
  # --- Apply patches ---
  cd "$sourcedir"
  # patch -d ${pkgname}-$pkgver -p1 < ${_pkgname}-0001-fix.patch
  # patch --forward --strip=1 --input="${srcdir}/${_pkgname}-0001-fix.patch"
  # patch -d "${_sourcedir}" --forward --strip=1 --input="${srcdir}/${pkgname}-0001-fix.patch"
  # or
  # patch -d "${_sourcedir}" --forward --strip=1 --input="${_uploaddir}/${pkgname}-0001-fix.patch"
  #
  #
  # patch -d "${_sourcedir}" --forward --strip=1 --input="${_uploaddir}/${pkgname}-00-fix-pkgconfig.patch"
  # patch -d "${_sourcedir}" --forward --strip=1 --input="${_uploaddir}/${pkgname}-01-fix-build-ffmpeg5.patch"
  # patch -d "${_sourcedir}" --forward --strip=1 --input="${_uploaddir}/${pkgname}-fix-Archlinux-compilation.patch"
}



build() {
  echo "--- Entering section prepare() ---"
  echo pwd=$(pwd)
  patch -d "${_sourcedir}" --forward --strip=1 --input="${_uploaddir}/${_patchfileprefix}-00-fix-pkgconfig.patch"
  echo line 70
  patch -d "${_sourcedir}" --forward --strip=1 --input="${_uploaddir}/${_patchfileprefix}-02-reproducible.patch"
  echo line 72
  patch -d "${_sourcedir}" --forward --strip=1 --input="${_uploaddir}/${_patchfileprefix}-fix-Archlinux-compilation.patch"
  echo line 74
  ls -al
  #patch -d ${pkgname}-$pkgver -p1 < file.patch
  #patch -d ${pkgname}-$pkgver -p1 < linphone-00-fix-pkgconfig.patch
  #echo line 76
  #patch -d ${pkgname}-$pkgver -p1 < linphone-05-fix-jsoncpp_static.patch
  #echo line 78
  # patch -d ${pkgname}-$pkgver -p1 < linphone-06-fix-LinphoneCore_version.patch
  #patch -d ${pkgname}-$pkgver -p1 < linphone-fix-Archlinux-compilation.patch
  echo line 81
  # patch LinphoneCore version
  sourcedir=/usr/src/packages/BUILD/${_pkgname}/src/${_pkgname}-${pkgver}
  # Adjust Linphone core version shown in About box
  sed -i "s|project(linphone VERSION 5.2.[0-9]* LANGUAGES C CXX)|project(linphone VERSION ${_LinphoneCoreVersion} LANGUAGES C CXX)|g" $sourcedir/CMakeLists.txt
  echo "--- Exiting section prepare() ---" 
  echo
  uploaddir=/usr/src/packages/SOURCES
  builddir=/usr/src/packages/BUILD/${_pkgname}/build
  _builddir=/usr/src/packages/BUILD/${_pkgname}/src/${_pkgname}-${pkgver}/OUTPUT
  sourcedir=/usr/src/packages/BUILD/${_pkgname}/src/${_pkgname}-${pkgver}
  echo uploaddir=$uploaddir
  echo sourcedir=$sourcedir
  echo \${srcdir}=${srcdir}
  echo builddir=$builddir
  echo \${_builddir}=${_builddir}
  echo pwd=$(pwd)
  echo "--- Machine data we are building on ---"
  echo "Total disk: $_TOTAL_DISK"
  echo "Output of free -h:"
  echo "$_FREEMEM"
  echo "Total memory: $_TOTAL_MEM"
  echo "Total RAM: $_TOTAL_RAM"
  echo "Total SWAP: $_TOTAL_SWAP"
  echo "_numberOfProcessorsOnMachine=$_numberOfProcessorsOnMachine"
  echo "_wantedJobs=$_wantedJobs"
  echo "_jobsIget=$_jobsIget"
  echo "--- End machine data we are building on ---"
  #echo "--- List files ---"
  #echo "Avoid /usr/src/packages/BUILD/$pkgname/pkg"
  #echo "which will break compilation with \"permission denied\"."
  #find /usr/src/packages/SOURCES 2>/dev/null
  #find /usr/src/packages/BUILD/$pkgname/src 2>/dev/null
  #find /usr/lib 2>/dev/null
  #find /usr/include
  #echo "--- End list files ---"
  echo
  echo
  echo CMAKE_MODULE_PATH=${CMAKE_MODULE_PATH}
  echo
  cd "$pkgname-$pkgver"
  echo srcdir=${srcdir}
  echo buildroot=$
  #
  # We need to add Findjsoncpp.cmake
  # We can copy Findjsoncpp.cmake:
  # cp /usr/src/packages/SOURCES/Findjsoncpp.cmake /usr/src/packages/BUILD/$pkgname/src/$pkgname-$pkgver/cmake/.
  # or add
  # /usr/src/packages/SOURCES
  # to variable CMAKE_MODULE_PATH
  #
  cmake -S ${sourcedir} -B ${builddir} \
    -DCMAKE_BUILD_PARALLEL_LEVEL=${_jobsIget} \
    -DCMAKE_INSTALL_PREFIX=/usr \
    -DCMAKE_MODULE_PATH="$CMAKE_MODULE_PATH;/usr/src/packages/SOURCES" \
    -DCMAKE_VERBOSE_MAKEFILE=YES \
    -DENABLE_UNIT_TESTS=OFF \
    -DENABLE_TOOLS=OFF     \
    -DENABLE_DOC=OFF \
    -DENABLE_QRCODE=OFF \
    -DENABLE_STATIC=OFF \
    -DENABLE_STRICT=OFF
  cmake --build ${builddir} --parallel ${_jobsIget}
}



package() {
  echo
  uploaddir=/usr/src/packages/SOURCES
  builddir=/usr/src/packages/BUILD/${_pkgname}/build
  _builddir=/usr/src/packages/BUILD/${_pkgname}/src/${_pkgname}-${pkgver}/OUTPUT
  sourcedir=/usr/src/packages/BUILD/${_pkgname}/src/${_pkgname}-${pkgver}
  echo uploaddir=$uploaddir
  echo sourcedir=$sourcedir
  echo \${srcdir}=${srcdir}
  echo builddir=$builddir
  echo \${_builddir}=${_builddir}
  echo pwd=$(pwd)
  echo
  DESTDIR="$pkgdir" cmake --install ${builddir} --strip
}
openSUSE Build Service is sponsored by