-
-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathsetup-rofi
executable file
·93 lines (76 loc) · 2.51 KB
/
setup-rofi
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
#!/usr/bin/env bash
set -euo pipefail
function get_latest_reposiotry() {
local repo_uri="${1}"
local repo_dir="${2}"
echo "Repository URI: ${repo_uri}"
if [[ ! -d "${repo_dir}" ]]; then
echo "Cloning repository..."
mkdir -p "$(dirname "${repo_dir}")"
git clone --quiet --recursive --depth 10 "${repo_uri}" "${repo_dir}"
pushd "${repo_dir}" >/dev/null
else
echo "Pulling latest commits..."
pushd "${repo_dir}" >/dev/null
git pull
git submodule update --init
fi
popd >/dev/null
}
function setup_python_package() {
local package_name="${1}"
if test "$(pyenv version-name | cut -d'.' -f1)" != "3"; then
echo "Python 3 is required!"
exit 1
fi
echo "Installing Python package: ${package_name}"
pip install --quiet "${package_name}"
}
function setup_apt_packages() {
echo "Installing packages: $*"
sudo apt-get install -qq --yes "$@"
}
function link_binary() {
local binary_name="${1}"
echo "Setting up binary: ${binary_name}"
sudo ln -nsf "${HOME}/.local/bin/${binary_name}" "/usr/local/bin/${binary_name}"
}
function setup_rofi() {
local branch="${1}"
get_latest_reposiotry "https://github.com/davatorium/rofi" "${HOME}/Dev/github/davatorium/rofi"
pushd "${HOME}/Dev/github/davatorium/rofi" >/dev/null
if [[ "$(git branch --show-current)" != "${branch}" ]]; then
echo ""
echo "Run the following command to checkout '${branch}' branch:"
echo " git -C ${HOME}/Dev/github/davatorium/rofi checkout ${branch}"
echo ""
echo "And run the script again:"
echo " setup-rofi ${branch}"
exit 1
fi
echo "Installing dependencies..."
if [[ "${branch}" = "master" ]]; then
setup_python_package meson
fi
setup_apt_packages build-essential cppcheck flex libbison-dev libgif-dev libjpeg-dev libnl-3-dev libpango1.0-dev librsvg2-dev libstartup-notification0-dev libxcb-cursor-dev libxcb-ewmh-dev libxcb-icccm4-dev libxcb-randr0-dev libxcb-util-dev libxcb-xinerama0-dev libxcb-xkb-dev libxcb-xrm-dev libxcb1-dev libxkbcommon-x11-dev ninja-build ohcount pkg-config ronn uncrustify
echo "Running build..."
if [[ "${branch}" = "master" ]]; then
meson ./ ./build
meson configure --prefix="${HOME}/.local" ./build
ninja -C ./build
else
autoreconf --install
mkdir -p build
cd build
../configure --prefix="${HOME}/.local" --disable-check
fi
echo "Installing..."
if [[ "${branch}" = "master" ]]; then
ninja -C ./build install
else
make
make install
fi
link_binary "rofi"
}
setup_rofi "${1:-"next"}"