Browse Source

Fix build script to properly handle DESTDIR and PREFIX options.

sisyphus
Dustin Falgout 8 years ago
parent
commit
f9706cb3b9
  1. 35
      Makefile
  2. 31
      build/utils.sh
  3. 4
      web-greeter/whither.yml

35
Makefile

@ -3,6 +3,7 @@
DO := ./build/utils.sh DO := ./build/utils.sh
SET_CONFIG := $(DO) set-config SET_CONFIG := $(DO) set-config
DESTDIR ?= / DESTDIR ?= /
PREFIX ?= /usr
MAYBE_SUDO_DO := $(DO) MAYBE_SUDO_DO := $(DO)
define colorecho define colorecho
@ -11,11 +12,6 @@ define colorecho
@tput sgr0 || true @tput sgr0 || true
endef endef
ifeq ($(MAKECMDGOALS),build_dev)
debug_mode := True
decorated := True
stays_on_top := False
endif
ifeq ($(DESTDIR),/) ifeq ($(DESTDIR),/)
MAYBE_SUDO_DO := sudo $(DO) MAYBE_SUDO_DO := sudo $(DO)
@ -24,18 +20,25 @@ endif
# Configuration: Use values from command line if provided, default values otherwise. # Configuration: Use values from command line if provided, default values otherwise.
at_spi_service ?= True at_spi_service ?= True
background_images_dir ?= $(abspath $(DESTDIR)/usr/share/backgrounds) background_images_dir ?= $(abspath $(PREFIX)/share/backgrounds)
config_dir ?= $(abspath $(DESTDIR)/etc/lightdm) config_dir ?= $(abspath /etc/lightdm)
debug_mode ?= False debug_mode := False
decorated ?= False decorated := False
greeters_dir ?= $(abspath $(DESTDIR)/usr/share/xgreeters) greeters_dir ?= $(abspath $(PREFIX)/share/xgreeters)
locale_dir ?= $(abspath $(DESTDIR)/usr/share/locale) locale_dir ?= $(abspath $(PREFIX)/share/locale)
themes_dir ?= $(abspath $(DESTDIR)/usr/share/web-greeter/themes) themes_dir ?= $(abspath $(PREFIX)/share/web-greeter/themes)
logo_image ?= $(themes_dir)/default/img/antergos-logo-user.png logo_image ?= $(themes_dir)/default/img/antergos-logo-user.png
stays_on_top ?= True stays_on_top := True
user_image ?= $(themes_dir)/default/img/antergos.png user_image ?= $(themes_dir)/default/img/antergos.png
ifeq ($(MAKECMDGOALS),build_dev)
debug_mode := True
decorated := True
stays_on_top := False
endif
_apply_config: _apply_config:
@$(SET_CONFIG) at_spi_service $(at_spi_service) @$(SET_CONFIG) at_spi_service $(at_spi_service)
@$(SET_CONFIG) background_images_dir $(background_images_dir) @$(SET_CONFIG) background_images_dir $(background_images_dir)
@ -55,7 +58,7 @@ _build_init: clean
all: install all: install
build: _build_init _apply_config build: _build_init _apply_config
$(DO) build $(DO) build $(PREFIX)
build_dev: install build_dev: install
$(MAYBE_SUDO_DO) install-dev $(MAYBE_SUDO_DO) install-dev
@ -64,8 +67,8 @@ clean:
$(DO) clean $(DO) clean
install: build install: build
./build/utils.sh prepare-install ./build/utils.sh prepare-install $(PREFIX)
$(MAYBE_SUDO_DO) install $(DESTDIR) $(MAYBE_SUDO_DO) install $(DESTDIR) $(PREFIX)
$(call colorecho, SUCCESS!) $(call colorecho, SUCCESS!)

31
build/utils.sh

