# HG changeset patch # User Rob Landley # Date 1231750052 21600 # Node ID 9dffdd74c186f7d900f947ee63e013b28ac4ddf4 # Parent 90bea985c98e2406edc02c57b125ebb82cdccb9b More changes for initramfs and hw- targets with a base architecture. The $BASE_ARCH approach didn't work because targets need to override things like KERNEL_PATH, so they need to source the relevant details file themselves. Shuffle things around so they can do that: move $CROSS into cross-compiler.sh, add cross compiler to $PATH independently of that, remove $ARCH from CONFIG_DIR and change users to add it, have getconfig check $ARCH_NAME directory first, redo qemu_defaults to chop out initramfs options less uncleanly... diff -r 90bea985c98e -r 9dffdd74c186 sources/functions.sh --- a/sources/functions.sh Sun Jan 11 14:24:22 2009 -0600 +++ b/sources/functions.sh Mon Jan 12 02:47:32 2009 -0600 @@ -11,13 +11,18 @@ function getconfig() { - if unstable "$1" && [ -f "$CONFIG_DIR/miniconfig-alt-$1" ] - then - echo "$CONFIG_DIR/miniconfig-alt-$1" - return - fi + for i in $(unstable $1 && echo {$ARCH_NAME,$ARCH}/miniconfig-alt-$1) \ + {$ARCH_NAME,$ARCH}/miniconfig-$1 + do + if [ -f "$CONFIG_DIR/$i" ] + then + echo "$CONFIG_DIR/$i" + return + fi + done - echo "$CONFIG_DIR/miniconfig-$1" + echo "getconfig $1 failed" >&2 + dienow } # Strip the version number off a tarball @@ -188,8 +193,8 @@ FILENAME=`echo "$URL" | sed 's .*/ '` ALTFILENAME=alt-"$(noversion "$FILENAME" -0)" - # Is there an unstable version to download, and is it selected? - if [ ! -z "$UNSTABLE" ] && unstable "$(basename "$FILENAME")" + # Is the unstable version selected? + if unstable "$(basename "$FILENAME")" then # Keep old version around, if present. touch -c "$SRCDIR/$FILENAME" 2>/dev/null diff -r 90bea985c98e -r 9dffdd74c186 sources/include.sh --- a/sources/include.sh Sun Jan 11 14:24:22 2009 -0600 +++ b/sources/include.sh Mon Jan 12 02:47:32 2009 -0600 @@ -69,17 +69,11 @@ exit 1 fi - # Read the relevant config file, iterating to find base architecture if any. + # Read the relevant config file. ARCH="$ARCH_NAME" - CONFIG_DIR="${TOP}/sources/targets/${ARCH}" - source "${CONFIG_DIR}/details" - if [ ! -z "$BASE_ARCH" ] - then - ARCH="$BASE_ARCH" - CONFIG_DIR="${TOP}/sources/targets/${ARCH}" - source "${CONFIG_DIR}/details" - fi + CONFIG_DIR="${TOP}/sources/targets" + source "${CONFIG_DIR}/${ARCH}/details" # Which platform are we building for? @@ -97,9 +91,8 @@ # Setup directories and add the cross compiler to the start of the path. - export CROSS="${BUILD}/cross-compiler-$ARCH" export NATIVE="${BUILD}/mini-native-$ARCH" - export PATH="${CROSS}/bin:$PATH" + export PATH="${BUILD}/cross-compiler-$ARCH/bin:$PATH" if [ ! -z "${NATIVE_TOOLSDIR}" ] then diff -r 90bea985c98e -r 9dffdd74c186 sources/targets/hw-wrt610n/details --- a/sources/targets/hw-wrt610n/details Sun Jan 11 14:24:22 2009 -0600 +++ b/sources/targets/hw-wrt610n/details Mon Jan 12 02:47:32 2009 -0600 @@ -1,1 +1,6 @@ -BASE_ARCH=mipsel +# Include base architecture + +ARCH=mipsel +source "$CONFIG_DIR/$ARCH/details" + +KERNEL_PATH=thingy diff -r 90bea985c98e -r 9dffdd74c186 system-image.sh --- a/system-image.sh Sun Jan 11 14:24:22 2009 -0600 +++ b/system-image.sh Mon Jan 12 02:47:32 2009 -0600 @@ -8,8 +8,9 @@ echo -e "$PACKAGE_COLOR" echo "=== Packaging system image from mini-native" -SYSIMAGE="${BUILD}/system-image-${ARCH}" -IMAGE="${SYSIMAGE}/image-${ARCH}.ext2" +[ -z "$SYSIMAGE_TYPE" ] && SYSIMAGE_TYPE=ext2 + +SYSIMAGE="${BUILD}/system-image-${ARCH_NAME}" TOOLSDIR=tools [ -z "$NATIVE_TOOLSDIR" ] && TOOLSDIR=usr @@ -19,13 +20,30 @@ rm -rf "${SYSIMAGE}" mkdir -p "${SYSIMAGE}" || dienow +# This next bit is a little complicated; we generate the root filesystem image +# in the middle of building a kernel. This is necessary to embed an +# initramfs in the kernel, and allows us to parallelize the kernel build with +# the image generation. Having the other image types in the same if/else +# staircase with initramfs lets us detect unknown image types (probably typos) +# without repeating any. + # Build a linux kernel for the target setupfor linux make ARCH="${KARCH}" KCONFIG_ALLCONFIG="$(getconfig linux)" \ allnoconfig > /dev/null || dienow -if [ ! -z "$USE_INITRAMFS" ] +# Build kernel in parallel with initramfs + +( make -j $CPUS ARCH="${KARCH}" CROSS_COMPILE="${ARCH}-" || dienow ) & + +# If we exit before removing this handler, kill everything in the current +# process group, which should take out backgrounded kernel make. +trap "kill 0" EXIT + +# Embed an initramfs image in the kernel? + +if [ "$SYSIMAGE_TYPE" == "initramfs" ] then echo "Generating initramfs (in background)" ( @@ -41,17 +59,11 @@ ) | gzip -9 > initramfs_data.cpio.gz || dienow echo Initramfs generated. ) & -fi -# Build a kernel. + # Wait for initial kernel build to finish. -make -j $CPUS ARCH="${KARCH}" CROSS_COMPILE="${ARCH}-" || dienow -wait4background 0 + wait4background 0 -# Embed an initramfs image in the kernel? - -if [ ! -z "$USE_INITRAMFS" ] -then # This is a repeat of an earlier make invocation, but if we try to # consolidate them the dependencies build unnecessary prereqisites # and then decide that they're newer than the cpio.gz we supplied, @@ -62,8 +74,44 @@ touch initramfs_data.cpio.gz && mv initramfs_data.cpio.gz usr && make -j $CPUS ARCH="${KARCH}" CROSS_COMPILE="${ARCH}-" || dienow + + # No need to supply an hda image to emulator. + + IMAGE= +elif [ "$SYSIMAGE_TYPE" == "ext2" ] +then + # Generate a 64 megabyte ext2 filesystem image from the $NATIVE directory, + # with a temporary file defining the /dev nodes for the new filesystem. + + echo "Generating ext2 image (in background)" + + IMAGE="image-${ARCH}.ext2" + DEVLIST="$WORK"/devlist + + echo "/dev d 755 0 0 - - - - -" > "$DEVLIST" && + echo "/dev/console c 640 0 0 5 1 0 0 -" >> "$DEVLIST" && + + genext2fs -z -D "$DEVLIST" -d "${NATIVE}" -i 1024 -b $[64*1024] \ + "${SYSIMAGE}/${IMAGE}" && + rm "$DEVLIST" || dienow + +#elif [ "$SYSIMAGE_TYPE" == "squashfs" ] +#then +# We used to do this, but updating the squashfs patch for each new kernel +# was just too much work. If it gets merged someday, we may care again... + +# IMAGE="image-${ARCH}.sqf" +# echo -n "Creating squashfs image (in background)" +# "${WORK}/mksquashfs" "${NATIVE}" "${SYSIMAGE}/$IMAGE" \ +# -noappend -all-root -info || dienow fi +# Wait for kernel build to finish (may be a NOP) + +echo Image generation complete. +wait4background 0 +trap "" EXIT + # Install kernel [ -d "${TOOLS}/src" ] && cp .config "${TOOLS}"/src/config-linux @@ -72,30 +120,20 @@ cleanup linux -if [ -z "$USE_INITRAMFS" ] -then - # Generate a 64 megabyte ext2 filesystem image from the $NATIVE directory, - # with a temporary file defining the /dev nodes for the new filesystem. - - cat > "$WORK/devlist" << EOF && -/dev d 755 0 0 - - - - - -/dev/console c 640 0 0 5 1 0 0 - -EOF - genext2fs -z -D "$WORK/devlist" -d "${NATIVE}" -i 1024 -b $[64*1024] \ - "$IMAGE" && - rm "$WORK/devlist" || dienow -fi - # Provide qemu's common command line options between architectures. The lack # of ending quotes on -append is intentional, callers append more kernel # command line arguments and provide their own ending quote. function qemu_defaults() { - echo -n "-nographic -no-reboot \$WITH_HDB" - [ -z "$USE_INITRAMFS" ] && echo -n " -hda \"$1\"" - echo " -kernel \"$2\" -append \"root=/dev/$ROOT console=$CONSOLE" \ - "rw init=/$TOOLSDIR/sbin/init.sh panic=1" \ - 'PATH=$DISTCC_PATH_PREFIX/$TOOLSDIR/bin $KERNEL_EXTRA"' + if [ "$SYSIMAGE_TYPE" != "initramfs" ] + then + HDA="-hda \"$1\" " + APPEND="root=/dev/$ROOT console=$CONSOLE rw init=/$TOOLSDIR/sbin/init.sh " + fi + + echo "-nographic -no-reboot -kernel \"$2\" \$WITH_HDB $HDA" \ + "-append \"${APPEND}panic=1 PATH=\$DISTCC_PATH_PREFIX/\$TOOLSDIR/bin" \ + '$KERNEL_EXTRA"' } # Write out a script to call the appropriate emulator. We split out the @@ -118,13 +156,3 @@ -C "$BUILD" system-image-$ARCH || dienow echo -e "=== Packaging complete\e[0m" - - -# We used to do this, but updating the squashfs patch for each new kernel -# was just too much work. If it gets merged someday, we may care again... - -#echo -n "Creating tools.sqf" -#("${WORK}/mksquashfs" "${NATIVE}/tools" "${WORK}/tools.sqf" \ -# -noappend -all-root -info || dienow) | dotprogress - -