Skip to content

Commit

Permalink
Make it possible to run Pieman from any directory
Browse files Browse the repository at this point in the history
  • Loading branch information
eugulixes committed Jul 15, 2020
1 parent 1049696 commit aab2f92
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 18 deletions.
8 changes: 4 additions & 4 deletions bootstrap/15-networking.sh
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,10 @@ elif is_debian_based; then
fi
fi

install_readonly files/etc/hostname.template "${ETC}"/hostname
install_readonly "${PIEMAN_DIR}"/files/etc/hostname.template "${ETC}"/hostname
sed -i "s/{HOSTNAME}/${HOST_NAME}/" "${ETC}/hostname"

install_readonly files/etc/hosts.template "${ETC}"/hosts
install_readonly "${PIEMAN_DIR}"/files/etc/hosts.template "${ETC}"/hosts
sed -i "s/{HOSTNAME}/${HOST_NAME}/" "${ETC}/hosts"

render "${PIEMAN_DIR}"/files/network/interfaces.j2 "${ETC}"/network/interfaces
Expand All @@ -72,7 +72,7 @@ if ${ENABLE_WIRELESS}; then
wget https://raw.githubusercontent.com/RPi-Distro/firmware-nonfree/86e88fbf0345da49555d0ec34c80b4fbae7d0cd3/brcm/brcmfmac43430-sdio.bin -O "${R}"/lib/firmware/brcm/brcmfmac43430-sdio.bin
wget https://raw.githubusercontent.com/RPi-Distro/firmware-nonfree/86e88fbf0345da49555d0ec34c80b4fbae7d0cd3/brcm/brcmfmac43430-sdio.txt -O "${R}"/lib/firmware/brcm/brcmfmac43430-sdio.txt

install_readonly files/network/wpa_supplicant.conf "${ETC}"/wpa_supplicant/wpa_supplicant.conf
install_readonly "${PIEMAN_DIR}"/files/network/wpa_supplicant.conf "${ETC}"/wpa_supplicant/wpa_supplicant.conf

if [[ -n ${WPA_SSID} ]]; then
do_wpa_passphrase >> "${ETC}"/wpa_supplicant/wpa_supplicant.conf
Expand All @@ -87,7 +87,7 @@ if is_alpine; then
info "Adding the networking service to the default runlevel"
chroot_exec rc-update add networking default

install_exec files/etc/local.d/11-up_eth0.start "${ETC}"/local.d/11-up_eth0.start
install_exec "${PIEMAN_DIR}"/files/etc/local.d/11-up_eth0.start "${ETC}"/local.d/11-up_eth0.start

# The networking service should depend on the local service since one of
# the scripts from /etc/local.d raises the network interface.
Expand Down
2 changes: 1 addition & 1 deletion bootstrap/30-fixes.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
if is_alpine; then
# For some reason the rw parameter in cmdline.txt is ignored, so the rootfs
# should be remounted at startup.
install_exec files/etc/local.d/10-remount_root.start "${ETC}"/local.d/10-remount_root.start
install_exec "${PIEMAN_DIR}"/files/etc/local.d/10-remount_root.start "${ETC}"/local.d/10-remount_root.start

# Since the system is already installed, the message may confuse users.
sed -i '/You can setup the system/,+1d' "${ETC}/motd"
Expand Down
4 changes: 2 additions & 2 deletions bootstrap/40-deskop.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.

if ${XFCE4}; then
install_exec files/desktop/06xfce4.desktop "${R}"/usr/share/xsessions/06xfce4.desktop
install_exec "${PIEMAN_DIR}"/files/desktop/06xfce4.desktop "${R}"/usr/share/xsessions/06xfce4.desktop
fi

if ${XFCE4}; then
install_exec files/desktop/lxdm.conf "${R}"/etc/lxdm.conf
install_exec "${PIEMAN_DIR}"/files/desktop/lxdm.conf "${R}"/etc/lxdm.conf
fi
2 changes: 1 addition & 1 deletion bootstrap/50-firstboot.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ info "Preparing ${FIRSTBOOT}"
touch "${FIRSTBOOT}"
chmod +x "${FIRSTBOOT}"

for script in files/firstboot/*.sh; do
for script in "${PIEMAN_DIR}"/files/firstboot/*.sh; do
cat "${script}" >> "${FIRSTBOOT}"
done

Expand Down
25 changes: 15 additions & 10 deletions pieman.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/bin/bash
# Copyright (C) 2017 Evgeny Golyshev <eugulixes@gmail.com>
# Copyright (C) 2017-2020 Evgeny Golyshev <eugulixes@gmail.com>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
Expand All @@ -19,7 +19,11 @@ if [ "$(id -u)" -ne "0" ]; then
exit 1
fi

. ./essentials.sh
PIEMAN_DIR=${PIEMAN_DIR:=$( readlink -f "$( dirname "$0" )" )}
export PIEMAN_DIR

# shellcheck source=./essentials.sh
. "${PIEMAN_DIR}"/essentials.sh

set -eE

Expand Down Expand Up @@ -102,8 +106,6 @@ def_var OS "raspbian-buster-armhf"

def_protected_var PASSWORD "secret"

def_var PIEMAN_DIR "$(pwd)"

def_bool_var PREPARE_ONLY_TOOLSET false

def_var PYTHON "python3"
Expand Down Expand Up @@ -166,15 +168,17 @@ def_private_var REDIS_IS_AVAILABLE true

def_private_var TOOLSET_FULL_PATH "${TOOLSET_DIR}/${TOOLSET_CODENAME}"

def_private_var SOURCE_DIR "devices/${DEVICE}/${OS}"
def_private_var SOURCE_DIR "${PIEMAN_DIR}/devices/${DEVICE}/${OS}"

def_private_var YML_FILE "${SOURCE_DIR}/pieman.yml"

run_scripts "helpers"
run_scripts "${PIEMAN_DIR}/helpers"

. ./mutually_exclusive_params.sh
# shellcheck source=./mutually_exclusive_params.sh
. "${PIEMAN_DIR}"/mutually_exclusive_params.sh

. ./depend_on.sh
# shellcheck source=./depend_on.sh
. "${PIEMAN_DIR}"/depend_on.sh

if [[ -n ${WPA_PSK} ]]; then
check_if_wpa_psk_is_valid
Expand Down Expand Up @@ -212,7 +216,8 @@ info "checking toolset ${TOOLSET_CODENAME}"
if [ ! -d "${TOOLSET_FULL_PATH}" ]; then
info "building toolset ${TOOLSET_CODENAME} since it does not exist"
fi
. toolset.sh
# shellcheck source=./toolset.sh
. "${PIEMAN_DIR}"/toolset.sh

# shellcheck source=./pieman/pieman/build_status_codes
. "${PIEMAN_DIR}"/pieman/pieman/build_status_codes
Expand Down Expand Up @@ -258,7 +263,7 @@ for param in ${params}; do
eval ${param}=true
done

run_scripts "bootstrap"
run_scripts "${PIEMAN_DIR}/bootstrap"

umount_required_filesystems

Expand Down

0 comments on commit aab2f92

Please sign in to comment.