@ -5,6 +5,7 @@ REPO_DIR="$(dirname "${BUILD_DIR}")"
INSTALL_ROOT="${BUILD_DIR}/install_root" INSTALL_ROOT="${BUILD_DIR}/install_root"
PKGNAME='web-greeter' PKGNAME='web-greeter'
DESTDIR='' DESTDIR=''
PREFIX=''
_handle_error() { _handle_error() {
@ -38,10 +39,10 @@ do_build() {
&& mv greeter.py __main__.py \ && mv greeter.py __main__.py \
&& zip -rq ../"${PKGNAME}.zip" . -x '**__pycache__**' 'resources/*' \ && zip -rq ../"${PKGNAME}.zip" . -x '**__pycache__**' 'resources/*' \
&& cd - >/dev/null \ && cd - >/dev/null \
&& mkdir -p "${INSTALL_ROOT}"/usr/{bin,share} \ && mkdir -p "${INSTALL_ROOT}${PREFIX}"/{bin,share} \
&& echo '#!/bin/python3' >> "${INSTALL_ROOT}/usr/bin/web-greeter" \ && echo '#!/bin/python3' >> "${INSTALL_ROOT}${PREFIX}/bin/web-greeter" \
&& cat web-greeter.zip >> "${INSTALL_ROOT}/usr/bin/web-greeter" \ && cat web-greeter.zip >> "${INSTALL_ROOT}${PREFIX}/bin/web-greeter" \
&& chmod +x "${INSTALL_ROOT}/usr/bin/web-greeter") && chmod +x "${INSTALL_ROOT}${PREFIX}/bin/web-greeter")
} }
do_install() { do_install() {
@ -53,13 +54,6 @@ do_install_dev() {
cp -RH "${REPO_DIR}/whither/whither" /usr/lib/python3.6/site-packages/ cp -RH "${REPO_DIR}/whither/whither" /usr/lib/python3.6/site-packages/
} }
do_success() {
NO_COLOR=\x1b[0m
SUCCESS_COLOR=\x1b[32;01m
SUCCESS="${SUCCESS_COLOR}[SUCCESS!]${NO_COLOR}"
echo "${SUCCESS}"
}
generate_pot_file() { generate_pot_file() {
REPO_ROOT="$(dirname "${REPO_DIR}")" REPO_ROOT="$(dirname "${REPO_DIR}")"
xgettext --from-code UTF-8 -o "${REPO_ROOT}/po/lightdm-webkit2-greeter.pot" -d lightdm-webkit2-greeter "${REPO_ROOT}"/src/*.c xgettext --from-code UTF-8 -o "${REPO_ROOT}/po/lightdm-webkit2-greeter.pot" -d lightdm-webkit2-greeter "${REPO_ROOT}"/src/*.c
@ -74,25 +68,25 @@ init_build_dir() {
prepare_install() { prepare_install() {
cd "${BUILD_DIR}" cd "${BUILD_DIR}"
mkdir -p \ mkdir -p \
"${INSTALL_ROOT}"/usr/share/{man/man1,metainfo,web-greeter,xgreeters} \ "${INSTALL_ROOT}${PREFIX}"/share/{man/man1,metainfo,web-greeter,xgreeters} \
"${INSTALL_ROOT}/etc/lightdm" "${INSTALL_ROOT}/etc/lightdm"
# Themes # Themes
(cp -R "${REPO_DIR}/themes" "${INSTALL_ROOT}/usr/share/web-greeter" \ (cp -R "${REPO_DIR}/themes" "${INSTALL_ROOT}${PREFIX}/share/web-greeter" \
&& cd "${INSTALL_ROOT}/usr/share/web-greeter" \ && cd "${INSTALL_ROOT}${PREFIX}/share/web-greeter" \
&& mv themes/_vendor .) && mv themes/_vendor .)
# Man Page # Man Page
cp "${BUILD_DIR}/dist/${PKGNAME}.1" "${INSTALL_ROOT}/usr/share/man/man1" cp "${BUILD_DIR}/dist/${PKGNAME}.1" "${INSTALL_ROOT}${PREFIX}/share/man/man1"
# Greeter Config # Greeter Config
cp "${BUILD_DIR}/dist/${PKGNAME}.yml" "${INSTALL_ROOT}/etc/lightdm" cp "${BUILD_DIR}/dist/${PKGNAME}.yml" "${INSTALL_ROOT}/etc/lightdm"
# AppData File # AppData File
cp "${BUILD_DIR}/dist/com.antergos.${PKGNAME}.appdata.xml" "${INSTALL_ROOT}/usr/share/metainfo" cp "${BUILD_DIR}/dist/com.antergos.${PKGNAME}.appdata.xml" "${INSTALL_ROOT}${PREFIX}/share/metainfo"
# Desktop File # Desktop File
cp "${BUILD_DIR}/dist/com.antergos.${PKGNAME}.desktop" "${INSTALL_ROOT}/usr/share/xgreeters" cp "${BUILD_DIR}/dist/com.antergos.${PKGNAME}.desktop" "${INSTALL_ROOT}${PREFIX}/share/xgreeters"
} }
set_config() { set_config() {
@ -119,6 +113,7 @@ case "$1" in
;; ;;
build) build)
PREFIX="$2"
do_build do_build
;; ;;
@ -132,6 +127,7 @@ case "$1" in
install) install)
DESTDIR="$2" DESTDIR="$2"
PREFIX="$3"
do_install do_install
clean_build_dir clean_build_dir
;; ;;
@ -141,6 +137,7 @@ case "$1" in
;; ;;
prepare-install) prepare-install)
PREFIX="$2"
prepare_install prepare_install
;; ;;

4
web-greeter/whither.yml

@ -41,9 +41,9 @@ WebGreeter:
locale_dir: '@locale_dir@' locale_dir: '@locale_dir@'
themes_dir: '@themes_dir@' themes_dir: '@themes_dir@'
version: version:
full: '3.0.0alpha4' full: '3.0.0alpha5'
major: 3 major: 3
minor: 0 minor: 0
micro: 0 micro: 0
alpha: 4 alpha: 5
beta: False beta: False

Loading…
Cancel
Save