# HG changeset patch # User Rob Landley # Date 1423623773 21600 # Node ID 7f1b9fb1099efbd2c446154716e924d7aa2537d1 # Parent 7c89513343ea52b6ce21762583b568b5d00f1e63 Move simple-root-filesystem.sh to root-filesystem.sh diff -r 7c89513343ea -r 7f1b9fb1099e build.sh --- a/build.sh Tue Feb 10 20:58:05 2015 -0600 +++ b/build.sh Tue Feb 10 21:02:53 2015 -0600 @@ -3,7 +3,7 @@ # Run all the steps needed to build a system image from scratch. # The default set of stages run by this script is (in order): -# download, host-tools, simple-cross-compiler, simple-root-filesystem, +# download, host-tools, simple-cross-compiler, root-filesystem, # native-compiler, system-image. # That sanitizes the host build environment and builds a cross compiler, @@ -12,7 +12,7 @@ # by qemu. # The optional cross-compiler stage (after simple-cross-compiler but before -# simple-root-filesystem) creates a more powerful and portable cross compiler +# root-filesystem) creates a more powerful and portable cross compiler # that can be used to cross compile more stuff (if you're into that sort of # thing). To enable that: @@ -21,7 +21,7 @@ # Where "i686" is whichever target you want the new cross compiler to run on. # The simplest set of stages (if you run them yourself) is: -# download, simple-cross-compiler, simple-root-filesystem, system-image. +# download, simple-cross-compiler, root-filesystem, system-image. # If this script was run with no arguments, list available architectures @@ -101,7 +101,7 @@ then # If we need to build cross compiler, assume root filesystem is stale. - zap simple-root-filesystem cross-compiler native-compiler linux-kernel + zap root-filesystem cross-compiler native-compiler linux-kernel time ./simple-cross-compiler.sh "$ARCH" || exit 1 fi @@ -112,7 +112,7 @@ if [ ! -z "$CROSS_COMPILER_HOST" ] && not_already cross-compiler then - zap simple-root-filesystem native-compiler linux-kernel + zap root-filesystem native-compiler linux-kernel # Build the host compiler if necessary @@ -126,12 +126,12 @@ # Build the basic root filesystem. -if not_already simple-root-filesystem +if not_already root-filesystem then zap system-image [ "$SYSIMAGE_TYPE" == rootfs ] && zap linux-kernel - time ./simple-root-filesystem.sh "$ARCH" || exit 1 + time ./root-filesystem.sh "$ARCH" || exit 1 fi # Build a native compiler. It's statically linked by default so it can diff -r 7c89513343ea -r 7f1b9fb1099e native-compiler.sh --- a/native-compiler.sh Tue Feb 10 20:58:05 2015 -0600 +++ b/native-compiler.sh Tue Feb 10 21:02:53 2015 -0600 @@ -56,7 +56,7 @@ fi # Delete some unneeded files and strip everything else - +mv "$STAGE_DIR"/{etc,..} || dienow if [ -z "$SKIP_STRIP" ] then rm -rf "$STAGE_DIR"/{info,man,libexec/gcc/*/*/install-tools} diff -r 7c89513343ea -r 7f1b9fb1099e root-filesystem.sh --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/root-filesystem.sh Tue Feb 10 21:02:53 2015 -0600 @@ -0,0 +1,96 @@ +#!/bin/bash + +# Build a basic busybox+uClibc root filesystem for a given target. + +# Requires a cross-compiler (or simple-cross-compiler) in the $PATH or in +# the build directory. In theory you can supply your own as long as the +# prefix- name is correct. + +source sources/include.sh || exit 1 +load_target "$1" +check_for_base_arch || exit 0 +check_prerequisite "${ARCH}-cc" + +# Determine which directory layout we're using + +mkdir -p "$STAGE_DIR"/{tmp,proc,sys,dev,home,mnt,root} && +chmod a+rwxt "$STAGE_DIR/tmp" || dienow + +STAGE_USR="$STAGE_DIR/usr" + +# Having lots of repeated locations at / and also under /usr is silly, so +# symlink them together. (The duplication happened back in the 1970's +# when Ken and Dennis ran out of space on their PDP-11's root disk and +# leaked the OS into the disk containing the user home directories. It's +# been mindlessly duplicated ever since.) +for i in bin sbin lib etc +do + mkdir -p "$STAGE_USR/$i" && ln -s "usr/$i" "$STAGE_DIR/$i" || dienow +done + +# Copy qemu setup script and so on. + +cp -r "$SOURCES/root-filesystem/." "$STAGE_USR/" && +echo -e "CROSS_TARGET=$CROSS_TARGET\nKARCH=$KARCH" > \ + "$STAGE_USR/src/host-info" && +cp "$SRCDIR"/MANIFEST "$STAGE_USR/src" || dienow + +# If user specified different files to put in the root filesystem, add them. +# (This overwrites existing files.) + +if [ ! -z "$SIMPLE_ROOT_OVERLAY" ] +then + cd "$TOP" + tar -c -C "$SIMPLE_ROOT_OVERLAY" . | tar -x -C "$STAGE_DIR" || dienow +fi + +# Build toybox + +STAGE_DIR="$STAGE_USR" build_section busybox +cp "$WORK"/config-busybox "$STAGE_USR"/src || dienow +build_section toybox + +# Put statically and dynamically linked hello world programs on there for +# test purposes. + +"${ARCH}-cc" "${SOURCES}/root-filesystem/src/hello.c" -Os $CFLAGS \ + -o "$STAGE_USR/bin/hello-dynamic" || dienow + +if [ "$BUILD_STATIC" != none ] +then + "${ARCH}-cc" "${SOURCES}/root-filesystem/src/hello.c" -Os $CFLAGS -static \ + -o "$STAGE_USR/bin/hello-static" || dienow + STATIC=--static +else + STATIC= +fi + +# Debug wrapper for use with /usr/src/record-commands.sh + +"${ARCH}-cc" "$SOURCES/toys/wrappy.c" -Os $CFLAGS $STATIC \ + -o "$STAGE_USR/bin/record-commands-wrapper" || dienow + +# Do we need shared libraries? + +if ! is_in_list toybox $BUILD_STATIC || ! is_in_list busybox $BUILD_STATIC +then + echo Copying compiler libraries... + mkdir -p "$STAGE_USR/lib" || dienow + (path_search \ + "$("$ARCH-cc" --print-search-dirs | sed -n 's/^libraries: =*//p')" \ + "*.so*" 'cp -H "$DIR/$FILE" "$STAGE_USR/lib/$FILE"' \ + || dienow) | dotprogress + + [ -z "$SKIP_STRIP" ] && + "${ARCH}-strip" --strip-unneeded "$STAGE_USR"/lib/*.so +fi + +# Clean up and package the result + +[ -z "$SKIP_STRIP" ] && + "${ARCH}-strip" "$STAGE_USR"/{bin/*,sbin/*} + +create_stage_tarball + +# Color back to normal +echo -e "\e[0mBuild complete" diff -r 7c89513343ea -r 7f1b9fb1099e simple-root-filesystem.sh --- a/simple-root-filesystem.sh Tue Feb 10 20:58:05 2015 -0600 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,96 +0,0 @@ -#!/bin/bash - -# Build a basic busybox+uClibc root filesystem for a given target. - -# Requires a cross-compiler (or simple-cross-compiler) in the $PATH or in -# the build directory. In theory you can supply your own as long as the -# prefix- name is correct. - -source sources/include.sh || exit 1 -load_target "$1" -check_for_base_arch || exit 0 -check_prerequisite "${ARCH}-cc" - -# Determine which directory layout we're using - -mkdir -p "$STAGE_DIR"/{tmp,proc,sys,dev,home,mnt,root} && -chmod a+rwxt "$STAGE_DIR/tmp" || dienow - -STAGE_USR="$STAGE_DIR/usr" - -# Having lots of repeated locations at / and also under /usr is silly, so -# symlink them together. (The duplication happened back in the 1970's -# when Ken and Dennis ran out of space on their PDP-11's root disk and -# leaked the OS into the disk containing the user home directories. It's -# been mindlessly duplicated ever since.) -for i in bin sbin lib etc -do - mkdir -p "$STAGE_USR/$i" && ln -s "usr/$i" "$STAGE_DIR/$i" || dienow -done - -# Copy qemu setup script and so on. - -cp -r "$SOURCES/root-filesystem/." "$STAGE_USR/" && -echo -e "CROSS_TARGET=$CROSS_TARGET\nKARCH=$KARCH" > \ - "$STAGE_USR/src/host-info" && -cp "$SRCDIR"/MANIFEST "$STAGE_USR/src" || dienow - -# If user specified different files to put in the root filesystem, add them. -# (This overwrites existing files.) - -if [ ! -z "$SIMPLE_ROOT_OVERLAY" ] -then - cd "$TOP" - tar -c -C "$SIMPLE_ROOT_OVERLAY" . | tar -x -C "$STAGE_DIR" || dienow -fi - -# Build toybox - -STAGE_DIR="$STAGE_USR" build_section busybox -cp "$WORK"/config-busybox "$STAGE_USR"/src || dienow -build_section toybox - -# Put statically and dynamically linked hello world programs on there for -# test purposes. - -"${ARCH}-cc" "${SOURCES}/root-filesystem/src/hello.c" -Os $CFLAGS \ - -o "$STAGE_USR/bin/hello-dynamic" || dienow - -if [ "$BUILD_STATIC" != none ] -then - "${ARCH}-cc" "${SOURCES}/root-filesystem/src/hello.c" -Os $CFLAGS -static \ - -o "$STAGE_USR/bin/hello-static" || dienow - STATIC=--static -else - STATIC= -fi - -# Debug wrapper for use with /usr/src/record-commands.sh - -"${ARCH}-cc" "$SOURCES/toys/wrappy.c" -Os $CFLAGS $STATIC \ - -o "$STAGE_USR/bin/record-commands-wrapper" || dienow - -# Do we need shared libraries? - -if ! is_in_list toybox $BUILD_STATIC || ! is_in_list busybox $BUILD_STATIC -then - echo Copying compiler libraries... - mkdir -p "$STAGE_USR/lib" || dienow - (path_search \ - "$("$ARCH-cc" --print-search-dirs | sed -n 's/^libraries: =*//p')" \ - "*.so*" 'cp -H "$DIR/$FILE" "$STAGE_USR/lib/$FILE"' \ - || dienow) | dotprogress - - [ -z "$SKIP_STRIP" ] && - "${ARCH}-strip" --strip-unneeded "$STAGE_USR"/lib/*.so -fi - -# Clean up and package the result - -[ -z "$SKIP_STRIP" ] && - "${ARCH}-strip" "$STAGE_USR"/{bin/*,sbin/*} - -create_stage_tarball - -# Color back to normal -echo -e "\e[0mBuild complete" diff -r 7c89513343ea -r 7f1b9fb1099e system-image.sh --- a/system-image.sh Tue Feb 10 20:58:05 2015 -0600 +++ b/system-image.sh Tue Feb 10 21:02:53 2015 -0600 @@ -63,9 +63,9 @@ chmod +x "$STAGE_DIR/$FILE" || dienow done -# Package simple-root-filesystem into cpio file for initramfs +# Package root-filesystem into cpio file for initramfs -SYSIMAGE_TYPE=cpio image_filesystem "$BUILD/simple-root-filesystem-$ARCH" \ +SYSIMAGE_TYPE=cpio image_filesystem "$BUILD/root-filesystem-$ARCH" \ "$STAGE_DIR/rootfs" && SYSIMAGE_TYPE=squashfs image_filesystem "$BUILD/native-compiler-$ARCH" \ "$STAGE_DIR/toolchain" || dienow @@ -75,7 +75,7 @@ setupfor linux getconfig linux > mini.conf [ "$SYSIMAGE_TYPE" == rootfs ] && - echo -e "CONFIG_INITRAMFS_SOURCE=\"$BUILD/simple-root-filesystem-$ARCH/rootfs.cpio.gz\"\n" \ + echo -e "CONFIG_INITRAMFS_SOURCE=\"$BUILD/root-filesystem-$ARCH/rootfs.cpio.gz\"\n" \ >> mini.conf make ARCH=${BOOT_KARCH:-$KARCH} $LINUX_FLAGS KCONFIG_ALLCONFIG=mini.conf \ allnoconfig >/dev/null &&