initial version

This commit is contained in:
Penelope Gwen 2024-04-22 14:33:44 -06:00
parent 26890265a1
commit c41e6f1ad7
5 changed files with 91 additions and 0 deletions

8
clean.sh Executable file
View file

@ -0,0 +1,8 @@
#!/bin/bash
script_root=$(dirname $0)
find "${script_root}" -name "*.deb" -delete
if [[ -d "${script_root}/tmp" ]];then
rm -r "${script_root}/tmp"
fi

75
package.sh Executable file
View file

@ -0,0 +1,75 @@
#!/bin/bash
package_name="scrcpy"
verlte() {
printf '%s\n' "$1" "$2" | sort -C -V
}
verlt() {
! verlte "$2" "$1"
}
installed_version=$( scrcpy --version | head -n 1 | cut -d ' ' -f 2);[[ -z ${installed_version} ]] && installed_version="0.0.0"
github_metadata=$( curl -s https://api.github.com/repos/Genymobile/scrcpy/releases/latest )
tarball_url=$( echo "${github_metadata}" | grep 'tarball_url' | head -n 1 | cut -d '"' -f 4 )
server_url=$( echo "${github_metadata}" | grep "server" | grep 'browser_download_url' | head -n 1 | cut -d '"' -f 4 )
tarball_version=$( echo "${github_metadata}" | grep 'tag_name' | head -n 1 | cut -d '"' -f 4 | tr -d 'v' )
echo $server_url
echo $tarball_url
echo $tarball_version
echo $installed_version
if verlt $installed_version $tarball_version || [[ "$1" == "force" ]]; then
echo "proceeding..."
else
echo "already up-to-date!"
exit
fi
script_root=$( realpath $(dirname $0) )
src_dir="${script_root}/src/"
src_deb_dir="${src_dir}/debian"
work_dir="${script_root}/tmp"; rm -r "${work_dir}" # clean work dir
dl_dir="${work_dir}/dl";mkdir -p "${dl_dir}" # location to store downloaded tarball
wget "${tarball_url}" -O "${dl_dir}/${package_name}-${tarball_version}.tar.gz" # download tarball
wget "${server_url}" -O "${dl_dir}/scrcpy-server"
tarball_path=$( find "${dl_dir}" -name "*.tar.gz" | head -n 1 ); #locate downloaded tarball
source_dir="${work_dir}/src" # where the program source be extracted/worked on
build_dir="${work_dir}/${package_name}-${tarball_version}" #debuild dir name
mkdir -p "${source_dir}"; tar -C "${source_dir}" -xf "${tarball_path}" --strip-components 1 # extract tarball into deb template
cd "${source_dir}"
meson setup build --buildtype=release --strip -Db_lto=true -Dprebuilt_server="${dl_dir}/scrcpy-server" -Dprefix="${build_dir}"
ninja -C build
ninja -C build/ install
cd "${build_dir}"; dh_make -sy -f "${tarball_path}"; cd "${script_root}"
build_deb_dir="${build_dir}/debian"
sed '/Depends:/a \ ffmpeg' "${build_deb_dir}/control"
sed '/Depends:/a \ adb' "${build_deb_dir}/control"
sed '/Depends:/a \ libsdl2-2.0-0' "${build_deb_dir}/control"
sed '/Depends:/a \ libusb-1.0-0' "${build_deb_dir}/control"
cp "${src_deb_dir}/"* "${build_deb_dir}"
find "${build_dir}" -type f -not -path "${build_deb_dir}*" | tee "${build_deb_dir}/source/include-binaries"
sed -i 's;'"${build_dir}"'/;;' "${build_deb_dir}/source/include-binaries"
echo "override_dh_shlibdeps:" >> "${build_deb_dir}/rules"
echo " dh_shlibdeps --dpkg-shlibdeps-params=--ignore-missing-info" >> "${build_deb_dir}/rules"
cd "${build_dir}"
EDITOR=/bin/true dpkg-source -q --commit . "prepdeb"
debuild
cd "${script_root}"
mv "${work_dir}/"*.deb "${script_root}/"
rm -r "${work_dir}"

2
src/debian/install Normal file
View file

@ -0,0 +1,2 @@
bin/* /usr/bin/
share/* /usr/share/

3
src/debian/postinst Executable file
View file

@ -0,0 +1,3 @@
#!/bin/bash
#ln -s "/usr/lib/$(uname -m)-linux-gnu/libwlroots.so.11" /usr/lib/

3
src/debian/postrm Executable file
View file

@ -0,0 +1,3 @@
#!/bin/bash
#rm /usr/lib/libwlroots.so.11