From 0aa07bd386f516176364e710e8b9132036c72986 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Mon, 24 Jun 2013 21:29:10 +0200 Subject: Reorganizing frontend in source tree. --- Makefile | 12 +++-- backend/dracut/live.script | 2 +- backend/initramfs-tools/live.hook | 6 ++- backend/initramfs-tools/live.script | 2 +- bin/live-swapfile | 100 ------------------------------------ frontend/live-boot | 20 ++++++++ frontend/live-swapfile | 100 ++++++++++++++++++++++++++++++++++++ scripts/boot.sh | 20 -------- 8 files changed, 134 insertions(+), 128 deletions(-) delete mode 100755 bin/live-swapfile create mode 100755 frontend/live-boot create mode 100755 frontend/live-swapfile delete mode 100755 scripts/boot.sh diff --git a/Makefile b/Makefile index 16ad560..28709cc 100644 --- a/Makefile +++ b/Makefile @@ -4,7 +4,7 @@ SHELL := sh -e LANGUAGES = $(shell cd manpages/po && ls) -SCRIPTS = backend/*/* bin/* scripts/*.sh scripts/*/*-* +SCRIPTS = backend/*/* frontend/* scripts/*/*-* all: build @@ -43,7 +43,7 @@ build: install: # Installing scripts mkdir -p $(DESTDIR)/lib/live - cp -r scripts/boot.sh scripts/boot $(DESTDIR)/lib/live + cp scripts/boot/* $(DESTDIR)/lib/live # Installing executables mkdir -p $(DESTDIR)/usr/share/initramfs-tools/hooks @@ -51,6 +51,9 @@ install: mkdir -p $(DESTDIR)/usr/share/initramfs-tools/scripts cp backend/initramfs-tools/live.script $(DESTDIR)/usr/share/initramfs-tools/scripts/live + mkdir -p $(DESTDIR)/bin + cp frontend/* $(DESTDIR)/bin + # Installing docs mkdir -p $(DESTDIR)/usr/share/doc/live-boot cp -r COPYING $(DESTDIR)/usr/share/doc/live-boot @@ -73,8 +76,9 @@ install: uninstall: # Uninstalling executables - rm -f $(DESTDIR)/sbin/live-swapfile - rmdir --ignore-fail-on-non-empty $(DESTDIR)/sbin > /dev/null 2>&1 || true + rm -f $(DESTDIR)/bin/live-boot + rm -f $(DESTDIR)/bin/live-swapfile + rmdir --ignore-fail-on-non-empty $(DESTDIR)/bin > /dev/null 2>&1 || true rm -f $(DESTDIR)/usr/share/initramfs-tools/hooks/live rm -f $(DESTDIR)/usr/share/initramfs-tools/scripts/live diff --git a/backend/dracut/live.script b/backend/dracut/live.script index 223f355..0774bfb 100755 --- a/backend/dracut/live.script +++ b/backend/dracut/live.script @@ -2,7 +2,7 @@ #set -e -. /lib/live/boot.sh +. /bin/live-boot DRACUT_FIXME () { diff --git a/backend/initramfs-tools/live.hook b/backend/initramfs-tools/live.hook index 1814211..560dd0f 100755 --- a/backend/initramfs-tools/live.hook +++ b/backend/initramfs-tools/live.hook @@ -17,7 +17,7 @@ do done # Checking live-boot -if [ ! -e /lib/live/boot ] +if [ ! -e /bin/live-boot ] then echo echo "W: live-boot-initramfs-tools (backend) installed without live-boot," @@ -27,8 +27,10 @@ fi [ "${QUIET}" ] || echo -n " core" +mkdir -p "${DESTDIR}/bin" +cp -a /bin/live-boot /lib/live/boot "${DESTDIR}/bin" mkdir -p "${DESTDIR}/lib/live" -cp -a /lib/live/boot.sh /lib/live/boot "${DESTDIR}/lib/live" +cp -a /lib/live/boot "${DESTDIR}/lib/live" # klibc dependencies for FILE in /lib/libacl* /lib/libblkid* /lib/libuuid* /lib/libdevmapper* /lib/libattr* diff --git a/backend/initramfs-tools/live.script b/backend/initramfs-tools/live.script index 9646274..ff2915a 100755 --- a/backend/initramfs-tools/live.script +++ b/backend/initramfs-tools/live.script @@ -2,7 +2,7 @@ #set -e -. /lib/live/boot.sh +. /bin/live-boot . /scripts/functions diff --git a/bin/live-swapfile b/bin/live-swapfile deleted file mode 100755 index 745fa87..0000000 --- a/bin/live-swapfile +++ /dev/null @@ -1,100 +0,0 @@ -#!/bin/sh - -# File: live-swapfile - create and use a swap file -# Copyright: (C) 2009 Daniel Baumann -# License: GPL-3+ - -set -e - -# Options -_SWAP_DIRECTORY="${_SWAP_DIRECTORY:-/live/swap}" -_SWAP_FILE="${_SWAP_FILE:-swapfile.img}" - -_SWAP_SIZE="${_SWAP_SIZE:-auto}" -_SWAP_FACTOR="${_SWAP_FACTOR:-2}" - -_SWAP_PURGE="${_SWAP_PURGE:-true}" -_FORCE="${_FORCE:-true}" - -case "${1}" in - add) - # Reading size of physical memory - _MEM_TOTAL_KB="$(awk '/^MemTotal: / { print $2 }' /proc/meminfo)" - _MEM_TOTAL_MB="$(expr ${_MEM_TOTAL_KB} / 1024)" - - echo "Found ${_MEM_TOTAL_MB} MB physical memory." - - # Setting size of new swapfile - if [ -z "${_SWAP_SIZE}" ] || [ "${_SWAP_SIZE}" = "auto" ] - then - _SWAP_SIZE_KB="$(expr ${_MEM_TOTAL_KB} '*' ${_SWAP_FACTOR})" - _SWAP_SIZE_MB="$(expr ${_SWAP_SIZE_KB} / 1024)" - else - _SWAP_SIZE_MB="${_SWAP_SIZE}" - fi - - echo "Requesting ${_SWAP_SIZE_MB} MB swapfile." - - # Reading size of old swapfile - if [ -e "${_SWAP_DIRECTORY}/${_SWAP_FILE}" ] - then - _SWAP_FILESIZE="$(ls -hl ${_SWAP_DIRECTORY}/${_SWAP_FILE} | awk '{ print $5 }')" - - echo "Found ${_SWAP_FILESIZE} MB swapfile." - fi - - # Creating new swap file - if [ "${_SWAP_FILESIZE}" != "${_SWAP_SIZE_MB}M" ] - then - if [ "${_FORCE}" = "true" ] - then - # Removing old swapfile - rm -f "${_SWAP_DIRECTORY}/${_SWAP_FILE}" - - echo "Creating ${_SWAP_SIZE_MB} MB swapfile." - - mkdir -p "${_SWAP_DIRECTORY}" - - # Unfortunately, swapon does not support files - # with holes, therefore we cannot preallocate. - dd if=/dev/zero of="${_SWAP_DIRECTORY}/${_SWAP_FILE}" bs=1024k count="${_SWAP_SIZE_MB}" - else - echo "Exit." - return 1 - fi - fi - - echo "Enabling ${_SWAP_DIRECTORY}/${_SWAP_FILE}." - - mkswap "${_SWAP_DIRECTORY}/${_SWAP_FILE}" - swapon "${_SWAP_DIRECTORY}/${_SWAP_FILE}" - ;; - - rm|remove) - if grep -qs "${_SWAP_DIRECTORY}/${_SWAP_FILE}" /proc/swaps - then - echo "Disabling ${_SWAP_DIRECTORY}/${_SWAP_FILE}." - - swapoff "${_SWAP_DIRECTORY}/${_SWAP_FILE}" - fi - - if [ "${_SWAP_PURGE}" = "true" ] - then - echo "Removing ${_SWAP_DIRECTORY}/${_SWAP_FILE}." - - rm -f "${_SWAP_DIRECTORY}/${_SWAP_FILE}" - - __DIRECTORY="${_SWAP_DIRECTORY}" - while [ "${__DIRECTORY}" != "/" ] - do - rmdir --ignore-fail-on-non-empty "${__DIRECTORY}" - __DIRECTORY="$(dirname ${__DIRECTORY})" - done - fi - ;; - - *) - echo "Usage: ${0} {add|remove}" - exit 1 - ;; -esac diff --git a/frontend/live-boot b/frontend/live-boot new file mode 100755 index 0000000..67585f9 --- /dev/null +++ b/frontend/live-boot @@ -0,0 +1,20 @@ +#!/bin/sh + +# set -e + +# Reading configuration file from filesystem and live-media +for _FILE in /etc/live/boot.conf /etc/live/boot/* +do + if [ -e "${_FILE}" ] + then + . "${_FILE}" + fi +done + +for _SCRIPT in /lib/live/boot/????-* +do + if [ -e "${_SCRIPT}" ] + then + . ${_SCRIPT} + fi +done diff --git a/frontend/live-swapfile b/frontend/live-swapfile new file mode 100755 index 0000000..745fa87 --- /dev/null +++ b/frontend/live-swapfile @@ -0,0 +1,100 @@ +#!/bin/sh + +# File: live-swapfile - create and use a swap file +# Copyright: (C) 2009 Daniel Baumann +# License: GPL-3+ + +set -e + +# Options +_SWAP_DIRECTORY="${_SWAP_DIRECTORY:-/live/swap}" +_SWAP_FILE="${_SWAP_FILE:-swapfile.img}" + +_SWAP_SIZE="${_SWAP_SIZE:-auto}" +_SWAP_FACTOR="${_SWAP_FACTOR:-2}" + +_SWAP_PURGE="${_SWAP_PURGE:-true}" +_FORCE="${_FORCE:-true}" + +case "${1}" in + add) + # Reading size of physical memory + _MEM_TOTAL_KB="$(awk '/^MemTotal: / { print $2 }' /proc/meminfo)" + _MEM_TOTAL_MB="$(expr ${_MEM_TOTAL_KB} / 1024)" + + echo "Found ${_MEM_TOTAL_MB} MB physical memory." + + # Setting size of new swapfile + if [ -z "${_SWAP_SIZE}" ] || [ "${_SWAP_SIZE}" = "auto" ] + then + _SWAP_SIZE_KB="$(expr ${_MEM_TOTAL_KB} '*' ${_SWAP_FACTOR})" + _SWAP_SIZE_MB="$(expr ${_SWAP_SIZE_KB} / 1024)" + else + _SWAP_SIZE_MB="${_SWAP_SIZE}" + fi + + echo "Requesting ${_SWAP_SIZE_MB} MB swapfile." + + # Reading size of old swapfile + if [ -e "${_SWAP_DIRECTORY}/${_SWAP_FILE}" ] + then + _SWAP_FILESIZE="$(ls -hl ${_SWAP_DIRECTORY}/${_SWAP_FILE} | awk '{ print $5 }')" + + echo "Found ${_SWAP_FILESIZE} MB swapfile." + fi + + # Creating new swap file + if [ "${_SWAP_FILESIZE}" != "${_SWAP_SIZE_MB}M" ] + then + if [ "${_FORCE}" = "true" ] + then + # Removing old swapfile + rm -f "${_SWAP_DIRECTORY}/${_SWAP_FILE}" + + echo "Creating ${_SWAP_SIZE_MB} MB swapfile." + + mkdir -p "${_SWAP_DIRECTORY}" + + # Unfortunately, swapon does not support files + # with holes, therefore we cannot preallocate. + dd if=/dev/zero of="${_SWAP_DIRECTORY}/${_SWAP_FILE}" bs=1024k count="${_SWAP_SIZE_MB}" + else + echo "Exit." + return 1 + fi + fi + + echo "Enabling ${_SWAP_DIRECTORY}/${_SWAP_FILE}." + + mkswap "${_SWAP_DIRECTORY}/${_SWAP_FILE}" + swapon "${_SWAP_DIRECTORY}/${_SWAP_FILE}" + ;; + + rm|remove) + if grep -qs "${_SWAP_DIRECTORY}/${_SWAP_FILE}" /proc/swaps + then + echo "Disabling ${_SWAP_DIRECTORY}/${_SWAP_FILE}." + + swapoff "${_SWAP_DIRECTORY}/${_SWAP_FILE}" + fi + + if [ "${_SWAP_PURGE}" = "true" ] + then + echo "Removing ${_SWAP_DIRECTORY}/${_SWAP_FILE}." + + rm -f "${_SWAP_DIRECTORY}/${_SWAP_FILE}" + + __DIRECTORY="${_SWAP_DIRECTORY}" + while [ "${__DIRECTORY}" != "/" ] + do + rmdir --ignore-fail-on-non-empty "${__DIRECTORY}" + __DIRECTORY="$(dirname ${__DIRECTORY})" + done + fi + ;; + + *) + echo "Usage: ${0} {add|remove}" + exit 1 + ;; +esac diff --git a/scripts/boot.sh b/scripts/boot.sh deleted file mode 100755 index 67585f9..0000000 --- a/scripts/boot.sh +++ /dev/null @@ -1,20 +0,0 @@ -#!/bin/sh - -# set -e - -# Reading configuration file from filesystem and live-media -for _FILE in /etc/live/boot.conf /etc/live/boot/* -do - if [ -e "${_FILE}" ] - then - . "${_FILE}" - fi -done - -for _SCRIPT in /lib/live/boot/????-* -do - if [ -e "${_SCRIPT}" ] - then - . ${_SCRIPT} - fi -done -- cgit v1.2.3