From patchwork Thu Jun 1 17:29:17 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Emil Velikov via arch-projects X-Patchwork-Id: 188 Return-Path: Delivered-To: patchwork@archlinux.org Received: from nymeria.archlinux.org by nymeria.archlinux.org (Dovecot) with LMTP id EQIeDgpPMFmgeAAAtiB/HQ for ; Thu, 01 Jun 2017 19:29:46 +0200 Received: from nymeria.archlinux.org (localhost.localdomain [127.0.0.1]) by nymeria.archlinux.org (Postfix) with ESMTP id 9E1CA40308; Thu, 1 Jun 2017 19:29:44 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on nymeria.archlinux.org X-Spam-Level: X-Spam-Status: No, score=-4.3 required=2.5 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,RCVD_IN_DNSWL_MED shortcircuit=no autolearn=ham autolearn_force=no version=3.4.1 Received: from luna.archlinux.org (luna.archlinux.org [IPv6:2a01:4f8:160:3033::2]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by nymeria.archlinux.org (Postfix) with ESMTPS; Thu, 1 Jun 2017 19:29:44 +0200 (CEST) Received: from luna.archlinux.org (luna.archlinux.org [127.0.0.1]) by luna.archlinux.org (Postfix) with ESMTP id EC470213C6; Thu, 1 Jun 2017 17:29:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=archlinux.org; s=luna2; t=1496338183; bh=sJGxMDl0EBxd8YQoS+Kq/f65g3t62jgnpleZvLNMTX0=; h=To:Date:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:Cc; b=Pndna1oo/OdOrvPpU4yC0dfv3zD5VD7olVVL5+zlAIWQQER1u0JHc027o3UbBJXTH DjoRJYtRST5vsTZImmwhaL9JEv3AmbzZVj0v5rLLrXy13CkNMOhy7uO1mFOi1R2MUY bEliSo0ITPAypCI4GELPXimnDVYnUKKvAU9XvckjDzkJB1lIgJL4gdY5pCm6l1T/hJ 8RYRqE4wEzAi6mIOoWa1vpPTh8/hYXgzqiw9S/6oj+CSaPlWrW5k1gU+8GVoD006aN uraviYEqGEQ9Gg/QmhHHRSnLCXOCkMhg/I4GIOdI9nnFkiRcZPrVJ7bFCgDEBRpai6 BdAthrXccs0CfKAt/GZV9ynbHehy/cc7BQ52ztR+zVG+bohAmToBCdDQdpGC75ZizU 986tEkWn48DW/GW9E6yX9V5rt9aR5LvkjvraxXZEw3B2LzNF3hVk/iABGsSq3uTjKP g4WsA06/eQlz8lV87K8ZIkS9iGw6bnOQf069rJC8YSmUFvOEjj+zeT32mg3NfSyP1U Nnl+aiTp04eqC2eijY7qKtzTwf8BH9fjwPo9gsyaocEZATze/xSF+4r2Piw/N2cC09 M6e49nMQf1yQVnM6ORwd35DcM2M33I7G1RATTqlKL2508VIi0p2ujxFGKeqidz/ggM d2ITbVfeskHq3UHr6n4BNarA= Received: from luna.archlinux.org (luna.archlinux.org [127.0.0.1]) by luna.archlinux.org (Postfix) with ESMTP id 126B5208B3 for ; Thu, 1 Jun 2017 17:29:42 +0000 (UTC) Received: from nymeria.archlinux.org (nymeria.archlinux.org [IPv6:2a00:1828:2000:547::2]) by luna.archlinux.org (Postfix) with ESMTPS for ; Thu, 1 Jun 2017 17:29:42 +0000 (UTC) Received: from nymeria.archlinux.org (localhost.localdomain [127.0.0.1]) by nymeria.archlinux.org (Postfix) with ESMTP id 243D540253; Thu, 1 Jun 2017 19:29:39 +0200 (CEST) Received: from mail-lf0-x244.google.com (mail-lf0-x244.google.com [IPv6:2a00:1450:4010:c07::244]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by nymeria.archlinux.org (Postfix) with ESMTPS; Thu, 1 Jun 2017 19:29:38 +0200 (CEST) Received: by mail-lf0-x244.google.com with SMTP id h4so4759921lfj.3; Thu, 01 Jun 2017 10:29:38 -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; bh=lq883GBdwJvnnQINoE/pbRsNSDZoiS4qzJApoa0nGus=; b=L3HfeFxm8YMwsVB1GsEZFhe2xR1omnu7cMVSs9Nw946M2jRh5/aIvYTVZacSnC7Tbj rYSF2PXNVK1zDCq3Vp3qWaW8hm3pqlZzJ7J2cLYHT4HyRoV9lhSCI49LOZIQ3bAjw/SL SKcn1BpbmqEqtfIqV5B2HvQpWLaA1vu1IsKns72Aq2+hG8kd2i3jtgD3dur9rq5scNug uAq8tSZcvbWxG65VJsNWPcU74J3Y5wxzspsl7G9u+40Jh0cEbiaSXKEMJKjEcpV9VS26 zR85pp2ZhyPrVpjANhpthFynWw9k1+XoTKGPHLn/eKbD6ZozImy9kkduO3Bwxb8vLD+V 8csQ== X-Gm-Message-State: AODbwcAJcCGYhuLVDo1SUMyNC2V3fUsoGitfxhOKlMhDgMflWYp4eMDG jPVeGnIoK8vAYMEm X-Received: by 10.46.69.7 with SMTP id s7mr915934lja.72.1496338178182; Thu, 01 Jun 2017 10:29:38 -0700 (PDT) Received: from erik-mate-1604.lan (90-227-62-61-no75.tbcn.telia.com. [90.227.62.61]) by smtp.gmail.com with ESMTPSA id s26sm4382409ljd.27.2017.06.01.10.29.37 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 01 Jun 2017 10:29:37 -0700 (PDT) To: dreisner@archlinux.org, arch-projects@archlinux.org Date: Thu, 1 Jun 2017 19:29:17 +0200 Message-Id: <1496338158-3540-1-git-send-email-erik.stromdahl@gmail.com> X-Mailer: git-send-email 2.7.4 Subject: [arch-projects] [mkinitcpio][PATCH v2 1/2] functions: add_full_dir: recursive filter X-BeenThere: arch-projects@archlinux.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Arch Linux projects development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , From: Erik Stromdahl via arch-projects Reply-To: Arch Linux projects development discussion Cc: Erik Stromdahl Errors-To: arch-projects-bounces@archlinux.org Sender: "arch-projects" X-UID: 443 Status: X-Keywords: Content-Length: 809 By passing the filter glob in all recursive invocations of add_full_dir, the filtering is performed on all subdirs and not just the top dir. This makes the implementation correspond to the documented behavior in the man page. Signed-off-by: Erik Stromdahl --- functions | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions b/functions index e35a03b..0c407e9 100644 --- a/functions +++ b/functions @@ -435,7 +435,7 @@ add_full_dir() { add_symlink "$f" "$(readlink "$f")" fi elif [[ -d $f ]]; then - add_full_dir "$f" + add_full_dir "$f" "$filter" elif [[ -f $f ]]; then if [[ $f = $filter ]]; then add_file "$f" From patchwork Thu Jun 1 17:29:18 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Emil Velikov via arch-projects X-Patchwork-Id: 189 Return-Path: Delivered-To: patchwork@archlinux.org Received: from nymeria.archlinux.org by nymeria.archlinux.org (Dovecot) with LMTP id GWxpHA1PMFmYeAAAtiB/HQ for ; Thu, 01 Jun 2017 19:29:49 +0200 Received: from nymeria.archlinux.org (localhost.localdomain [127.0.0.1]) by nymeria.archlinux.org (Postfix) with ESMTP id 8FE6340420; Thu, 1 Jun 2017 19:29:46 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on nymeria.archlinux.org X-Spam-Level: X-Spam-Status: No, score=-4.3 required=2.5 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,RCVD_IN_DNSWL_MED shortcircuit=no autolearn=unavailable autolearn_force=no version=3.4.1 Received: from luna.archlinux.org (luna.archlinux.org [IPv6:2a01:4f8:160:3033::2]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by nymeria.archlinux.org (Postfix) with ESMTPS; Thu, 1 Jun 2017 19:29:46 +0200 (CEST) Received: from luna.archlinux.org (luna.archlinux.org [127.0.0.1]) by luna.archlinux.org (Postfix) with ESMTP id 211EE213FB; Thu, 1 Jun 2017 17:29:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=archlinux.org; s=luna2; t=1496338186; bh=vkfv/Kc9bMMRDxqmnGWF20dsUtOooYd0XPIShIKjKn8=; h=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc; b=N86zx6y5UFhXsupaFeigq6zkpoBrWdEua2Tsmnmxp/Z+NCCsq2tLY+/gA86jLqL13 oJDn30HQy7Sa+FtlrnQJKXa9hiTrvwpDCGJldOAQWa9MS3tu+teeY5lJMbtbjjKkbV JwPUADNVCls23W/jN3mVl9Mok23pF3LLXweQR1yp9maQgi/Y+aTtLT4ddHcmCQb2LQ cASB0SsOLR0DPxL0qhlIuhSXgVSVdZYTk8GH/0R01m5QlU/DhdauleCxBBML2W+w/R t1MMc1GsnhrMfzhq/fmaFrzGpal0AOSWsW+wbaCsm9Q6It+aR1oPH8ZiIZc/dOVmxv 5xvIUc3v7YvNM1Q0bR2QwE+x8THtrJNw70yay4kqd1tpxcmfFteueqFRWbqxXWErV1 FH0dhrx/0+deVjRtv5MY3mBqeTKvDjR6Zzaf2fyZc90tUZqXxkq7gxy807+uRA2vql 9PCSUvCqPKjog7jcDWhaA/9yRQgRbiZZjh0B8IKcChULqZ8WG9sC0qRqDf6zc4exxB jVyx5F5IWbgicV63DjELpIOdYOz488ItFvzAQ2Bc/JFMQyP0WpdjjH65SHn/i8IKIy Fgv93/s8kKaISPigMHoxuySkg8TG7OPxPGtuGlqTDbEUwjw2rVP/uifDaEV6TT8u4i xP96c4RQhsZj2Uf0Vd30o0HE= Received: from luna.archlinux.org (luna.archlinux.org [127.0.0.1]) by luna.archlinux.org (Postfix) with ESMTP id A9C15213F7 for ; Thu, 1 Jun 2017 17:29:44 +0000 (UTC) Received: from nymeria.archlinux.org (nymeria.archlinux.org [89.238.67.251]) by luna.archlinux.org (Postfix) with ESMTPS for ; Thu, 1 Jun 2017 17:29:44 +0000 (UTC) Received: from nymeria.archlinux.org (localhost.localdomain [127.0.0.1]) by nymeria.archlinux.org (Postfix) with ESMTP id D8C7E40274; Thu, 1 Jun 2017 19:29:40 +0200 (CEST) Received: from mail-lf0-x243.google.com (mail-lf0-x243.google.com [IPv6:2a00:1450:4010:c07::243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by nymeria.archlinux.org (Postfix) with ESMTPS; Thu, 1 Jun 2017 19:29:40 +0200 (CEST) Received: by mail-lf0-x243.google.com with SMTP id 99so4754794lfu.2; Thu, 01 Jun 2017 10:29:40 -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=CmRJfr4bT4ogeG66MOG/BwmbnIQB+Zs5LNJUd3mhQoE=; b=Dgv5tv/4AYpI50iNhSTbNDKlZotYJ42XKyqPmRIF4aqtpuKQu/hZoujHjl50HwhkkL oUDjqoKiSUGzMvIEvpPq0Op5JKUWG9n5NbTD1+N89h52WmGumW+FuHjSvFhSdn4/Td8j rbPmU7j/Y1sTsszaq2EGKFwFgVY6vr06Rxg8aDRWSlZq4R7KcRMB3WYAgmbStABBxiIN Y8T0ciolKw0v883SWXs4wcfXjtTE6X6K/R9ygVJXwbce20MI7szCDPj5bvK1LVIrWJxf GQ93qqpc7haO2pZPgXPYN62BFeuIhLudJF0oGjhCXZB7ZBQA+ibeU+PT9zQASkI+5xwP wa7A== X-Gm-Message-State: AODbwcAiBJGcJhDLIiIsgcOFawwQdis6bU6gPDsP/2wDNRK0Nb2Il3+P LOt7kouE0cdlTFKE X-Received: by 10.46.8.18 with SMTP id 18mr968385lji.90.1496338179096; Thu, 01 Jun 2017 10:29:39 -0700 (PDT) Received: from erik-mate-1604.lan (90-227-62-61-no75.tbcn.telia.com. [90.227.62.61]) by smtp.gmail.com with ESMTPSA id s26sm4382409ljd.27.2017.06.01.10.29.38 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 01 Jun 2017 10:29:38 -0700 (PDT) To: dreisner@archlinux.org, arch-projects@archlinux.org Date: Thu, 1 Jun 2017 19:29:18 +0200 Message-Id: <1496338158-3540-2-git-send-email-erik.stromdahl@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1496338158-3540-1-git-send-email-erik.stromdahl@gmail.com> References: <1496338158-3540-1-git-send-email-erik.stromdahl@gmail.com> Subject: [arch-projects] [mkinitcpio][PATCH v2 2/2] functions: add_full_dir: path prefix strip-off X-BeenThere: arch-projects@archlinux.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Arch Linux projects development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , From: Erik Stromdahl via arch-projects Reply-To: Arch Linux projects development discussion Cc: Erik Stromdahl Errors-To: arch-projects-bounces@archlinux.org Sender: "arch-projects" X-UID: 444 Status: X-Keywords: Content-Length: 2877 Add third argument to add_full_dir: strip_prefix. The strip_prefix will be stripped off from the destination path (path in the initramfs image) when adding files. Rationale: Make it easier to add rootfs overlay hooks when generating images. add_full_dir can be invoked in this way: add_full_dir /path/on/parent/rootfs-overlay * /path/on/parent/rootfs-overlay The above invocation will add all content of */path/on/parent/rootfs-overlay* into */* in the initramfs image. Signed-off-by: Erik Stromdahl --- functions | 9 +++++---- man/mkinitcpio.8.txt | 7 ++++++- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/functions b/functions index 0c407e9..2325a86 100644 --- a/functions +++ b/functions @@ -423,8 +423,9 @@ add_full_dir() { # No parsing is performed and the contents of the directory is added as is. # $1: path to directory # $2: glob pattern to filter file additions (optional) + # $3: path prefix that will be stripped off from the image path (optional) - local f= filter=${2:-*} + local f= filter=${2:-*} strip_prefix=$3 if [[ -n $1 && -d $1 ]]; then add_dir "$1" @@ -432,13 +433,13 @@ add_full_dir() { for f in "$1"/*; do if [[ -L $f ]]; then if [[ $f = $filter ]]; then - add_symlink "$f" "$(readlink "$f")" + add_symlink "${f#$strip_prefix}" "$(readlink "$f")" fi elif [[ -d $f ]]; then - add_full_dir "$f" "$filter" + add_full_dir "$f" "$filter" "$strip_prefix" elif [[ -f $f ]]; then if [[ $f = $filter ]]; then - add_file "$f" + add_file "$f" "${f#$strip_prefix}" fi fi done diff --git a/man/mkinitcpio.8.txt b/man/mkinitcpio.8.txt index 5c3118e..931a167 100644 --- a/man/mkinitcpio.8.txt +++ b/man/mkinitcpio.8.txt @@ -139,7 +139,7 @@ functions exist to facilitate this. Adds a directory and its parents to the image. -*add_full_dir* 'directory' [ 'glob' ]:: +*add_full_dir* 'directory' [ 'glob' ] [ 'strip_prefix' ]:: Recursively adds a directory to the image by walking the given path and calling *add_file*, *add_dir*, and *add_symlink* accordingly. This function @@ -148,6 +148,11 @@ functions exist to facilitate this. If the 'glob' argument is passed, only files and symlinks matching this glob will be added. + If the 'strip_prefix' argument is passed, it will be used to strip the + destination path (path in the initramfs image) from the prefix specified by + the 'strip_prefix' argument. This can be useful when writing rootfs-overlay + hooks. + *add_symlink* 'path' [ 'link-target' ]:: Adds a symlink to the image at the specified `path`, optionally pointing to