made deboco more generic by adding the python-path option
this allowed me to successfully install debops controller on mazinger.ipr too in addition to graffy-ws2 work related to https://bugzilla.ipr.univ-rennes.fr/show_bug.cgi?id=2713
This commit is contained in:
		
							parent
							
								
									bcf8310c59
								
							
						
					
					
						commit
						9def80af12
					
				|  | @ -95,6 +95,32 @@ replace_in_file() | |||
| 	fi | ||||
| } | ||||
| 
 | ||||
| is_version_greater_than() | ||||
| { | ||||
| 	 | ||||
| 	first_value="${1}" | ||||
| 	value_to_compare="${2}" | ||||
| 
 | ||||
| 	## Return False by default | ||||
| 	return_is_version_greater_than="1" | ||||
| 	 | ||||
| 	log 'debug' "is_version_greater_than - Is first value (${first_value}) greater than the second value (${value_to_compare})." | ||||
| 	 | ||||
| 	if printf '%s\n' "${first_value}" "${value_to_compare}" | sort --check=quiet --version-sort; then | ||||
| 		log 'debug' "${debug_prefix}is_version_greater_than - ${first_value} <= ${value_to_compare} ." | ||||
| 		return_is_version_greater_than="1" | ||||
| 	else | ||||
| 		log 'debug' "${debug_prefix}is_version_greater_than - ${first_value} > ${value_to_compare} ." | ||||
| 		return_is_version_greater_than="0" | ||||
| 	fi | ||||
| 
 | ||||
| 	unset first_value | ||||
| 	unset value_to_compare | ||||
| 
 | ||||
| 	return "${return_is_version_greater_than}" | ||||
| } | ||||
| 
 | ||||
| 
 | ||||
| controller__get_local_repos_path() | ||||
| { | ||||
| 	local debops_controller_path="$1" | ||||
|  | @ -178,9 +204,18 @@ deboco__init() | |||
| 	if [ "$bug_3715_is_fixed" = 'false' ] | ||||
| 	then | ||||
| 		# make sure that the python version is at least 3.10 so that ansible>=2.15 is installed (as debops 3.1 requires ansible>=2.15) | ||||
| 		local python_version=$(${PYTHON_PATH} --version | cut --delimiter=" " --fields=2 --) | ||||
| 		log 'debug' "python_version=$python_version" | ||||
| 
 | ||||
| 		if is_version_greater_than "3.10" "${python_version}" | ||||
| 		then | ||||
| 			log 'error' "debops only works with python version 3.10 or more, and your version of python is $python_version" | ||||
| 			return $RETURNCODE_ERROR | ||||
| 		fi | ||||
| 
 | ||||
| 		replace_in_file "$debops_update_script_path" \ | ||||
| 			'virtualenv --quiet -- ' \ | ||||
| 			'/usr/bin/python3.10 -m venv ' | ||||
| 			"${PYTHON_PATH} -m venv " | ||||
| 		if [ $? != "$RETURNCODE_SUCCESS" ] | ||||
| 		then | ||||
| 			return $RETURNCODE_ERROR | ||||
|  | @ -313,9 +348,13 @@ deboco_print_usage() | |||
| 	echo "$0 performs a debops controller operation" | ||||
| 	echo  | ||||
| 	echo "usage:" | ||||
| 	echo " $0 <command>" | ||||
| 	echo " $0 [options] <command>" | ||||
| 	echo  | ||||
| 	echo "where:" | ||||
| 	echo "  [options] is a set of:" | ||||
| 	echo "     --python-path <python-path>" | ||||
| 	echo "        specifies the python executable to use (must be python 3.10 or above). Default is $DEFAULT_PYTHON_PATH" | ||||
| 	echo  | ||||
| 	echo "  <command> is one of:" | ||||
| 	echo "     init <debobs-controller-path>" | ||||
| 	echo "        creates a debops controller in <debobs-controller-path>" | ||||
|  | @ -332,21 +371,31 @@ deboco_print_usage() | |||
| 	echo "     configure_machine <debobs-controller-path> <machine-fqdn>" | ||||
| 	echo "        configures the machine <machine-fqdn> using the debops controller in <debobs-controller-path>". Equivivalent to a init_machine followed by update_machine | ||||
| 	echo  | ||||
| 	echo "example:" | ||||
| 	echo "     deboco --python-path /usr/bin/python3.10 init ~/work/debops/constrollers/alambix" | ||||
| } | ||||
| 
 | ||||
| deboco() | ||||
| { | ||||
| 	local command_name="$1" | ||||
| 	shift | ||||
| 	if type "deboco__${command_name}" >/dev/null 2>&1 | ||||
| 	then | ||||
| 		"deboco__${command_name}" "$@" | ||||
| 		return $? | ||||
| 	else | ||||
| 		log 'error' "unknown command: ${command_name}" | ||||
| 		deboco_print_usage | ||||
| 		return "$RETURNCODE_ERROR" | ||||
| 	fi | ||||
| 	PYTHON_PATH="$DEFAULT_PYTHON_PATH" | ||||
| 	while true | ||||
| 	do | ||||
| 		local arg="$1" | ||||
| 		shift | ||||
| 		if [ "$arg" = '--python-path' ] | ||||
| 		then | ||||
| 			PYTHON_PATH="$1" | ||||
| 			shift | ||||
| 		elif type "deboco__${arg}" >/dev/null 2>&1 | ||||
| 		then | ||||
| 			"deboco__${arg}" "$@" | ||||
| 			return $? | ||||
| 		else | ||||
| 			log 'error' "unhandled argument: ${arg}" | ||||
| 			deboco_print_usage | ||||
| 			return "$RETURNCODE_ERROR" | ||||
| 		fi | ||||
| 	done | ||||
| } | ||||
| 
 | ||||
| 
 | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue