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"