2024-01-31 16:47:17 +03:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
set -e
|
|
|
|
|
|
|
|
usage() {
|
|
|
|
echo "Usage: $(basename "$0") [-h] [-a <x64|armv7l|arm64|all> default=x64]"
|
|
|
|
echo
|
|
|
|
echo " Options:"
|
|
|
|
echo " -a Architecture to build for (<x64|armv7l|arm64|all> default=x64)"
|
|
|
|
echo " -h Show this help and exit"
|
|
|
|
}
|
|
|
|
|
2024-03-09 12:37:35 +03:00
|
|
|
prepare_tarball(){
|
2024-02-15 16:39:22 +03:00
|
|
|
arch=${1}
|
2024-03-09 12:37:35 +03:00
|
|
|
echo "Preparing tarball for ${arch}"
|
|
|
|
if [ ! -f "tar/yandex-music_${version}_${arch}.tar.gz" ]; then
|
|
|
|
echo "Building tarball for ${arch}"
|
|
|
|
bash build_tarball.sh -a "${arch}"
|
|
|
|
fi
|
|
|
|
cp "tar/yandex-music_${version}_${arch}.tar.gz" "${TEMPDIR}/yandex-music_${version}_${arch}.tar.gz"
|
2024-02-15 16:39:22 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
build_deb(){
|
|
|
|
arch=${1}
|
|
|
|
pkgarch=${2}
|
|
|
|
|
|
|
|
echo "Building ${arch} package"
|
|
|
|
pkgdir="${TEMPDIR}/yandex-music-${arch}"
|
|
|
|
|
|
|
|
mkdir -p "${pkgdir}/DEBIAN"
|
|
|
|
cp "./templates/control" "${pkgdir}/DEBIAN/control"
|
|
|
|
sed -i "s/%version%/${version}/g" "${pkgdir}/DEBIAN/control"
|
|
|
|
sed -i "s/%arch%/${pkgarch}/g" "${pkgdir}/DEBIAN/control"
|
|
|
|
|
2024-03-09 12:37:35 +03:00
|
|
|
# extract tarball to pkgdir
|
|
|
|
tar -xzf "${TEMPDIR}/yandex-music_${version}_${arch}.tar.gz" -C "${pkgdir}"
|
2024-02-15 16:39:22 +03:00
|
|
|
|
|
|
|
dpkg-deb --build "${pkgdir}" "deb/yandex-music_${version}_${pkgarch}.deb"
|
|
|
|
}
|
|
|
|
|
|
|
|
x64=0
|
2024-01-31 16:47:17 +03:00
|
|
|
armv7l=0
|
|
|
|
arm64=0
|
|
|
|
|
|
|
|
#checking for arch option (if not specified set x64) and h option
|
|
|
|
while getopts :a:h name; do
|
2024-02-15 16:39:22 +03:00
|
|
|
case ${name} in
|
2024-01-31 16:47:17 +03:00
|
|
|
a)
|
2024-02-15 16:39:22 +03:00
|
|
|
case ${OPTARG} in
|
|
|
|
x64) x64=1 ;;
|
|
|
|
armv7l) armv7l=1 ;;
|
|
|
|
arm64) arm64=1 ;;
|
2024-01-31 16:47:17 +03:00
|
|
|
all)
|
|
|
|
x64=1
|
|
|
|
armv7l=1
|
|
|
|
arm64=1
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
echo "Invalid architecture specified"
|
|
|
|
usage
|
|
|
|
exit 1
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
;;
|
|
|
|
h)
|
|
|
|
usage
|
|
|
|
exit 0
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
usage
|
|
|
|
exit 1
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
done
|
|
|
|
|
2024-02-15 16:39:22 +03:00
|
|
|
#checking if at least one arch is specified else set x64
|
|
|
|
if [ ${x64} -eq 0 ] && [ ${armv7l} -eq 0 ] && [ ${arm64} -eq 0 ]; then
|
|
|
|
x64=1
|
|
|
|
fi
|
|
|
|
|
2024-01-31 16:47:17 +03:00
|
|
|
clear() {
|
2024-02-15 16:39:22 +03:00
|
|
|
rm -rf "${TEMPDIR}"
|
2024-01-31 16:47:17 +03:00
|
|
|
}
|
|
|
|
TEMPDIR="$(mktemp -d)"
|
|
|
|
trap clear EXIT
|
|
|
|
|
|
|
|
#loading version info with jq
|
2024-02-18 21:00:32 +03:00
|
|
|
version=$(jq -r '.ym.version' ./utility/version_info.json)
|
2024-01-31 16:47:17 +03:00
|
|
|
|
|
|
|
mkdir -p "deb"
|
|
|
|
|
2024-02-15 16:39:22 +03:00
|
|
|
if [ ${x64} -eq 1 ]; then
|
2024-03-09 12:37:35 +03:00
|
|
|
prepare_tarball "x64"
|
2024-02-15 16:39:22 +03:00
|
|
|
build_deb "x64" "amd64"
|
2024-01-31 16:47:17 +03:00
|
|
|
fi
|
|
|
|
|
2024-02-15 16:39:22 +03:00
|
|
|
if [ ${armv7l} -eq 1 ]; then
|
2024-03-09 12:37:35 +03:00
|
|
|
prepare_tarball "armv7l"
|
2024-02-15 16:39:22 +03:00
|
|
|
build_deb "armv7l" "armhf"
|
2024-01-31 16:47:17 +03:00
|
|
|
fi
|
|
|
|
|
2024-02-15 16:39:22 +03:00
|
|
|
if [ ${arm64} -eq 1 ]; then
|
2024-03-09 12:37:35 +03:00
|
|
|
prepare_tarball "arm64"
|
2024-02-15 16:39:22 +03:00
|
|
|
build_deb "arm64" "arm64"
|
2024-01-31 16:47:17 +03:00
|
|
|
fi
|