| 1 |
#!/bin/sh |
| 2 |
# SPDX-FileCopyrightText: © 2009 Oprea Dan |
| 3 |
# SPDX-FileCopyrightText: © 2013 Germar Reitze |
| 4 |
# SPDX-FileCopyrightText: © 2022 Jürgen Altfeld |
| 5 |
# SPDX-FileCopyrightText: © 2022 Christian Buhtz <[email protected]> |
| 6 |
# SPDX-FileCopyrightText: © 2023 Kian-Meng Ang |
| 7 |
# SPDX-FileCopyrightText: © 2023 Fabio Fantoni |
| 8 |
# SPDX-FileCopyrightText: © 2024 Tejas Guruswamy |
| 9 |
# |
| 10 |
# SPDX-License-Identifier: GPL-2.0-or-later |
| 11 |
# |
| 12 |
# This file is part of the program "Back In Time" which is released under GNU |
| 13 |
# General Public License v2 (GPLv2). See LICENSES directory or go to |
| 14 |
# <https://spdx.org/licenses/GPL-2.0-or-later.html>. |
| 15 |
# |
| 16 |
# This is the configuration file for the Read the Docs service. |
| 17 |
# See https://docs.readthedocs.io/en/stable/config-file/v2.html for details. |
| 18 |
|
| 19 |
#clean up |
| 20 |
if [ -e Makefile ]; then |
| 21 |
rm Makefile; |
| 22 |
fi |
| 23 |
|
| 24 |
#tmp files |
| 25 |
MAKEFILE="$(mktemp)" |
| 26 |
UNINSTALL_FILES="$(mktemp)" |
| 27 |
UNINSTALL_DIRS="$(mktemp)" |
| 28 |
|
| 29 |
#set default options |
| 30 |
PYTHON="/usr/bin/python3" |
| 31 |
|
| 32 |
USR_BIN_FILES="backintime-qt backintime-qt_polkit" |
| 33 |
DBUS_SERVICE_FILES="net.launchpad.backintime.serviceHelper.service" |
| 34 |
|
| 35 |
usage () { |
| 36 |
echo "Usage:" |
| 37 |
echo "$0 [--python | --python3 | --python=PYTHON_BINARY]" |
| 38 |
echo "" |
| 39 |
echo "--python" |
| 40 |
echo "\tuse 'python' to start Python3" |
| 41 |
echo "--python3" |
| 42 |
echo "\tuse 'python3' to start Python3" |
| 43 |
echo "--python=PYTHON_BINARY" |
| 44 |
echo "\tuse PYTHON_BINARY to start Python3" |
| 45 |
} |
| 46 |
|
| 47 |
addInstallFiles () { |
| 48 |
file=$1 |
| 49 |
dest=$2 |
| 50 |
mode=$3 |
| 51 |
if [ -z "$mode" ]; then |
| 52 |
mode=644 |
| 53 |
fi |
| 54 |
for i in $(ls $file); do |
| 55 |
addInstallFile "$i" "$dest" "$mode" |
| 56 |
done |
| 57 |
} |
| 58 |
|
| 59 |
addInstallFile () { |
| 60 |
file=$1 |
| 61 |
dest=$2 |
| 62 |
mode=$3 |
| 63 |
if [ -z "$mode" ]; then |
| 64 |
mode=644 |
| 65 |
fi |
| 66 |
printf "\tinstall --mode=$mode $file \$(DEST)$dest\n" >> ${MAKEFILE} |
| 67 |
addUninstallFile "$file" "$dest" |
| 68 |
} |
| 69 |
|
| 70 |
addInstallFileRename () { |
| 71 |
file=$1 |
| 72 |
dest=$2 |
| 73 |
mode=$3 |
| 74 |
if [ -z "$mode" ]; then |
| 75 |
mode=644 |
| 76 |
fi |
| 77 |
printf "\tinstall --mode=$mode $file \$(DEST)$dest\n" >> ${MAKEFILE} |
| 78 |
addUninstallFileRename "$dest" |
| 79 |
} |
| 80 |
|
| 81 |
addUninstallFile () { |
| 82 |
file=$(basename "$1") |
| 83 |
dest=$2 |
| 84 |
printf "\trm -f \$(DEST)$dest/$file\n" >> ${UNINSTALL_FILES} |
| 85 |
} |
| 86 |
|
| 87 |
addUninstallFileRename () { |
| 88 |
file=$1 |
| 89 |
printf "\trm -f \$(DEST)$file\n" >> ${UNINSTALL_FILES} |
| 90 |
} |
| 91 |
|
| 92 |
addInstallDir () { |
| 93 |
dest=$1 |
| 94 |
printf "\tinstall -d \$(DEST)$dest\n" >> ${MAKEFILE} |
| 95 |
addUninstallDir "$dest" |
| 96 |
} |
| 97 |
|
| 98 |
addUninstallDir () { |
| 99 |
dest=$1 |
| 100 |
printf "\tif [ -d \$(DEST)$dest ]; then rmdir --ignore-fail-on-non-empty \$(DEST)$dest; fi\n" >> ${UNINSTALL_DIRS} |
| 101 |
} |
| 102 |
|
| 103 |
addComment () { |
| 104 |
printf "\t# Install $1\n" >> ${MAKEFILE} |
| 105 |
printf "\t# Uninstall files $1\n" >> ${UNINSTALL_FILES} |
| 106 |
printf "\t# Uninstall directory $1\n" >> ${UNINSTALL_DIRS} |
| 107 |
} |
| 108 |
|
| 109 |
addNewline () { |
| 110 |
printf "\n" >> ${MAKEFILE} |
| 111 |
printf "\n" >> ${UNINSTALL_FILES} |
| 112 |
printf "\n" >> ${UNINSTALL_DIRS} |
| 113 |
} |
| 114 |
|
| 115 |
# get commandline arguments |
| 116 |
unknown_args="" |
| 117 |
for arg in $*; do |
| 118 |
case $arg in |
| 119 |
--python=*) |
| 120 |
PYTHON=$(echo $arg | cut -f2 -d'=') |
| 121 |
;; |
| 122 |
--python3) |
| 123 |
PYTHON="/usr/bin/python3" |
| 124 |
;; |
| 125 |
--python) |
| 126 |
PYTHON="/usr/bin/python" |
| 127 |
;; |
| 128 |
--help | -h) usage; exit 0;; |
| 129 |
*) unknown_args="$unknown_args $arg";; |
| 130 |
esac |
| 131 |
done |
| 132 |
|
| 133 |
if [ -n "$unknown_args" ]; then |
| 134 |
echo "Unknown Arguments: $unknown_args" |
| 135 |
fi |
| 136 |
|
| 137 |
if [ ! -f "$PYTHON" ]; then |
| 138 |
echo "Warning: \"${PYTHON}\" not found on this computer" |
| 139 |
fi |
| 140 |
|
| 141 |
# patch python command |
| 142 |
# use 'python' or 'python3' to start Python Version 3.x |
| 143 |
if [ -n "$(sed -e "s#^/usr/bin/python3\? #${PYTHON} #gw /dev/stdout" -i $USR_BIN_FILES)" ] \ |
| 144 |
&& [ -n "$(sed -e "s#^Exec=/usr/bin/python3\? #Exec=${PYTHON} #gw /dev/stdout" -i $DBUS_SERVICE_FILES)" ] |
| 145 |
then |
| 146 |
echo "Replacement of python path with \"${PYTHON}\" successful." |
| 147 |
else |
| 148 |
echo "WARNING: Replacement of python path with \"${PYTHON}\" FAILED. Maybe you ran configure more than once?" |
| 149 |
fi |
| 150 |
|
| 151 |
# Start Makefile |
| 152 |
printf ".PHONY: test test-v unitest unittest-v\n" >> ${MAKEFILE} |
| 153 |
|
| 154 |
printf "PREFIX=/usr\n" >> ${MAKEFILE} |
| 155 |
printf "DEST=\$(DESTDIR)\$(PREFIX)\n\n" >> ${MAKEFILE} |
| 156 |
|
| 157 |
printf "all:\tbuild\n\n" >> ${MAKEFILE} |
| 158 |
|
| 159 |
printf "build:\tcompress\n\n" >> ${MAKEFILE} |
| 160 |
|
| 161 |
printf "clean:\n" >> ${MAKEFILE} |
| 162 |
printf "\trm -f po/*.mo\n" >> ${MAKEFILE} |
| 163 |
printf "\trm -f ../doc/manpages/*.gz\n\n" >> ${MAKEFILE} |
| 164 |
|
| 165 |
# Create install and uninstall target |
| 166 |
printf "install:\n" >> ${MAKEFILE} |
| 167 |
|
| 168 |
# Migration |
| 169 |
printf "\t# Clean-up installed old files that were renamed or moved in later BiT versions\n" >> ${MAKEFILE} |
| 170 |
printf "\trm -f \$(DEST)/etc/dbus-1/system.d/net.launchpad.backintime.serviceHelper.conf\n" >> ${MAKEFILE} |
| 171 |
printf "\trm -f \$(DEST)/share/backintime/plugins/qt4plugin.py\n" >> ${MAKEFILE} |
| 172 |
addNewline |
| 173 |
|
| 174 |
printf "\t# Inject version string into source files\n" >> ${MAKEFILE} |
| 175 |
printf "\t(cd .. && ./updateversion.sh)\n" >> ${MAKEFILE} |
| 176 |
addNewline |
| 177 |
|
| 178 |
addComment "python" |
| 179 |
addUninstallDir "/share/backintime/qt/__pycache__" |
| 180 |
addUninstallFile "*.pyc" "/share/backintime/qt/__pycache__" |
| 181 |
addInstallDir "/share/backintime/qt" |
| 182 |
addInstallFiles "*.py" "/share/backintime/qt" |
| 183 |
addInstallDir "/share/backintime/qt/manageprofiles" |
| 184 |
addInstallFiles "manageprofiles/*.py" "/share/backintime/qt/manageprofiles" |
| 185 |
addNewline |
| 186 |
|
| 187 |
addComment "plugin" |
| 188 |
addUninstallDir "/share/backintime/plugins/__pycache__" |
| 189 |
addUninstallFile "*.pyc" "/share/backintime/plugins/__pycache__" |
| 190 |
addInstallDir "/share/backintime/plugins" |
| 191 |
addInstallFiles "plugins/*.py" "/share/backintime/plugins" |
| 192 |
addUninstallDir "/share/backintime" |
| 193 |
addNewline |
| 194 |
|
| 195 |
addComment "application" |
| 196 |
addInstallDir "/bin" |
| 197 |
addInstallFile "backintime-qt" "/bin" "755" |
| 198 |
addInstallFile "backintime-qt_polkit" "/bin" "755" |
| 199 |
addInstallDir "/share/metainfo" |
| 200 |
addInstallFile "io.github.bit_team.back_in_time.gui.metainfo.xml" "/share/metainfo" |
| 201 |
addNewline |
| 202 |
|
| 203 |
addComment "dbus service" |
| 204 |
addInstallDir "/share/dbus-1/system-services" |
| 205 |
addInstallFiles "net.launchpad.backintime*.service" "/share/dbus-1/system-services" |
| 206 |
addUninstallDir "/share/dbus-1" |
| 207 |
addNewline |
| 208 |
|
| 209 |
addComment "dbus conf" |
| 210 |
addInstallDir "/share/dbus-1/system.d" |
| 211 |
addInstallFiles "net.launchpad.backintime*.conf" "/share/dbus-1/system.d" |
| 212 |
addUninstallDir "/share/dbus-1" |
| 213 |
addUninstallDir "/share" |
| 214 |
addNewline |
| 215 |
|
| 216 |
addComment "polkit action" |
| 217 |
addInstallDir "/share/polkit-1/actions" |
| 218 |
addInstallFiles "net.launchpad.backintime*.policy" "/share/polkit-1/actions" |
| 219 |
addUninstallDir "/share/polkit-1" |
| 220 |
addNewline |
| 221 |
|
| 222 |
addComment "documentation" |
| 223 |
addInstallDir "/share/doc/backintime-qt" |
| 224 |
addInstallFile "../AUTHORS" "/share/doc/backintime-qt" |
| 225 |
addInstallFile "../README.md" "/share/doc/backintime-qt" |
| 226 |
addInstallFile "../FAQ.md" "/share/doc/backintime-qt" |
| 227 |
addInstallFile "../CHANGES" "/share/doc/backintime-qt" |
| 228 |
addInstallFile "../LICENSES.md" "/share/doc/backintime-qt" |
| 229 |
addInstallDir "/share/doc/backintime-qt/LICENSES" |
| 230 |
addInstallFiles "../LICENSES/*" "/share/doc/backintime-qt/LICENSES" |
| 231 |
addNewline |
| 232 |
|
| 233 |
addComment ".desktop" |
| 234 |
addInstallDir "/share/applications" |
| 235 |
addInstallFiles "*.desktop" "/share/applications" |
| 236 |
addNewline |
| 237 |
|
| 238 |
addComment "man" |
| 239 |
addInstallDir "/share/man/man1" |
| 240 |
addInstallFile "../doc/manpages/backintime-qt.1.gz" "/share/man/man1" |
| 241 |
addUninstallDir "/share/man" |
| 242 |
addNewline |
| 243 |
|
| 244 |
addComment "icons" |
| 245 |
# application logo (scalable SVG) |
| 246 |
addInstallDir "/share/icons/hicolor/scalable/apps" |
| 247 |
addInstallFile "icons/scalable/apps/backintime.svg" "/share/icons/hicolor/scalable/apps" |
| 248 |
# addInstallFile "icons/scalable/apps/backintime-symbolic.svg" "/share/icons/hicolor/scalable/apps" |
| 249 |
# icon: show-hidden (scalable SVG) |
| 250 |
addInstallDir "/share/icons/hicolor/scalable/actions" |
| 251 |
addInstallFile "icons/scalable/actions/show-hidden.svg" "/share/icons/hicolor/scalable/actions" |
| 252 |
|
| 253 |
# # rasterized versions of the logo |
| 254 |
# for s in 16 22 24 48 64 128 256 512; do |
| 255 |
# # application logo (PNG) |
| 256 |
# addInstallDir "/share/icons/hicolor/${s}x${s}/apps" |
| 257 |
# addInstallFile "icons/${s}x${s}/apps/backintime.png" "/share/icons/hicolor/${s}x${s}/apps" |
| 258 |
# addInstallFile "icons/${s}x${s}/apps/backintime-symbolic.png" "/share/icons/hicolor/${s}x${s}/apps" |
| 259 |
# |
| 260 |
# # icon: show-hidden (PNG |
| 261 |
# addInstallDir "/share/icons/hicolor/${s}x${s}/actions" |
| 262 |
# addInstallFile "icons/${s}x${s}/actions/show-hidden.png" "/share/icons/hicolor/${s}x${s}/actions" |
| 263 |
# done |
| 264 |
# |
| 265 |
# printf "\tgtk-update-icon-cache -f /usr/share/icons/hicolor\n" >> ${MAKEFILE} |
| 266 |
|
| 267 |
addNewline |
| 268 |
|
| 269 |
# compress |
| 270 |
printf "compress:\n" >> ${MAKEFILE} |
| 271 |
printf "\t# Man pages\n" >> ${MAKEFILE} |
| 272 |
printf "\t@cd ./../doc/manpages && ./build_manpages.sh backintime-qt.1.adoc\n" >> ${MAKEFILE} |
| 273 |
|
| 274 |
# Uninstall |
| 275 |
printf "uninstall: uninstall_files uninstall_dirs\n\n" >> ${MAKEFILE} |
| 276 |
printf "uninstall_files:\n" >> ${MAKEFILE} |
| 277 |
cat ${UNINSTALL_FILES} >> ${MAKEFILE} |
| 278 |
printf "uninstall_dirs:\n" >> ${MAKEFILE} |
| 279 |
cat ${UNINSTALL_DIRS} >> ${MAKEFILE} |
| 280 |
|
| 281 |
for target in test test-v unittest unittest-v; do |
| 282 |
printf "\n\n%s:\n" "$target" >> ${MAKEFILE} |
| 283 |
printf "\t@echo \"Target '%s' not available anymore. " "$target">> ${MAKEFILE} |
| 284 |
printf "Use a test runner of your own choice " >> ${MAKEFILE} |
| 285 |
printf "(e.g. 'unittest' or 'pytest').\"" >> ${MAKEFILE} |
| 286 |
printf "\n\t@false" >> ${MAKEFILE} |
| 287 |
done |
| 288 |
|
| 289 |
# copy Makefile |
| 290 |
mv ${MAKEFILE} Makefile |
| 291 |
chmod 644 Makefile |
| 292 |
|
| 293 |
# clean up |
| 294 |
for i in "${UNINSTALL_FILES}" "${UNINSTALL_DIRS}"; do |
| 295 |
if [ -e "$i" ]; then |
| 296 |
rm "$i" |
| 297 |
fi |
| 298 |
done |
| 299 |
|
| 300 |
# check python version |
| 301 |
PYTHON_VERSION_REQUIRED="3.9" |
| 302 |
PYTHON_VERSION_CURRENT=$(${PYTHON} --version | tr --delete 'Python ') |
| 303 |
|
| 304 |
# Credits: https://unix.stackexchange.com/a/285928/136851 |
| 305 |
if [ "$(printf '%s\n' "$PYTHON_VERSION_REQUIRED" "$PYTHON_VERSION_CURRENT" | sort -V | head -n1)" != "$PYTHON_VERSION_REQUIRED" ]; then |
| 306 |
printf "Error: Wrong Python version ${PYTHON_VERSION_CURRENT}. " |
| 307 |
printf "But minimal version ${PYTHON_VERSION_REQUIRED} required.\n" |
| 308 |
exit 1 |
| 309 |
fi |
| 310 |
|
| 311 |
printf "All OK. Now run:\n" |
| 312 |
printf " make\n" |
| 313 |
printf " sudo make install\n" |