Skip to content
This repository has been archived by the owner on May 22, 2019. It is now read-only.

Commit

Permalink
Fix build script to properly handle DESTDIR and PREFIX options.
Browse files Browse the repository at this point in the history
  • Loading branch information
lots0logs committed Feb 13, 2017
1 parent 6899920 commit f9706cb
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 35 deletions.
35 changes: 19 additions & 16 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
DO := ./build/utils.sh
SET_CONFIG := $(DO) set-config
DESTDIR ?= /
PREFIX ?= /usr
MAYBE_SUDO_DO := $(DO)

define colorecho
Expand All @@ -11,11 +12,6 @@ define colorecho
@tput sgr0 || true
endef

ifeq ($(MAKECMDGOALS),build_dev)
debug_mode := True
decorated := True
stays_on_top := False
endif

ifeq ($(DESTDIR),/)
MAYBE_SUDO_DO := sudo $(DO)
Expand All @@ -24,18 +20,25 @@ endif

# Configuration: Use values from command line if provided, default values otherwise.
at_spi_service ?= True
background_images_dir ?= $(abspath $(DESTDIR)/usr/share/backgrounds)
config_dir ?= $(abspath $(DESTDIR)/etc/lightdm)
debug_mode ?= False
decorated ?= False
greeters_dir ?= $(abspath $(DESTDIR)/usr/share/xgreeters)
locale_dir ?= $(abspath $(DESTDIR)/usr/share/locale)
themes_dir ?= $(abspath $(DESTDIR)/usr/share/web-greeter/themes)
background_images_dir ?= $(abspath $(PREFIX)/share/backgrounds)
config_dir ?= $(abspath /etc/lightdm)
debug_mode := False
decorated := False
greeters_dir ?= $(abspath $(PREFIX)/share/xgreeters)
locale_dir ?= $(abspath $(PREFIX)/share/locale)
themes_dir ?= $(abspath $(PREFIX)/share/web-greeter/themes)
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


ifeq ($(MAKECMDGOALS),build_dev)
debug_mode := True
decorated := True
stays_on_top := False
endif


_apply_config:
@$(SET_CONFIG) at_spi_service $(at_spi_service)
@$(SET_CONFIG) background_images_dir $(background_images_dir)
Expand All @@ -55,7 +58,7 @@ _build_init: clean
all: install

build: _build_init _apply_config
$(DO) build
$(DO) build $(PREFIX)

build_dev: install
$(MAYBE_SUDO_DO) install-dev
Expand All @@ -64,8 +67,8 @@ clean:
$(DO) clean

install: build
./build/utils.sh prepare-install
$(MAYBE_SUDO_DO) install $(DESTDIR)
./build/utils.sh prepare-install $(PREFIX)
$(MAYBE_SUDO_DO) install $(DESTDIR) $(PREFIX)
$(call colorecho, SUCCESS!)


Expand Down
31 changes: 14 additions & 17 deletions build/utils.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ REPO_DIR="$(dirname "${BUILD_DIR}")"
INSTALL_ROOT="${BUILD_DIR}/install_root"
PKGNAME='web-greeter'
DESTDIR=''
PREFIX=''


_handle_error() {
Expand Down Expand Up @@ -38,10 +39,10 @@ do_build() {
&& mv greeter.py __main__.py \
&& zip -rq ../"${PKGNAME}.zip" . -x '**__pycache__**' 'resources/*' \
&& cd - >/dev/null \
&& mkdir -p "${INSTALL_ROOT}"/usr/{bin,share} \
&& echo '#!/bin/python3' >> "${INSTALL_ROOT}/usr/bin/web-greeter" \
&& cat web-greeter.zip >> "${INSTALL_ROOT}/usr/bin/web-greeter" \
&& chmod +x "${INSTALL_ROOT}/usr/bin/web-greeter")
&& mkdir -p "${INSTALL_ROOT}${PREFIX}"/{bin,share} \
&& echo '#!/bin/python3' >> "${INSTALL_ROOT}${PREFIX}/bin/web-greeter" \
&& cat web-greeter.zip >> "${INSTALL_ROOT}${PREFIX}/bin/web-greeter" \
&& chmod +x "${INSTALL_ROOT}${PREFIX}/bin/web-greeter")
}

do_install() {
Expand All @@ -53,13 +54,6 @@ do_install_dev() {
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() {
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
Expand All @@ -74,25 +68,25 @@ init_build_dir() {
prepare_install() {
cd "${BUILD_DIR}"
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"

# Themes
(cp -R "${REPO_DIR}/themes" "${INSTALL_ROOT}/usr/share/web-greeter" \
&& cd "${INSTALL_ROOT}/usr/share/web-greeter" \
(cp -R "${REPO_DIR}/themes" "${INSTALL_ROOT}${PREFIX}/share/web-greeter" \
&& cd "${INSTALL_ROOT}${PREFIX}/share/web-greeter" \
&& mv themes/_vendor .)

# 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
cp "${BUILD_DIR}/dist/${PKGNAME}.yml" "${INSTALL_ROOT}/etc/lightdm"

# 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
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() {
Expand All @@ -119,6 +113,7 @@ case "$1" in
;;

build)
PREFIX="$2"
do_build
;;

Expand All @@ -132,6 +127,7 @@ case "$1" in

install)
DESTDIR="$2"
PREFIX="$3"
do_install
clean_build_dir
;;
Expand All @@ -141,6 +137,7 @@ case "$1" in
;;

prepare-install)
PREFIX="$2"
prepare_install
;;

Expand Down
4 changes: 2 additions & 2 deletions web-greeter/whither.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@ WebGreeter:
locale_dir: '@locale_dir@'
themes_dir: '@themes_dir@'
version:
full: '3.0.0alpha4'
full: '3.0.0alpha5'
major: 3
minor: 0
micro: 0
alpha: 4
alpha: 5
beta: False

0 comments on commit f9706cb

Please sign in to comment.