Last active
February 23, 2017 20:14
-
-
Save nathanross/c962de32be11a93d0444 to your computer and use it in GitHub Desktop.
Install Sway on Debian Jessie
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# | |
# This program is free software: you can redistribute it and/or modify | |
# it under the terms of the GNU General Public License as published by | |
# the Free Software Foundation, either version 3 of the License, or | |
# (at your option) any later version. | |
# | |
# This program is distributed in the hope that it will be useful, | |
# but WITHOUT ANY WARRANTY; without even the implied warranty of | |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
# GNU General Public License for more details. | |
# | |
# A copy of the GNU General Public License can be found at <http://www.gnu.org/licenses/>. | |
# Proof-of-concept installation script for sway on debian 8.x ("jessie") | |
# on an amd64 pc. debian jessie is the current "debian stable" | |
# this can be run as a script, but bash is fragile and this may not | |
# work depending on the particularities of your setup, so I would suggest | |
# just treating it as a guide so if at some point something doesn't | |
# work at one step of a process, it's very clear where and why. | |
main() { | |
asRoot | |
getRecentCmake | |
getRecentWayland | |
installWlc | |
installSway | |
} | |
getRecentCmake() { | |
# cmake from website is statically linked | |
# whereas installing it from stretch means installing dynamic | |
# libs as well as upgrading packages that the newer version | |
# may make use of the newer cmake, but the newer version | |
# is not necessary to install sway. e.g. libreoffice. | |
if [[ -e /usr/bin/cmake && ! `cmake --version | grep -i 3.0` ]]; then return 0; fi | |
log 1 "getting recent Cmake (stable+backports has 3.0.2, 3.1 is expected)" | |
CMAKE_URL=https://cmake.org/files/v3.3/cmake-3.3.2-Linux-x86_64.tar.gz | |
CMAKE_ARCHIVE=`basename $CMAKE_URL` | |
mkdtmp dirCmake | |
log 2 "downloading ... this may take several seconds." | |
wget -q $CMAKE_URL -O $dirCmake/$CMAKE_ARCHIVE | |
tar xf $dirCmake/$CMAKE_ARCHIVE -C $dirCmake | |
log 2 "extracting" | |
extractedTo=$dirCmake/`basename $CMAKE_ARCHIVE .tar.gz` | |
cp -R $extractedTo/* / | |
cp -R $extractedTo/bin/* /usr/bin/ | |
for f in cmake ccmake cpack cpack-gui ctest; | |
do | |
rm -f /usr/bin/$f | |
ln -s /bin/$f /usr/bin/$f | |
done | |
cd /tmp | |
rm -r $dirCmake | |
} | |
getRecentWayland() { | |
# You will need a newer version, or the cmake will pass but the | |
# make will fail as the code will not compile correctly. | |
#if we already have a recent enough version, skip. | |
waylandHeader=/usr/include/wayland-server-protocol.h | |
if [[ -e $waylandHeader && `grep -Ei "release.*data device" $waylandHeader` ]]; then return 0; fi | |
log 1 "getting recent Wayland (stable+backports has 1.6, 1.9 is expected) and other Wlc dependencies as needed" | |
echo "deb http://http.debian.net/debian stretch main contrib" > /etc/apt/sources.list.d/stretch.list | |
log 2 "adding debian stretch repo and running apt-get update" | |
apt-get -qq update | |
# libdrm is not part of wayland, but a more recent version is also | |
# required by wlc, so it's also fetched here. | |
log 2 "installing packages" | |
apt-get -qqy install libgles2-mesa-dev libdrm2 libdrm-dev libegl1-mesa-dev xwayland || exit 1 | |
rm /etc/apt/sources.list.d/stretch.list | |
log 2 "rm debian stretch repo and running apt-get update" | |
apt-get -qqy update | |
} | |
installWlc() { | |
#if we already have wlc we can skip this. | |
if [ -e /usr/include/wlc ]; then return 0; fi | |
log 1 "getting WLC" | |
mkdtmp dirWlc | |
while [ ! -e $dirWlc ]; do | |
sleep 0.01 | |
done | |
log 2 "cloning repo" | |
git clone --quiet https://github.com/Cloudef/wlc.git $dirWlc | |
cd $dirWlc | |
git submodule update --quiet --init --recursive || exit 1 | |
log 2 "installing dependencies for which only trusty v. is req'd " | |
apt-get -qqy install build-essential libinput5 libinput-dev libxkbcommon0 libxkbcommon-dev libudev-dev libxcb-ewmh-dev libxcb-image0 libxcb-image0-dev libxcb-composite0 libxcb-composite0-dev libxcb-xkb1 libxcb-xkb-dev libgbm1 libgbm-dev libdbus-1-dev libsystemd-dev zlib1g-dev libpixman-1-dev || exit 1 | |
mkdir target | |
cd target | |
log 2 "configuring" | |
export errlog=`cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/usr/ .. 2>&1` || dumpErrlog | |
log 2 "compiling and installing " | |
export errlog=`make 2>&1 && make install 2>&1` || dumpErrlog | |
cd /tmp | |
rm -r $dirWlc | |
} | |
installSway() { | |
# we don't do an idempotency check here because we're assuming | |
# a user would only run this script if they to install the latest | |
# version of sway. Making a script that was both idempotent | |
# and allowed for easy upgrading of sway would require the | |
# use of args or env. variables; it's a complexity tradeoff. | |
log 1 "getting Sway" | |
mkdtmp dirSway | |
while [ ! -e $dirSway ]; do | |
sleep 0.01 | |
done | |
log 2 "cloning repo" | |
git clone --quiet https://github.com/SirCmpwn/sway.git $dirSway | |
log 2 "installing dependencies" | |
apt-get -qqy install libpcre3 libpcre3-dev libcairo2 libcairo2-dev libpango1.0-0 libpango1.0-dev asciidoc libjson-c2 libjson-c-dev || exit $? | |
log 2 "configuring" | |
cd ${dirSway} | |
export errlog=`cmake ${dirSway} . 2>&1` || dumpErrlog | |
log 2 "compiling and installing " | |
export errlog=`make 2>&1 && make install 2>&1` || dumpErrlog | |
log 1 "complete. as your regular username (not root) please create your sway config" | |
log 1 "if you have never used i3 or sway copy /etc/sway/config to ~/.config/sway/config/ (you may need to make the directory first) " | |
log 1 "if you have used i3 and have a config, copy ~/.i3/config to ~/.config/sway/config/ (you may need to make the directory first) " | |
cd /tmp | |
rm -r $dirSway | |
} | |
dumpErrlog() { | |
echo -e $errlog | |
exit 1 | |
} | |
log() { | |
i=0; | |
while [ $i -lt $1 ]; do | |
printf "\t" | |
i=`expr $i + 1` | |
done | |
echo -ne "$2\n" | |
} | |
asRoot() { | |
#in most cases to install systemwide you will need root privileges | |
if [ `whoami` != "root" ]; | |
then | |
echo "error: you must run this script as root"; exit 1; | |
fi | |
} | |
mkdtmp() { | |
# utility function used by other functions to create temporary directories | |
# in tmp to avoid name conflicts | |
local -n l=$1; | |
l=`mktemp -d 2>/dev/null || mktemp -d -t 'mytmpdir'`; | |
} | |
main $@ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This script doesn't work because
libgbm1
is a higher version thanlibgbm-dev
, and both are trying to be installed.To fix this, simple remove
libgbm-dev
from the install list in WLC, as I made to my fork.