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 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334
|
#!/usr/bin/env bash
KWORKFLOW=${KWORKFLOW:-'kw'}
# Global paths
# If kw gets installed in the system instead of the user's home, the main
# binary will be available at /usr/bin. Let's use it to update the global
# paths.
KW_SYSTEM_WIDE_INSTALLATION='/usr/bin/kw'
# Share files
KW_SHARE_DIR="${XDG_DATA_HOME:-"${HOME}/.local/share"}/${KWORKFLOW}"
KW_DOC_DIR="${KW_SHARE_DIR}/doc"
KW_MAN_DIR="${KW_SHARE_DIR}/man"
KW_SOUND_DIR="${KW_SHARE_DIR}/sound"
KW_DB_DIR="${KW_SHARE_DIR}/database"
# Configuration files
KW_ETC_DIR="${XDG_CONFIG_HOME:-"${HOME}/.config"}/${KWORKFLOW}"
# Set system-wide path
if [[ -f "$KW_SYSTEM_WIDE_INSTALLATION" ]]; then
KW_LIB_DIR='/usr/share/kw'
KW_SOUND_DIR='/usr/share/sounds/kw'
KW_DOC_DIR='/usr/share/doc/kw/html/'
KW_ETC_DIR='/etc/kw'
else
KW_LIB_DIR="${KW_LIB_DIR:-"${HOME}/.local/lib"}/${KWORKFLOW}"
fi
KW_SRC_LIB_DIR="${KW_SRC_LIB_DIR:-"${KW_LIB_DIR}/lib"}"
KW_PLUGINS_DIR="${KW_PLUGINS_DIR:-"${KW_LIB_DIR}/plugins"}"
# User specific data files (currently this collapses with the share dir,
# but would not for a system-wide installation)
KW_DATA_DIR="${XDG_DATA_HOME:-"${HOME}/.local/share"}/${KWORKFLOW}"
# Cache folder
KW_CACHE_DIR="${XDG_CACHE_HOME:-"${HOME}/.cache"}/${KWORKFLOW}"
# State files
KW_STATE_DIR="${XDG_STATE_HOME:-"${HOME}/.local/state"}/${KWORKFLOW}"
# ENV dir name
ENV_DIR='envs'
##BEGIN-REPO-MODE##
KW_BIN="$(readlink -f "${BASH_SOURCE[0]}")"
KW_BASE_DIR="$(dirname "${KW_BIN}")"
KW_REPO_MODE='n'
if [ -f "${KW_BASE_DIR}/src/lib/kwlib.sh" ]; then
# running from source directory
KW_REPO_MODE='y'
KW_LIB_DIR="${KW_BASE_DIR}/src"
# KW_DATA_DIR # use default data folder
KW_DOC_DIR="${KW_BASE_DIR}/documentation"
KW_MAN_DIR="${KW_BASE_DIR}/documentation/man"
KW_SOUND_DIR="${KW_BASE_DIR}/sound"
KW_DB_DIR="${KW_BASE_DIR}/database"
KW_ETC_DIR="${KW_BASE_DIR}/etc"
KW_PLUGINS_DIR="${KW_LIB_DIR}/plugins"
KW_SRC_LIB_DIR="${KW_LIB_DIR}/lib"
# KW_CACHE_DIR # use default cache folder
fi
##END-REPO-MODE##
# Export external variables required by kworkflow
export KWORKFLOW
#INJECT_CODE_TRACING_SETUP
# This is the one and only time a file will be sourced this way.
# The include function (sourced from this file) should always be used for file sourcing.
. "${KW_LIB_DIR}/lib/kw_include.sh" --source-only
include "${KW_LIB_DIR}/lib/signal_manager.sh"
# Print a notice message if on REPO mode
if [[ "${KW_REPO_MODE}" == 'y' ]]; then
repo_mode_msg=''
repo_mode_msg+="${SEPARATOR}"$'\n'
repo_mode_msg+='[INFO]: Running kw using repository executable.'$'\n'$'\n'
repo_mode_msg+='KW environment variables are set to the following:'$'\n'$'\n'
repo_mode_msg+=$'\t'"KW_CACHE_DIR=${KW_CACHE_DIR}"$'\n'
repo_mode_msg+=$'\t'"KW_DATA_DIR=${KW_DATA_DIR}"$'\n'
repo_mode_msg+=$'\t'"KW_DB_DIR=${KW_DB_DIR}"$'\n'
repo_mode_msg+=$'\t'"KW_DOC_DIR=${KW_DOC_DIR}"$'\n'
repo_mode_msg+=$'\t'"KW_ETC_DIR=${KW_ETC_DIR}"$'\n'
repo_mode_msg+=$'\t'"KW_LIB_DIR=${KW_LIB_DIR}"$'\n'
repo_mode_msg+=$'\t'"KW_MAN_DIR=${KW_MAN_DIR}"$'\n'
repo_mode_msg+=$'\t'"KW_PLUGINS_DIR=${KW_PLUGINS_DIR}"$'\n'
repo_mode_msg+=$'\t'"KW_SRC_LIB_DIR=${KW_SRC_LIB_DIR}"$'\n'
repo_mode_msg+=$'\t'"KW_SOUND_DIR=${KW_SOUND_DIR}"$'\n'$'\n'
repo_mode_msg+="${SEPARATOR}"
# Message is redirected to stderr such that it can be easily ignored if needed.
# Otherwise, it could mess up the output expected by integration tests which
# are runnning kw in repo-mode and the tests would fail (we may eventually want
# such tests because in repo-mode we can execute kw without installing it).
say "${repo_mode_msg}" >&2
fi
function kw()
{
action="$1"
shift
signal_manager || warning 'Was not able to set signal handler'
mkdir -p "$KW_CACHE_DIR"
case "$action" in
init)
(
include "${KW_LIB_DIR}/init.sh"
init_main "$@"
return "$?"
)
;;
build | b)
(
include "${KW_LIB_DIR}/build.sh"
build_kernel_main '' "$@"
local ret="$?"
alert_completion 'kw build' "$1"
return "$ret"
)
;;
deploy | d)
(
include "${KW_LIB_DIR}/deploy.sh"
deploy_main '' "$@"
local ret="$?"
alert_completion 'kw deploy' "$1"
return "$ret"
)
;;
bd)
(
include "${KW_LIB_DIR}/build_and_deploy.sh"
build_and_deploy_main "$@"
local ret="$?"
alert_completion 'kw bd' "$1"
return "$ret"
)
;;
diff | df)
include "${KW_LIB_DIR}/diff.sh"
diff_main "$@"
;;
ssh | s)
(
include "${KW_LIB_DIR}/lib/kw_config_loader.sh"
include "${KW_LIB_DIR}/kw_ssh.sh"
kw_ssh_main "$@"
)
;;
codestyle | c)
(
include "${KW_LIB_DIR}/codestyle.sh"
codestyle_main "$@"
)
;;
self-update | u)
(
include "${KW_LIB_DIR}/self_update.sh"
self_update_main "$@"
)
;;
maintainers | m)
(
include "${KW_LIB_DIR}/maintainers.sh"
maintainers_main "$@"
)
;;
kernel-config-manager | k)
(
include "${KW_LIB_DIR}/kernel_config_manager.sh"
kernel_config_manager_main "$@"
)
;;
config | g)
(
include "${KW_LIB_DIR}/config.sh"
config_main "$@"
)
;;
remote)
(
include "${KW_LIB_DIR}/kw_remote.sh"
remote_main "$@"
)
;;
explore | e)
(
include "${KW_LIB_DIR}/explore.sh"
explore_main "$@"
return "$?"
)
;;
pomodoro | p)
(
include "${KW_LIB_DIR}/pomodoro.sh"
pomodoro_main "$@"
)
;;
report | r)
(
include "${KW_LIB_DIR}/report.sh"
report_main "$@"
)
;;
device)
(
include "${KW_LIB_DIR}/device_info.sh"
device_main "$@"
)
;;
backup)
(
include "${KW_LIB_DIR}/backup.sh"
backup "$@"
)
;;
debug)
(
include "${KW_LIB_DIR}/debug.sh"
debug_main "$@"
)
;;
send-patch)
(
include "${KW_LIB_DIR}/send_patch.sh"
send_patch_main "$@"
)
;;
env)
(
include "${KW_LIB_DIR}/kw_env.sh"
env_main "$@"
)
;;
patch-hub)
(
include "${KW_LIB_DIR}/patch_hub.sh"
patch_hub_main "$@"
)
;;
clear-cache)
include "${KW_LIB_DIR}/deploy.sh"
cleanup "$@"
;;
# Subsystems support
drm)
(
include "${KW_PLUGINS_DIR}/subsystems/drm/drm.sh"
drm_main "$@"
)
;;
# VM
vm)
(
include "${KW_LIB_DIR}/vm.sh"
vm_main "$@"
)
;;
version | --version | -v)
(
include "${KW_LIB_DIR}/help.sh"
kworkflow_version
)
;;
man)
(
include "${KW_LIB_DIR}/help.sh"
kworkflow_man "$@"
)
;;
help | --help)
(
include "${KW_LIB_DIR}/help.sh"
kworkflow_man
)
;;
h | -h)
(
include "${KW_LIB_DIR}/help.sh"
kworkflow_help
)
;;
*)
(
include "${KW_LIB_DIR}/help.sh"
complain 'Invalid option'
kworkflow_help
return 1 # EPERM
)
;;
esac
#INJECT_CODE_TRACING_COMMIT
}
kw "$@"
|