.gear-rules | 2 + .../37ab10382577ab6eb3d0d59ddd0f78464c5f7a11 | 6 + .gear-tags/list | 1 + klibc-find-provides | 33 ++++ klibc-find-requires | 38 ++++ klibc.spec | 189 ++++++++++++++++++++ usr/kinit/Kbuild | 9 +- usr/kinit/create_dev.c | 13 ++ usr/kinit/do_mounts.c | 7 - usr/kinit/md_run/Kbuild | 27 +++ usr/kinit/md_run/md_run.c | 14 ++ 11 files changed, 329 insertions(+), 10 deletions(-) diff --git a/.gear-rules b/.gear-rules new file mode 100644 index 0000000..f78a96e --- /dev/null +++ b/.gear-rules @@ -0,0 +1,2 @@ +tar: @name@-@version@:. +diff: @name@-@version@:. . diff --git a/.gear-tags/37ab10382577ab6eb3d0d59ddd0f78464c5f7a11 b/.gear-tags/37ab10382577ab6eb3d0d59ddd0f78464c5f7a11 new file mode 100644 index 0000000..889344d --- /dev/null +++ b/.gear-tags/37ab10382577ab6eb3d0d59ddd0f78464c5f7a11 @@ -0,0 +1,6 @@ +object 27d18ef425d98af7ebcbdf7a7fd3ce06f9080121 +type commit +tag klibc-1.5 +tagger H. Peter Anvin + +Released on Sun, 04 Mar 2007 01:52:10 +0000 diff --git a/.gear-tags/list b/.gear-tags/list new file mode 100644 index 0000000..146d0c0 --- /dev/null +++ b/.gear-tags/list @@ -0,0 +1 @@ +37ab10382577ab6eb3d0d59ddd0f78464c5f7a11 klibc-1.5 diff --git a/klibc-find-provides b/klibc-find-provides new file mode 100755 index 0000000..17ea9f6 --- /dev/null +++ b/klibc-find-provides @@ -0,0 +1,33 @@ +#!/bin/sh -efu +file= +handler() +{ + local rc=$? + trap - EXIT + [ -z "$file" ] || rm -f -- "$file" + exit $rc +} +trap handler EXIT HUP INT QUIT PIPE TERM +file=`mktemp -t find-provides.XXXXXXXXXX` + +ProcessFile() +{ + local f="$1" && shift + + [ -f "$f" ] || return 0 + local fname="${f#$RPM_BUILD_ROOT}" + fname="${fname#.}" + if [ -z "${fname##/lib/klibc-*.so}" ] || + [ -z "${fname##/lib64/klibc-*.so}" ]; then + printf '%s\n' "$fname" >>"$file" + fi +} + +( + while IFS= read -r f; do + printf '%s\n' "$f" + ProcessFile "$f" + done +) | "$@" + +LC_ALL=C sort -u < "$file" diff --git a/klibc-find-requires b/klibc-find-requires new file mode 100755 index 0000000..3ff43a4 --- /dev/null +++ b/klibc-find-requires @@ -0,0 +1,38 @@ +#!/bin/sh -efu +file= +handler() +{ + local rc=$? + trap - EXIT + [ -z "$file" ] || rm -f -- "$file" + exit $rc +} +trap handler EXIT HUP INT QUIT PIPE TERM +file=`mktemp -t find-requires.XXXXXXXXXX` + +ProcessFile() +{ + local f="$1" && shift + + local t interp + [ -f "$f" ] || return 0 + t="$(file -b "$f")" || return 0 + if [ -z "${t##*ELF* executable*uses shared libs*}" ]; then + interp="$( + readelf -l "$f" | + sed -ne 's,^[[:space:]]*\[Requesting program interpreter: \(/[^]]\+\)\]$,\1,p' + )" || return + if [ -n "$interp" ] && [ -z "${interp##*/klibc-*.so}" ]; then + printf '%s\n' "$interp" >>"$file" + fi + fi +} + +( + while IFS= read -r f; do + printf '%s\n' "$f" + ProcessFile "$f" + done +) | "$@" + +LC_ALL=C sort -u < "$file" diff --git a/klibc.spec b/klibc.spec new file mode 100644 index 0000000..86fae92 --- /dev/null +++ b/klibc.spec @@ -0,0 +1,189 @@ +Name: klibc +Version: 1.5 +Release: alt1 + +Summary: A minimal libc subset for use with initramfs +License: BSD/GPL +Group: System/Libraries +URL: http://www.zytor.com/mailman/listinfo/klibc +Packager: Sergey Vlasov + +# http://www.kernel.org/pub/linux/libs/klibc-%version.tar.gz +Source0: %name-%version.tar + +Patch0: %name-%version-%release.patch + +# due to %%base_arch +BuildPreReq: kernel-build-tools + +BuildPreReq: kernel-headers-std >= 2.6.18 + +%define klibcdir %_libdir/klibc +%define libdocdir %_docdir/%name-%version-%release +%define bindocdir %_docdir/%name-utils-%version-%release + +# Use special scripts to find dependencies on klibc-*.so (default RPM scripts +# do not pick up these dependencies). +%global __find_provides %_builddir/%name-%version/klibc-find-provides %__find_provides +%global __find_requires %_builddir/%name-%version/klibc-find-requires %__find_requires + +%description +%name is intended to be a minimalistic libc subset for use with +initramfs. It is deliberately written for small size, minimal +entanglement, and portability, not speed. + +%package devel +Summary: Libraries and tools needed to compile applications against klibc +Group: Development/C +Requires: %name = %version-%release + +%description devel +This package contains the link libraries, header files, and gcc +wrapper scripts needed to compile applications against klibc. + +%package utils +Summary: Small utilities built with klibc +Group: System/Kernel and hardware +Requires: %name = %version-%release + +%description utils +This package contains a collection of programs that are linked against +klibc. These duplicate some of the functionality of a regular Linux +toolset, but are typically much smaller than their full-function +counterparts. They are intended for inclusion in initramfs images and +embedded systems. + +%package utils-initramfs +Summary: Utilities for initramfs images generated by mkinitrd +Group: System/Kernel and hardware +Requires: %name = %version-%release +PreReq: mkinitrd-initramfs + +%description utils-initramfs +This package contains utilities for use in initramfs images +generated by mkinitrd. + +%prep +%setup +%patch0 -p1 + +chmod 755 klibc-find-provides klibc-find-requires + +# Assume that adjust_kernel_headers --first has been run. +mkdir -p linux/include +ln -s "$(readlink -ev /usr/include/linux/../..)"/include/* linux/include/ + +# Convert i386 headers to the form expected by klibc ("make headers_install" +# from kernel puts asm-$ARCH headers directly in asm/ instead of creating +# a symlink, but klibc expects asm-$ARCH like in the kernel sources). +[ -L linux/include/asm-%base_arch ] || { + mv linux/include/asm linux/include/asm-%base_arch + ln -s asm-%base_arch linux/include/asm +} + +%build +%make_build \ + KLIBCARCH=%base_arch prefix=%prefix bindir=%_bindir \ + SHLIBDIR=/%_lib \ + INSTALLDIR=%klibcdir mandir=%_mandir INSTALLROOT=%buildroot + +%install +%make_install KLIBCARCH=%base_arch prefix=%prefix bindir=%_bindir \ + SHLIBDIR=/%_lib \ + INSTALLDIR=%klibcdir mandir=%_mandir INSTALLROOT=%buildroot \ + install + +install -p klibc-find-requires %buildroot%klibcdir/ + +# Install the docs +mkdir -p %buildroot%bindocdir %buildroot%libdocdir +install -m 444 README %buildroot%libdocdir +install -m 444 usr/klibc/README %buildroot%libdocdir/README.klibc +install -m 444 usr/klibc/arch/README %buildroot%libdocdir/README.klibc.arch + +install -m 444 usr/gzip/COPYING %buildroot%bindocdir/COPYING.gzip +install -m 444 usr/gzip/README %buildroot%bindocdir/README.gzip +install -m 444 usr/kinit/ipconfig/README %buildroot%bindocdir/README.ipconfig +install -m 444 usr/kinit/README %buildroot%bindocdir/README.kinit + +# This file must have normal symbols - they are used for linking +# (klibc does not use the dynamic symbol table). +%add_strip_skiplist %klibcdir/lib/libc.so + +# Install mkinitrd-klibc files +klibc_soname=`cd %buildroot/%_lib && ls -1 klibc-*.so` +mkdir -p %buildroot/lib/mkinitrd/klibc/{bin,sbin,%_lib} +ln -s /%_lib/"$klibc_soname" \ + %buildroot/lib/mkinitrd/klibc/%_lib/"$klibc_soname" +install -p usr/dash/sh.shared %buildroot/lib/mkinitrd/klibc/bin/sh +install -p usr/utils/shared/{cat,false,kill,ln,mkdir,mknod,mount,nuke,readlink,sleep,true,umount} \ + %buildroot/lib/mkinitrd/klibc/bin/ +install -p usr/utils/shared/{halt,insmod} \ + %buildroot/lib/mkinitrd/klibc/sbin/ +ln %buildroot/lib/mkinitrd/klibc/sbin/halt \ + %buildroot/lib/mkinitrd/klibc/sbin/poweroff +ln %buildroot/lib/mkinitrd/klibc/sbin/halt \ + %buildroot/lib/mkinitrd/klibc/sbin/reboot +for prog in fstype ipconfig md_run nfsmount resume run-init; do + install -p usr/kinit/$prog/shared/$prog \ + %buildroot/lib/mkinitrd/klibc/bin/ +done + +%files +/%_lib/klibc-*.so + +%files devel +%dir %klibcdir +%klibcdir/include +%klibcdir/lib +%klibcdir/klibc-find-requires +%_bindir/klcc +%_man1dir/* +%doc %libdocdir + +%files utils +%dir %klibcdir +%klibcdir/bin +%doc %bindocdir + +%files utils-initramfs +/lib/mkinitrd/klibc + +%changelog +* Thu Mar 29 2007 Sergey Vlasov 1.5-alt1 +- Version 1.5. + +* Mon Feb 19 2007 Sergey Vlasov 1.4.34-alt1 +- Version 1.4.34. +- Fixed broken shared library build on x86_64 with binutils versions having + max-page-size=0x200000 (caused immediate segfault on kernels with the + exec-shield patch applied). + +* Thu Feb 08 2007 Sergey Vlasov 1.4.32-alt1 +- First build for ALT Linux. +- Version 1.4.32. +- Spec file cleanup according to ALT conventions. +- Use kernel-headers-std >= 2.6.18 headers for build. +- Move klibc-*.so from /lib to /%%_lib (which is /lib64 on x86_64). +- Move other klibc files to %%_libdir instead of %%_prefix/lib. +- Move libc.so and interp.o to the devel subpackage (RPM dependencies should + prevent mismatches between runtime and devel packages). +- Do not strip libc.so (klibc uses normal symbols for linking). +- Add klibc-find-provides and klibc-find-requires scripts to generate proper + dependencies on /%%_lib/klibc-*.so (klibc-find-provides is used privately, + klibc-find-requires is available in the devel subpackage for use by other + packages which link with klibc). +- Add klibc-utils-initramfs subpackage which contains the subset of + utilities used by mkinitrd-generated initramfs images; these files are + installed under /lib/mkinitrd to make them available even without /usr. +- Add md_run utility to handle old-style RAID startup separate from kinit. +- umount: Add -l option for lazy unmount. + +* Tue Mar 1 2005 H. Peter Anvin +- New "make install" scheme, klcc + +* Tue Jul 6 2004 H. Peter Anvin +- Update to use kernel-source RPM for the kernel symlink. + +* Sat Nov 29 2003 Bryan O'Sullivan - +- Initial build. diff --git a/usr/kinit/Kbuild b/usr/kinit/Kbuild index ff1d449..1c99ace 100644 --- a/usr/kinit/Kbuild +++ b/usr/kinit/Kbuild @@ -3,13 +3,13 @@ # # library part of kinit. Is used by programs in sub-directories (resume et al) -lib-y := name_to_dev.o devname.o getarg.o +lib-y := create_dev.o do_mounts_md.o name_to_dev.o devname.o getarg.o # use lib for kinit kinit-y := lib.a kinit-y += kinit.o do_mounts.o ramdisk_load.o initrd.o kinit-y += getintfile.o readfile.o xpio.o -kinit-y += do_mounts_md.o do_mounts_mtd.o nfsroot.o +kinit-y += do_mounts_mtd.o nfsroot.o kinit-y += ipconfig/ kinit-y += nfsmount/ @@ -28,9 +28,12 @@ KLIBCCFLAGS += -I$(srctree)/$(src)/fstype \ -I$(srctree)/$(src)/resume \ -I$(srctree)/$(src)/run-init +# Subdirectories which do not have lib.a used by kinit +subdir-y := md_run + # Cleaning targets += kinit kinit.g kinit.shared kinit.shared.g -subdir- := fstype ipconfig nfsmount resume run-init +subdir- := fstype ipconfig md_run nfsmount resume run-init # install binary diff --git a/usr/kinit/create_dev.c b/usr/kinit/create_dev.c new file mode 100644 index 0000000..5397db4 --- /dev/null +++ b/usr/kinit/create_dev.c @@ -0,0 +1,13 @@ +#include +#include +#include +#include + +#include "do_mounts.h" + +/* Create the device node "name" */ +int create_dev(const char *name, dev_t dev) +{ + unlink(name); + return mknod(name, S_IFBLK | 0600, dev); +} diff --git a/usr/kinit/do_mounts.c b/usr/kinit/do_mounts.c index 9daa006..12c5000 100644 --- a/usr/kinit/do_mounts.c +++ b/usr/kinit/do_mounts.c @@ -15,13 +15,6 @@ #include "fstype.h" #include "zlib.h" -/* Create the device node "name" */ -int create_dev(const char *name, dev_t dev) -{ - unlink(name); - return mknod(name, S_IFBLK | 0600, dev); -} - /* mount a filesystem, possibly trying a set of different types */ const char *mount_block(const char *source, const char *target, const char *type, unsigned long flags, diff --git a/usr/kinit/md_run/Kbuild b/usr/kinit/md_run/Kbuild new file mode 100644 index 0000000..0176487 --- /dev/null +++ b/usr/kinit/md_run/Kbuild @@ -0,0 +1,27 @@ +# +# Kbuild file for md_run +# + +static-y := static/md_run +shared-y := shared/md_run + +# common .o files +objs := md_run.o + +# TODO - do we want a stripped version +# TODO - do we want the static.g + shared.g directories? + +# Additional include paths files +KLIBCCFLAGS += -I$(srctree)/$(src)/.. + +# .o files used to built executables +static/md_run-y := $(objs) +static/md_run-lib := ../lib.a +shared/md_run-y := $(objs) +shared/md_run-lib := ../lib.a + +# Cleaning +clean-dirs := static shared + +# install binary +install-y := $(shared-y) diff --git a/usr/kinit/md_run/md_run.c b/usr/kinit/md_run/md_run.c new file mode 100644 index 0000000..cd5db92 --- /dev/null +++ b/usr/kinit/md_run/md_run.c @@ -0,0 +1,14 @@ +/* + * Handle autoconfiguration of md devices. + * + * Processes "md=..." and "raid=..." parameters passed as separate + * command arguments, ignores other parameters. + */ + +#include "kinit.h" + +int main(int argc, char *argv[]) +{ + md_run(argc - 1, argv + 1); + return 0; +}