Permalink
Browse files

- Moving the building to a separate build dir

- Adding a script for building various awks
  • Loading branch information...
1 parent 027ae6c commit 56321c57981b60cbd4f9737b8fd53e9ea8bc854d @geirha committed Sep 17, 2012
Showing with 121 additions and 39 deletions.
  1. +32 −15 Makefile
  2. +50 −0 build-awk
  3. +5 −3 build-bash
  4. +3 −1 build-linux
  5. +31 −20 generate-initramfs
View
@@ -1,15 +1,19 @@
+bashes = build/bin/bash1 build/bin/bash2 build/bin/bash3 build/bin/bash4
+awks = build/bin/bwk build/bin/gawk3 build/bin/gawk4 build/bin/mawk build/bin/nawk build/bin/oawk
evalbot: hda
-initramfs.cpio.gz: bash1.14.7 bash2.05b bash3.2 bash4.2
- ./generate-initramfs
+initramfs.cpio.gz: $(bashes) $(awks) initramfs
{ cd initramfs && pax -x sv4cpio -w .; } | gzip -9 > initramfs.cpio.gz
-bzImage:
+initramfs: generate-initramfs
+ ./generate-initramfs
+
+build/bzImage:
./build-linux http://www.kernel.org/pub/linux/kernel/v3.0/linux-3.5.4.tar.bz2
-hda: initramfs.cpio.gz bzImage
+hda: initramfs.cpio.gz build/bzImage
qemu-img create -f qcow2 hda.tmp 1M
./savestate hda.tmp _sh
./savestate hda.tmp _4
@@ -20,14 +24,27 @@ hda: initramfs.cpio.gz bzImage
mv hda.tmp hda
clean:
- rm -rf bash-*/ linux-*/
- rm -f initramfs.cpio.gz hda hda.tmp fifo *~ bash1.14.7 bash2.05b bash3.2 bash4.2 bzImage
-
-bash1.14.7:
- ./build-bash 1.14.7
-bash2.05b:
- ./build-bash 2.05b
-bash3.2:
- ./build-bash 3.2
-bash4.2:
- ./build-bash 4.2
+ rm -rf build/ initramfs/
+ rm -f initramfs.cpio.gz hda hda.tmp fifo *~
+
+build/bin/bash1:
+ ./build-bash 1.14.7 bash1
+build/bin/bash2:
+ ./build-bash 2.05b bash2
+build/bin/bash3:
+ ./build-bash 3.2 bash3
+build/bin/bash4:
+ ./build-bash 4.2 bash4
+
+build/bin/bwk:
+ ./build-awk bwk
+build/bin/gawk3:
+ ./build-awk gawk 3.1.8 gawk3
+build/bin/gawk4:
+ ./build-awk gawk 4.0.1 gawk4
+build/bin/mawk:
+ ./build-awk mawk
+build/bin/nawk:
+ ./build-awk nawk
+build/bin/oawk:
+ ./build-awk oawk
View
@@ -0,0 +1,50 @@
+#!/bin/bash
+
+awk=$1 version=$2 bin_name=${3:-$1$2}
+
+mkdir -p build/bin &&
+cd build &&
+case $awk in
+ bwk)
+ wget -c -O bwk.tar.gz http://plan9.bell-labs.com/cm/cs/who/bwk/awk.tar.gz &&
+ mkdir -p bwk &&
+ cd bwk &&
+ gzip -cd ../bwk.tar.gz | pax -r &&
+ make CFLAGS=-D_POSIX_C_SOURCE=200112L &&
+ cp a.out ../bin/bwk
+ ;;
+ oawk)
+ wget -c -O heirloom-070715.tar.bz2 http://sourceforge.net/projects/heirloom/files/heirloom/070715/heirloom-070715.tar.bz2/download &&
+ bzip2 -cd heirloom-070715.tar.bz2 | pax -r &&
+ cd heirloom-070715 &&
+ make {libcommon,libuxre,oawk}/Makefile
+ make -C libcommon &&
+ make -C libuxre &&
+ make -C oawk &&
+ cp oawk/awk ../bin/oawk
+ ;;
+ nawk)
+ wget -c -O nawk.tar.gz http://www.cs.princeton.edu/~bwk/btl.mirror/awk.tar.gz &&
+ mkdir -p nawk &&
+ cd nawk &&
+ gzip -cd ../nawk.tar.gz | pax -r &&
+ make &&
+ cp a.out ../bin/nawk
+ ;;
+ gawk)
+ wget -c -O "gawk-$version.tar.gz" "http://ftp.gnu.org/gnu/gawk/gawk-$version.tar.gz" &&
+ gzip -cd "gawk-$version.tar.gz" | pax -r &&
+ cd "gawk-$version" &&
+ ./configure &&
+ make &&
+ cp gawk "../bin/$bin_name"
+ ;;
+ mawk)
+ wget -c -O mawk.tar.gz http://invisible-island.net/datafiles/release/mawk.tar.gz &&
+ gzip -cd mawk.tar.gz | pax -rs '|^[^/]*|mawk|' &&
+ cd mawk &&
+ ./configure &&
+ make &&
+ cp mawk ../bin/mawk
+ ;;
+esac
View
@@ -1,8 +1,10 @@
#!/bin/bash
-version=$1
+version=$1 bin_name=${2:-bash$version}
-wget -nc "http://ftp.gnu.org/gnu/bash/bash-$version.tar.gz" &&
+mkdir -p build/bin &&
+cd build &&
+wget -c -O "bash-$version.tar.gz" "http://ftp.gnu.org/gnu/bash/bash-$version.tar.gz" &&
gzip -cd "bash-$version.tar.gz" | pax -r || exit
configure_opts=()
@@ -96,4 +98,4 @@ fi
./configure "${configure_opts[@]}" &&
make &&
-cp bash "../bash$version"
+cp bash "../bin/$bin_name"
View
@@ -4,6 +4,8 @@ if [[ $1 != *.bz2 ]]; then
printf 'No url or filename to a linux bzip2ed tarball provided.\n' >&2
exit 1
fi
+mkdir -p build/ &&
+cd build || exit
kernel=$1
if [[ ! -f $kernel ]]; then # assuming url
@@ -13,7 +15,7 @@ fi
bzip2 -cd "$kernel" | pax -r &&
dir=${kernel##*/} dir=${dir%.tar.bz2} &&
-cp kernel.config "$dir/.config" &&
+cp ../kernel.config "$dir/.config" &&
cd "$dir" &&
make silentoldconfig &&
make &&
View
@@ -1,9 +1,6 @@
#!/bin/bash
-#cp() { echo cp "$@"; }
-#mkdir() { echo mkdir "$@"; }
-#ln() { echo ln "$@"; }
-#chmod() { echo chmod "$@"; }
+PATH=$PWD/build/bin:$PATH
declare -A commands='(
@@ -184,11 +181,9 @@ declare -A commands='(
## Other useful commands (non-POSIX)
[bzip2]="a block-sorting file compressor, v1.0.6"
[dash]="command interpreter (shell)"
- [gawk]="pattern scanning and processing language"
[getent]="get entries from administrative database"
[gzip]="compress or expand files"
[hostname]="show or set the system'\''s host name"
- [mawk]="pattern scanning and text processing language"
[mknod]="make block or character special files"
[mktemp]="create a temporary file or directory"
[mount]="mount a filesystem"
@@ -198,8 +193,19 @@ declare -A commands='(
[strace]="trace system calls and signals"
[tac]="concatenate and print files in reverse"
[umount]="unmount file systems"
-)'
+ ## Built with build-bash and build-awk
+ [bash1]="GNU Bourne-Again SHell 1.x"
+ [bash2]="GNU Bourne-Again SHell 2.x"
+ [bash3]="GNU Bourne-Again SHell 3.x"
+ [bash4]="GNU Bourne-Again SHell 4.x"
+ [bwk]="pattern-directed scanning and processing language"
+ [gawk3]="pattern scanning and processing language"
+ [gawk4]="pattern scanning and processing language"
+ [mawk]="pattern scanning and text processing language"
+ [nawk]="pattern-directed scanning and processing language"
+ [oawk]="pattern scanning and processing language"
+)'
mkdir -p initramfs/{bin,dev,etc,lib,root,usr/share}
@@ -348,24 +354,29 @@ esac
printf "(shell exited with %d)\n" "$?"
printf o > /proc/sysrq-trigger
EOF
-chmod +x initramfs/init
+chmod 750 initramfs/init
-# Shells
shopt -s nullglob
-f=(bash1.*); (( ${#f[@]} )) && cp "${f[-1]}" "initramfs/bin/bash1" && ln -sf bash1 initramfs/bin/bash
-f=(bash2.*); (( ${#f[@]} )) && cp "${f[-1]}" "initramfs/bin/bash2" && ln -sf bash2 initramfs/bin/bash
-f=(bash3.*); (( ${#f[@]} )) && cp "${f[-1]}" "initramfs/bin/bash3" && ln -sf bash3 initramfs/bin/bash
-f=(bash4.*); (( ${#f[@]} )) && cp "${f[-1]}" "initramfs/bin/bash4" && ln -sf bash4 initramfs/bin/bash
-
-for shell in dash ksh bash{4..1}; do
- [[ -e initramfs/bin/$shell ]] || continue
- ln -sf "$shell" initramfs/bin/sh
+# decide on a /bin/bash
+bashes=( initramfs/bin/bash[1-4] )
+ln -sf "${bashes[-1]##*/}" initramfs/bin/bash || exit
+
+
+# decide on a /bin/sh
+for shell in initramfs/bin/{dash,ksh,bash}; do
+ [[ -e $shell ]] || continue
+ ln -sf "${shell##*/}" initramfs/bin/sh
break
done
-# awk
-for awk in gawk mawk; do
+[[ -e initramfs/bin/sh ]] || exit
+
+# awk symlinks
+awks=( initramfs/bin/gawk?* )
+ln -s "${awks[-1]##*/}" initramfs/bin/gawk || exit
+
+for awk in nawk mawk gawk oawk bwk; do
[[ -e initramfs/bin/$awk ]] || continue;
- ln -sf "$awk" initramfs/bin/awk
+ ln -s "$awk" initramfs/bin/awk
break
done

0 comments on commit 56321c5

Please sign in to comment.