1
0
mirror of https://github.com/qTox/qTox.git synced 2024-03-22 14:00:36 +08:00
qTox/tools/buildPackages.sh

111 lines
3.2 KiB
Bash
Raw Normal View History

2014-09-02 02:45:48 +08:00
#!/bin/bash
# Config (Update me if needed !)
VERSION_UPSTREAM="1.0"
VERSION_PACKAGE="1"
PACKAGENAME="qtox"
UPSTREAM_URL="https://github.com/tux3/qTox/archive/master.tar.gz"
# Make some vars for convenience
VERNAME=$PACKAGENAME"_"$VERSION_UPSTREAM
FULLVERNAME=$VERNAME"-"$VERSION_PACKAGE
ARCHIVENAME=$VERNAME".orig.tar.gz"
# ARCHIVENAME > FULLVERNAME > VERNAME = PACKAGENAME+UPVER
2014-09-02 03:09:31 +08:00
# Get some args
OPT_SUDO=true
OPT_APT=true
OPT_KEEP=false
while [ $# -ge 1 ] ; do
if [ ${1} = "-s" -o ${1} = "--no-sudo" ] ; then
OPT_SUDO=false
shift
elif [ ${1} = "-a" -o ${1} = "--no-apt" ] ; then
OPT_APT=false
shift
elif [ ${1} = "-k" -o ${1} = "--keep" ]; then
OPT_KEEP=true
shift
else
if [ ${1} != "-h" -a ${1} != "--help" ] ; then
echo "[ERROR] Unknown parameter \"${1}\""
echo ""
fi
# print help
echo "Use this script to build qTox packages for Debian and Red Hat families"
echo ""
echo "usage:"
echo " ${0} [-h|--help|-k|--keep|-s|--no-sudo|-a|--no-apt]"
echo ""
echo "parameters:"
echo " -h|--help : displays this help"
echo " -s|--no-sudo: disables using sudo for apt and alien"
echo " -a|--no-apt : disables apt-get (used for build deps) entirely"
echo " -k|--keep : does not delete the build files afterwards"
echo ""
echo "example usages:"
echo " ${0} -- build packages, cleaning up trash and running sudo alien and apt-get"
echo " ${0} -s -k -- build packages, keeping build files and non-sudo alien and apt-get"
exit 1
fi
done
2014-09-02 02:45:48 +08:00
# Get the requried tools if needed
2014-09-02 03:09:31 +08:00
if [[ $OPT_APT = "true" ]]; then
echo "Installing missing tools (if any)..."
if [[ $EUID -ne 0 && $OPT_SUDO = "true" ]]; then
2014-09-28 06:43:01 +08:00
sudo apt-get install wget debhelper cdbs devscripts alien tar gzip build-essential sudo autoconf libtool pkg-config libvpx-dev -y
2014-09-02 03:09:31 +08:00
else
2014-09-28 06:43:01 +08:00
apt-get install wget debhelper cdbs devscripts alien tar gzip build-essential sudo autoconf libtool pkg-config libvpx-dev -y
2014-09-02 03:09:31 +08:00
fi
2014-09-02 02:45:48 +08:00
fi
# Get the requried dependencies if needed
if [[ $OPT_APT = "true" ]]; then
echo "Installing missing dependencies (if any)..."
if [[ $EUID -ne 0 && $OPT_SUDO = "true" ]]; then
sudo apt-get install qt5-qmake libopenal-dev libopencv-dev libopus-dev -y
else
apt-get install qt5-qmake libopenal-dev libopencv-dev libopus-dev -y
fi
fi
2014-09-02 02:45:48 +08:00
mkdir -p .packages
cd .packages
# Cleanup
rm -r $VERNAME 2> /dev/null
rm $ARCHIVENAME 2> /dev/null
# Fectch sources and layout directories
wget -O $ARCHIVENAME $UPSTREAM_URL
2014-09-02 03:09:31 +08:00
tar xvf $ARCHIVENAME 2> /dev/null # Extracts to qTox-master
2014-09-02 02:45:48 +08:00
mv qTox-master $VERNAME
#tar cz $VERNAME > $ARCHIVENAME
# Build packages
cd $VERNAME
2014-10-06 13:49:26 +08:00
./bootstrap.sh --local
debuild -us -uc -aamd64
debuild -us -uc -ai386
2014-09-02 02:45:48 +08:00
cd ..
# alien warns that it should probably be run as root...
2014-09-02 03:09:31 +08:00
if [[ $EUID -ne 0 && $OPT_SUDO = "true" ]]; then
sudo alien ./$FULLVERNAME*.deb -r
2014-09-02 02:45:48 +08:00
else
2014-09-02 03:09:31 +08:00
alien ./$FULLVERNAME*.deb -r
2014-09-02 02:45:48 +08:00
fi
mv *.deb ..
2014-09-02 03:09:31 +08:00
mv -f *.rpm ..
if [[ $OPT_KEEP = "false" ]]; then
rm -r *
fi
2014-09-02 02:45:48 +08:00
cd ..
2014-09-02 03:09:31 +08:00
rmdir .packages 2> /dev/null # fails if non empty