#!/bin/bash # ContributeRecipe - submits a GoboLinux recipe to the review panel # Copyright (C) 2008 Michael Homer # # 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 # the Free Software Foundation, either version 2 of the License, or # (at your option) any later version. # # This program 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 program. If not, see . ### Imports ################################################################### source ScriptFunctions Import GoboLinux Import OptionParser Import Versions Parse_Conf Compile/Compile.conf submissionTarget='http://recipes.gobolinux.org/review/submit?ver=1' ### Options ################################################################### scriptDescription="Contribute a recipe to the global store" scriptCredits="Copyright (C) 2008-2009 Michael Homer. Released under the GNU GPL." helpOnNoArguments=yes scriptUsage="{ | [] }" scriptExample="firefox" Add_Option_Boolean "p" "pretend" "Don't really submit, just dump the report to stdout." Parse_Options "$@" ### Operation ################################################################# entry="$(Arg 1)" version="$(Arg 2)" # Uncompress the file if it's a tarball if file $entry | grep -q bzip2 then entry=`Unpack_Archive $entry $compileLocalRecipesDir | cut -d/ -f1 | head -n 1` # Get path from LocalRecipes if only a name is given elif ! echo $entry | grep -q / then entry=`ls "$compileLocalRecipesDir" | grep -i "^$(Arg 1)$"` [ "$entry" ] || Die "Could not find $(Arg 1) in $compileLocalRecipesDir." entry="$compileLocalRecipesDir/$entry" else if [ -f "$entry/Recipe" ] then version=$(basename $entry) entry=$(dirname $entry) fi fi cd $compileLocalRecipesDir [ -d "$entry" ] || Die "Could not read $entry." program=`basename $entry` if ! [ "$version" ] then [ `ls "$entry" | wc -l` -eq 1 ] || Die "Please specify a version for $program. Available versions are:\n$(ls $entry)" version=`ls "$entry"` fi PackRecipe $program $version || Die "Recipe failed validation. Not submitting." [ -r "$entry/$version/Resources/Description" ] || Die "No description file found. Not submitting." [ -r "$entry/$version/Recipe" ] || Die "Could not read Recipe file in $entry/$version." # Perform some simple cleanups for i in `find $entry/$version -name Recipe` do [ -w `dirname "$i"` ] || Die "Need write permissions to the recipe." sed -i.bak -e 's,$target/../Settings,$settings_target,g' \ -e 's,$target/../Variable,$variable_target,g' \ $i rm $i.bak done # Removes revisions from submitted recipes if echo "$version" | grep -q "\-r" then newversion=`echo $version | sed 's,-r[0-9]*$,,'` if [ -d "$program/$newversion" ] then Die "Attempted to remove revision from $version but $program/$newversion is in the way." fi mv "$program/$version" "$program/$newversion" version=$newversion fi scriptsVersion=`Get_Version Scripts Current` compileVersion=`Get_Version Compile Current` mkdir temp-$$ mkdir -p empty-$$/$program diff -urNa empty-$$/$program $program/$version>temp-$$/empty-patch base_recipe="$(FindPackage -l --type=recipe $program $version|grep -v LocalRecipes|head -n 1)" if ! [ "$base_recipe" ] then base_recipe="$(FindPackage -l --type=recipe $program|grep -v LocalRecipes|head -n 1)" fi base=$(GetRecipe "$base_recipe") if [ -e "$base" ] then # It's an updated version of an existing recipe lastversion=$(basename $base) echo "Generating diff from $lastversion->$version" diff -urNa $base $program/$version>temp-$$/patch else cp temp-$$/empty-patch temp-$$/patch fi # Generate the report and save it to a file because wget requires that { echo "ContributeRecipe protocol 1" echo "Submitter: $compileRecipeAuthor" echo "Program: $program" echo "Version: $version" echo "Compile: $compileVersion" echo "Scripts: $scriptsVersion" echo -n "GoboLinuxVersion: " # GoboLinuxVersion had a newline on the end in some versions # including 012, which corrupts the submission. Cut it off. echo $(cat $goboSettings/GoboLinuxVersion) echo "Origin: ${lastversion:-none}" echo cat temp-$$/empty-patch|base64 echo cat temp-$$/patch|base64 } > temp-$$/report if Boolean "pretend" then cat temp-$$/report echo echo echo "Submission report ends. Unencoded update patch follows." cat temp-$$/patch elif ! wget -O - -q --post-file=temp-$$/report "$submissionTarget" then Log_Error "There was an error using wget to submit your recipe." Log_Error "This may be a temporary network problem or a firewall issue." Log_Terse "You can also submit your recipe by emailing the packed" Log_Terse "tarball to gobolinux-recipes@lists.gobolinux.org" fi rm -rf temp-$$ empty-$$