[devtools,1/1] makechrootpkg: try to copy with hard links

Message ID 20170714100428.5109-1-list@eworm.de
State Rejected
Headers show
Series [devtools,1/1] makechrootpkg: try to copy with hard links | expand

Commit Message

Christian Hesse July 14, 2017, 10:04 a.m. UTC
From: Christian Hesse <mail@eworm.de>

Using rsync for a fresh copy double the amount of used memory. Instead
use cp with hard links.

Signed-off-by: Christian Hesse <mail@eworm.de>
---
 makechrootpkg.in | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

Comments

Emil Velikov via arch-projects Aug. 12, 2017, 11:18 p.m. UTC | #1
On Fri, Jul 14, 2017 at 12:04 PM Christian Hesse <list@eworm.de> wrote:

> Using rsync for a fresh copy double the amount of used memory. Instead
> use cp with hard links.
>

This seems rather unsafe. Changes to files in the copydir contaminate the
rootdir.
<div dir="ltr">On Fri, Jul 14, 2017 at 12:04 PM Christian Hesse &lt;<a href="mailto:list@eworm.de">list@eworm.de</a>&gt; wrote:<br><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Using rsync for a fresh copy double the amount of used memory. Instead<br>
use cp with hard links.<br></blockquote><div><br></div><div>This seems rather unsafe. Changes to files in the copydir contaminate the rootdir.<br></div></div></div>

Patch

diff --git a/makechrootpkg.in b/makechrootpkg.in
index 8d8fd05..f711201 100644
--- a/makechrootpkg.in
+++ b/makechrootpkg.in
@@ -127,8 +127,11 @@  sync_chroot() {
 		btrfs subvolume snapshot "$rootdir" "$copydir" >/dev/null ||
 			die "Unable to create subvolume %s" "$copydir"
 	else
-		mkdir -p "$copydir"
-		rsync -a --delete -q -W -x "$rootdir/" "$copydir"
+		if [[ -e "$copydir" ]]; then
+			rsync -a --delete -q -W -x "$rootdir/" "$copydir/"
+		else
+			cp --archive --link "$rootdir/" "$copydir/"
+		fi
 	fi
 	stat_done