morpheus

suckless linux distro
git clone git://git.2f30.org/morpheus
Log | Files | Refs | Submodules | README | LICENSE

commit d71bb4e96602bd12e8ec334c7f6fca3178274363
parent 6d1ab24ca7ef21f48592ae68a587eb146bd0368a
Author: Daniel Bainton <dpb@driftaway.org>
Date:   Thu, 27 Feb 2014 14:41:37 +0200

Move to a mk based build system

Diffstat:
A.gitignore | 2++
MREADME | 8++++----
Dbuild | 49-------------------------------------------------
Aconfig.mk | 12++++++++++++
Dcreate-bootable | 40----------------------------------------
Amkfile | 24++++++++++++++++++++++++
Dpkgbuild | 33---------------------------------
Mpkgs/abduco | 22++++++----------------
Mpkgs/busybox | 20++++++--------------
Mpkgs/crossmusl | 27++++++++++++---------------
Mpkgs/dvtm | 29+++++++----------------------
Mpkgs/dwm | 35+++++++++--------------------------
Mpkgs/fs | 17++++++-----------
Mpkgs/jupp | 33+++++++--------------------------
Mpkgs/kernel | 30++++++++----------------------
Mpkgs/kernel-headers | 30++++++++++++------------------
Mpkgs/libevent | 28+++++++---------------------
Mpkgs/make | 28+++++++---------------------
Mpkgs/man | 25+++++--------------------
Mpkgs/mksh | 34++++++++++++----------------------
Mpkgs/mpg123 | 28+++++++---------------------
Mpkgs/ncurses | 35+++++++++++------------------------
Apkgs/prepare-root | 17+++++++++++++++++
Mpkgs/rsync | 28+++++++---------------------
Mpkgs/sbase | 22++++++----------------
Mpkgs/sdhcp | 27++++++++-------------------
Mpkgs/sic | 25++++++-------------------
Mpkgs/sinit | 23++++++-----------------
Mpkgs/smdev | 22++++++----------------
Mpkgs/syslinux | 18++++--------------
Mpkgs/terminus | 28++++++----------------------
Mpkgs/tinyalsa | 25+++++--------------------
Mpkgs/tinywm | 11++---------
Mpkgs/tinyxlib | 27++++++---------------------
Mpkgs/tinyxserver | 26+++++---------------------
Mpkgs/tmux | 28+++++++---------------------
Mpkgs/ubase | 22++++++----------------
Mpkgs/uuterm | 25++++++-------------------
Mpkgs/vim | 28+++++++---------------------
Mpkgs/xsetroot | 11++---------
Mpkgs/zlib | 28+++++++---------------------
Dprepare-env | 15---------------
Dprepare-root | 17-----------------
Dstage0 | 42------------------------------------------
Astuff/cmp-pkgs | 4++++
Astuff/create-bootable | 43+++++++++++++++++++++++++++++++++++++++++++
46 files changed, 330 insertions(+), 821 deletions(-)

