Received: from list by lists.gnu.org with archive (Exim 4.90_1) id 1mBtbp-0002OR-2X for mharc-grub-devel@gnu.org; Fri, 06 Aug 2021 02:45:33 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:39402) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mBtbn-0002LZ-M1 for grub-devel@gnu.org; Fri, 06 Aug 2021 02:45:31 -0400 Received: from smtp-out2.suse.de ([195.135.220.29]:36478) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mBtbg-0000mg-Iv for grub-devel@gnu.org; Fri, 06 Aug 2021 02:45:31 -0400 Received: from imap1.suse-dmz.suse.de (imap1.suse-dmz.suse.de [192.168.254.73]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id CF0B31FEAF; Fri, 6 Aug 2021 06:45:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1628232321; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=F4JJy16wxdF9o2e6NU7kHrJ5BeFWN+HNiuYYL0zEBSs=; b=VkhqBqs143sCu5sw0Aho3T65thvOiVI2/VBfmtS1hlsy5U/BrkZRMCtsvZHUuvfkfJPeSM 5Ek9yxhzJFZgO3GetJt18sOLsEHsYzXr+vqrBbmBf9Mw8jXmJxQ5EJXkKKrgH2JeyMMjrx 1nUL9gLhHMWfZc3fEwhtOr3jf3gshwQ= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1628232321; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=F4JJy16wxdF9o2e6NU7kHrJ5BeFWN+HNiuYYL0zEBSs=; b=OIHbVOiH9D7JbbIDgzsi/5gx7AETjJnD9oSzXRlbqIJcRXzjPeZzUWk4617I8Oy9cFSKI3 cBA+MBcLy2puT2Cg== Received: from imap1.suse-dmz.suse.de (imap1.suse-dmz.suse.de [192.168.254.73]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap1.suse-dmz.suse.de (Postfix) with ESMTPS id 960F0136D9; Fri, 6 Aug 2021 06:45:21 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap1.suse-dmz.suse.de with ESMTPSA id uEehIoHaDGFACAAAGKfGzw (envelope-from ); Fri, 06 Aug 2021 06:45:21 +0000 From: Petr Vorel To: grub-devel@gnu.org Cc: Petr Vorel , Daniel Kiper Subject: [PATCH 2/2] autogen.sh: Detect python Date: Fri, 6 Aug 2021 08:45:08 +0200 Message-Id: <20210806064508.4489-2-pvorel@suse.cz> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210806064508.4489-1-pvorel@suse.cz> References: <20210806064508.4489-1-pvorel@suse.cz> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Received-SPF: pass client-ip=195.135.220.29; envelope-from=pvorel@suse.cz; helo=smtp-out2.suse.de X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: The development of GNU GRUB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 06 Aug 2021 06:45:31 -0000 It help to avoid error on distros which has only python3 binary: ./autogen.sh: line 20: python: command not found Using bash builtin 'command -v' to avoid requiring which as extra dependency (usable on containers). Keep the possibility to define PYTHON. Signed-off-by: Petr Vorel --- autogen.sh | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/autogen.sh b/autogen.sh index 31b0ced7e..46f9e1a6d 100755 --- a/autogen.sh +++ b/autogen.sh @@ -7,8 +7,21 @@ if [ ! -e grub-core/lib/gnulib/stdlib.in.h ]; then exit 1 fi -# Set ${PYTHON} to plain 'python' if not set already -: ${PYTHON:=python} +# Detect python +if [ -z "$PYTHON" ]; then + for i in python python3 python2; do + if command -v "$i" > /dev/null 2>&1; then + PYTHON="$i" + echo "Using $PYTHON" >&2 + break + fi + done + + if [ -z "$PYTHON" ]; then + echo "python not found" >&2 + exit 1 + fi +fi export LC_COLLATE=C unset LC_ALL -- 2.32.0