#!/usr/bin/env zsh # # Copyright (c) 2016 Dyne.org Foundation # libdevuansdk is written and maintained by # Jaromil # KatolaZ # parazyd # # This file is part of libdevuansdk # # This source code is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This software is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this source code. If not, see . ## blend-related functions ## Apply a blend, i.e. read the "blend" file and source the ## corresponding *_init and *_run files ## ## FIXME!!!! We need a way to check that the source of init and run ## files were successful, so that we can popd as necessary upon failure ## blend_apply(){ fn blend_apply $@ blenddir=$1 req=(blenddir strapdir arch) reqck || return 1 if [[ ! -d $blenddir || ! -f ${blenddir}/blend ]]; then error "::1 dir:: is not a valid blend" $blenddir return 1 fi pushd $blenddir source blend ## Check if release is among the supported blend_releases [[ -z ${blend_releases[(r)$release]} ]] && { error "::1 rel:: is not among the releases supported by blend ::2 dir:: " $rel $blenddir; popd; return 1 } [[ -z ${blend_archs[(r)$arch]} ]] && { error "::1 arch:: is not among the architectures supported by blend ::2 dir:: " $arch $blenddir; popd; return 1 } notice "Selecting blend architecture ::1 arch:: " $arch pushd ${arch} [[ -n ${blend_init} ]] && { notice "Initialising blend ::1 blend:: " $blenddir ## [[ ! -f ${blend_init} ]] && { error "Blend initialisation file \"::1 file::\" not found" ${blend_init} popd popd return 1 } source ${blend_init} act "Initialisation successful" } [[ -n ${blend_run} ]] && { notice "Applying blend ::1 blend:: " $blenddir ## [[ ! -f ${blend_run} ]] && { error "Blend run file \"::1 file::\" not found" ${blend_run} popd popd return 1 } source ${blend_run} act "Application successful" } # come back to blend main dir popd # come back to working directory before the call to blend_apply popd }