From patchwork Sat Apr 28 09:31:07 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Panteleev X-Patchwork-Id: 500 Return-Path: Delivered-To: patchwork@archlinux.org Received: from apollo.archlinux.org (localhost [127.0.0.1]) by apollo.archlinux.org (Postfix) with ESMTP id 6C7533A263C5 for ; Sat, 28 Apr 2018 09:31:42 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on apollo.archlinux.org X-Spam-Level: X-Spam-Status: No, score=-3.3 required=5.0 tests=MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3 autolearn=ham autolearn_force=no version=3.4.1 X-Spam-BL-Results: [127.0.9.2] [127.0.0.15, 127.0.0.6] Received: from orion.archlinux.org (orion.archlinux.org [88.198.91.70]) by apollo.archlinux.org (Postfix) with ESMTPS for ; Sat, 28 Apr 2018 09:31:42 +0000 (UTC) Received: from orion.archlinux.org (localhost [127.0.0.1]) by orion.archlinux.org (Postfix) with ESMTP id DD03AA167B2E8; Sat, 28 Apr 2018 09:31:36 +0000 (UTC) Received: from luna.archlinux.org (luna.archlinux.org [5.9.250.164]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by orion.archlinux.org (Postfix) with ESMTPS; Sat, 28 Apr 2018 09:31:36 +0000 (UTC) Received: from luna.archlinux.org (luna.archlinux.org [127.0.0.1]) by luna.archlinux.org (Postfix) with ESMTP id C4EF02CE16; Sat, 28 Apr 2018 09:31:36 +0000 (UTC) Authentication-Results: luna.archlinux.org; dkim=none Received: from luna.archlinux.org (luna.archlinux.org [127.0.0.1]) by luna.archlinux.org (Postfix) with ESMTP id 855182BE39 for ; Sat, 28 Apr 2018 09:31:34 +0000 (UTC) Received: from orion.archlinux.org (orion.archlinux.org [88.198.91.70]) by luna.archlinux.org (Postfix) with ESMTPS for ; Sat, 28 Apr 2018 09:31:34 +0000 (UTC) Received: from orion.archlinux.org (localhost [127.0.0.1]) by orion.archlinux.org (Postfix) with ESMTP id 127CAA167B2DD for ; Sat, 28 Apr 2018 09:31:30 +0000 (UTC) Received: from mail-wr0-f196.google.com (mail-wr0-f196.google.com [209.85.128.196]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by orion.archlinux.org (Postfix) with ESMTPS for ; Sat, 28 Apr 2018 09:31:29 +0000 (UTC) Received: by mail-wr0-f196.google.com with SMTP id v5-v6so3814562wrf.9 for ; Sat, 28 Apr 2018 02:31:29 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=VWaEB5KlZK+9aLLB53vmSCfa6PBoObNZPRDxVd17dj4=; b=PvzRixjOc8fmt5q4jnfNZPUSPvkpfS64tZC/5rG9No4rvT7KMPYdBA4vCotfZ6Xobt rubvjVxk6DpxodSgo44DoqCgY2ZvKAKJ8ApR5XvnzdQqkPlOjHcxSXiMUoAOqGf+bN9P nGuJZxbaZebcYCZHz9kNX+PrBMQ5q7VnaZD3tqvWD7w9sxqrDV0TvfUrfSNueOyjkJGV psRr458BvvrphBTetfsBhap2LKdABrQylzfkbf0jGeVcm8Luj0aGXnw0yHJ4YmPCaIaq B7H64pfolgT1aWR5aCwn9aM/8Q1Le00yfaxEkJU8X5/HX6dKSJjSMs5OVAo18fz5826s QIWQ== X-Gm-Message-State: ALQs6tD5ewY8jFhiv+MEj2rn5/3ibBcYdIxFw6/ht8nXnvTtnYrw0Pey Ti1zzoMJme6kkG3g8oOzL9bZQqOn X-Google-Smtp-Source: AB8JxZoYCckehIDj7tay5JfCewbtBwp95ZxVj0JNU+mP5RKRsK4BaP/5qlytcb+1UWsDchH6KuCFqA== X-Received: by 2002:adf:c753:: with SMTP id b19-v6mr1256822wrh.65.1524907889449; Sat, 28 Apr 2018 02:31:29 -0700 (PDT) Received: from home.thecybershadow.net ([89.28.117.31]) by smtp.gmail.com with ESMTPSA id o16sm2907038wmi.14.2018.04.28.02.31.27 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 28 Apr 2018 02:31:28 -0700 (PDT) From: Vladimir Panteleev To: pacman-dev@archlinux.org Date: Sat, 28 Apr 2018 09:31:07 +0000 Message-Id: <20180428093108.8263-2-archlinux@thecybershadow.net> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180428093108.8263-1-archlinux@thecybershadow.net> References: <20180428093108.8263-1-archlinux@thecybershadow.net> Subject: [pacman-dev] [PATCH 1/2] libmakepkg: Fix handling of file paths in get_filepath X-BeenThere: pacman-dev@archlinux.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: Discussion list for pacman development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: Discussion list for pacman development Cc: Vladimir Panteleev Errors-To: pacman-dev-bounces@archlinux.org Sender: "pacman-dev" With local sources containing a path component, get_filepath used to silently discard the non-filename part of the source URI, which led to uninformative errors (as well as not being able to place source files in a subdirectory). Correct this bug by explicitly adding a case for the local protocol, and appropriately resolve file paths (local or global) to an absolute one usable by extract_file. --- scripts/libmakepkg/util/source.sh.in | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/scripts/libmakepkg/util/source.sh.in b/scripts/libmakepkg/util/source.sh.in index 17e44664..5092347d 100644 --- a/scripts/libmakepkg/util/source.sh.in +++ b/scripts/libmakepkg/util/source.sh.in @@ -85,8 +85,9 @@ get_filename() { # Return the absolute filename of a source entry get_filepath() { - local file="$(get_filename "$1")" - local proto="$(get_protocol "$1")" + local netfile="$1" + local file="$(get_filename "$netfile")" + local proto="$(get_protocol "$netfile")" case $proto in bzr*|git*|hg*|svn*) @@ -98,6 +99,23 @@ get_filepath() { return 1 fi ;; + local) + if [[ "$netfile" == /* ]]; then + # absolute path + if [[ -f "$netfile" ]]; then + file="$netfile" + else + return 1 + fi + elif [[ -f "$startdir/$netfile" ]]; then + # relative path + file="$startdir/$netfile" + elif [[ -f "$SRCDEST/$netfile" ]]; then + file="$SRCDEST/$netfile" + else + return 1 + fi + ;; *) if [[ -f "$startdir/$file" ]]; then file="$startdir/$file" From patchwork Sat Apr 28 09:31:08 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Panteleev X-Patchwork-Id: 501 Return-Path: Delivered-To: patchwork@archlinux.org Received: from apollo.archlinux.org (localhost [127.0.0.1]) by apollo.archlinux.org (Postfix) with ESMTP id F15A13A26400 for ; Sat, 28 Apr 2018 09:31:51 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on apollo.archlinux.org X-Spam-Level: X-Spam-Status: No, score=-3.3 required=5.0 tests=MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3 autolearn=ham autolearn_force=no version=3.4.1 X-Spam-BL-Results: [127.0.9.2] [127.0.0.6] Received: from orion.archlinux.org (orion.archlinux.org [IPv6:2a01:4f8:160:6087::1]) by apollo.archlinux.org (Postfix) with ESMTPS for ; Sat, 28 Apr 2018 09:31:51 +0000 (UTC) Received: from orion.archlinux.org (localhost [127.0.0.1]) by orion.archlinux.org (Postfix) with ESMTP id 26DE0A167B2F8; Sat, 28 Apr 2018 09:31:40 +0000 (UTC) Received: from luna.archlinux.org (luna.archlinux.org [5.9.250.164]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by orion.archlinux.org (Postfix) with ESMTPS; Sat, 28 Apr 2018 09:31:40 +0000 (UTC) Received: from luna.archlinux.org (luna.archlinux.org [127.0.0.1]) by luna.archlinux.org (Postfix) with ESMTP id E4DF52CFB3; Sat, 28 Apr 2018 09:31:36 +0000 (UTC) Authentication-Results: luna.archlinux.org; dkim=none Received: from luna.archlinux.org (luna.archlinux.org [127.0.0.1]) by luna.archlinux.org (Postfix) with ESMTP id 442602CE14 for ; Sat, 28 Apr 2018 09:31:36 +0000 (UTC) Received: from orion.archlinux.org (orion.archlinux.org [88.198.91.70]) by luna.archlinux.org (Postfix) with ESMTPS for ; Sat, 28 Apr 2018 09:31:36 +0000 (UTC) Received: from orion.archlinux.org (localhost [127.0.0.1]) by orion.archlinux.org (Postfix) with ESMTP id CE542A167B2DF for ; Sat, 28 Apr 2018 09:31:31 +0000 (UTC) Received: from mail-wm0-f42.google.com (mail-wm0-f42.google.com [74.125.82.42]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by orion.archlinux.org (Postfix) with ESMTPS for ; Sat, 28 Apr 2018 09:31:31 +0000 (UTC) Received: by mail-wm0-f42.google.com with SMTP id a137so4437772wme.1 for ; Sat, 28 Apr 2018 02:31:31 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=8Unryd/T89y7cNw+UvOq1qiAjmBlsyciTq500h2eoeo=; b=ngsCDhSY7IWgqeQvzIA5DcOg4c0Zo1OJuCLX8B+BQS50XD/MLTNhK4MBdrTRjYHBUk iDAKWne++NL8iUvBdwGUHnSah+2MH5ILxct3dlEl8ca7XlK/nN2clijXLdxXlNH6ssxy J42csoxsE/PDaO4pEQVmWQNWCpIFXfAtObcX3a9IbCvPTC9Bbju4MmOxJdQF6bxgcVMp 7i4XYQQ3Jw7wRLjeY9JW21iDiBKZoA3uwrKOqn/9P2e1H6djngKmHXOADq1sP8UWgsg1 yyymU1slLhknFB/kFeC3gKHS8+LopyQ9dApsjx9WscvWsnE4xBeMJ5QUJt8mG4A9esbu 03oQ== X-Gm-Message-State: ALQs6tCDkLkCrNRlsa/ozKtV5iAJj1Q+qCsnVu02kaWJVk+D2npYU7Fj Rcb8VjbORCwGt/eQDRJc8lB98yNn X-Google-Smtp-Source: AB8JxZqIFDSZABF00R3bIleNjuwrD74CsPQ2ycDsj66CtNIHrWkMiwDicTkq62qOo0BSGLrJwtXKGg== X-Received: by 10.28.94.201 with SMTP id s192mr582990wmb.54.1524907891195; Sat, 28 Apr 2018 02:31:31 -0700 (PDT) Received: from home.thecybershadow.net ([89.28.117.31]) by smtp.gmail.com with ESMTPSA id o16sm2907038wmi.14.2018.04.28.02.31.29 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 28 Apr 2018 02:31:30 -0700 (PDT) From: Vladimir Panteleev To: pacman-dev@archlinux.org Date: Sat, 28 Apr 2018 09:31:08 +0000 Message-Id: <20180428093108.8263-3-archlinux@thecybershadow.net> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180428093108.8263-1-archlinux@thecybershadow.net> References: <20180428093108.8263-1-archlinux@thecybershadow.net> Subject: [pacman-dev] [PATCH 2/2] libmakepkg: Use the correct path in extract_sources X-BeenThere: pacman-dev@archlinux.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: Discussion list for pacman development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: Discussion list for pacman development Cc: Vladimir Panteleev Errors-To: pacman-dev-bounces@archlinux.org Sender: "pacman-dev" When extracting sources, we need to get the full path to the file being extracted (so that we can operate on it), instead of just the filename component. Previously, the filename coincidentally resolved to the same file as the one we should be working on (due to the working directory being appropriately set), but this assumption no longer holds now that a source may reside in a different directory. Fix this fragile assumption by correctly using the full path instead. --- scripts/libmakepkg/source.sh.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/libmakepkg/source.sh.in b/scripts/libmakepkg/source.sh.in index 02bb16f5..0bdd9602 100644 --- a/scripts/libmakepkg/source.sh.in +++ b/scripts/libmakepkg/source.sh.in @@ -90,7 +90,7 @@ extract_sources() { get_all_sources_for_arch 'all_sources' for netfile in "${all_sources[@]}"; do - local file=$(get_filename "$netfile") + local file=$(get_filepath "$netfile") local proto=$(get_protocol "$netfile") case "$proto" in bzr*)