Skip to content
This repository has been archived by the owner on Apr 13, 2022. It is now read-only.

Commit

Permalink
- Moving the building to a separate build dir
Browse files Browse the repository at this point in the history
- Adding a script for building various awks
  • Loading branch information
geirha committed Sep 17, 2012
1 parent 027ae6c commit 56321c5
Show file tree
Hide file tree
Showing 5 changed files with 121 additions and 39 deletions.
47 changes: 32 additions & 15 deletions Makefile
@@ -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 evalbot: hda




initramfs.cpio.gz: bash1.14.7 bash2.05b bash3.2 bash4.2 initramfs.cpio.gz: $(bashes) $(awks) initramfs
./generate-initramfs
{ cd initramfs && pax -x sv4cpio -w .; } | gzip -9 > initramfs.cpio.gz { 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 ./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 qemu-img create -f qcow2 hda.tmp 1M
./savestate hda.tmp _sh ./savestate hda.tmp _sh
./savestate hda.tmp _4 ./savestate hda.tmp _4
Expand All @@ -20,14 +24,27 @@ hda: initramfs.cpio.gz bzImage
mv hda.tmp hda mv hda.tmp hda


clean: clean:
rm -rf bash-*/ linux-*/ rm -rf build/ initramfs/
rm -f initramfs.cpio.gz hda hda.tmp fifo *~ bash1.14.7 bash2.05b bash3.2 bash4.2 bzImage rm -f initramfs.cpio.gz hda hda.tmp fifo *~


bash1.14.7: build/bin/bash1:
./build-bash 1.14.7 ./build-bash 1.14.7 bash1
bash2.05b: build/bin/bash2:
./build-bash 2.05b ./build-bash 2.05b bash2
bash3.2: build/bin/bash3:
./build-bash 3.2 ./build-bash 3.2 bash3
bash4.2: build/bin/bash4:
./build-bash 4.2 ./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
50 changes: 50 additions & 0 deletions build-awk
@@ -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
8 changes: 5 additions & 3 deletions build-bash
@@ -1,8 +1,10 @@
#!/bin/bash #!/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 gzip -cd "bash-$version.tar.gz" | pax -r || exit


configure_opts=() configure_opts=()
Expand Down Expand Up @@ -96,4 +98,4 @@ fi


./configure "${configure_opts[@]}" && ./configure "${configure_opts[@]}" &&
make && make &&
cp bash "../bash$version" cp bash "../bin/$bin_name"
4 changes: 3 additions & 1 deletion build-linux
Expand Up @@ -4,6 +4,8 @@ if [[ $1 != *.bz2 ]]; then
printf 'No url or filename to a linux bzip2ed tarball provided.\n' >&2 printf 'No url or filename to a linux bzip2ed tarball provided.\n' >&2
exit 1 exit 1
fi fi
mkdir -p build/ &&
cd build || exit


kernel=$1 kernel=$1
if [[ ! -f $kernel ]]; then # assuming url if [[ ! -f $kernel ]]; then # assuming url
Expand All @@ -13,7 +15,7 @@ fi


bzip2 -cd "$kernel" | pax -r && bzip2 -cd "$kernel" | pax -r &&
dir=${kernel##*/} dir=${dir%.tar.bz2} && dir=${kernel##*/} dir=${dir%.tar.bz2} &&
cp kernel.config "$dir/.config" && cp ../kernel.config "$dir/.config" &&
cd "$dir" && cd "$dir" &&
make silentoldconfig && make silentoldconfig &&
make && make &&
Expand Down
51 changes: 31 additions & 20 deletions generate-initramfs
@@ -1,9 +1,6 @@
#!/bin/bash #!/bin/bash


#cp() { echo cp "$@"; } PATH=$PWD/build/bin:$PATH
#mkdir() { echo mkdir "$@"; }
#ln() { echo ln "$@"; }
#chmod() { echo chmod "$@"; }


declare -A commands='( declare -A commands='(
Expand Down Expand Up @@ -184,11 +181,9 @@ declare -A commands='(
## Other useful commands (non-POSIX) ## Other useful commands (non-POSIX)
[bzip2]="a block-sorting file compressor, v1.0.6" [bzip2]="a block-sorting file compressor, v1.0.6"
[dash]="command interpreter (shell)" [dash]="command interpreter (shell)"
[gawk]="pattern scanning and processing language"
[getent]="get entries from administrative database" [getent]="get entries from administrative database"
[gzip]="compress or expand files" [gzip]="compress or expand files"
[hostname]="show or set the system'\''s host name" [hostname]="show or set the system'\''s host name"
[mawk]="pattern scanning and text processing language"
[mknod]="make block or character special files" [mknod]="make block or character special files"
[mktemp]="create a temporary file or directory" [mktemp]="create a temporary file or directory"
[mount]="mount a filesystem" [mount]="mount a filesystem"
Expand All @@ -198,8 +193,19 @@ declare -A commands='(
[strace]="trace system calls and signals" [strace]="trace system calls and signals"
[tac]="concatenate and print files in reverse" [tac]="concatenate and print files in reverse"
[umount]="unmount file systems" [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} mkdir -p initramfs/{bin,dev,etc,lib,root,usr/share}


Expand Down Expand Up @@ -348,24 +354,29 @@ esac
printf "(shell exited with %d)\n" "$?" printf "(shell exited with %d)\n" "$?"
printf o > /proc/sysrq-trigger printf o > /proc/sysrq-trigger
EOF EOF
chmod +x initramfs/init chmod 750 initramfs/init


# Shells
shopt -s nullglob shopt -s nullglob
f=(bash1.*); (( ${#f[@]} )) && cp "${f[-1]}" "initramfs/bin/bash1" && ln -sf bash1 initramfs/bin/bash # decide on a /bin/bash
f=(bash2.*); (( ${#f[@]} )) && cp "${f[-1]}" "initramfs/bin/bash2" && ln -sf bash2 initramfs/bin/bash bashes=( initramfs/bin/bash[1-4] )
f=(bash3.*); (( ${#f[@]} )) && cp "${f[-1]}" "initramfs/bin/bash3" && ln -sf bash3 initramfs/bin/bash ln -sf "${bashes[-1]##*/}" initramfs/bin/bash || exit
f=(bash4.*); (( ${#f[@]} )) && cp "${f[-1]}" "initramfs/bin/bash4" && ln -sf bash4 initramfs/bin/bash


for shell in dash ksh bash{4..1}; do # decide on a /bin/sh
[[ -e initramfs/bin/$shell ]] || continue for shell in initramfs/bin/{dash,ksh,bash}; do
ln -sf "$shell" initramfs/bin/sh [[ -e $shell ]] || continue
ln -sf "${shell##*/}" initramfs/bin/sh
break break
done done


# awk [[ -e initramfs/bin/sh ]] || exit
for awk in gawk mawk; do
# 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; [[ -e initramfs/bin/$awk ]] || continue;
ln -sf "$awk" initramfs/bin/awk ln -s "$awk" initramfs/bin/awk
break break
done done

0 comments on commit 56321c5

Please sign in to comment.