commit 9697ea08fddede07d979d2012e30ab329bcfb202
parent c24e0134ca2311a2e4cfe7d942db9e1e1df3b49a
Author: Daniel Bainton <dpb@driftaway.org>
Date: Sat, 1 Mar 2014 02:10:36 +0200
Merge branch 'mk'
Diffstat:
54 files changed, 369 insertions(+), 874 deletions(-)
diff --git a/.gitignore b/.gitignore
@@ -0,0 +1,7 @@
+.cache
+pkgs.mk
+*.img
+root
+src
+stuff/tinywm
+stuff/xsetroot
diff --git a/README b/README
@@ -3,8 +3,8 @@ Morpheus is a statically linked musl based toy distro.
The base system includes sbase[1], ubase[2], sdhcp[3], smdev[4], mksh
as well as other tools.
-To build the world use `./stage0'. You need an x86_64 host to build
-morpheus. Please review the `prepare-env' script and adjust anything
+To build the world use `mk world'. You need an x86_64 host to build
+morpheus. Please review the `config.mk' file and adjust anything
needed.
Morpheus has been build-tested on CRUX, Debian, Archlinux, Slackware
@@ -12,13 +12,17 @@ and Ubuntu 13.04.
To build specific packages:
- ./pkgbuild pkg1 pkg2 ...
+ mk pkg1 pkg2 ...
+
+To force build packages and all their dependencies:
+
+ mk -a pkg1 pkg2 ...
After you've built stage0 you can create a bootable image:
sudo modprobe -r loop
sudo modprobe loop max_part=15 # to be done only once
- sudo ./create-bootable
+ sudo mk bootable
This creates a 4GB image. You can dd this image to a USB stick if you
want to. Make sure to change the kernel command line to point it to
diff --git a/TODO b/TODO
@@ -1,18 +1,12 @@
Generic stuff
-------------
- * Only support a build() target in the package files.
- * Don't hardcode the cross-compiler name in the package files.
- * Factor out unpacking of packages in the generic build script.
- * Makefile based build system.
* Make morpheus self-hosting.
- * Use $optcflags and $optldflags.
Packages
--------
* e2fsprogs
- * Use latest 3.10 lts kernel.
* Install tic as part of ncurses.
* Create an hwclock service file.
* Create a tinyalsa service file.
diff --git a/build b/build
@@ -1,49 +0,0 @@
-#!/bin/sh
-#
-# Only meant to be executed from within the stage0 script
-
-set -e -x
-
-fetch() {
- return
-}
-
-unpack() {
- return
-}
-
-patch() {
- return
-}
-
-build() {
- return
-}
-
-install() {
- return
-}
-
-. $1
-(
- fetch || {
- echo "Failed to fetch $1" >> "$top/morpheus.log"
- exit 1
- }
- unpack || {
- echo "Failed to unpack $1" >> "$top/morpheus.log"
- exit 1
- }
- patch || {
- echo "Failed to patch $1" >> "$top/morpheus.log"
- exit 1
- }
- build || {
- echo "Failed to build $1" >> "$top/morpheus.log"
- exit 1
- }
- install || {
- echo "Failed to install $1" >> "$top/morpheus.log"
- exit 1
- }
-)
diff --git a/clean b/clean
@@ -1,3 +0,0 @@
-#!/bin/sh
-
-rm -rf root src morpheus.log stuff/tinywm stuff/xsetroot
diff --git a/config.mk b/config.mk
@@ -0,0 +1,19 @@
+top = `{pwd}
+root = ${top}/root
+#arch = i486
+arch = x86_64
+libcroot = ${root}/opt/cross/${arch}-linux-musl/${arch}-linux-musl
+nprocs = 4 # number of processes for building separate packages
+NPROC = 4 # number of processes for mk concurrency
+version = 0.0
+mirror = http://dl.2f30.org/morpheus-pkgs/${arch}/${version}
+CC = ${arch}-linux-musl-gcc
+
+# these don't work for all packages yet...
+optldflags = -s -Wl,--gc-sections -Wl,-z,relro,-z,now
+optcflags = -fdata-sections -ffunction-sections -Os -g0 -fno-unwind-tables -fno-asynchronous-unwind-tables -Wa,--noexecstack
+
+CFLAGS = -I${libcroot}/include -static # ${optcflags}
+LDFLAGS = -L${libcroot}/lib -static # ${optldflags}
+
+PATH = ${root}/opt/cross/${arch}-linux-musl/bin:${PATH}
diff --git a/create-bootable b/create-bootable
@@ -1,40 +0,0 @@
-#!/bin/sh
-#
-# Ensure you've loaded the loop module with max_part=15
-
-set -e -x
-
-. ./prepare-env
-
-img=morpheus-$arch-$version.img
-
-dd if=/dev/zero of=$img bs=512M count=8
-(
-cat << EOF
-o
-n
-p
-1
-
-
-a
-1
-w
-EOF
-) | fdisk $img
-
-lodev=$(losetup -f --show $img) || exit 1
-partition="$lodev"p1
-mkfs.ext2 -L MORPHEUS $partition || exit 1
-mount $partition /mnt || exit 1
-rmdir /mnt/lost+found
-
-fakeroot cp -arP "$root"/* /mnt
-extlinux --install /mnt/boot || exit 1
-
-dd if=stuff/mbr.bin of=$lodev conv=notrunc bs=440 count=1
-sync
-
-umount /mnt
-sleep 3
-losetup -d $lodev
diff --git a/qemu-mk-overlay b/misc/qemu-mk-overlay
diff --git a/mkfile b/mkfile
@@ -0,0 +1,40 @@
+<config.mk
+
+allpkgs = `{ls pkgs/*}
+pkgs = ${allpkgs:pkgs/%=%}
+
+help:VQ:
+ echo 'Usage: mk <pkg>'
+ echo '\nTo build all the targets in pkgs/, run `mk world´'
+
+all world:VQ: $pkgs
+
+clean:V:
+ rm -f .cache/* pkgs.mk
+
+fetchpkgs = ${pkgs:%=%-fetch}
+
+fetch-all fetch-world:VQ: ${fetchpkgs}
+
+# generate a pkgs.mk file with the tarkets for all packages in pkgs/
+`{ mkdir -p src }
+`{ mkdir -p .cache }
+`{ echo '# auto-generated file, do not edit' > pkgs.mk }
+`{ cd pkgs && for pkg in *; do cat $pkg ../stuff/fetch-pkg.mk |\
+ sed -e "s,^build:,$pkg:QP./stuff/cmp-pkgs: $pkg-fetch pkgs/$pkg," |\
+ sed -e "s,^fetch-target:,$pkg-fetch:," |\
+ sed -e "s,^v=,${pkg}_v=," |\
+ sed -e "s,\$v,\${${pkg}_v}," |\
+ sed -e "s,\$url,\${${pkg}_url}," |\
+ sed -e "s, url=, ${pkg}_url=," |\
+ sed -e "s,\$git,\${${pkg}_git}," |\
+ sed -e "s,^git=,${pkg}_git=," |\
+ sed -e "s,^url=,${pkg}_url=," >> ../pkgs.mk; done }
+
+<pkgs.mk
+
+test:VQ:
+ echo test
+
+bootable:V:
+ stuff/create-bootable "$root" morpheus-$arch-$version.img
diff --git a/mkinitrd b/mkinitrd
@@ -1,5 +0,0 @@
-#!/bin/sh
-
-. ./prepare-env
-
-cd $root && find . | cpio --quiet -H newc -o | gzip -9 -n > ../morpheus-initrd.img
diff --git a/pkgbuild b/pkgbuild
@@ -1,33 +0,0 @@
-#!/bin/sh
-#
-# Simple package build script.
-# For example to build the kernel do: ./pkgbuild kernel
-#
-# Please note that if the package has already been unpacked in src/
-# then it will not be unpacked again. This is to make it easy
-# to build new packages by first hacking src/<pkg> until it can be
-# successfully compiled. If you want to force unpacking of the package
-# simply rm the unpacked directory. Similarly if you want to force
-# re-downloading of the package, simply rm the packed version as well.
-
-umask 022
-
-if test -z "$1"; then
- echo usage: $0 pkg... 1>&2
- exit 1
-fi
-
-. ./prepare-env
-
-if test "$(uname -m)" != "$arch"; then
- echo You need an $arch host to build morpheus 1>&2
- exit 1
-fi
-
-. ./prepare-root
-mkdir -p src
-
-while [ $# -gt 0 ]; do
- ./build "pkgs/$1"
- shift
-done
diff --git a/pkgs/abduco b/pkgs/abduco
@@ -1,22 +1,11 @@
-url=git://repo.or.cz/abduco.git
+git="git://repo.or.cz/abduco.git"
-fetch() {
- [ -d src/abduco ] || git clone $url src/abduco
-}
-
-build() {
+build: crossmusl
cd src/abduco
make clean
sed -i "s@PREFIX = /usr/local@PREFIX = /@" config.mk
sed -i "s@INCS = -I. -I/usr/include -I/usr/local/include@INCS = -I. -I$libcroot/include@" config.mk
- sed -i "s@LDFLAGS += -L/usr/lib -L/usr/local/lib ${LIBS}@LDFLAGS += -L$libcroot/lib ${LIBS} -static @" config.mk
- sed -i 's@CC = cc@CC = x86_64-linux-musl-gcc@' config.mk
- make || return 1
- cd -
-}
-
-install() {
- cd src/abduco
+ sed -i "s@LDFLAGS += -L/usr/lib -L/usr/local/lib ${LIBS}@LDFLAGS += $LDFLAGS ${LIBS} @" config.mk
+ sed -i "s@CC = cc@CC = $CC@" config.mk
+ make
make DESTDIR="$root" install
- cd -
-}
diff --git a/pkgs/busybox b/pkgs/busybox
@@ -1,16 +1,10 @@
-url=$mirror/busybox
+url="$mirror/busybox"
-fetch() {
- wget -c $url -O src/busybox
-}
-
-install() {
- # Install package
- cd src/
+build: crossmusl
+ cd src
chmod +x busybox
- cp busybox "$root/bin"
- cd -
- cd "$root/bin"
+ cp busybox "${root}/bin"
+ cd "${root}/bin"
ln -sf busybox addgroup
ln -sf busybox adduser
ln -sf busybox awk
@@ -47,5 +41,3 @@ install() {
ln -sf busybox top
ln -sf busybox vi
ln -sf busybox wget
- cd -
-}
diff --git a/pkgs/crossmusl b/pkgs/crossmusl
@@ -1,17 +1,14 @@
-url=$mirror/crossx86-x86_64-linux-musl-0.9.15.tar.xz
+v="0.9.15"
+url="$mirror/crossx86-$arch-linux-musl-$v.tar.xz"
-fetch() {
- wget -c $url -O src/crossx86-x86_64-linux-musl-0.9.15.tar.xz
-}
-
-install() {
- tar xJf src/crossx86-x86_64-linux-musl-0.9.15.tar.xz -C "$root/opt/cross"
- mv "$root/opt/cross/x86_64-linux-musl/x86_64-linux-musl/lib64"/* "$root/opt/cross/x86_64-linux-musl/x86_64-linux-musl/lib"
- cd "$root/bin"
+build: prepare_root
targets="ar as c++ g++ gcc ld ld.bfd nm objcopy objdump ranlib strip"
- for t in $targets; do
- ln -sf ../opt/cross/x86_64-linux-musl/bin/x86_64-linux-musl-$t $t
+ cd src
+ cp -r $arch-linux-musl "$root/opt/cross/"
+ if test "$arch" = "x86_64"; then
+ mv "$root/opt/cross/$arch-linux-musl/$arch-linux-musl/lib64"/* "$root/opt/cross/$arch-linux-musl/$arch-linux-musl/lib"
+ fi
+ for t in ${targets}; do
+ ln -sf ../opt/cross/$arch-linux-musl/bin/$arch-linux-musl-$t $root/bin/$t
done
- ln -sf gcc cc
- cd -
-}
+ ln -sf gcc ${root}/bin/cc
diff --git a/pkgs/dvtm b/pkgs/dvtm
@@ -1,28 +1,12 @@
-url=http://www.brain-dump.org/projects/dvtm/dvtm-0.10.tar.gz
+v="0.10"
+url="http://www.brain-dump.org/projects/dvtm/dvtm-$v.tar.gz"
-fetch() {
- wget -c $url -O src/dvtm-0.10.tar.gz
-}
-
-unpack() {
- cd src
- [ -d dvtm-0.10 ] || tar -xzf dvtm-0.10.tar.gz
- cd -
-}
-
-build() {
- cd src/dvtm-0.10
+build: ncurses
+ cd src/dvtm-$v
+ make clean
sed -i "s@PREFIX = /usr/local@PREFIX = /@" config.mk
sed -i "s@INCS = -I. -I/usr/include -I/usr/local/include@INCS = -I. -I$libcroot/include -I$libcroot/include/ncursesw@" config.mk
- sed -i "s@LDFLAGS += -L/usr/lib -L/usr/local/lib ${LIBS}@LDFLAGS += -L$libcroot/lib ${LIBS} -static @" config.mk
- sed -i 's@CC = cc@CC = x86_64-linux-musl-gcc@' config.mk
- make || return 1
- cd -
-}
-
-install() {
- cd src/dvtm-0.10
+ sed -i "s@LDFLAGS += -L/usr/lib -L/usr/local/lib ${LIBS}@LDFLAGS += $LDFLAGS @" config.mk
+ sed -i "s@CC = cc@CC = $CC@" config.mk
+ make
make DESTDIR="$root" install
- cd -
-}
-
diff --git a/pkgs/dwm b/pkgs/dwm
@@ -1,28 +1,12 @@
-url=$mirror/dwm-git.tar.gz
+url="$mirror/dwm-git.tar.gz"
-fetch() {
- wget -c $url -O src/dwm-git.tar.gz
-}
-
-unpack() {
- cd src
- [ -d dwm ] || tar xzf dwm-git.tar.gz
- cd -
-}
-
-build() {
- cd src/dwm
- sed -i "s@X11INC = /usr/X11R6/include@X11INC = $libcroot/include@" config.mk
- sed -i "s@X11LIB = /usr/X11R6/lib@X11LIB = $libcroot/lib@" config.mk
- sed -i 's@LDFLAGS = -s ${LIBS}@LDFLAGS = -s ${LIBS} -static@' config.mk
- sed -i 's@CC = cc@CC = x86_64-linux-musl-gcc@' config.mk
- make || return 1
- cd -
-}
-
-install() {
+build: tinyxlib
cd src/dwm
- cp dwm "$root/bin"
- cp dwm.1 "$root/share/man/man1"
- cd -
-}
+ make clean
+ sed -i 's@PREFIX = /usr/local@PREFIX = @' config.mk
+ sed -i "s@X11INC = /usr/X11R6/include@X11INC = $libcroot/include @" config.mk
+ sed -i "s@X11LIB = /usr/X11R6/lib@X11LIB = $libcroot/lib @" config.mk
+ sed -i "s@LDFLAGS = -s ${LIBS}@LDFLAGS = $LDFLAGS ${LIBS} @" config.mk
+ sed -i "s@CC = cc@CC = $CC@" config.mk
+ make
+ make DESTDIR=${root} install
diff --git a/pkgs/fs b/pkgs/fs
@@ -1,11 +1,5 @@
-url=git://git.2f30.org/fs
+git="git://git.2f30.org/fs"
-fetch() {
- [ -d src/fs ] || git clone $url src/fs
-}
-
-install() {
+build: prepare_root
cd src/fs
- cp -r * "$root/"
- cd -
-}
+ cp -r * "${root}/"
diff --git a/pkgs/jupp b/pkgs/jupp
@@ -1,26 +1,10 @@
-url=$mirror/joe-3.1jupp26.tgz
+v="3.1jupp26"
+url="$mirror/joe-$v.tgz"
-fetch() {
- wget -c $url -O src/joe-3.1jupp26.tgz
-}
-
-unpack() {
- cd src
- [ -d jupp ] || tar xzf joe-3.1jupp26.tgz
- cd -
-}
-
-build() {
- cd src/jupp
- make clean
- CC=x86_64-linux-musl-gcc sh configure --prefix="/" CFLAGS="-I$libcroot/include" \
- LDFLAGS="-L$libcroot/lib -static" || return 1
- make || return 1
- cd -
-}
-
-install() {
+build: crossmusl
cd src/jupp
+ CC=$CC sh configure --prefix="/"
+ make
cp joe termidx "$root/bin"
mkdir -p "$root/share/man/man1"
cp joe.1 "$root/share/man/man1"
@@ -29,13 +13,7 @@ install() {
cp joerc jmacsrc "$root/etc/joe"
mkdir -p "$root/etc/joe/syntax"
cp syntax/* "$root/etc/joe/syntax"
- cd -
-
cd "$root/bin"
ln -sf joe jmacs
- cd -
-
cd "$root/share/man/man1"
ln -sf joe.1 jmacs.1
- cd -
-}
diff --git a/pkgs/kernel b/pkgs/kernel
@@ -1,28 +1,11 @@
-url=$mirror/kernel.tar.gz
-version=3.10.32
+v="3.10.32"
-fetch() {
- wget -c $url -O src/kernel.tar.gz
-}
-
-unpack() {
- cd src
- [ -d linux-$version ] || tar xzf kernel.tar.gz
- cd -
-}
-
-build() {
- cd src/linux-$version
+build: crossmusl kernel_headers
+ cd src/linux-$v
cp $top/stuff/kernel-config .config
- make menuconfig
- make bzImage -j$nprocs || return 1
- cd -
-}
-
-install() {
- cd src/linux-$version
+ #make menuconfig
+ make oldconfig
+ make bzImage -j$nprocs
cp arch/x86/boot/bzImage "$root/boot"
cp .config "$root/boot/bzImage.config"
cp System.map "$root/boot"
- cd -
-}
diff --git a/pkgs/kernel-headers b/pkgs/kernel-headers
@@ -1,19 +0,0 @@
-url=$mirror/kernel.tar.gz
-version=3.10.12
-
-fetch() {
- wget -c $url -O src/kernel.tar.gz
-}
-
-unpack() {
- cd src
- [ -d linux-$version ] || tar xzf kernel.tar.gz
- cd -
-}
-
-install() {
- cd src/linux-$version
- make ARCH="$arch" INSTALL_HDR_PATH="$root" headers_install
- unlink "$root/include/include" 2>/dev/null # I don't know why it creates this bogus link
- cd -
-}
diff --git a/pkgs/kernel_headers b/pkgs/kernel_headers
@@ -0,0 +1,11 @@
+v="3.10.32"
+url="$mirror/kernel.tar.gz"
+
+build:
+ cd src/linux-$v
+ if test "$arch" = x86_64; then
+ A=$arch
+ else
+ A=x86
+ fi
+ make ARCH="$A" INSTALL_HDR_PATH="$root" headers_install
diff --git a/pkgs/libevent b/pkgs/libevent
@@ -1,24 +1,8 @@
-url=$mirror/libevent-2.0.21-stable.tar.gz
-
-fetch() {
- wget -c $url -O src/libevent-2.0.21-stable.tar.gz
-}
-
-unpack() {
- cd src
- [ -d libevent-2.0.21-stable ] || tar xzf libevent-2.0.21-stable.tar.gz
- cd -
-}
-
-build() {
- cd src/libevent-2.0.21-stable
- CC="x86_64-linux-musl-gcc -static" ./configure --prefix="$libcroot" --disable-shared --enable-static || return 1
- make -j$nprocs || return 1
- cd -
-}
-
-install() {
- cd src/libevent-2.0.21-stable
- make install || return 1
- cd -
-}
+v="2.0.21"
+url="$mirror/libevent-$v-stable.tar.gz"
+
+build: crossmusl
+ cd src/libevent-$v-stable
+ CC="$CC -static" ./configure --prefix="$libcroot" --disable-shared --enable-static
+ make -j$nprocs
+ make install
diff --git a/pkgs/make b/pkgs/make
@@ -1,24 +1,8 @@
-url=$mirror/make-3.82.tar.bz2
-
-fetch() {
- wget -c $url -O src/make-3.82.tar.bz2
-}
-
-unpack() {
- cd src
- [ -d make-3.82 ] || tar xjf make-3.82.tar.bz2
- cd -
-}
-
-build() {
- cd src/make-3.82
- CC="x86_64-linux-musl-gcc -static" ./configure --prefix="$root" --disable-nls || return 1
- make -j$nprocs || return 1
- cd -
-}
-
-install() {
- cd src/make-3.82
- make install || return 1
- cd -
-}
+v="3.82"
+url="$mirror/make-$v.tar.bz2"
+
+build: crossmusl
+ cd src/make-$v
+ CC="$CC -static" ./configure --prefix="$root" --disable-nls
+ make -j$nprocs
+ make install
diff --git a/pkgs/man b/pkgs/man
@@ -1,23 +1,6 @@
-url=$mirror/man.tar.gz
+url="$mirror/man.tar.gz"
-fetch() {
- wget -c $url -O src/man.tar.gz
-}
-
-unpack() {
- cd src
- [ -d man ] || tar xzf man.tar.gz
- cd -
-}
-
-build() {
- cd src/man
- x86_64-linux-musl-gcc -std=gnu99 -o man man.c -static || return 1
- cd -
-}
-
-install() {
+build: crossmusl
cd src/man
+ $CC -std=gnu99 -o man man.c -static
cp man "$root/bin"
- cd -
-}
diff --git a/pkgs/mksh b/pkgs/mksh
@@ -1,24 +1,12 @@
-url=$mirror/mksh-R47.tar.gz
+v="R47"
+url="$mirror/mksh-$v.tar.gz"
-fetch() {
- wget -c $url -O src/mksh-R47.tar.gz
-}
-
-unpack() {
- cd src
- [ -d mksh ] || tar xzf mksh-R47.tar.gz
- cd -
-}
-
-build() {
+build: crossmusl
cd src/mksh
- CC=x86_64-linux-musl-gcc LDFLAGS=-static sh Build.sh || return 1
- cd -
-}
-
-install() {
- cp src/mksh/mksh "$root/bin"
+ CC=$CC sh Build.sh
+ mkdir -p "$root/share/man/man1" "$root/share/man/cat1"
+ cp mksh "$root/bin"
+ cp mksh.1 "$root/share/man/man1/mksh.1"
+ cp mksh.cat1 "$root/share/man/cat1/mksh.0"
cd "$root/bin"
- ln -sf /bin/mksh sh
- cd -
-}
+ ln -sf mksh sh
diff --git a/pkgs/mpg123 b/pkgs/mpg123
@@ -1,25 +1,9 @@
-url=$mirror/mpg123-1.18.0.tar.bz2
-
-fetch() {
- wget -c $url -O src/mpg123-1.18.0.tar.bz2
-}
-
-unpack() {
- cd src
- [ -d mpg123-1.18.0 ] || tar xjf mpg123-1.18.0.tar.bz2
- cd -
-}
-
-build() {
- cd src/mpg123-1.18.0
- CC=x86_64-linux-musl-gcc ./configure --prefix="$root" --with-default-audio=tinyalsa \
- CFLAGS="-I$libcroot/include" LDFLAGS="-L$libcroot/lib -static" || return 1
- make || return 1
- cd -
-}
-
-install() {
- cd src/mpg123-1.18.0
- make install || return 1
- cd -
-}
+v="1.18.0"
+url="$mirror/mpg123-$v.tar.bz2"
+
+build: tinyalsa
+ cd src/mpg123-$v
+ CC=$CC ./configure --prefix="$root" --with-default-audio=tinyalsa \
+ --enable-static=yes --enable-shared=no
+ make
+ make install
diff --git a/pkgs/ncurses b/pkgs/ncurses
@@ -1,32 +1,17 @@
-url=$mirror/ncurses.tar.gz
+v="5.9"
+url="$mirror/ncurses.tar.gz"
-fetch() {
- wget -c $url -O src/ncurses.tar.gz
-}
-
-unpack() {
- cd src
- [ -d ncurses-5.9 ] || tar xzf ncurses.tar.gz
- cd -
-}
-
-build() {
- cd src/ncurses-5.9
+build: crossmusl
+ cd src/ncurses-$v
cp $top/stuff/ncurses-fallback.c ncurses/fallback.c
- CC="x86_64-linux-musl-gcc -static" ./configure --prefix="$libcroot" --without-tests \
+ CC="$CC -static" ./configure --prefix="${libcroot}" --mandir="$root/share" --without-tests \
--with-normal --enable-sigwinch --disable-nls --without-dlsym \
--without-cxx-binding --enable-widec \
- --with-fallbacks="linux vt100 xterm xterm256-color" </dev/ptmx || return 1
- make -j$nprocs || return 1
- cd -
-}
-
-install() {
- cd src/ncurses-5.9
- make install || return 1
- cd -
+ --with-fallbacks="linux vt100 xterm xterm256-color" </dev/ptmx
+ make -j$nprocs
+ make install
cd $root/lib
- ln -s libncursesw_g.a libncurses_g.a
- ln -s libncursesw.a libncurses.a
- cd -
-}
+ for lib in ncurses form panel menu ; do
+ ln -sf lib${lib}w_g.a lib${lib}_g.a
+ ln -sf lib${lib}w.a lib${lib}.a
+ done
diff --git a/pkgs/prepare_root b/pkgs/prepare_root
@@ -0,0 +1,17 @@
+build:
+ mkdir -p ${root}
+ cd ${root}
+ mkdir -p boot bin dev emul etc home mnt opt proc root share src sys tmp var
+ mkdir -p dev/pts dev/shm opt/cross share/doc share/fonts/encodings share/man share/terminfo var/empty var/log var/run
+ rm -f include
+ ln -s opt/cross/${arch}-linux-musl/${arch}-linux-musl/include include
+ rm -f lib
+ ln -s opt/cross/${arch}-linux-musl/${arch}-linux-musl/lib lib
+ rm -f usr
+ ln -s . usr
+ rm -f sbin
+ ln -s bin sbin
+ rm -f var/tmp
+ ln -s ../tmp var/tmp
+ chmod 1777 tmp
+ chmod 700 root
diff --git a/pkgs/rsync b/pkgs/rsync
@@ -1,24 +1,8 @@
-url=$mirror/rsync-3.0.9.tar.gz
-
-fetch() {
- wget -c $url -O src/rsync-3.0.9.tar.gz
-}
-
-unpack() {
- cd src
- [ -d rsync-3.0.9 ] || tar xzf rsync-3.0.9.tar.gz
- cd -
-}
-
-build() {
- cd src/rsync-3.0.9
- CC=x86_64-linux-musl-gcc ./configure --prefix="$root" LDFLAGS="-static" || return 1
- make -j$nprocs || return 1
- cd -
-}
-
-install() {
- cd src/rsync-3.0.9
- make install || return 1
- cd -
-}
+v="3.0.9"
+url="$mirror/rsync-$v.tar.gz"
+
+build: crossmusl
+ cd src/rsync-$v
+ CC=$CC ./configure --prefix="$root"
+ make -j$nprocs
+ make install
diff --git a/pkgs/sbase b/pkgs/sbase
@@ -1,18 +1,7 @@
-url=git://git.2f30.org/sbase
+git="git://git.2f30.org/sbase"
-fetch() {
- [ -d src/sbase ] || git clone $url src/sbase
-}
-
-build() {
+build: crossmusl
cd src/sbase
make clean
- make -j$nprocs CC=x86_64-linux-musl-gcc LDFLAGS=-static || return 1
- cd -
-}
-
-install() {
- cd src/sbase
+ make -j$nprocs CC=$CC LDFLAGS="$LDFLAGS"
make PREFIX="$root" install
- cd -
-}
diff --git a/pkgs/sdhcp b/pkgs/sdhcp
@@ -1,22 +1,9 @@
-url=$mirror/sdhcp.tar.gz
+url="$mirror/sdhcp.tar.gz"
-fetch() {
- wget -c $url -O src/sdhcp.tar.gz
-}
-
-unpack() {
- cd src
- [ -d sdhcp ] || tar xzf sdhcp.tar.gz
- cd -
-}
-
-build() {
+build: crossmusl
cd src/sdhcp
make clean
- make CC=x86_64-linux-musl-gcc LDFLAGS=-static || return 1
- cd -
-}
-
-install() {
- cp src/sdhcp/sdhcp "$root/bin" || return 1
-}
+ make CC=$CC
+ cp sdhcp "$root/bin"
+ mkdir -p "$root/share/man/man8"
+ cp sdhcp.8 "$root/share/man/man8/sdhcp.8"
diff --git a/pkgs/sic b/pkgs/sic
@@ -1,22 +1,7 @@
-url=$mirror/sic.tar.gz
+url="$mirror/sic.tar.gz"
-fetch() {
- wget -c $url -O src/sic.tar.gz
-}
-
-unpack() {
- cd src
- [ -d sic ] || tar xzf sic.tar.gz
- cd -
-}
-
-build() {
+build: crossmusl
cd src/sic
make clean
- make CC=x86_64-linux-musl-gcc LDFLAGS=-static || return 1
- cd -
-}
-
-install() {
- cp src/sic/sic "$root/bin"
-}
+ make CC=$CC LDFLAGS="$LDFLAGS"
+ cp sic "$root/bin"
diff --git a/pkgs/sinit b/pkgs/sinit
@@ -1,21 +1,9 @@
-url=git://git.2f30.org/sinit
+git="git://git.2f30.org/sinit"
-fetch() {
- [ -d src/sinit ] || git clone $url src/sinit
-}
-
-build() {
+build: crossmusl
cd src/sinit
make clean
- make -j$nprocs CC=x86_64-linux-musl-gcc LDFLAGS=-static || return 1
- cd -
-}
-
-install() {
- cd src/sinit
+ make -j$nprocs CC=$CC LDFLAGS="$LDFLAGS"
make PREFIX="$root" install
- cd -
cd "$root"
ln -sf /bin/sinit init
- cd -
-}
diff --git a/pkgs/smdev b/pkgs/smdev
@@ -1,18 +1,7 @@
-url=git://git.2f30.org/smdev
+git="git://git.2f30.org/smdev"
-fetch() {
- [ -d src/smdev ] || git clone $url src/smdev
-}
-
-build() {
+build: crossmusl
cd src/smdev
make clean
- make CC=x86_64-linux-musl-gcc LDFLAGS=-static || return 1
- cd -
-}
-
-install() {
- cd src/smdev
- make PREFIX="$root" install || return 1
- cd -
-}
+ make CC=$CC LDFLAGS="$LDFLAGS"
+ make PREFIX="$root" install
diff --git a/pkgs/syslinux b/pkgs/syslinux
@@ -1,16 +1,5 @@
-url=$mirror/syslinux.tar.gz
+url="$mirror/syslinux.tar.gz"
-fetch() {
- # Fetch package
- wget -c $url -O src/syslinux.tar.gz
-}
-
-unpack() {
+build: prepare_root
cd src
- [ -d syslinux ] || tar xzf syslinux.tar.gz
- cd -
-}
-
-install() {
- cp -r src/syslinux/* $root/
-}
+ cp -r syslinux/* $root/
diff --git a/pkgs/terminus b/pkgs/terminus
@@ -1,33 +1,15 @@
-url=$mirror/terminus-font-4.38.tar.gz
+v="4.38"
+url="$mirror/terminus-font-$v.tar.gz"
-fetch() {
- wget -c $url -O src/terminus-font-4.38.tar.gz
-}
-
-unpack() {
- cd src
- [ -d terminus-font-4.38 ] || tar xzf terminus-font-4.38.tar.gz
- cd -
-}
-
-build() {
- cd src/terminus-font-4.38
+build: crossmusl
+ cd src/terminus-font-$v
sh configure --psfdir="$root/share/fonts/console" \
- --x11dir="$root/share/fonts/misc" || return 1
- make || return 1
- cd -
-}
-
-install() {
- cd src/terminus-font-4.38
- make DESTDIR=/ install || return 1
- cd -
+ --x11dir="$root/share/fonts/misc"
+ make
+ make DESTDIR=/ install
cd "$root/share/fonts/misc"
gzip -d *.gz
mkfontscale
mkfontdir
- cd -
cd "$root/share/fonts/console"
gzip -d *.gz
- cd -
-}
diff --git a/pkgs/tinyalsa b/pkgs/tinyalsa
@@ -1,26 +1,9 @@
-url=$mirror/tinyalsa.tar.gz
+url="$mirror/tinyalsa.tar.gz"
-fetch() {
- wget -c $url -O src/tinyalsa.tar.gz
-}
-
-unpack() {
- cd src
- [ -d tinyalsa ] || tar xzf tinyalsa.tar.gz
- cd -
-}
-
-build() {
+build: crossmusl
cd src/tinyalsa
make clean 2>/dev/null
- make CC=x86_64-linux-musl-gcc LDFLAGS="-static" || return 1
- cd -
-}
-
-install() {
- cd src/tinyalsa
+ make CC=$CC
cp tinycap tinymix tinypcminfo tinyplay "$root/bin"
cp libtinyalsa.a "$root/lib"
cp -r include/tinyalsa "$root/include"
- cd -
-}
diff --git a/pkgs/tinywm b/pkgs/tinywm
@@ -1,11 +1,4 @@
-build() {
- cd stuff
- x86_64-musl-linux-gcc -I"$libcroot/include" -L"$libcroot/lib" tinywm.c -o tinywm -lX11 -static || return 1
- cd -
-}
-
-install() {
+build: tinyxlib
cd stuff
+ $CC -I"$libcroot/include" -L"$libcroot/lib" tinywm.c -o tinywm -lX11 -static
cp tinywm "$root/bin"
- cd -
-}
diff --git a/pkgs/tinyxlib b/pkgs/tinyxlib
@@ -1,25 +1,8 @@
-url=$mirror/tinyxlib.tar.gz
+url="$mirror/tinyxlib.tar.gz"
-fetch() {
- wget -c $url -O src/tinyxlib.tar.gz
-}
-
-unpack() {
- cd src
- [ -d tinyxlib ] || tar xzf tinyxlib.tar.gz
- cd -
-}
-
-build() {
+build: crossmusl
cd src/tinyxlib
make clean
- make CC=x86_64-linux-musl-gcc BINDIR="/bin" LIBDIR="/lib" STATIC=1 \
- FONT_ENCODINGS_DIRECTORY="/usr/share/fonts/encodings/encodings.dir" || return 1
- cd -
-}
-
-install() {
- cd src/tinyxlib
- make DESTDIR="$libcroot" BINDIR="/bin" LIBDIR="/lib" STATIC=1 install || return 1
- cd -
-}
+ make CC=$CC BINDIR="/bin" LIBDIR="/lib" STATIC=1 \
+ FONT_ENCODINGS_DIRECTORY="/share/fonts/encodings/encodings.dir"
+ make DESTDIR="$libcroot" BINDIR="/bin" LIBDIR="/lib" STATIC=1 install
diff --git a/pkgs/tinyxserver b/pkgs/tinyxserver
@@ -1,30 +1,11 @@
-url=$mirror/tinyxserver.tar.gz
+url="$mirror/tinyxserver.tar.gz"
-fetch() {
- wget -c $url -O src/tinyxserver.tar.gz
-}
-
-unpack() {
- cd src
- [ -d tinyxserver ] || tar xzf tinyxserver.tar.gz
- cd -
-}
-
-build() {
+build: tinyxlib zlib
cd src/tinyxserver
make clean
- make CC=x86_64-linux-musl-gcc EXTRA_CFLAGS="-D_XSERVER64=1 -I$libcroot/include" \
- LDFLAGS="-static -L$libcroot/lib" \
- FONTDIR="/usr/share/fonts" || return 1
- cd -
-}
-
-install() {
- cd src/tinyxserver
- make DESTDIR="$root" BINDIR="/bin" install || return 1
- cd -
+ make CC=$CC EXTRA_CFLAGS="-D_XSERVER64=1 $CFLAGS" \
+ FONTDIR="/usr/share/fonts"
+ make DESTDIR="$root" BINDIR="/bin" install
cd "$root/usr/share/fonts/misc"
mkfontscale
mkfontdir
- cd -
-}
diff --git a/pkgs/tmux b/pkgs/tmux
@@ -1,25 +1,9 @@
-url=$mirror/tmux-1.8.tar.gz
-
-fetch() {
- wget -c $url -O src/tmux-1.8.tar.gz
-}
-
-unpack() {
- cd src
- [ -d tmux-1.8 ] || tar xzf tmux-1.8.tar.gz
- cd -
-}
-
-build() {
- cd src/tmux-1.8
- CC=x86_64-linux-musl-gcc ./configure --prefix="$root" LDFLAGS=-static \
- CFLAGS="-I$libcroot/include/ncursesw" || return 1
- make -j$nprocs || return 1
- cd -
-}
-
-install() {
- cd src/tmux-1.8
- make install || return 1
- cd -
-}
+v="1.8"
+url="$mirror/tmux-$v.tar.gz"
+
+build: ncurses libevent
+ cd src/tmux-$v
+ CC=$CC ./configure --prefix="$root" \
+ CFLAGS="-I$libcroot/include/ncursesw $CFLAGS"
+ make -j$nprocs
+ make install
diff --git a/pkgs/ubase b/pkgs/ubase
@@ -1,19 +1,8 @@
-url=git://git.2f30.org/ubase
+git="git://git.2f30.org/ubase"
-fetch() {
- [ -d src/ubase ] || git clone $url src/ubase
-}
-
-build() {
+build: crossmusl
cd src/ubase
make clean
- make -j$nprocs CC=x86_64-linux-musl-gcc LDFLAGS=-static || return 1
- cd -
-}
-
-install() {
- cd src/ubase
- make PREFIX="$root" install || return 1
+ make -j$nprocs CC=$CC LDFLAGS="$LDFLAGS"
+ make PREFIX="$root" install
chmod 4755 "$root/bin/su"
- cd -
-}
diff --git a/pkgs/uuterm b/pkgs/uuterm
@@ -1,21 +1,7 @@
-url=$mirror/uuterm.tar.gz
+url="$mirror/uuterm.tar.gz"
-fetch() {
- wget -c $url -O src/uuterm.tar.gz
-}
-
-unpack() {
- cd src
- [ -d uuterm ] || tar xzf uuterm.tar.gz
- cd -
-}
-
-build() {
+build: tinyxlib
cd src/uuterm
- make CC=x86_64-linux-musl-gcc LDFLAGS_X11="-L$libcroot/lib -static" uuterm-x11 || return 1
- cd -
-}
-
-install() {
- cp src/uuterm/uuterm-x11 "$root/bin"
-}
+ make clean
+ make CC=$CC LDFLAGS_X11="$LDFLAGS" uuterm-x11
+ cp uuterm-x11 "$root/bin"
diff --git a/pkgs/vim b/pkgs/vim
@@ -1,26 +1,11 @@
-url=http://ftp.vim.org/pub/vim/unix/vim-7.4.tar.bz2
+v="7.4"
+url="http://ftp.vim.org/pub/vim/unix/vim-$v.tar.bz2"
-fetch() {
- wget -c $url -O src/vim-7.4.tar.bz2
-}
-
-unpack() {
- cd src
- [ -d vim-7.4 ] || tar xjf vim-7.4.tar.bz2
- cd -
-}
-
-build() {
+build: ncurses
cd src/vim74
- CC=x86_64-linux-musl-gcc CFLAGS="-I$libcroot/include" LDFLAGS="-L$libcroot/lib -static" ./configure --prefix=/ \
+ make clean
+ CC=$CC ./configure --prefix=/ \
--enable-multibyte --disable-gui --with-x=no \
- --disable-nls --disable-netbeans || return 1
- make -j$nprocs || return 1
- cd -
-}
-
-install() {
- cd src/vim74
- make DESTDIR="$root" install || return 1
- cd -
-}
+ --disable-nls --disable-netbeans
+ make -j$nprocs
+ make DESTDIR="$root" install
diff --git a/pkgs/xsetroot b/pkgs/xsetroot
@@ -1,11 +1,4 @@
-build() {
- cd stuff
- x86_64-musl-linux-gcc -I"$libcroot/include" -L"$libcroot/lib" xsetroot.c -o xsetroot -lX11 -static || return 1
- cd -
-}
-
-install() {
+build: tinyxlib
cd stuff
+ $CC -I"$libcroot/include" -L"$libcroot/lib" xsetroot.c -o xsetroot -lX11 -static
cp xsetroot "$root/bin"
- cd -
-}
diff --git a/pkgs/zlib b/pkgs/zlib
@@ -1,24 +1,8 @@
-url=$mirror/zlib-1.2.8.tar.gz
-
-fetch() {
- wget -c $url -O src/zlib-1.2.8.tar.gz
-}
-
-unpack() {
- cd src
- [ -d zlib-1.2.8 ] || tar xzf zlib-1.2.8.tar.gz
- cd -
-}
-
-build() {
- cd src/zlib-1.2.8
- CC=x86_64-linux-musl-gcc ./configure --prefix="$libcroot" --static || return 1
- make -j$nprocs || return 1
- cd -
-}
-
-install() {
- cd src/zlib-1.2.8
- make install || return 1
- cd -
-}
+v="1.2.8"
+url="$mirror/zlib-$v.tar.gz"
+
+build: crossmusl
+ cd src/zlib-$v
+ CC=$CC ./configure --prefix="$libcroot" --static
+ make -j$nprocs
+ make install
diff --git a/prepare-env b/prepare-env
@@ -1,15 +0,0 @@
-top=$(pwd)
-root=$top/root
-libcroot=$root/opt/cross/x86_64-linux-musl/x86_64-linux-musl
-nprocs=4
-arch=x86_64
-version=0.0
-mirror=http://dl.2f30.org/morpheus-pkgs/$arch/$version
-export top root libcroot nprocs arch version mirror
-
-optldflags="-s -Wl,--gc-sections -Wl,-z,relro,-z,now"
-optcflags="-fdata-sections -ffunction-sections -Os -g0 -fno-unwind-tables -fno-asynchronous-unwind-tables -Wa,--noexecstack"
-export optldflags optcflags
-
-PATH=$root/opt/cross/x86_64-linux-musl/bin:$PATH
-export PATH
diff --git a/prepare-root b/prepare-root
@@ -1,17 +0,0 @@
-mkdir -p $root
-cd $root
-mkdir -p boot bin dev emul etc home mnt opt proc root share src sys tmp var
-mkdir -p dev/pts dev/shm opt/cross share/doc share/fonts/encodings share/man share/terminfo var/empty var/log var/run
-rm -f include
-ln -s opt/cross/x86_64-linux-musl/x86_64-linux-musl/include include
-rm -f lib
-ln -s opt/cross/x86_64-linux-musl/x86_64-linux-musl/lib lib
-rm -f usr
-ln -s . usr
-rm -f sbin
-ln -s bin sbin
-rm -f var/tmp
-ln -s ../tmp var/tmp
-chmod 1777 tmp
-chmod 700 root
-cd -
diff --git a/qemu-run-initrd b/qemu-run-initrd
@@ -1,13 +0,0 @@
-#!/bin/sh
-
-. ./prepare-env
-
-vdesock="/tmp/morpheus-vde"
-
-ps -ef | grep vde_switch | grep "sock $vdesock" | grep -v grep > /dev/null || {
- vde_switch -sock "$vdesock" -daemon -mod 660 -group kvm &&
- slirpvde -s "$vdesock" --dhcp --daemon -H '10.1.2.0/24' -L '2223:10.1.2.15:22'
-}
-
-qemu-system-x86_64 -enable-kvm -smp 2 -m 1024 -net nic,model=ne2k_pci \
- -net vde,sock="${vdesock}" -kernel $root/boot/bzImage -initrd morpheus-initrd.img -append "quiet"
diff --git a/stage0 b/stage0
@@ -1,42 +0,0 @@
-#!/bin/sh
-#
-# This is the stage0 script, it prepares a basic usable system
-# in $root.
-
-rm -rf root morpheus.log
-
-packages="crossmusl
- ncurses
- libevent
- zlib
- tinyxlib
- tinyalsa
- kernel
- kernel-headers
- busybox
- fs
- make
- man
- mksh
- rsync
- sbase
- sdhcp
- sic
- sinit
- smdev
- syslinux
- tinyxserver
- tmux
- ubase
- uuterm
- tinywm
- xsetroot
- terminus
- dwm
- mpg123
- jupp
- vim
- dvtm
- abduco"
-
-./pkgbuild $packages
diff --git a/stuff/cmp-fetch b/stuff/cmp-fetch
@@ -0,0 +1,4 @@
+#!/bin/sh
+
+pkg=`echo $1 | sed -e 's,-fetch$,,'`
+cmp -s .cache/$1 pkgs/$pkg
diff --git a/stuff/cmp-pkgs b/stuff/cmp-pkgs
@@ -0,0 +1,3 @@
+#!/bin/sh
+
+cmp -s .cache/$1 pkgs/$1
diff --git a/stuff/create-bootable b/stuff/create-bootable
@@ -0,0 +1,43 @@
+#!/bin/sh
+#
+# Ensure you've loaded the loop module with max_part=15
+
+if test "$2" = ""; then
+ echo "Usage: $0 <rootdir> <imgfile>"
+ exit
+fi
+root=$1
+img=$2
+
+set -e -x
+
+dd if=/dev/zero of=$img bs=512M count=8
+(
+cat << EOF
+o
+n
+p
+1
+
+
+a
+1
+w
+EOF
+) | fdisk $img
+
+lodev=$(losetup -f --show $img) || exit 1
+partition="$lodev"p1
+mkfs.ext2 -L MORPHEUS $partition || exit 1
+mount $partition /mnt || exit 1
+rmdir /mnt/lost+found
+
+fakeroot cp -arP "$root"/* /mnt
+extlinux --install /mnt/boot || exit 1
+
+dd if=stuff/mbr.bin of=$lodev conv=notrunc bs=440 count=1
+sync
+
+umount /mnt
+sleep 3
+losetup -d $lodev
diff --git a/stuff/fetch-pkg.mk b/stuff/fetch-pkg.mk
@@ -0,0 +1,26 @@
+ cp $top/pkgs/$target $top/.cache/$target
+
+fetch-target:QP./stuff/cmp-fetch: .
+ cd src
+ pkg=`echo $target | sed -e 's,-fetch$,,'`
+ eval url=$url
+ if test "$url" = ""; then
+ if test "$git" = ""; then
+ echo $target: nothing to download
+ else
+ [ -d $pkg ] || git clone $git $pkg
+ fi
+ else
+ wget -c $url
+ file=`basename $url`
+ type=`file -b $file | cut -d ' ' -f 1`
+ if test "$type" = "gzip"; then
+ tar -xzf $file
+ elif test "$type" = "bzip2"; then
+ tar -xjf $file
+ elif test "$type" = "XZ"; then
+ tar -xJf $file
+ fi
+ fi
+ cp $top/pkgs/$pkg $top/.cache/$target
+