From: Mike Lowis Date: Thu, 28 Jan 2016 12:08:06 +0000 (+0000) Subject: Base system is now complete enough to successfully bootstrap the pkgsrc utilities... X-Git-Url: https://git.mdlowis.com/?a=commitdiff_plain;h=02e2cdf0008ddee42e24acd877286c551b0f9107;p=proto%2Faardvark-linux.git Base system is now complete enough to successfully bootstrap the pkgsrc utilities. It is still missing networking utilities which will allow pkgsrc to fetch packages for installation. --- diff --git a/bin/install b/bin/install new file mode 100755 index 0000000..d83ed52 --- /dev/null +++ b/bin/install @@ -0,0 +1,110 @@ +#!/bin/sh + +# Print the usage and exit +function usage(){ + echo "Usage: install [OPTION]... [-T] SOURCE DEST" + echo " or: install [OPTION]... SOURCE... DIRECTORY" + echo " or: install [OPTION]... -t DIRECTORY SOURCE..." + echo " or: install [OPTION]... -d DIRECTORY..." + exit 1 +} + +# Global flags that affect behavior +dirmode=0 +mkdirmode=0 +group= +mode= +owner= +sources= +destination= + +echo "Install received the following command line:" +echo " $@" +# Parse command-line args +while getopts bcCdDg:m:o:psS:t:Tv name; do + case $name in + d) dirmode=1 ;; + D) mkdirmode=1 ;; + g) group="$OPTARG" ;; + m) owner="$OPTARG" ;; + o) mode="$OPTARG" ;; + + # Unsupported for now + t) destination="$OPTARG" ;; + + # These options don't do anything + p) ;; + b) ;; + c) ;; + C) ;; + s) ;; + S) ;; + T) ;; + v) ;; + Z) ;; + + # Catch all errors and report them + ?) usage;; + esac +done +# remove the parsed flags from the positional arguments array +shift $((OPTIND-1)) + +if [ $dirmode -ne 1 ]; then + # Normal mode requires at least two positional args + if [ "$destination" == "" ] && [ $# -lt 2 ]; then + usage + fi +fi + +# All forms require at least one positional arg +if [ "$destination" != "" ] && [ $# -lt 1 ]; then + usage +fi + +#------------------------------------------------------------------------------ +# Helper Functions +#------------------------------------------------------------------------------ +function setgroup(){ + if [ "$group" != "" ]; then + chgrp "$group" "$@" + fi +} + +function setmode(){ + if [ "$mode" != "" ]; then + chmod "$mode" "$@" + fi +} + +function setowner(){ + if [ "$owner" != "" ]; then + chown "$owner" "$@" + fi +} + +#------------------------------------------------------------------------------ +# Main Routine +#------------------------------------------------------------------------------ +if [ $dirmode -eq 1 ]; then + while [ $# -gt 0 ]; do + mkdir -p $1 + shift + done +else + # Decide if the last arg is the target dir or a source + stopcount=1 + if [ "$destination" != "" ]; then + stopcount=0 + fi + # get the sources + while [ $# -gt $stopcount ]; do + sources="$sources $1" + shift + done + if [ $# -eq 1 ]; then + destination="$1" + fi + cp $sources $destination +fi + diff --git a/build.sh b/build.sh index 6069978..c0ac5e0 100755 --- a/build.sh +++ b/build.sh @@ -38,11 +38,25 @@ fetch crossx86-x86_64-linux-musl-1.1.12.tar.xz \ https://e82b27f594c813a5a4ea5b07b06f16c3777c3b8c.googledrive.com/host/0BwnS5DMB0YQ6bDhPZkpOYVFhbk0/musl-1.1.12/ \ "$AL_TOOLS" rm -f "$AL_TOOLS/$AL_TGT/lib/libc.so" +[ ! -L "$AL_ROOT/sbin" ] && ln -sfv bin "$AL_ROOT/sbin" +[ ! -L "$AL_ROOT/usr" ] && ln -sfv . "$AL_ROOT/usr" +mkdir -pv "$AL_ROOT/bin" +mkdir -pv "$AL_ROOT/dev" +mkdir -pv "$AL_ROOT/etc" +mkdir -pv "$AL_ROOT/proc" +mkdir -pv "$AL_ROOT/sys" +mkdir -pv "$AL_ROOT/tmp" +mkdir -pv "$AL_ROOT/root" +mkdir -pv "$AL_ROOT/var" +cp etc/* "$AL_ROOT/etc/" +cp bin/* "$AL_ROOT/bin/" # Install sbase gitclone http://git.suckless.org/sbase "$AL_SOURCES/sbase" if [ ! -f "$AL_ROOT/bin/ls" ]; then cd "$AL_SOURCES/sbase" + git checkout . + git apply ../../patches/sbase-touch-f.diff make $MAKEFLAGS CC="$CC" LD="$LD" LDFLAGS="$LDFLAGS" make $MAKEFLAGS PREFIX=$AL_ROOT install rm -f "$AL_ROOT/bin/grep" @@ -104,18 +118,54 @@ if [ ! -f "$AL_ROOT/bin/gawk" ]; then cd $AL fi -# Install GNU make -fetch make-4.1.tar.gz http://ftp.gnu.org/gnu/make/ "$AL_SOURCES/make" -if [ ! -f "$AL_ROOT/bin/make" ]; then - cd "$AL_SOURCES/make" - ./configure \ - LDFLAGS="--static" \ - --prefix="$AL_ROOT" \ - --without-guile +# Install shadow +fetch shadow-4.2.1.tar.xz http://pkg-shadow.alioth.debian.org/releases/ "$AL_SOURCES/shadow" +if [ ! -f "$AL_ROOT/bin/groups" ]; then + cd "$AL_SOURCES/shadow" + ./configure \ + LDFLAGS="--static" \ + --prefix="$AL_ROOT" \ + --exec-prefix="$AL_ROOT" \ + --sysconfdir="$AL_ROOT/etc" \ + --with-group-name-max-length=32 make $MAKEFLAGS install + sed -i 's/yes/no/; s/bash/sh/' "$AL_ROOT/etc/default/useradd" cd $AL fi +# Install GNU diffutils +fetch diffutils-3.3.tar.xz http://ftp.gnu.org/gnu/diffutils/ "$AL_SOURCES/diffutils" +if [ ! -f "$AL_ROOT/bin/diff" ]; then + cd "$AL_SOURCES/diffutils" + ./configure \ + --prefix="$AL_ROOT" + make $MAKEFLAGS install + cd $AL +fi + +## Install GNU make +#fetch make-4.1.tar.gz http://ftp.gnu.org/gnu/make/ "$AL_SOURCES/make" +#if [ ! -f "$AL_ROOT/bin/make" ]; then +# cd "$AL_SOURCES/make" +# ./configure \ +# LDFLAGS="--static" \ +# --prefix="$AL_ROOT" \ +# --without-guile +# make $MAKEFLAGS install +# cd $AL +#fi + + +## Install GNU inetutils +#fetch inetutils-1.9.4.tar.xz http://ftp.gnu.org/gnu/inetutils/ "$AL_SOURCES/inetutils" +#if [ ! -f "$AL_ROOT/bin/diff" ]; then +# cd "$AL_SOURCES/inetutils" +# ./configure \ +# --prefix="$AL_ROOT" +# make $MAKEFLAGS install +# cd $AL +#fi + ## Install GNU bc #fetch bc-1.06.tar.gz http://ftp.gnu.org/gnu/bc/ "$AL_SOURCES/bc" #if [ ! -f "$AL_ROOT/bin/bc" ]; then @@ -154,7 +204,7 @@ fi # cd $AL #fi #/tools/bin/../lib/gcc/x86_64-linux-musl/5.3.0/include - +# ## Install Perl #fetch perl-5.22.0.tar.bz2 http://www.cpan.org/src/5.0/ "$AL_SOURCES/perl" #if [ ! -f "$AL_ROOT/bin/perl" ]; then @@ -167,13 +217,15 @@ fi ############################################################################### # Install Sources ############################################################################### -fetch musl-1.1.12.tar.gz http://www.musl-libc.org/releases/ "$AL_ROOT/src/musl" -gitclone http://git.suckless.org/sbase "$AL_ROOT/src/sbase" -gitclone http://git.suckless.org/ubase "$AL_ROOT/src/ubase" -fetch mksh-R52b.tgz https://www.mirbsd.org/MirOS/dist/mir/mksh/ "$AL_ROOT/src/mksh" -fetch make-4.1.tar.gz http://ftp.gnu.org/gnu/make/ "$AL_ROOT/src/make" -fetch grep-2.9.tar.xz http://ftp.gnu.org/gnu/grep/ "$AL_ROOT/src/grep" -fetch gawk-4.1.3.tar.xz http://ftp.gnu.org/gnu/gawk/ "$AL_ROOT/src/gawk" +fetch pkgsrc.tar.bz2 http://ftp.netbsd.org/pub/pkgsrc/stable/ "$AL_ROOT/pkgsrc/" + +#fetch musl-1.1.12.tar.gz http://www.musl-libc.org/releases/ "$AL_ROOT/src/musl" +#gitclone http://git.suckless.org/sbase "$AL_ROOT/src/sbase" +#gitclone http://git.suckless.org/ubase "$AL_ROOT/src/ubase" +#fetch mksh-R52b.tgz https://www.mirbsd.org/MirOS/dist/mir/mksh/ "$AL_ROOT/src/mksh" +#fetch make-4.1.tar.gz http://ftp.gnu.org/gnu/make/ "$AL_ROOT/src/make" +#fetch grep-2.9.tar.xz http://ftp.gnu.org/gnu/grep/ "$AL_ROOT/src/grep" +#fetch gawk-4.1.3.tar.xz http://ftp.gnu.org/gnu/gawk/ "$AL_ROOT/src/gawk" #fetch bc-1.06.tar.gz http://ftp.gnu.org/gnu/bc/ "$AL_ROOT/src/bc" #fetch gzip-1.6.tar.xz http://ftp.gnu.org/gnu/gzip/ "$AL_ROOT/src/gzip" #fetch ncurses-6.0.tar.gz http://ftp.gnu.org/gnu/ncurses/ "$AL_ROOT/src/ncurses" @@ -183,11 +235,6 @@ fetch gawk-4.1.3.tar.xz http://ftp.gnu.org/gnu/gawk/ "$AL_ ############################################################################### # Finalize the Chroot ############################################################################### -mkdir -pv "$AL_ROOT/dev" -mkdir -pv "$AL_ROOT/proc" -mkdir -pv "$AL_ROOT/sys" -mkdir -pv "$AL_ROOT/tmp" -mkdir -pv "$AL_ROOT/root" ln -sfv "$AL_TGT-addr2line" "$AL_TOOLS/bin/addr2line" ln -sfv "$AL_TGT-ar" "$AL_TOOLS/bin/ar" ln -sfv "$AL_TGT-as" "$AL_TOOLS/bin/as" diff --git a/clean.sh b/clean.sh index 0e35f67..cc9f15d 100755 --- a/clean.sh +++ b/clean.sh @@ -1,6 +1,10 @@ #!/bin/sh . ./config.sh -echo rm -r "$AL_ROOT" -rm -rf "$AL_ROOT" +echo rm "$AL_ROOT/sbin" +rm "$AL_ROOT/sbin" +echo rm "$AL_ROOT/usr" +rm "$AL_ROOT/usr" echo rm -r "$AL_SOURCES" rm -rf "$AL_SOURCES" +echo rm -r "$AL_ROOT" +rm -rf "$AL_ROOT" diff --git a/enter-chroot.sh b/enter-chroot.sh index f7e52ce..062cf77 100755 --- a/enter-chroot.sh +++ b/enter-chroot.sh @@ -12,6 +12,7 @@ mount --make-rslave "$AL_ROOT/dev" # Setup env variables export PATH=/bin:/tools/bin +export MAKEFLAGS= # Enter the chroot chroot "$AL_ROOT" /bin/sh diff --git a/etc/group b/etc/group new file mode 100644 index 0000000..ae2dcd2 --- /dev/null +++ b/etc/group @@ -0,0 +1,29 @@ +root:x:0:root +bin:x:1:root,bin,daemon +daemon:x:2:root,bin,daemon +sys:x:3:root,bin,adm +adm:x:4:root,adm,daemon +tty:x:5: +disk:x:6:root,adm +lp:x:7:lp +mem:x:8: +kmem:x:9: +wheel:x:10:root +floppy:x:11:root +news:x:13:news +uucp:x:14:uucp +console:x:17: +audio:x:18: +cdrom:x:19: +tape:x:26:root +video:x:27:root +cdrw:x:80: +usb:x:85: +users:x:100: +utmp:x:406: +nogroup:x:65533: +nobody:x:65534: +man:x:15: +input:x:249: +messagebus:x:248: +polkitd:x:246: diff --git a/etc/passwd b/etc/passwd new file mode 100644 index 0000000..a3bf6e6 --- /dev/null +++ b/etc/passwd @@ -0,0 +1,12 @@ +root:x:0:0:root:/root:/bin/sh +bin:x:1:1:bin:/bin:/bin/false +daemon:x:2:2:daemon:/sbin:/bin/false +adm:x:3:4:adm:/var/adm:/bin/false +lp:x:4:7:lp:/var/spool/lpd:/bin/false +sync:x:5:0:sync:/sbin:/bin/sync +shutdown:x:6:0:shutdown:/sbin:/sbin/shutdown +halt:x:7:0:halt:/sbin:/sbin/halt +news:x:9:13:news:/var/spool/news:/bin/false +uucp:x:10:14:uucp:/var/spool/uucp:/bin/false +operator:x:11:0:operator:/root:/bin/sh +nobody:x:65534:65534:nobody:/var/empty:/bin/false diff --git a/patches/sbase-touch-f.diff b/patches/sbase-touch-f.diff new file mode 100644 index 0000000..d0037fb --- /dev/null +++ b/patches/sbase-touch-f.diff @@ -0,0 +1,13 @@ +diff --git a/touch.c b/touch.c +index b957fa5..4217dfb 100644 +--- a/touch.c ++++ b/touch.c +@@ -146,6 +146,8 @@ main(int argc, char *argv[]) + case 'T': + times[0].tv_sec = estrtonum(EARGF(usage()), 0, LLONG_MAX); + break; ++ case 'f': ++ break; + default: + usage(); + } ARGEND