#!/bin/bash ################################################## # Imports ################################################## if [ "$goboCrossCompiling" ] then unset goboCrossCompiling unset goboPrefix fi . ScriptFunctions Import OptionParser Import File Import GoboLinux Import Compile ################################################## # Options and configuration ################################################## Parse_Conf Compile.conf helpOnNoArguments=yes scriptDescription="Fetch a recipe and insert it in the recipes tree." scriptCredits="(C) 2003-2004 Carlo Calica et al. Released under the GNU GPL." scriptUsage="[|| [program-version]]" #scriptNotes="A full path to a recipe [that can be an url, a compressed local" \ #"recipe or an uncompressed one] is received, and the recipe is placed in" \ #"$compileGetRecipeDir" Add_Option_Boolean "W" "no-web" "Do not check remote site for recipes." Parse_Options "$@" unset noweb Boolean "no-web" && noweb="--no-web" ################################################## # Prepare Environment ################################################## Check_Dir_Variable compileGetRecipeDir # Ensure that current user can read and write recipes [ -z "$ROOTLESS_GOBOLINUX" ] && [ ! -w "$compileGetRecipeDir" -o ! -x "$compileGetRecipeDir" ] && $sudo_exec chown `whoami` "$compileGetRecipeDir" if ! Is_URL "$(Arg 1)" && ! { echo "$(Arg 1)" | Quiet grep "/" ;} && ! [ -f "$(Arg 1)" ] then url=`FindPackage --type=recipe $noweb $(Arg 1) $(Arg 2)` if [ "${url}" ] then GetRecipe $noweb "${url}" exit $? else Log_Terse "Recipe for" $(Arg 1) $(Arg 2) "not found" exit 1 fi fi for (( i=1 ; i<=$(Number_Of_Arguments) ; i++ )) do rawrecipe=$(Arg $i) # Getting program name and version if [ -d "$rawrecipe" ] then app=`Get_Token "${rawrecipe%/}" "/" "-2"` version=`Get_Token "${rawrecipe%/}" "/" "-1"` else x=`basename "$rawrecipe"` app=`Get_Token "$x" "--" "0"` version=`Get_Token "$x" "--" "1"` fi Log_Verbose "Trying to get $app $version from $rawrecipe" Log_Normal "Trying to get $rawrecipe" [ -z "$ROOTLESS_GOBOLINUX" -a -d "$compileGetRecipeDir/$app" ] && [ ! -w "$compileGetRecipeDir/$app" -o ! -x "$compileGetRecipeDir/$app" ] && $sudo_exec chown `whoami` "$compileGetRecipeDir/$app" [ -z "$ROOTLESS_GOBOLINUX" -a -d "$compileGetRecipeDir/$app/$version" ] && [ ! -w "$compileGetRecipeDir/$app/$version" -o ! -x "$compileGetRecipeDir/$app/$version" ] && $sudo_exec chown `whoami` "$compileGetRecipeDir/$app/$version" ##################################################### # Case #1 and #2: recipe is a local directory ##################################################### if [ -d "$(Arg 1)" ] then ##################################################### # Case #1: recipe is already in $compileRecipeDirs[@] ##################################################### for compileRecipeDir in "${compileRecipeDirs[@]}" do if Starts_With $compileRecipeDir "$rawrecipe" then echo "$compileRecipeDir/$app/$version" exit 0 fi done ##################################################### # Case #2: recipe is a local directory, but not at $compileRecipeDirs[@] ##################################################### cp -R "${rawrecipe%%/}"/* "$compileGetRecipeDir/$app/$version" echo "$compileGetRecipeDir/$app/$version" exit 0 fi ##################################################### # Case #3: recipe is a local compressed file ##################################################### if [ -f "$rawrecipe" ] && Ends_With "--recipe.tar.bz2" "$rawrecipe" then Verbose tar xjvf "$rawrecipe" -C "$compileGetRecipeDir" echo "$compileGetRecipeDir/$app/$version" exit 0 fi ##################################################### # Case #4: recipe is a remote compressed file (url) ##################################################### if ! Boolean "no-web" && Is_URL "$rawrecipe" then Log_Normal "Downloading recipe from $rawrecipe" if wget --help | grep -q no-check-certificate then wget="wget --no-check-certificate" else wget="wget" fi $wget --header='Accept: application/x-gobo-recipe, application/x-bzip2;q=0.9, */*;q=0.1' -t 5 "$rawrecipe" -O - -q | Verbose tar xjvf - -C "$compileGetRecipeDir" [ ${PIPESTATUS[0]} != 0 ] && Die "Could not fetch recipe. Check URL (${rawrecipe})" if [ -d "$compileGetRecipeDir/$app/$version" ] then echo "$compileGetRecipeDir/$app/$version" exit 0 fi fi ##################################################### # Case #5: error... ##################################################### Log_Normal "Error getting recipe $rawrecipe" done Die "Could not get recipe"