X-Original-To: alpine-aports@lists.alpinelinux.org Received: from newmail.tetrasec.net (unknown [172.21.74.12]) by lists.alpinelinux.org (Postfix) with ESMTP id 0B0905C43FA for ; Mon, 14 Nov 2016 14:05:57 +0000 (GMT) Received: from ncopa-macbook.copa.dup.pw (189-70-240-56.user.veloxzone.com.br [189.70.240.56]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) (Authenticated sender: n@tanael.org) by newmail.tetrasec.net (Postfix) with ESMTPSA id 74A965A12E3; Mon, 14 Nov 2016 14:05:54 +0000 (GMT) Date: Mon, 14 Nov 2016 06:05:47 -0800 From: Natanael Copa To: Linus =?UTF-8?B?U3fDpGxhcw==?= Cc: alpine-aports@lists.alpinelinux.org Subject: Re: [alpine-aports] [PATCH] main/mkinitfs: Bugfixes, speedup, data/code separation, new syntax, cleanup. Message-ID: <20161114060547.4029d93c@ncopa-macbook.copa.dup.pw> In-Reply-To: <20161105233420.GA15352@borderlessmail> References: <20161105233420.GA15352@borderlessmail> X-Mailer: Claws Mail 3.13.2 (GTK+ 2.24.28; x86_64-alpine-linux-musl) X-Mailinglist: alpine-aports Precedence: list List-Id: Alpine Development List-Unsubscribe: List-Post: List-Help: List-Subscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Hi, Thank you very much for this patch. Do you think you could split it up and send a patch againt the mkinitfs git repository instead of aports? http://git.alpinelinux.org/cgit/mkinitfs https://github.com/alpinelinux/mkinitfs Either of those are fine. On Sun, 6 Nov 2016 00:34:21 +0100 Linus Sw=C3=A4las wrote: > * Many small bugfixes. Do you think you could do bugifxes in a separate patch? I'd like bugfixes in for v3.5. > * ~100 times speedup on gathering files for the initramfs. It would be nice to have this in a spearate incremental patch too. > * Separated code/data so that directories to include in the > initramfs is no longer hardcoded in the binary but included > in features.d/base.files. > * Change of syntax in features.d/* - directories whose name end > in / will have the whole tree rooted at that path included, > directories where the name does NOT end in / will cause only > that directory to be included and nothing below that path. I like this idea, however, it is a bit scary change. People may have created their custom config files for kernel modules etc. Thing may break when they upgrade, and the consequence is non-bootable system. I am not convinced that we want this for v3.5 release. We might need test it carefully first. > * Some cleanup, quoting fixes and similar. Separate patch for this too. That way it makes it easy to review the patches and see what is actually going on and what is cleanup and quoting fixes. Thanks! > --- > ..._speedup_data-code-sep_new-syntax_cleanup.patch | 666 +++++++++++++++= ++++++ > main/mkinitfs/APKBUILD | 14 +- > main/mkinitfs/mkinitfs.pre-upgrade | 2 +- > main/mkinitfs/mkinitfs.trigger | 18 +- > 4 files changed, 685 insertions(+), 15 deletions(-) > create mode 100644 main/mkinitfs/0003-mkinitfs-bugfixes_speedup_data-cod= e-sep_new-syntax_cleanup.patch >=20 > diff --git a/main/mkinitfs/0003-mkinitfs-bugfixes_speedup_data-code-sep_n= ew-syntax_cleanup.patch b/main/mkinitfs/0003-mkinitfs-bugfixes_speedup_data= -code-sep_new-syntax_cleanup.patch > new file mode 100644 > index 0000000..62de46b > --- /dev/null > +++ b/main/mkinitfs/0003-mkinitfs-bugfixes_speedup_data-code-sep_new-synt= ax_cleanup.patch > @@ -0,0 +1,666 @@ > +diff -U3 -r mkinitfs-3.0.5/features.d/base.files mkinitfs-3.0.5-new/feat= ures.d/base.files > +--- mkinitfs-3.0.5/features.d/base.files 2016-06-15 12:57:27.000000000 += 0200 > ++++ mkinitfs-3.0.5-new/features.d/base.files 2016-10-28 13:39:54.0000000= 00 +0200 > +@@ -1,3 +1,16 @@ > ++/bin > ++/sbin > ++/dev > ++/proc > ++/sys > ++/run > ++/tmp > ++/etc/apk > ++/lib/modules > ++/media/floppy > ++/media/cdrom > ++/media/usb > ++/mdev/ > + /bin/busybox > + /bin/sh > + /lib/mdev > +diff -U3 -r mkinitfs-3.0.5/features.d/base.modules mkinitfs-3.0.5-new/fe= atures.d/base.modules > +--- mkinitfs-3.0.5/features.d/base.modules 2016-06-15 12:57:27.000000000= +0200 > ++++ mkinitfs-3.0.5-new/features.d/base.modules 2016-10-28 13:43:42.00000= 0000 +0200 > +@@ -1,2 +1,2 @@ > + kernel/drivers/block/loop.ko > +-kernel/fs/overlayfs > ++kernel/fs/overlayfs/ > +diff -U3 -r mkinitfs-3.0.5/features.d/btrfs.modules mkinitfs-3.0.5-new/f= eatures.d/btrfs.modules > +--- mkinitfs-3.0.5/features.d/btrfs.modules 2016-06-15 12:57:27.00000000= 0 +0200 > ++++ mkinitfs-3.0.5-new/features.d/btrfs.modules 2016-10-28 13:43:54.0000= 00000 +0200 > +@@ -1,3 +1,3 @@ > + kernel/arch/*/crypto/crc32* > + kernel/crypto/crc32* > +-kernel/fs/btrfs > ++kernel/fs/btrfs/ > +diff -U3 -r mkinitfs-3.0.5/features.d/cdrom.modules mkinitfs-3.0.5-new/f= eatures.d/cdrom.modules > +--- mkinitfs-3.0.5/features.d/cdrom.modules 2016-06-15 12:57:27.00000000= 0 +0200 > ++++ mkinitfs-3.0.5-new/features.d/cdrom.modules 2016-10-28 13:44:12.0000= 00000 +0200 > +@@ -1,2 +1,2 @@ > +-kernel/drivers/cdrom > +-kernel/fs/isofs > ++kernel/drivers/cdrom/ > ++kernel/fs/isofs/ > +diff -U3 -r mkinitfs-3.0.5/features.d/cramfs.modules mkinitfs-3.0.5-new/= features.d/cramfs.modules > +--- mkinitfs-3.0.5/features.d/cramfs.modules 2016-06-15 12:57:27.0000000= 00 +0200 > ++++ mkinitfs-3.0.5-new/features.d/cramfs.modules 2016-10-28 13:44:18.000= 000000 +0200 > +@@ -1 +1 @@ > +-kernel/fs/cramfs > ++kernel/fs/cramfs/ > +diff -U3 -r mkinitfs-3.0.5/features.d/ext2.modules mkinitfs-3.0.5-new/fe= atures.d/ext2.modules > +--- mkinitfs-3.0.5/features.d/ext2.modules 2016-06-15 12:57:27.000000000= +0200 > ++++ mkinitfs-3.0.5-new/features.d/ext2.modules 2016-10-28 13:44:42.00000= 0000 +0200 > +@@ -1 +1 @@ > +-kernel/fs/ext2 > ++kernel/fs/ext2/ > +diff -U3 -r mkinitfs-3.0.5/features.d/ext3.modules mkinitfs-3.0.5-new/fe= atures.d/ext3.modules > +--- mkinitfs-3.0.5/features.d/ext3.modules 2016-06-15 12:57:27.000000000= +0200 > ++++ mkinitfs-3.0.5-new/features.d/ext3.modules 2016-10-28 13:44:50.00000= 0000 +0200 > +@@ -1 +1 @@ > +-kernel/fs/ext3 > ++kernel/fs/ext3/ > +diff -U3 -r mkinitfs-3.0.5/features.d/ext4.modules mkinitfs-3.0.5-new/fe= atures.d/ext4.modules > +--- mkinitfs-3.0.5/features.d/ext4.modules 2016-06-15 12:57:27.000000000= +0200 > ++++ mkinitfs-3.0.5-new/features.d/ext4.modules 2016-10-28 13:44:54.00000= 0000 +0200 > +@@ -1 +1 @@ > +-kernel/fs/ext4 > ++kernel/fs/ext4/ > +diff -U3 -r mkinitfs-3.0.5/features.d/f2fs.modules mkinitfs-3.0.5-new/fe= atures.d/f2fs.modules > +--- mkinitfs-3.0.5/features.d/f2fs.modules 2016-06-15 12:57:27.000000000= +0200 > ++++ mkinitfs-3.0.5-new/features.d/f2fs.modules 2016-10-28 13:45:43.00000= 0000 +0200 > +@@ -1 +1 @@ > +-kernel/fs/f2fs > ++kernel/fs/f2fs/ > +diff -U3 -r mkinitfs-3.0.5/features.d/gfs2.modules mkinitfs-3.0.5-new/fe= atures.d/gfs2.modules > +--- mkinitfs-3.0.5/features.d/gfs2.modules 2016-06-15 12:57:27.000000000= +0200 > ++++ mkinitfs-3.0.5-new/features.d/gfs2.modules 2016-10-28 13:45:58.00000= 0000 +0200 > +@@ -1 +1 @@ > +-kernel/fs/gfs2 > ++kernel/fs/gfs2/ > +diff -U3 -r mkinitfs-3.0.5/features.d/jfs.modules mkinitfs-3.0.5-new/fea= tures.d/jfs.modules > +--- mkinitfs-3.0.5/features.d/jfs.modules 2016-06-15 12:57:27.000000000 = +0200 > ++++ mkinitfs-3.0.5-new/features.d/jfs.modules 2016-10-28 13:46:04.000000= 000 +0200 > +@@ -1 +1 @@ > +-kernel/fs/jfs > ++kernel/fs/jfs/ > +diff -U3 -r mkinitfs-3.0.5/features.d/kms.modules mkinitfs-3.0.5-new/fea= tures.d/kms.modules > +--- mkinitfs-3.0.5/features.d/kms.modules 2016-06-15 12:57:27.000000000 = +0200 > ++++ mkinitfs-3.0.5-new/features.d/kms.modules 2016-10-28 13:46:30.000000= 000 +0200 > +@@ -1,5 +1,5 @@ > +-kernel/drivers/char/agp > +-kernel/drivers/gpu > +-kernel/drivers/i2c > +-kernel/drivers/video > ++kernel/drivers/char/agp/ > ++kernel/drivers/gpu/ > ++kernel/drivers/i2c/ > ++kernel/drivers/video/ > + kernel/arch/x86/video/fbdev.ko > +diff -U3 -r mkinitfs-3.0.5/features.d/mmc.modules mkinitfs-3.0.5-new/fea= tures.d/mmc.modules > +--- mkinitfs-3.0.5/features.d/mmc.modules 2016-06-15 12:57:27.000000000 = +0200 > ++++ mkinitfs-3.0.5-new/features.d/mmc.modules 2016-10-28 13:47:25.000000= 000 +0200 > +@@ -1 +1 @@ > +-kernel/drivers/mmc > ++kernel/drivers/mmc/ > +diff -U3 -r mkinitfs-3.0.5/features.d/network.modules mkinitfs-3.0.5-new= /features.d/network.modules > +--- mkinitfs-3.0.5/features.d/network.modules 2016-06-15 12:57:27.000000= 000 +0200 > ++++ mkinitfs-3.0.5-new/features.d/network.modules 2016-10-28 13:47:34.00= 0000000 +0200 > +@@ -1,2 +1,2 @@ > +-kernel/drivers/net/ethernet > ++kernel/drivers/net/ethernet/ > + kernel/net/packet/af_packet.ko > +diff -U3 -r mkinitfs-3.0.5/features.d/ocfs2.modules mkinitfs-3.0.5-new/f= eatures.d/ocfs2.modules > +--- mkinitfs-3.0.5/features.d/ocfs2.modules 2016-06-15 12:57:27.00000000= 0 +0200 > ++++ mkinitfs-3.0.5-new/features.d/ocfs2.modules 2016-10-28 13:47:45.0000= 00000 +0200 > +@@ -1 +1 @@ > +-kernel/fs/ocfs2 > ++kernel/fs/ocfs2/ > +diff -U3 -r mkinitfs-3.0.5/features.d/reiserfs.modules mkinitfs-3.0.5-ne= w/features.d/reiserfs.modules > +--- mkinitfs-3.0.5/features.d/reiserfs.modules 2016-06-15 12:57:27.00000= 0000 +0200 > ++++ mkinitfs-3.0.5-new/features.d/reiserfs.modules 2016-10-28 13:49:47.0= 00000000 +0200 > +@@ -1 +1 @@ > +-kernel/fs/reiserfs > ++kernel/fs/reiserfs/ > +diff -U3 -r mkinitfs-3.0.5/features.d/scsi.modules mkinitfs-3.0.5-new/fe= atures.d/scsi.modules > +--- mkinitfs-3.0.5/features.d/scsi.modules 2016-06-15 12:57:27.000000000= +0200 > ++++ mkinitfs-3.0.5-new/features.d/scsi.modules 2016-10-28 13:49:57.00000= 0000 +0200 > +@@ -1,2 +1,2 @@ > + kernel/drivers/scsi/* > +-kernel/drivers/message/fusion > ++kernel/drivers/message/fusion/ > +diff -U3 -r mkinitfs-3.0.5/features.d/squashfs.modules mkinitfs-3.0.5-ne= w/features.d/squashfs.modules > +--- mkinitfs-3.0.5/features.d/squashfs.modules 2016-06-15 12:57:27.00000= 0000 +0200 > ++++ mkinitfs-3.0.5-new/features.d/squashfs.modules 2016-10-28 13:50:02.0= 00000000 +0200 > +@@ -1 +1 @@ > +-kernel/fs/squashfs > ++kernel/fs/squashfs/ > +diff -U3 -r mkinitfs-3.0.5/features.d/ubifs.modules mkinitfs-3.0.5-new/f= eatures.d/ubifs.modules > +--- mkinitfs-3.0.5/features.d/ubifs.modules 2016-06-15 12:57:27.00000000= 0 +0200 > ++++ mkinitfs-3.0.5-new/features.d/ubifs.modules 2016-10-28 13:50:08.0000= 00000 +0200 > +@@ -1 +1 @@ > +-kernel/fs/ubifs > ++kernel/fs/ubifs/ > +diff -U3 -r mkinitfs-3.0.5/features.d/usb.modules mkinitfs-3.0.5-new/fea= tures.d/usb.modules > +--- mkinitfs-3.0.5/features.d/usb.modules 2016-06-15 12:57:27.000000000 = +0200 > ++++ mkinitfs-3.0.5-new/features.d/usb.modules 2016-10-28 13:50:33.000000= 000 +0200 > +@@ -1,7 +1,7 @@ > +-kernel/drivers/usb/host > +-kernel/drivers/usb/storage > +-kernel/drivers/hid/usbhid > ++kernel/drivers/usb/host/ > ++kernel/drivers/usb/storage/ > ++kernel/drivers/hid/usbhid/ > + kernel/drivers/hid/hid-generic.ko > + kernel/drivers/hid/hid-cherry.ko > +-kernel/fs/fat > +-kernel/fs/nls > ++kernel/fs/fat/ > ++kernel/fs/nls/ > +diff -U3 -r mkinitfs-3.0.5/features.d/virtio.modules mkinitfs-3.0.5-new/= features.d/virtio.modules > +--- mkinitfs-3.0.5/features.d/virtio.modules 2016-06-15 12:57:27.0000000= 00 +0200 > ++++ mkinitfs-3.0.5-new/features.d/virtio.modules 2016-10-28 13:50:41.000= 000000 +0200 > +@@ -1,3 +1,3 @@ > + kernel/drivers/block/virtio* > +-kernel/drivers/virtio > ++kernel/drivers/virtio/ > + kernel/drivers/net/virtio_net* > +diff -U3 -r mkinitfs-3.0.5/features.d/xfs.modules mkinitfs-3.0.5-new/fea= tures.d/xfs.modules > +--- mkinitfs-3.0.5/features.d/xfs.modules 2016-06-15 12:57:27.000000000 = +0200 > ++++ mkinitfs-3.0.5-new/features.d/xfs.modules 2016-10-28 13:50:50.000000= 000 +0200 > +@@ -1,4 +1,4 @@ > + kernel/arch/*/crypto/crc32* > + kernel/arch/*/crypto/crc32* > + kernel/crypto/crc32* > +-kernel/fs/xfs > ++kernel/fs/xfs/ > +diff -U3 -r mkinitfs-3.0.5/mkinitfs.in mkinitfs-3.0.5-new/mkinitfs.in > +--- mkinitfs-3.0.5/mkinitfs.in 2016-10-30 06:52:56.000000000 +0100 > ++++ mkinitfs-3.0.5-new/mkinitfs.in 2016-10-30 06:51:59.000000000 +0100 > +@@ -4,64 +4,262 @@ > + sysconfdir=3D@sysconfdir@ > + datadir=3D@datadir@ > +=20 > +-config=3D"$sysconfdir"/mkinitfs.conf > +-init=3D"$datadir"/initramfs-init > +-fstab=3D"$datadir"/fstab > +-passwd=3D"$datadir"/passwd > +-group=3D"$datadir"/group > ++config=3D"${sysconfdir}/mkinitfs.conf" > ++init=3D"${datadir}/initramfs-init" > ++fstab=3D"${datadir}/fstab" > ++passwd=3D"${datadir}/passwd" > ++group=3D"${datadir}/group" > ++rootdir=3D'' > + basedir=3D'' > + tmpdir=3D'' > +=20 > +-startdir=3D$PWD > ++# Print files and directories while recursivly resolving links and > ++# printing the names of each link visited. > ++resolve_links() { > ++ local name=3D'' > ++ while read -r name; do > ++ # *) Check for existance. > ++ # *) If it's not a link we just output it and continue, nothing more = to do. > ++ # > ++ # *) Iteratively resolve and print all link steps. > ++ # *) If the final target is NOT a directory, just print the name. > ++ # *) If it is a directory, everything below that directory will be > ++ # searched and resolved. > ++ if [ ! -e "$name" ]; then > ++ echo "resolve_links: ${name}: No such file or directory." >&2 > ++ continue > ++ fi > ++ if [ ! -L "$name" ]; then > ++ echo "${name}" > ++ continue > ++ fi > ++ # Resolve links, all linked steps will be resolved and printed. > ++ while [ -L "$name" ]; do > ++ echo "$name" > ++ local target=3D"$(readlink "$name")" > ++ if [ "$target" !=3D "${target#/}" ]; then > ++ # Absolute link, prefix with $basedir. > ++ local name=3D"${basedir%/}/${target#/}" > ++ else > ++ # Relative link, move to the directory of the link, get the > ++ # resolved path for that directory and add the target name. > ++ if [ -z "${target##*/*}" ]; then > ++ cd -P "${name%/*}/${target%/*}" > ++ else > ++ cd -P "${name%/*}" > ++ fi > ++ local name=3D"${PWD}/${target##*/}" > ++ fi > ++ done > ++ if [ ! -d "$name" ]; then > ++ echo "${name}" > ++ continue > ++ fi > ++ #find "${name}" \! -type d -o \( -type d -empty \) | resolve_links > ++ find "${name%/}" \! -type d -print -o \( -type d -links 2 -exec sh -c= 'ls -A "{}" | grep -Eq "" || echo "{}"' \; \) | resolve_links > ++ done > ++} > ++ > ++resolve_ldsos() { > ++ local ld_library_path=3D"$1" > ++ shift > ++ local accumulate=3D'' > ++ local last_seen_rpath=3D'' > ++ while read -r line; do > ++ [ 2 -eq "${#line}" ] && continue > ++ #echo "line is $line" >&2 > ++ case "$line" in > ++ 0I*) > ++ echo "${line#??}" > ++ continue > ++ ;; > ++ 1R*) > ++ [ "$line" =3D "$last_seen_rpath" ] && continue > ++ local last_seen_rpath=3D"$line" > ++ local ld_library_path=3D"${line#??} > ++$ld_library_path" > ++ #echo "ld_library_path is now =3D \"$ld_library_path\"" >&2 > ++ continue > ++ ;; > ++ 2N*) > ++ local found=3D'N' > ++ local needed=3D"${line#??}" > ++ IFS=3D',' > ++ for lib in $needed; do > ++ IFS=3D' > ++' > ++ local lpath=3D'' > ++ for lpath in $ld_library_path; do > ++ if [ -e "${lpath}/${lib}" ]; then > ++ echo "${lpath}/${lib}" > ++ #echo "Found library: ${lpath}/${lib}" >&2 > ++ local found=3D'Y' > ++ if [ -z "$accumulate" ]; then > ++ local accumulate=3D"${lpath}/${lib}" > ++ else > ++ local accumulate=3D"$accumulate > ++${lpath}/${lib}" > ++ fi > ++ break > ++ fi > ++ done > ++ unset IFS > ++ if [ 'Y' !=3D "$found" ]; then > ++ echo "resolve_ldso_deps: Warning: Cannot find library \"$lib\". Se= arched in \"$ld_library_path\"." >&2 > ++ fi > ++ done > ++ unset IFS > ++ continue > ++ ;; > ++ esac > ++ done > ++ # No more libraries found. > ++ if [ -z "$accumulate" ]; then > ++ return > ++ fi > ++ #echo "Recursing on " >&2 > ++ #echo "$accumulate" | sort -u >&2 > ++ #echo "with ld_library_path=3D$ld_library_path" >&2 > ++ echo "$accumulate" | xargs scanelf -qF '#F0I%i > ++1R%r > ++2N%n' "$@" \ > ++ | sort -u \ > ++ | resolve_ldsos "$ld_library_path" "${lpath}/${lib}" > ++} > ++ > ++# Reads a list of filenames from stdin, figures out what ldso > ++# dependencies there are for any ELFs found in the input and > ++# outputs the list complemented by any dependencies found. > ++resolve_ldso_deps() { > ++ local basedir=3D"$1" > ++ > ++ scanelf >/dev/null 2>&1 > ++ local retcode=3D$? > ++ # System doesn't have scanelf, system probably doesn't support shared = libs > ++ # so we just act like an empty filter and pass everything along. > ++ if [ 126 -eq $retcode ] || [ 127 -eq $retcode ]; then > ++ echo "No scanelf found, ldso dependencies will not be resolved." >&2 > ++ while read -r name; do > ++ echo "$name" > ++ done > ++ return 0 > ++ fi > ++ > ++ # Prepare, don't want to do this in a loop. This sets ld_library_path = to a > ++ # newline separated list of paths to search for ldso:s. > ++ local ld_so_conf=3D"${basedir%/}/etc/ld.so.conf" > ++ local ld_library_path=3D"$(echo "$LD_PRELOAD > ++$LD_LIBRARY_PATH > ++$([ -e "$ld_so_conf" ] && cat "$ld_so_conf") > ++/lib > ++/usr/lib > ++/usr/local/lib" | sed -e '/^$/d' -e '/^#/d' -e 's/:/\ > ++/g' -e "s|^/|${basedir%/}/|" | sort -u)" > ++ > ++ # So, we don't want to call scanelf for every filename we read as that= is painfully > ++ # slow. Try calling it 10k times on /bin/sh and you'll understand. Cal= ling it once > ++ # with 10k /bin/sh as arguments is blindingly fast though. First case = is something > ++ # like 178 secs on my i7, latter case is 0.2 secs. So, instead of call= ing it for > ++ # every file we read, we sort out anything that is not a regular file = and then let > ++ # xargs accumulate as many args it can before running a scanelf on a b= unch of files. > ++ # We prefix the output from scanelf with 0I for interpreter, 1R for rp= ath and 2N > ++ # for needed libraries. We then sort -u the result, echo any interpret= ers found, > ++ # modify ld_library_path according to any rpaths found, and search ld_= library_path > ++ # for any needed libraries. > ++ local regulars=3D'' > ++ local name=3D'' > ++ read -r regulars > ++ while read -r name; do > ++ echo "$name" > ++ # Links we get are already resolved, we just want to check actual fil= es. > ++ if [ -L "$name" ] || [ ! -f "$name" ]; then > ++ continue > ++ fi > ++ # Accumulate regular files. > ++ local regulars=3D"$regulars > ++$name" > ++ done > ++ > ++ echo "$regulars" | xargs scanelf -qF '#F0I%i > ++1R%r > ++2N%n' "$@" \ > ++ | sort -u \ > ++ | resolve_ldsos "$ld_library_path" \ > ++ | resolve_links > ++} > ++ > ++# Expand config lines according to any globs they contain. > ++# The line read should be a the name of a file to be included in the in= itramfs. > ++# The line read should be a complete path, including any potential $bas= edir. > ++# If the line ends in / everything below that path will be added. > ++# If the line contains a globbing pattern it will be expanded and every= thing > ++# matching the glob will be added. > ++expand_globs() { > ++ # This first loop expands globs in config lines. > ++ local line=3D'' > ++ while read -r line; do > ++ local file=3D'' > ++ IFS=3D'' > ++ for file in $line; do > ++ echo "$file" > ++ done > ++ done | while read -r line; do > ++ case "$line" in > ++ */) > ++ #find "${line%/}" \! -type d -o \( -type d -empty \) > ++ find "${line%/}" \! -type d -print -o \( -type d -links 2 -exec sh -= c 'ls -A "{}" | grep -Eq "" || echo "{}"' \; \) > ++ ;; > ++ *) > ++ echo "$line" > ++ ;; > ++ esac > ++ done > ++} > +=20 > + feature_files() { > + local dir=3D"$1" > + local suffix=3D"$2" > +- local glob file > ++ local f=3D'' > + for f in $features; do > +- if [ ! -f "$features_dir/$f.$suffix" ]; then > ++ # Skip if there is no file for this feature with the selected suffix. > ++ if [ ! -f "${features_dir}/${f}.${suffix}" ]; then > + continue > + fi > +- for glob in $(sed -e '/^$/d' -e '/^#/d' -e "s|^/*|$dir|" "$features_d= ir/$f.$suffix"); do > +- for file in $glob; do > +- if [ -d $file ]; then > +- find $file -type f > +- elif [ -e "$file" ]; then > +- echo $file > +- fi > +- done > +- done > ++ # Remove comments, blank lines and translate paths to paths relative = to $dir. > ++ sed -e '/^$/d' -e '/^#/d' -e "s|^/*|${dir%/}/|" "${features_dir}/${f}= .${suffix}" \ > ++ | expand_globs \ > ++ | resolve_links > + done > + } > +=20 > +-initfs_base() { > +- local i=3D dirs=3D glob=3D file=3D > +- for i in dev proc sys sbin bin run .modloop lib/modules media/cdrom \ > +- etc/apk media/floppy media/usb newroot; do > +- dirs=3D"$dirs $tmpdir/$i" > +- done > +- mkdir -p $dirs > +=20 > +- local oldpwd=3D"$PWD" > +- cd "${basedir}" > +- lddtree -R "$basedir" -l --no-auto-root \ > +- $(feature_files "$basedir" files) \ > +- \ > +- | sed -e "s|^$basedir||" | sort -u \ > +- | cpio --quiet -pdm "$tmpdir" || return 1 > ++find_files() { > ++ cd "$basedir" || return 1 > ++ # | xargs lddtree -R "$basedir" -l --no-auto-root \ > ++ # | resolve_ldso_deps "$basedir" \ > ++ feature_files "$basedir" files \ > ++ | resolve_ldso_deps "$basedir" \ > ++ | sed -e "s|^${basedir%/}/||" \ > ++ | sort -u > ++ cd "$OLDPWD" || return 1 > ++} > +=20 > ++initfs_base() { > ++ cd "$basedir" || return 1 > ++ find_files \ > ++ | cpio --quiet -pdm "$tmpdir" || return 1 > + # copy init > +- cd "$startdir" > +- install -m755 "$init" "$tmpdir"/init || return 1 > ++ install -m755 "$init" "${tmpdir}/init" || return 1 > + for i in "$fstab" "$passwd" "$group"; do > +- install -Dm644 "$i" "$tmpdir"/etc/${i##*/} || return 1 > ++ install -Dm644 "$i" "${tmpdir}/etc/${i##*/}" || return 1 > + done > +- cd "$oldpwd" > ++ cd "$OLDPWD" > + } > +=20 > ++ > + find_kmod_deps() { > +- awk -v prepend=3D"/lib/modules/$kernel/" -v modulesdep=3D"${basedir}li= b/modules/$kernel/modules.dep" ' > +-function recursedeps(k, j, dep) { > ++ awk -v prepend=3D"lib/modules/${kernel}/" -v modulesdep=3D"${basedir}/= lib/modules/$kernel/modules.dep" ' > ++function recursedeps(k, j, dep) { > + if (k in visited) > + return; > + visited[k] =3D 1; > +@@ -95,55 +293,62 @@ > + } > +=20 > + find_kmods() { > +- local oldpwd=3D"$PWD" > + cd "$kerneldir" || return 1 > +- for file in $(feature_files "${kerneldir}/" modules); do > +- echo ${file#${kerneldir%/}/} > +- done | find_kmod_deps > +- cd "$oldpwd" > ++ feature_files "$kerneldir" modules \ > ++ | sed "s|${kerneldir%/}/||" \ > ++ | find_kmod_deps \ > ++ | sort -u > ++ cd "$OLDPWD" || return 1 > + } > +=20 > + initfs_kmods() { > +- local glob=3D file=3D files=3D dirs=3D > +- rm -rf "$tmpdir"/lib/modules > +- # make sure we have modules.dep > +- if ! [ -f "$kerneldir"/modules.dep ]; then > +- depmod -b "${basedir}" $kernel > ++ rm -rf "${tmpdir}/lib/modules" > ++ # Make sure we have modules.dep. > ++ if ! [ -f "${kerneldir}/modules.dep" ]; then > ++ depmod -b "${basedir}" "$kernel" > + fi > +- local oldpwd=3D"$PWD" > +- cd "${basedir}" > +- for file in $(find_kmods); do > +- echo "${file#/}" > +- done | sort -u | cpio --quiet -pdm "$tmpdir" || return 1 > ++ > ++ cd "${basedir}" || return 1 > ++ find_kmods \ > ++ | cpio --quiet -pdm "$tmpdir" || return 1 > ++ > ++ local file=3D'' > + for file in modules.order modules.builtin; do > +- if [ -f "$kerneldir"/$file ]; then > +- cp "$kerneldir"/$file "$tmpdir"/lib/modules/$kernel/ > ++ if [ -f "${kerneldir}/$file" ]; then > ++ cp "${kerneldir}/${file}" "${tmpdir}/lib/modules/${kernel}/" > + fi > + done > +- depmod $kernel -b "$tmpdir" > +- cd "$oldpwd" > ++ > ++ depmod "$kernel" -b "$tmpdir" > ++ cd "$OLDPWD" || return 1 > + } > +=20 > ++ > + initfs_firmware() { > +- rm -rf "$tmpdir"/lib/firmware > +- mkdir -p "$tmpdir"/lib/firmware > +- find "$tmpdir"/lib/modules -type f -name "*.ko" | xargs modinfo -F fir= mware | sort -u | while read FW; do > ++ rm -rf "${tmpdir}/lib/firmware" > ++ mkdir -p "${tmpdir}/lib/firmware" > ++ find "${tmpdir}/lib/modules" -type f -name "*.ko" \ > ++ | xargs modinfo -F firmware \ > ++ | sort -u \ > ++ | while read FW; do > + [ -e "${basedir}/lib/firmware/${FW}" ] && install -pD "${basedir}/lib= /firmware/${FW}" "${tmpdir}/lib/firmware/${FW}" > + done > + return 0 > + } > +=20 > ++ > + initfs_apk_keys() { > + # If the basedir has nothing to copy, and we're not asked to copy the = host's keys, don't do anything. > +- if [ ! -d "${basedir}etc/apk/keys/" ] && [ -z "$hostkeys" ]; then > ++ if [ ! -d "${basedir}/etc/apk/keys/" ] && [ -z "$hostkeys" ]; then > + return > + fi > + mkdir -p "${tmpdir}/etc/apk/keys" > + [ -n "$hostkeys" ] && cp "/etc/apk/keys/"* "${tmpdir}/etc/apk/keys/" > +- cp "${basedir}etc/apk/keys/"* "${tmpdir}/etc/apk/keys/" > ++ cp "${basedir}/etc/apk/keys/"* "${tmpdir}/etc/apk/keys/" > + } > +=20 > +-initfs_cpio() { > ++ > ++ initfs_cpio() { > + if [ -n "$list_sources" ]; then > + (cd "$tmpdir" && find . ) > + return > +@@ -203,7 +408,7 @@ > + shift $(( $OPTIND - 1 )) > +=20 > +=20 > +-. $(readlink -f "$config") > ++. "$(cd -P "${config%/*}" ; echo "${PWD}/${config##*/}")" > +=20 > + # Override any options read from the config with what the > + # user has specifed on the commandline. > +@@ -219,16 +424,16 @@ > + [ -n "$arg_tmpdir" ] && tmpdir=3D"$arg_tmpdir" > +=20 > +=20 > +-rootdir=3D"${rootdir%/}/" > +-[ "${rootdir}" =3D "${rootdir#/}" ] && rootdir=3D"${PWD}/${rootdir}" > ++rootdir=3D"$(cd -P "${rootdir%/}/"; echo "${PWD}")" > +=20 > +-features_dir=3D${features_dir:-"${rootdir%/}/${sysconfdir#/}/features.d= "} > ++features_dir=3D"${features_dir:-"${rootdir%/}/${sysconfdir#/}/features.= d"}" > ++features_dir=3D"$(cd -P "${features_dir}"; echo "${PWD}")" > +=20 > + if [ -n "$list_features" ]; then > +- for i in "$features_dir"/*.files "$features_dir"/*.modules; do > ++ cd "$features_dir" || return 1 > ++ for i in *.files *.modules; do > + [ -e "$i" ] || continue > +- local file=3D${i##*/} > +- echo ${file%.*} > ++ echo "${i%.*}" > + done | sort -u > + exit 0 > + fi > +@@ -236,45 +441,47 @@ > + if [ -z "$basedir" ]; then > + basedir=3D"$rootdir" > + else > +- [ "${basedir}" =3D "${basedir#/}" ] && basedir=3D"${PWD}/${basedir}" > ++ basedir=3D"$(cd -P "${basedir}"; echo "${PWD}")" > + fi > +=20 > ++init=3D"$(cd -P "${init%/*}"; echo "${PWD}/${init##*/}")" > +=20 > +-[ -n "$1" ] && kernel=3D"$1" > +-[ -z "$kernel" ] && kernel=3D$(uname -r) > +-kerneldir=3D"${basedir}lib/modules/$kernel" > +=20 > ++[ -n "$1" ] && kernel=3D"$1" > ++[ -z "$kernel" ] && kernel=3D"$(uname -r)" > ++kerneldir=3D"${basedir%/}/lib/modules/${kernel}" > + if [ ! -d "$kerneldir" ]; then > + echo "$kerneldir does not exist or is not a directory" > + exit 1 > + fi > +=20 > +-kflavor=3D${kernel##*-} > +-[ "$kflavor" =3D "$kernel" ] && kflavor=3Dvanilla > +- > + if [ -z "$outfile" ]; then > +- outfile=3D"${rootdir}boot/initramfs-${kernel}" > ++ outfile=3D"${rootdir%/}/boot/initramfs-${kernel}" > + fi > +=20 > ++if [ -n "$DEBUG_FILES" ]; then > ++ find_files > ++ exit 0 > ++fi > + if [ -n "$DEBUG_KMOD" ]; then > + find_kmods > + exit 0 > + fi > +=20 > ++ > + if [ -z "$tmpdir" ]; then > +- tmpdir=3D$(mktemp -d "${TMPDIR:-/tmp}/mkinitfs.XXXXXX") > ++ tmpdir=3D"$(mktemp -d "${TMPDIR:-/tmp}/mkinitfs.XXXXXX")" || exit > ++ tmpdir=3D"$(cd -P "$tmpdir" ; echo "$PWD")" > + else > +- mkdir -p "$tmpdir" > +-fi > +- > +-tmpdir=3D$(readlink -f "$tmpdir") > +-if [ '/' =3D=3D "$tmpdir" ] ; then > +- echo "tmpdir must not be /" > +- exit 1 > +-fi > +- > +-if [ -z "$keeptmp" ]; then > +- [ -d "$tmpdir" ] && rm -rf "$tmpdir" > ++ tmpdir=3D"$(cd -P "$tmpdir" ; echo "$PWD")" > ++ if [ '/' =3D=3D "$tmpdir" ] ; then > ++ echo "tmpdir must not be /" > ++ exit 1 > ++ fi > ++ if [ -z "$keeptmp" ]; then > ++ [ -d "$tmpdir" ] && rm -rf "$tmpdir" > ++ fi > ++ mkdir -p "$tmpdir" || exit > + fi > +=20 > + if [ -z "$list_sources" ] && [ -z "$quiet" ]; then > diff --git a/main/mkinitfs/APKBUILD b/main/mkinitfs/APKBUILD > index c75961c..2ba5c93 100644 > --- a/main/mkinitfs/APKBUILD > +++ b/main/mkinitfs/APKBUILD > @@ -2,13 +2,13 @@ > pkgname=3Dmkinitfs > pkgver=3D3.0.5 > _ver=3D${pkgver%_git*} > -pkgrel=3D5 > +pkgrel=3D6 > pkgdesc=3D"Tool to generate initramfs images for Alpine" > url=3D"http://git.alpinelinux.org/cgit/mkinitfs" > makedepends_build=3D"" > makedepends_host=3D"kmod-dev util-linux-dev cryptsetup-dev linux-headers" > makedepends=3D"$makedepends_build $makedepends_host" > -depends=3D"busybox apk-tools>=3D2.0 lddtree>=3D1.25" > +depends=3D"busybox apk-tools>=3D2.0 scanelf" > install=3D"$pkgname.pre-upgrade $pkgname.post-install $pkgname.post-upgr= ade" > triggers=3D"$pkgname.trigger=3D/usr/share/kernel/*" > source=3D"http://dev.alpinelinux.org/archive/$pkgname/$pkgname-$_ver.tar= .xz > @@ -17,6 +17,7 @@ source=3D"http://dev.alpinelinux.org/archive/$pkgname/$= pkgname-$_ver.tar.xz > 0001-group-sync-with-alpine-baselayout.patch > 0001-mkinitfs-add-K-flag-to-copy-host-keys-to-new-initram.patch > 0002-mkinitfs_cmdline-override_rootdir-support_honor-tmpdir.patch > + 0003-mkinitfs-bugfixes_speedup_data-code-sep_new-syntax_cleanup.patch > " > arch=3D"all" > license=3D"GPL2" > @@ -37,16 +38,19 @@ a4227598291fa7338ad1128bfef3720c 0001-init-add-suppo= rt-for-ttyMFD-and-ttyUSB-se > a74631b5f40001dd259a2a6ebcaec544 0001-init-dont-use-local-in-global-sco= pe.patch > db888a1a502fe281bbe0b1add81bf62f 0001-group-sync-with-alpine-baselayout= .patch > a46eb97de6742400ca04777a0a8478b2 0001-mkinitfs-add-K-flag-to-copy-host-= keys-to-new-initram.patch > -fadbbb5e49ead2c6fd8d4e880c83bafa 0002-mkinitfs_cmdline-override_rootdir= -support_honor-tmpdir.patch" > +fadbbb5e49ead2c6fd8d4e880c83bafa 0002-mkinitfs_cmdline-override_rootdir= -support_honor-tmpdir.patch > +baef5ed6d50f5087135f84036a6f3ea6 0003-mkinitfs-bugfixes_speedup_data-co= de-sep_new-syntax_cleanup.patch" > sha256sums=3D"3f13619f161c506796b91f2db17644eba25c2ffc923aa0c8fff0213d1f= 660aa4 mkinitfs-3.0.5.tar.xz > 17547dbc77bd19d940550ea6243b44212d21a6797aee4202e4e22c31143bf9e6 0001-i= nit-add-support-for-ttyMFD-and-ttyUSB-serial-consol.patch > 7253cd8ebc1487e4bfb98d81edd68b24a4364e9fa8e48c73fc6903f2077b056e 0001-i= nit-dont-use-local-in-global-scope.patch > 17b8a04db505eea9e176da00f9389ca80f65ed88c0288f6785f9ab108164361a 0001-g= roup-sync-with-alpine-baselayout.patch > 8daccc844576f0b06fc9c15a30d750bfecda019b476a0be4cf9bcd7139e219cf 0001-m= kinitfs-add-K-flag-to-copy-host-keys-to-new-initram.patch > -c24fb5b60a1bdd9d0888cd9ce76996fe5c45cb384b0e30a8837e3cf3724a7727 0002-m= kinitfs_cmdline-override_rootdir-support_honor-tmpdir.patch" > +c24fb5b60a1bdd9d0888cd9ce76996fe5c45cb384b0e30a8837e3cf3724a7727 0002-m= kinitfs_cmdline-override_rootdir-support_honor-tmpdir.patch > +042cc227a278cb43dd23383d6756a1682c00e9b7d27fed11ba1b7c6164cd0295 0003-m= kinitfs-bugfixes_speedup_data-code-sep_new-syntax_cleanup.patch" > sha512sums=3D"246f25ce3fb65ea19dbe611ad44a106930c28b2c7111908462d4a25243= 3011280715b2cf87ee81cc6f0860679fd1d0a109d03040647498137e42b22ccc711662 mki= nitfs-3.0.5.tar.xz > 35b4cf3f74e394d87b321d335ec4dff6973bfd9a38cdc81609e21e025ee3fb9af7d2744c= f9941531603df829af1f7fba433074915ba88a688d375cfe40dad07a 0001-init-add-sup= port-for-ttyMFD-and-ttyUSB-serial-consol.patch > ca1bd66bc6d366dc74da389397f3e0d81b3afa21a534269230ab33f415e633b19ce54327= b78713847461b67d6d23a85019c79e1fbbf1a964ee0bd26013ddf33f 0001-init-dont-us= e-local-in-global-scope.patch > 2736650e0c06d47f2cd0dcc4a9c3d575b2b5284ee8d1aa0cccd45b5855ff6704171f5b77= 61b8c88536c8dca84943810e9332db9f2e03681f6355c5068a3a3092 0001-group-sync-w= ith-alpine-baselayout.patch > 712038089d3b58a3937549f25412803291690c992bd8e3002f02a46fc9c24903c9408670= 4b5def3aecb422d46d7c501beeaa665000bc7da6ec20965e52eca5a1 0001-mkinitfs-add= -K-flag-to-copy-host-keys-to-new-initram.patch > -81880870195b6c64d55570954be2c8e879f58f779ec165ae34504bac43b969dfcb79b046= 9ab96100df12fb17a7e7b362bb52bbc3402705a931cd41f7304c6d0d 0002-mkinitfs_cmd= line-override_rootdir-support_honor-tmpdir.patch" > +81880870195b6c64d55570954be2c8e879f58f779ec165ae34504bac43b969dfcb79b046= 9ab96100df12fb17a7e7b362bb52bbc3402705a931cd41f7304c6d0d 0002-mkinitfs_cmd= line-override_rootdir-support_honor-tmpdir.patch > +2b9c9ca7b28c33ccbe854449f5b879620f3bc9feca801a05f9ec8a70d46471bf835d1660= a05f49b1d2d8b484175265fce53577269aff711e7a1563e8d4a0aa37 0003-mkinitfs-bug= fixes_speedup_data-code-sep_new-syntax_cleanup.patch" > diff --git a/main/mkinitfs/mkinitfs.pre-upgrade b/main/mkinitfs/mkinitfs.= pre-upgrade > index 0ece527..d49fb34 100644 > --- a/main/mkinitfs/mkinitfs.pre-upgrade > +++ b/main/mkinitfs/mkinitfs.pre-upgrade > @@ -7,7 +7,7 @@ for i in files modules; do > case "$j" in > *.apk-new) continue;; > esac > - mv $j /etc/mkinitfs/features.d/${j##*/}.$i > + mv "$j" "/etc/mkinitfs/features.d/${j##*/}.$i" > done > done > exit 0 > diff --git a/main/mkinitfs/mkinitfs.trigger b/main/mkinitfs/mkinitfs.trig= ger > index cedf363..4db9b4a 100644 > --- a/main/mkinitfs/mkinitfs.trigger > +++ b/main/mkinitfs/mkinitfs.trigger > @@ -3,16 +3,16 @@ > for i in "$@"; do > # get last element in path > flavor=3D${i##*/} > - if ! [ -f "$i"/kernel.release ]; then > + if ! [ -f "${i}/kernel.release" ]; then > # kernel was uninstalled > - rm -f $( readlink -f /boot/initramfs-$flavor ) \ > - /boot/initramfs-$flavor /boot/vmlinuz-$flavor \ > - /boot/$flavor /boot/$flavor.gz /$flavor /$flavor.gz > + rm -f $(readlink -f "/boot/initramfs-$flavor") \ > + "/boot/initramfs-$flavor" "/boot/vmlinuz-$flavor" \ > + "/boot/$flavor" "/boot/${flavor}.gz" "/$flavor" "/${flavor}.gz" > continue > fi > - abi_release=3D$(cat "$i"/kernel.release) > - initfs=3Dinitramfs-$flavor > - mkinitfs -o /boot/$initfs $abi_release > + abi_release=3D$(cat "${i}/kernel.release") > + initfs=3D"initramfs-$flavor" > + mkinitfs -o "/boot/$initfs" "$abi_release" > done > =20 > # extlinux will use path relative partition, so if /boot is on a > @@ -23,8 +23,8 @@ fi > =20 > # cleanup unused initramfs > for i in /boot/initramfs-[0-9]*; do > - [ -f $i ] || continue > - if ! [ -f /boot/vmlinuz-${i#/boot/initramfs-} ]; then > + [ -f "$i" ] || continue > + if ! [ -f "/boot/vmlinuz-${i#/boot/initramfs-}" ]; then > rm "$i" > fi > done --- Unsubscribe: alpine-aports+unsubscribe@lists.alpinelinux.org Help: alpine-aports+help@lists.alpinelinux.org ---