File PKGBUILD of Package broadvoice16

# Get some information about the machine we are building on:
_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"}')
_static=0
_shared=1
_tools=1
_pkgname=broadvoice16
_alt_pkgname=bv16-floatingpoint
pkgname=broadvoice16
pkgver=1.2
pkgrel=1
pkgdesc="BroadVoice 16 Speech Codec"
arch=(x86_64)
url="https://gitlab.linphone.org/BC/public/external/${_alt_pkgname}"
license=(GPL)
depends=(glibc)
makedepends=('cmake' 'git' 'tar' 'procps-ng' 'bc' 'gzip' 'unzip' 'meson')
source=("BroadVoice16OpenSource.v1.2.zip")
sha256sums=('SKIP')



prepare() {
  echo "--- This section is not visible in log ---"
  echo "--- Entering section prepare() ---"
  echo "--- Exiting section prepare() ---" 
}



build() {
  echo "--- Entering section build() ---"
  uploaddir=/usr/src/packages/SOURCES
  _installToDir=${pkgdir}/usr
  sourcedir=/usr/src/packages/BUILD/${_pkgname}/src/${_pkgname}-${pkgver}
  _builddir=${sourcedir}/OUTPUT
  echo sourcedir=$sourcedir
  echo \${srcdir}=${srcdir}
  echo \${_builddir}=${_builddir}
  echo \${builddir}=${builddir}
  echo _installToDir=$_installToDir
  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 ---"
  mkdir -p "${_builddir}"
  
  # The extraction does not behave like in OpenSUSE SPEC file. The archive is extracted though,
  # but with top directory which OpenSUSE SPEC file removes.
  # 
  # If you want to only remove one level of directories from the archive, 
  # (extract myarchive/dir/file as dir/file, not file), you could use bsdtar 
  # (which does supports zip files in addition to tar files) instead and its -s option.
  #
  # bsdtar -xf /path/to/file.zip -s'|[^/]*/||'
  #
  # or
  #
  # bsdtar --strip-components=1 -xvf file.zip
  #

  # Extract zip file without first directory like in RPM SPEC file
  # bsdtar -xf /usr/src/packages/BUILD/broadvoice16/src/BroadVoice16OpenSource.v1.2.zip -s'|[^/]*/||'
  # bsdtar -xf ${srcdir}/BroadVoice16OpenSource.v1.2.zip -s'|[^/]*/||'
  # find ${srcdir}
  
  cp -v ${uploaddir}/COPYING ${uploaddir}/README ${uploaddir}/README.SUSE ${srcdir}/BroadVoice16/.
  cp -v ${uploaddir}/meson_options.txt ${uploaddir}/meson.build ${srcdir}/BroadVoice16/FloatingPoint/.
  
  
  echo "--- List files ---"
  ls -al /usr/src/packages/BUILD
  find ${srcdir}
  echo "--- End list files ---"

  echo "--- Start apply patches ---"
  # ${srcdir}=/usr/src/packages/BUILD/${_pkgname}/src
  # patch file: /usr/src/packages/BUILD/${_pkgname}/src/myFixErrorDuringCompilation.patch
  cd "$sourcedir"
  # myPatchFileOne=myFixErrorDuringCompilation.patch
  # myPatchFileTwo=
  # myPatchFileThree=
  # patch --forward --strip=1 --input="${srcdir}/${myPatchFileOne}"
  # patch --forward --strip=1 --input="${srcdir}/${myPatchFileTwo}"
  # patch --forward --strip=1 --input="${srcdir}/${myPatchFileThree}"
  # or
  # patch --forward --strip=1 --input="${uploaddir}/${myPatchFileOne}"
  # patch --forward --strip=1 --input="${uploaddir}/${myPatchFileTwo}"
  # patch --forward --strip=1 --input="${uploaddir}/${myPatchFileThree}"  
  echo "--- End apply patches ---"
  
  cd "${_builddir}"
  echo
  echo "Current directory:"
  echo "   $(pwd)"
  echo
  
  # Trying to replicate the SPEC-file. Error: then unexpected. FIX THIS!   
  # meson ${srcdir}/BroadVoice16/FloatingPoint \
  # if [ ${static} -eq 1 ]; then \
  #     -Dstatic_libs=true \; \
  # fi
  # if [ ! ${shared} -eq 1 ]; then \
  #     -Dshared_libs=false \; \
  # fi
  # if [ ! ${tools} -eq 1 ]; then\
  #    -Dbuild_tools=false \; \
  # fi
  
  echo "meson ${srcdir}/BroadVoice16/FloatingPoint -Dstatic_libs=false -Dprefix=\"${_installToDir}\""
  meson ${srcdir}/BroadVoice16/FloatingPoint -Dstatic_libs=false -Dprefix="${_installToDir}"
  
  # Buildfiles are in /usr/src/packages/BUILD/broadvoice16/src/broadvoice16-1.2.0/OUTPUT
  # ${_builddir}=/usr/src/packages/BUILD/broadvoice16/src/broadvoice16-1.2.0/OUTPUT
  ninja -C ${_builddir} -j ${_jobsIget}
  echo
  echo "Current directory:"
  echo "   $(pwd)"
  echo
  echo "--- Show what was built ---"
  find ${builddir}
  echo "--- End show what was built ---"
  echo "--- Exiting section build() ---"
}



package() {
  echo "--- Entering section package() ---"
  _installToDir=${pkgdir}/usr
  builddir=/usr/src/packages/BUILD/${_pkgname}/build
  sourcedir=/usr/src/packages/BUILD/${_pkgname}/src/${_pkgname}-${pkgver}
  _builddir=${sourcedir}/OUTPUT
  echo builddir=$builddir
  echo sourcedir=$sourcedir
  echo \${srcdir}=${srcdir}
  echo \${_builddir}=${_builddir}
  echo \${builddir}=${builddir}
  echo _installToDir=${_installToDir}
  mkdir -p "${_builddir}"
  echo pwd=$(pwd)
  rm -rf "$pkgdir"
  mkdir -p "$pkgdir"
  cd "${_builddir}"

  #
  # meson --reconfigure --prefix=/usr/src/packages/BUILD/debian/tmp
  #
  ninja -C ${_builddir} install -j ${_jobsIget}
  echo
  echo
  echo
  echo
  echo
  echo "--- List packaged files ---"
  find ${pkgdir}
  echo "--- End list packaged files ---"
  echo
  echo
  echo
  echo
  echo
  echo "--- Exiting section package() ---"
}
openSUSE Build Service is sponsored by