From 1b35dd595d6e7623c515becd64fe610b36e38bd0 Mon Sep 17 00:00:00 2001 From: clayton craft Date: Wed, 20 Sep 2017 18:36:22 +0000 Subject: [PATCH] Improve copy in mkinitfs (#599) 'install' does not properly handle symlinks, it copies the entire file instead of a symlink to it. This PR uses `cp -a` to preserve symlinks. For example, with `install`, the files libc.musl-armhf.so.1 and ld-musl-armhf.so.1 are the same size, despite the fact that in rootfs libc.musl-armhf.so.1 is actually a symlink to ld-musl-armhf.so.1. According to @drebrez research, the initramfs size shrunk from 1 567 930 to 1 168 591. --- main/postmarketos-mkinitfs/APKBUILD | 4 ++-- main/postmarketos-mkinitfs/mkinitfs.sh | 6 ++---- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/main/postmarketos-mkinitfs/APKBUILD b/main/postmarketos-mkinitfs/APKBUILD index cb3173570..bc14b8935 100644 --- a/main/postmarketos-mkinitfs/APKBUILD +++ b/main/postmarketos-mkinitfs/APKBUILD @@ -1,5 +1,5 @@ pkgname=postmarketos-mkinitfs -pkgver=0.3.5 +pkgver=0.3.6 pkgrel=0 pkgdesc="Tool to generate initramfs images for postmarketOS" url="https://github.com/postmarketOS" @@ -27,4 +27,4 @@ package() { } sha512sums="91860e61cc42b77c02522ab273cf4793b78ee595a75c026c057522a5e6d1fdcc7ec868cbdaea5912c90dea61483468dc609dc69144a6d8e68ef47c9d1459fdb6 init.sh.in 8823d0685c40f4a21936a3a371914a9af39f12ad48371ccdaea88379e2109bdd13728252ce774cc53f6053cecd51334ee3b7a3d559ba4b77e45d0e233714d930 init_functions.sh -6408f8b3302d965b7eb335ce617b28e8159420a9ec137243844f6ccf1f13055556b999c4f32385a4249aa8e9cce33898153a45dd53499a73a39d61dff18f3291 mkinitfs.sh" +8aae74c95df0f0c1cff317d0038c897d7406f29622d9657115b6cab02c6e79ec00b66df8270a1dc62f50ff65483cca96e30810915b24a70fb643ac5a101d65d2 mkinitfs.sh" diff --git a/main/postmarketos-mkinitfs/mkinitfs.sh b/main/postmarketos-mkinitfs/mkinitfs.sh index 9b6b3598b..75c0f5b56 100644 --- a/main/postmarketos-mkinitfs/mkinitfs.sh +++ b/main/postmarketos-mkinitfs/mkinitfs.sh @@ -125,13 +125,11 @@ get_binaries_extra() # FIXME: this is a performance bottleneck # $1: files # $2: destination -# $3: file mode bits (as in chmod), default: 755 copy_files() { - mode="${3:-755}" for file in $1; do [ -e "$file" ] || continue - install -Dm$mode "$file" "$2$file" + cp -a --parents "$file" "$2" done } @@ -256,7 +254,7 @@ fi create_folders copy_files "$(get_modules)" "$tmpdir" copy_files "$(get_binaries)" "$tmpdir" -copy_files "/etc/deviceinfo" "$tmpdir" "644" +copy_files "/etc/deviceinfo" "$tmpdir" copy_files "/etc/postmarketos-mkinitfs/hooks/*.sh" "$tmpdir" create_device_nodes ln -s "/bin/busybox" "$tmpdir/bin/sh"