#!/bin/bash # Author : Angel Berlanas Vicente # LliureX Team # Licensed under GPL v3 or higher. # SOME USEFULL VALUES SYSTEM_CONF_PATH="/etc/live/build.d" DEFAULT_BUILD_DIR="/graveyard/" BINARY_CASPER_DIR="binary/casper" CURRENT_INITRD="$BINARY_CASPER_DIR/initrd.img-3.2.0-60-generic" CURRENT_VMLINUZ="binary/casper/vmlinuz-3.2.0-60-generic" CHROOT_HOOKS_DIRECTORY="/usr/share/lliurex-maker/chroot-hooks/" get_the_current_initrd() { # Need to get the correct initrd CURRENT_INITRD_AUX=$(find "$BINARY_CASPER_DIR" -name *initrd.img* | grep -v "pae" | grep -v "3.13" |head -1) [ -z "$CURRENT_INITRD_AUX" ] || CURRENT_INITRD="$CURRENT_INITRD_AUX" echo "[lliurex-maker] : The current initrd is $CURRENT_INITRD" [ -f $CURRENT_INITRD ] || { echo "Die gracefully ...." ; exit 1; } return $CURRENT_INITRD } get_the_current_vmlinuz() { # Need to get the correct vmlinuz CURRENT_VMLINUZ_AUX=$(find "$BINARY_CASPER_DIR" -name *vmlinuz* | grep -v "pae" | grep -v "3.13" |head -1) [ -z "$CURRENT_VMLINUZ_AUX" ] || CURRENT_VMLINUZ="$CURRENT_VMLINUZ_AUX" echo "[lliurex-maker] : The current vmlinuz is $CURRENT_VMLINUZ" } prepare_environment() { # Make the sanity checks # Exists the DEFAULT_BUILD_DIR [ -d "$DEFAULT_BUILD_DIR" ] || mkdir -p "$DEFAULT_BUILD_DIR" } show_all_flavours() { [ ! -d $SYSTEM_CONF_PATH ] || for line in $(ls -1 $SYSTEM_CONF_PATH); do echo " $line"; done } show_usage() { echo "USAGE: lliurex-maker clean" echo "USAGE: lliurex-maker build FLAVOUR.conf" show_all_flavours exit 1 } clean() { echo "[lliurex-maker] Cleaning environment" rm -rf ./chroot ./.stage ./config ./auto ./cache binary.headers ./binary.packages.install ./binary.packages.live ./binary ./binary-hybrid.iso ./binary.list } die() { # This is a simple function in a Perl-Style echo "$1" exit 1 } fix_the_kernel() { #Copy the kernel to the correct place to build the ISO echo "Copy the Kernel to the correct place" get_the_current_vmlinuz if [ -e "$CURRENT_VMLINUZ" ] ; then cp "$CURRENT_VMLINUZ" binary/casper/vmlinuz fi get_the_current_initrd if [ -e "$CURRENT_INITRD" ] ; then cp "$CURRENT_INITRD" binary/casper/initrd.lz fi } rebuild_the_iso() { # Reset the token rm -rf .stage/binary_iso # Rebuild the ISO lb binary_iso } fix_disk_info() { # Put the correct Disk info mkdir -p "binary/.disk/" echo "LliureX 14.06 \"Platinum\" - Build LIVE Binary $(date +%Y-%m-%d)" > "binary/.disk/info" } build() { if [ -r $1 ] ; then # If the given configuration file exists and can be read.. # work with it as a System Build Template lb config -c $SYSTEM_CONF_PATH/$1 elif [ -r $SYSTEM_CONF_PATH/$1 ] ; then # If isn't a custom configuration file , then search it at # system repositori. lb config -c $SYSTEM_CONF_PATH/$1 else # The given configuration not present, or system repositori is # not know about this file. die "Not flavour conf present." fi # Now is needed to make a hook and a hack cp -r "$CHROOT_HOOKS_DIRECTORY/"* ./config/chroot_local-hooks/ # If configuration is OK ... then make the ISO. lb build # Move current kernel to the correct place fix_the_kernel # Disk Info fix_disk_info # Rebuild the final stage (binary_iso) if [ -e binary-hybrid.iso ] ; then rebuild_the_iso fi } #===================# # MAIN # #===================# if [ $# -eq 0 ]; then show_usage fi case $1 in clean) clean ;; makedesktop) echo "$0 build lliurex-escriptori.conf" ;; build) shift prepare_environment cd "$DEFAULT_BUILD_DIR" build $1 ;; *) show_usage ;; esac exit 0