mirror of
				https://github.com/torvalds/linux.git
				synced 2025-10-31 16:48:26 +02:00 
			
		
		
		
	scripts: sphinx-pre-install: only ask to activate valid venvs
If a venv doesn't contain Sphinx, or has an older Sphinx version, ignore it. Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org> Link: https://lore.kernel.org/r/d11a00d88514e8a0357e1b0a05ebd518952a1d39.1587478901.git.mchehab+huawei@kernel.org Signed-off-by: Jonathan Corbet <corbet@lwn.net>
This commit is contained in:
		
							parent
							
								
									1f5ea8720e
								
							
						
					
					
						commit
						a8b380c379
					
				
					 1 changed files with 37 additions and 16 deletions
				
			
		|  | @ -231,6 +231,27 @@ sub get_sphinx_fname() | ||||||
| 	return ""; | 	return ""; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | sub get_sphinx_version($) | ||||||
|  | { | ||||||
|  | 	my $cmd = shift; | ||||||
|  | 	my $ver; | ||||||
|  | 
 | ||||||
|  | 	open IN, "$cmd --version 2>&1 |"; | ||||||
|  | 	while (<IN>) { | ||||||
|  | 		if (m/^\s*sphinx-build\s+([\d\.]+)(\+\/[\da-f]+)?$/) { | ||||||
|  | 			$ver=$1; | ||||||
|  | 			last; | ||||||
|  | 		} | ||||||
|  | 		# Sphinx 1.2.x uses a different format | ||||||
|  | 		if (m/^\s*Sphinx.*\s+([\d\.]+)$/) { | ||||||
|  | 			$ver=$1; | ||||||
|  | 			last; | ||||||
|  | 		} | ||||||
|  | 	} | ||||||
|  | 	close IN; | ||||||
|  | 	return $ver; | ||||||
|  | } | ||||||
|  | 
 | ||||||
| sub check_sphinx() | sub check_sphinx() | ||||||
| { | { | ||||||
| 	my $rec_version; | 	my $rec_version; | ||||||
|  | @ -266,19 +287,8 @@ sub check_sphinx() | ||||||
| 		return; | 		return; | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	open IN, "$sphinx --version 2>&1 |" or die "$sphinx returned an error"; | 	$cur_version = get_sphinx_version($sphinx); | ||||||
| 	while (<IN>) { | 	die ("$sphinx returned an error") if (!$cur_version); | ||||||
| 		if (m/^\s*sphinx-build\s+([\d\.]+)(\+\/[\da-f]+)?$/) { |  | ||||||
| 			$cur_version=$1; |  | ||||||
| 			last; |  | ||||||
| 		} |  | ||||||
| 		# Sphinx 1.2.x uses a different format |  | ||||||
| 		if (m/^\s*Sphinx.*\s+([\d\.]+)$/) { |  | ||||||
| 			$cur_version=$1; |  | ||||||
| 			last; |  | ||||||
| 		} |  | ||||||
| 	} |  | ||||||
| 	close IN; |  | ||||||
| 
 | 
 | ||||||
| 	die "$sphinx didn't return its version" if (!$cur_version); | 	die "$sphinx didn't return its version" if (!$cur_version); | ||||||
| 
 | 
 | ||||||
|  | @ -765,10 +775,21 @@ sub check_needs() | ||||||
| 		my @activates = glob "$ENV{'PWD'}/${virtenv_prefix}*/bin/activate"; | 		my @activates = glob "$ENV{'PWD'}/${virtenv_prefix}*/bin/activate"; | ||||||
| 
 | 
 | ||||||
| 		@activates = sort {$b cmp $a} @activates; | 		@activates = sort {$b cmp $a} @activates; | ||||||
|  | 		my ($activate, $ver); | ||||||
|  | 		foreach my $f (@activates) { | ||||||
|  | 			$activate = $f; | ||||||
|  | 			next if ($activate lt $min_activate); | ||||||
| 
 | 
 | ||||||
| 		if ($need_sphinx && scalar @activates > 0 && $activates[0] ge $min_activate) { | 			my $sphinx_cmd = $activate; | ||||||
| 			printf "\nNeed to activate a compatible Sphinx version on virtualenv with:\n"; | 			$sphinx_cmd =~ s/activate/sphinx-build/; | ||||||
| 			printf "\t. $activates[0]\n"; | 			next if (! -f $sphinx_cmd); | ||||||
|  | 
 | ||||||
|  | 			$ver = get_sphinx_version($sphinx_cmd); | ||||||
|  | 			last if ($ver ge $min_version); | ||||||
|  | 		} | ||||||
|  | 		if ($need_sphinx && ($activate ne "")) { | ||||||
|  | 			printf "\nNeed to activate Sphinx (version $ver) on virtualenv with:\n"; | ||||||
|  | 			printf "\t. $activate\n"; | ||||||
| 			deactivate_help(); | 			deactivate_help(); | ||||||
| 			exit (1); | 			exit (1); | ||||||
| 		} else { | 		} else { | ||||||
|  |  | ||||||
		Loading…
	
		Reference in a new issue
	
	 Mauro Carvalho Chehab
						Mauro Carvalho Chehab