diff --git a/.gitignore b/.gitignore @@ -0,0 +1,2 @@ +.state +pkgs.mk 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,13 @@ and Ubuntu 13.04. To build specific packages: - ./pkgbuild pkg1 pkg2 ... + mk 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/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/config.mk b/config.mk @@ -0,0 +1,12 @@ +top = `{pwd} +root = ${top}/root +#arch = i486 +arch = x86_64 +libcroot = ${root}/opt/cross/${arch}-linux-musl/${arch}-linux-musl +nprocs = 4 +version = 0.0 +mirror = http://dl.2f30.org/morpheus-pkgs/${arch}/${version} +CC = ${arch}-linux-musl-gcc + +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/mkfile b/mkfile @@ -0,0 +1,24 @@ +<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 .state/* + +# generate a pkgs.mk file with the tarkets for all packages in pkgs/ +`{ mkdir -p .state } +`{ echo '# auto-generated file, do not edit' > pkgs.mk } +`{ cd pkgs && for pkg in *; do cat $pkg | sed -e "s,^build:,$pkg:QP./stuff/cmp-pkgs: pkgs/$pkg," >> ../pkgs.mk && echo '\tcd $top && cp pkgs/$target .state/$target\n' >> ../pkgs.mk; done } + +<pkgs.mk + +bootable:V: + stuff/create-bootable "$root" morpheus-$arch-$version.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,12 @@ -url=git://repo.or.cz/abduco.git - -fetch() { - [ -d src/abduco ] || git clone $url src/abduco -} - -build() { - cd src/abduco +build: crossmusl + url="git://repo.or.cz/abduco.git" + cd src + [ -d abduco ] || git clone $url + cd 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 + sed -i "s@CC = cc@CC = $CC@" config.mk make || return 1 - cd - -} - -install() { - cd src/abduco make DESTDIR="$root" install - cd - -} diff --git a/pkgs/busybox b/pkgs/busybox @@ -1,16 +1,10 @@ -url=$mirror/busybox - -fetch() { - wget -c $url -O src/busybox -} - -install() { - # Install package - cd src/ +build: crossmusl + url="$mirror/busybox" + cd src + wget -c ${url} 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 - -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 + v="0.9.15" + url="$mirror/crossx86-$arch-linux-musl-$v.tar.xz" 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 + wget -c $url + tar xJf crossx86-$arch-linux-musl-$v.tar.xz -C "$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,13 @@ -url=http://www.brain-dump.org/projects/dvtm/dvtm-0.10.tar.gz - -fetch() { - wget -c $url -O src/dvtm-0.10.tar.gz -} - -unpack() { +build: ncurses + v="0.10" + url="http://www.brain-dump.org/projects/dvtm/dvtm-$v.tar.gz" cd src - [ -d dvtm-0.10 ] || tar -xzf dvtm-0.10.tar.gz - cd - -} - -build() { - cd src/dvtm-0.10 + wget -c $url + [ -d dvtm-$v ] || tar -xzf dvtm-$v.tar.gz + cd dvtm-$v 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 + sed -i "s@CC = cc@CC = $CC@" config.mk make || return 1 - cd - -} - -install() { - cd src/dvtm-0.10 make DESTDIR="$root" install - cd - -} - diff --git a/pkgs/dwm b/pkgs/dwm @@ -1,28 +1,11 @@ -url=$mirror/dwm-git.tar.gz - -fetch() { - wget -c $url -O src/dwm-git.tar.gz -} - -unpack() { +build: tinyxlib + url="$mirror/dwm-git.tar.gz" cd src + wget -c $url [ -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() { - cd src/dwm - cp dwm "$root/bin" - cp dwm.1 "$root/share/man/man1" - cd - -} + sed -i "s@X11INC = /usr/X11R6/include@X11INC = $libcroot/include @" dwm/config.mk + sed -i "s@X11LIB = /usr/X11R6/lib@X11LIB = $libcroot/lib @" dwm/config.mk + sed -i 's@LDFLAGS = -s ${LIBS}@LDFLAGS = -s ${LIBS} -static @' dwm/config.mk + sed -i "s@CC = cc@CC = $CC@" dwm/config.mk + make -C dwm + make -C dwm DESTDIR=${root} install diff --git a/pkgs/fs b/pkgs/fs @@ -1,11 +1,6 @@ -url=git://git.2f30.org/fs - -fetch() { - [ -d src/fs ] || git clone $url src/fs -} - -install() { - cd src/fs - cp -r * "$root/" - cd - -} +build: prepare-root + url="git://git.2f30.org/fs" + cd src + [ -d fs ] || git clone ${url} + cd fs + cp -r * "${root}/" diff --git a/pkgs/jupp b/pkgs/jupp @@ -1,26 +1,13 @@ -url=$mirror/joe-3.1jupp26.tgz - -fetch() { - wget -c $url -O src/joe-3.1jupp26.tgz -} - -unpack() { +build: crossmusl + v="3.1jupp26" + url="$mirror/joe-$v.tgz" 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" \ + wget -c $url + [ -d jupp ] || tar xzf joe-$v.tgz + cd jupp + CC=$CC sh configure --prefix="/" CFLAGS="-I$libcroot/include" \ LDFLAGS="-L$libcroot/lib -static" || return 1 make || return 1 - cd - -} - -install() { - cd src/jupp cp joe termidx "$root/bin" mkdir -p "$root/share/man/man1" cp joe.1 "$root/share/man/man1" @@ -29,13 +16,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,14 @@ -url=$mirror/kernel.tar.gz -version=3.10.32 - -fetch() { - wget -c $url -O src/kernel.tar.gz -} - -unpack() { +build: crossmusl + v="3.10.32" + url="$mirror/kernel.tar.gz" cd src - [ -d linux-$version ] || tar xzf kernel.tar.gz - cd - -} - -build() { - cd src/linux-$version + wget -c $url + [ -d linux-$v ] || tar xzf kernel.tar.gz + cd linux-$v cp $top/stuff/kernel-config .config - make menuconfig + #make menuconfig + make oldconfig make bzImage -j$nprocs || return 1 - cd - -} - -install() { - cd src/linux-$version 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 +1,13 @@ -url=$mirror/kernel.tar.gz -version=3.10.12 - -fetch() { - wget -c $url -O src/kernel.tar.gz -} - -unpack() { +build: + v="3.10.32" + url="$mirror/kernel.tar.gz" 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 - -} + wget -c $url + [ -d linux-$v ] || tar xzf kernel.tar.gz + cd 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,10 @@ -url=$mirror/libevent-2.0.21-stable.tar.gz - -fetch() { - wget -c $url -O src/libevent-2.0.21-stable.tar.gz -} - -unpack() { +build: crossmusl + v="2.0.21" + url="$mirror/libevent-$v-stable.tar.gz" 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 + wget -c $url + [ -d libevent-$v-stable ] || tar xzf libevent-$v-stable.tar.gz + cd libevent-$v-stable + CC="$CC -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 - -} diff --git a/pkgs/make b/pkgs/make @@ -1,24 +1,10 @@ -url=$mirror/make-3.82.tar.bz2 - -fetch() { - wget -c $url -O src/make-3.82.tar.bz2 -} - -unpack() { +build: crossmusl + v="3.82" + url="$mirror/make-$v.tar.bz2" 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 + wget -c $url + [ -d make-$v ] || tar xjf make-$v.tar.bz2 + cd make-$v + CC="$CC -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 - -} diff --git a/pkgs/man b/pkgs/man @@ -1,23 +1,8 @@ -url=$mirror/man.tar.gz - -fetch() { - wget -c $url -O src/man.tar.gz -} - -unpack() { +build: crossmusl + url="$mirror/man.tar.gz" cd src + wget -c $url [ -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() { - cd src/man + cd man + $CC -std=gnu99 -o man man.c -static || return 1 cp man "$root/bin" - cd - -} diff --git a/pkgs/mksh b/pkgs/mksh @@ -1,24 +1,14 @@ -url=$mirror/mksh-R47.tar.gz - -fetch() { - wget -c $url -O src/mksh-R47.tar.gz -} - -unpack() { +build: crossmusl + v="R47" + url="$mirror/mksh-$v.tar.gz" cd src - [ -d mksh ] || tar xzf mksh-R47.tar.gz - cd - -} - -build() { - cd src/mksh - CC=x86_64-linux-musl-gcc LDFLAGS=-static sh Build.sh || return 1 - cd - -} - -install() { - cp src/mksh/mksh "$root/bin" + wget -c $url + [ -d mksh ] || tar xzf mksh-$v.tar.gz + cd mksh + CC=$CC LDFLAGS=-static sh Build.sh || return 1 + 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,11 @@ -url=$mirror/mpg123-1.18.0.tar.bz2 - -fetch() { - wget -c $url -O src/mpg123-1.18.0.tar.bz2 -} - -unpack() { +build: tinyalsa + v="1.18.0" + url="$mirror/mpg123-$v.tar.bz2" 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 \ + wget -c $url + [ -d mpg123-$v ] || tar xjf mpg123-$v.tar.bz2 + cd mpg123-$v + CC=$CC ./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 - -} diff --git a/pkgs/ncurses b/pkgs/ncurses @@ -1,32 +1,19 @@ -url=$mirror/ncurses.tar.gz - -fetch() { - wget -c $url -O src/ncurses.tar.gz -} - -unpack() { +build: crossmusl + v="5.9" + url="$mirror/ncurses.tar.gz" cd src - [ -d ncurses-5.9 ] || tar xzf ncurses.tar.gz - cd - -} - -build() { - cd src/ncurses-5.9 + wget -c $url + [ -d ncurses-$v ] || tar xzf ncurses.tar.gz + cd 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}" --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 - 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,10 @@ -url=$mirror/rsync-3.0.9.tar.gz - -fetch() { - wget -c $url -O src/rsync-3.0.9.tar.gz -} - -unpack() { +build: crossmusl + v="3.0.9" + url="$mirror/rsync-$v.tar.gz" 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 + wget -c $url + [ -d rsync-$v ] || tar xzf rsync-$v.tar.gz + cd rsync-$v + CC=$CC ./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 - -} diff --git a/pkgs/sbase b/pkgs/sbase @@ -1,18 +1,8 @@ -url=git://git.2f30.org/sbase - -fetch() { - [ -d src/sbase ] || git clone $url src/sbase -} - -build() { - cd src/sbase +build: crossmusl + url="git://git.2f30.org/sbase" + cd src + [ -d sbase ] || git clone $url + cd 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=-static || return 1 make PREFIX="$root" install - cd - -} diff --git a/pkgs/sdhcp b/pkgs/sdhcp @@ -1,22 +1,11 @@ -url=$mirror/sdhcp.tar.gz - -fetch() { - wget -c $url -O src/sdhcp.tar.gz -} - -unpack() { +build: crossmusl + url="$mirror/sdhcp.tar.gz" cd src + wget -c $url [ -d sdhcp ] || tar xzf sdhcp.tar.gz - cd - -} - -build() { - cd src/sdhcp + cd 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 LDFLAGS=-static || return 1 + cp sdhcp "$root/bin" || return 1 + 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,9 @@ -url=$mirror/sic.tar.gz - -fetch() { - wget -c $url -O src/sic.tar.gz -} - -unpack() { +build: crossmusl + url="$mirror/sic.tar.gz" cd src + wget -c $url [ -d sic ] || tar xzf sic.tar.gz - cd - -} - -build() { - cd src/sic + cd 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=-static || return 1 + cp sic "$root/bin" diff --git a/pkgs/sinit b/pkgs/sinit @@ -1,21 +1,10 @@ -url=git://git.2f30.org/sinit - -fetch() { - [ -d src/sinit ] || git clone $url src/sinit -} - -build() { - cd src/sinit +build: crossmusl + url="git://git.2f30.org/sinit" + cd src + [ -d sinit ] || git clone $url + cd 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=-static || return 1 make PREFIX="$root" install - cd - cd "$root" ln -sf /bin/sinit init - cd - -} diff --git a/pkgs/smdev b/pkgs/smdev @@ -1,18 +1,8 @@ -url=git://git.2f30.org/smdev - -fetch() { - [ -d src/smdev ] || git clone $url src/smdev -} - -build() { - cd src/smdev +build: crossmusl + url="git://git.2f30.org/smdev" + cd src + [ -d smdev ] || git clone $url + cd smdev make clean - make CC=x86_64-linux-musl-gcc LDFLAGS=-static || return 1 - cd - -} - -install() { - cd src/smdev + make CC=$CC LDFLAGS=-static || return 1 make PREFIX="$root" install || return 1 - cd - -} diff --git a/pkgs/syslinux b/pkgs/syslinux @@ -1,16 +1,6 @@ -url=$mirror/syslinux.tar.gz - -fetch() { - # Fetch package - wget -c $url -O src/syslinux.tar.gz -} - -unpack() { +build: prepare-root + url="$mirror/syslinux.tar.gz" cd src + wget -c $url [ -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,17 @@ -url=$mirror/terminus-font-4.38.tar.gz - -fetch() { - wget -c $url -O src/terminus-font-4.38.tar.gz -} - -unpack() { +build: crossmusl + v="4.38" + url="$mirror/terminus-font-$v.tar.gz" cd src - [ -d terminus-font-4.38 ] || tar xzf terminus-font-4.38.tar.gz - cd - -} - -build() { - cd src/terminus-font-4.38 + wget -c $url + [ -d terminus-font-$v ] || tar xzf terminus-font-$v.tar.gz + cd 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 - 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,11 @@ -url=$mirror/tinyalsa.tar.gz - -fetch() { - wget -c $url -O src/tinyalsa.tar.gz -} - -unpack() { +build: crossmusl + url="$mirror/tinyalsa.tar.gz" cd src + wget -c $url [ -d tinyalsa ] || tar xzf tinyalsa.tar.gz - cd - -} - -build() { - cd src/tinyalsa + cd 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 LDFLAGS="-static" || return 1 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 || return 1 cp tinywm "$root/bin" - cd - -} diff --git a/pkgs/tinyxlib b/pkgs/tinyxlib @@ -1,25 +1,10 @@ -url=$mirror/tinyxlib.tar.gz - -fetch() { - wget -c $url -O src/tinyxlib.tar.gz -} - -unpack() { +build: crossmusl + url="$mirror/tinyxlib.tar.gz" cd src + wget -c $url [ -d tinyxlib ] || tar xzf tinyxlib.tar.gz - cd - -} - -build() { - cd src/tinyxlib + cd 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 CC=$CC BINDIR="/bin" LIBDIR="/lib" STATIC=1 \ + FONT_ENCODINGS_DIRECTORY="/share/fonts/encodings/encodings.dir" || return 1 make DESTDIR="$libcroot" BINDIR="/bin" LIBDIR="/lib" STATIC=1 install || return 1 - cd - -} diff --git a/pkgs/tinyxserver b/pkgs/tinyxserver @@ -1,30 +1,14 @@ -url=$mirror/tinyxserver.tar.gz - -fetch() { - wget -c $url -O src/tinyxserver.tar.gz -} - -unpack() { +build: tinyxlib zlib + url="$mirror/tinyxserver.tar.gz" cd src + wget -c $url [ -d tinyxserver ] || tar xzf tinyxserver.tar.gz - cd - -} - -build() { - cd src/tinyxserver + cd tinyxserver make clean - make CC=x86_64-linux-musl-gcc EXTRA_CFLAGS="-D_XSERVER64=1 -I$libcroot/include" \ + make CC=$CC 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 - cd "$root/usr/share/fonts/misc" mkfontscale mkfontdir - cd - -} diff --git a/pkgs/tmux b/pkgs/tmux @@ -1,25 +1,11 @@ -url=$mirror/tmux-1.8.tar.gz - -fetch() { - wget -c $url -O src/tmux-1.8.tar.gz -} - -unpack() { +build: ncurses + v="1.8" + url="$mirror/tmux-$v.tar.gz" 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 \ + wget -c $url + [ -d tmux-$v ] || tar xzf tmux-$v.tar.gz + cd tmux-$v + CC=$CC ./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 - -} diff --git a/pkgs/ubase b/pkgs/ubase @@ -1,19 +1,9 @@ -url=git://git.2f30.org/ubase - -fetch() { - [ -d src/ubase ] || git clone $url src/ubase -} - -build() { - cd src/ubase +build: crossmusl + url="git://git.2f30.org/ubase" + cd src + [ -d ubase ] || git clone $url + cd ubase make clean - make -j$nprocs CC=x86_64-linux-musl-gcc LDFLAGS=-static || return 1 - cd - -} - -install() { - cd src/ubase + make -j$nprocs CC=$CC LDFLAGS=-static || return 1 make PREFIX="$root" install || return 1 chmod 4755 "$root/bin/su" - cd - -} diff --git a/pkgs/uuterm b/pkgs/uuterm @@ -1,21 +1,8 @@ -url=$mirror/uuterm.tar.gz - -fetch() { - wget -c $url -O src/uuterm.tar.gz -} - -unpack() { +build: tinyxlib + url="$mirror/uuterm.tar.gz" cd src + wget -c $url [ -d uuterm ] || tar xzf uuterm.tar.gz - cd - -} - -build() { - 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" -} + cd uuterm + make CC=$CC LDFLAGS_X11="-L$libcroot/lib -static" uuterm-x11 || return 1 + cp uuterm-x11 "$root/bin" diff --git a/pkgs/vim b/pkgs/vim @@ -1,26 +1,12 @@ -url=http://ftp.vim.org/pub/vim/unix/vim-7.4.tar.bz2 - -fetch() { - wget -c $url -O src/vim-7.4.tar.bz2 -} - -unpack() { +build: ncurses + v="7.4" + url="http://ftp.vim.org/pub/vim/unix/vim-$v.tar.bz2" cd src - [ -d vim-7.4 ] || tar xjf vim-7.4.tar.bz2 - cd - -} - -build() { - cd src/vim74 - CC=x86_64-linux-musl-gcc CFLAGS="-I$libcroot/include" LDFLAGS="-L$libcroot/lib -static" ./configure --prefix=/ \ + wget -c $url + [ -d vim74 ] || tar xjf vim-$v.tar.bz2 + cd vim74 + CC=$CC CFLAGS="-I$libcroot/include" LDFLAGS="-L$libcroot/lib -static" ./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 - -} 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 || return 1 cp xsetroot "$root/bin" - cd - -} diff --git a/pkgs/zlib b/pkgs/zlib @@ -1,24 +1,10 @@ -url=$mirror/zlib-1.2.8.tar.gz - -fetch() { - wget -c $url -O src/zlib-1.2.8.tar.gz -} - -unpack() { +build: crossmusl + v="1.2.8" + url="$mirror/zlib-$v.tar.gz" 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 + wget -c $url + [ -d zlib-$v ] || tar xzf zlib-$v.tar.gz + cd zlib-$v + CC=$CC ./configure --prefix="$libcroot" --static || return 1 make -j$nprocs || return 1 - cd - -} - -install() { - cd src/zlib-1.2.8 make install || return 1 - cd - -} 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:$top/stuff/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/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-pkgs b/stuff/cmp-pkgs @@ -0,0 +1,4 @@ +#!/bin/sh + +val=`cmp -s .state/$1 pkgs/$1` +return $val 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