diff --git a/build.sh b/build.sh index c7f3f1c..4533fbb 100755 --- a/build.sh +++ b/build.sh @@ -12,7 +12,7 @@ if [ -z $CC ]; then fi if [ -z $projects ]; then - projects="console-tools coreutils sysutils-linux findutils networking miscutils shell loginutils procps" + projects="init console-tools coreutils sysutils-linux findutils networking miscutils shell loginutils procps" fi #Compile @@ -26,7 +26,7 @@ for project in $projects; do cd $PROJECT_DIR/$i echo " * Compile" $i chmod -v +x build.sh - env CC=$CC CFLAGS="$CFLAGS -I$PROJECT_DIR -I$PROJECT_DIR/include/libmu -lm" OUTPUT="-o $PROJECT_DIR"/bin/$(basename $i) ./build.sh + env CC=$CC CFLAGS="$CFLAGS -I$PROJECT_DIR -I$PROJECT_DIR/include/libmu -lm" OUTPUT="$PROJECT_DIR"/bin/ ./build.sh cd $PROJECT_DIR done echo diff --git a/config.h b/config.h index 75c5e0e..2462657 100644 --- a/config.h +++ b/config.h @@ -28,6 +28,13 @@ #define LS_FIFO_COLOR LS_LINK_COLOR #define LS_EXE_COLOR "\033[1;32m" +/* Init scripts */ +#ifdef INIT +char *INIT_POWEROFF[] = {"/etc/rc.poweroff"}; +char *INIT_START[] = {"/etc/rc.init"}; +#define INIT_MSG "Starting micro-init..." +#endif + /* Max args (xargs) */ #define NARGS 1024 diff --git a/configs/passwd b/configs/passwd new file mode 100644 index 0000000..013ee3d --- /dev/null +++ b/configs/passwd @@ -0,0 +1,2 @@ +root::0:0:root:/usr/root:/bin/sh +nobody:*:65534:65534:nobody:/nonexistent:/bin/false diff --git a/configs/rc.init b/configs/rc.init new file mode 100755 index 0000000..a6c175d --- /dev/null +++ b/configs/rc.init @@ -0,0 +1,9 @@ +#!/bin/sh +echo "Mounting.." +mount -t proc /proc +mount -t sysfs /sys +mount -t devtmpfs /dev +mount -t tmpfs /tmp + +echo "Starting shell..." +sh diff --git a/configs/rc.poweroff b/configs/rc.poweroff new file mode 100755 index 0000000..34a3778 --- /dev/null +++ b/configs/rc.poweroff @@ -0,0 +1,8 @@ +#!/bin/sh +echo "Umounting..." +umount /proc +umount /sys +umount /dev +umount /tmp + +echo "Poweroff..." diff --git a/configs/resolv.conf b/configs/resolv.conf new file mode 100644 index 0000000..54ae34b --- /dev/null +++ b/configs/resolv.conf @@ -0,0 +1 @@ +nameserver 192.168.0.1 diff --git a/src/console-tools/clear/build.sh b/src/console-tools/clear/build.sh index 3b2db38..6d8974b 100755 --- a/src/console-tools/clear/build.sh +++ b/src/console-tools/clear/build.sh @@ -1,2 +1,3 @@ #!/bin/sh -echo ./*.c $CFLAGS $OUTPUT | xargs $CC +project_dir=$(pwd) +echo ./*.c $CFLAGS -o $OUTPUT$(basename $project_dir) | xargs $CC diff --git a/src/console-tools/reset/build.sh b/src/console-tools/reset/build.sh index 3b2db38..6d8974b 100755 --- a/src/console-tools/reset/build.sh +++ b/src/console-tools/reset/build.sh @@ -1,2 +1,3 @@ #!/bin/sh -echo ./*.c $CFLAGS $OUTPUT | xargs $CC +project_dir=$(pwd) +echo ./*.c $CFLAGS -o $OUTPUT$(basename $project_dir) | xargs $CC diff --git a/src/coreutils/basename/build.sh b/src/coreutils/basename/build.sh index 3b2db38..6d8974b 100755 --- a/src/coreutils/basename/build.sh +++ b/src/coreutils/basename/build.sh @@ -1,2 +1,3 @@ #!/bin/sh -echo ./*.c $CFLAGS $OUTPUT | xargs $CC +project_dir=$(pwd) +echo ./*.c $CFLAGS -o $OUTPUT$(basename $project_dir) | xargs $CC diff --git a/src/coreutils/cat/build.sh b/src/coreutils/cat/build.sh index 3b2db38..6d8974b 100755 --- a/src/coreutils/cat/build.sh +++ b/src/coreutils/cat/build.sh @@ -1,2 +1,3 @@ #!/bin/sh -echo ./*.c $CFLAGS $OUTPUT | xargs $CC +project_dir=$(pwd) +echo ./*.c $CFLAGS -o $OUTPUT$(basename $project_dir) | xargs $CC diff --git a/src/coreutils/chgrp/build.sh b/src/coreutils/chgrp/build.sh index 3b2db38..6d8974b 100755 --- a/src/coreutils/chgrp/build.sh +++ b/src/coreutils/chgrp/build.sh @@ -1,2 +1,3 @@ #!/bin/sh -echo ./*.c $CFLAGS $OUTPUT | xargs $CC +project_dir=$(pwd) +echo ./*.c $CFLAGS -o $OUTPUT$(basename $project_dir) | xargs $CC diff --git a/src/coreutils/chmod/build.sh b/src/coreutils/chmod/build.sh index 3b2db38..6d8974b 100755 --- a/src/coreutils/chmod/build.sh +++ b/src/coreutils/chmod/build.sh @@ -1,2 +1,3 @@ #!/bin/sh -echo ./*.c $CFLAGS $OUTPUT | xargs $CC +project_dir=$(pwd) +echo ./*.c $CFLAGS -o $OUTPUT$(basename $project_dir) | xargs $CC diff --git a/src/coreutils/chown/build.sh b/src/coreutils/chown/build.sh index 3b2db38..6d8974b 100755 --- a/src/coreutils/chown/build.sh +++ b/src/coreutils/chown/build.sh @@ -1,2 +1,3 @@ #!/bin/sh -echo ./*.c $CFLAGS $OUTPUT | xargs $CC +project_dir=$(pwd) +echo ./*.c $CFLAGS -o $OUTPUT$(basename $project_dir) | xargs $CC diff --git a/src/coreutils/chroot/build.sh b/src/coreutils/chroot/build.sh index 3b2db38..6d8974b 100755 --- a/src/coreutils/chroot/build.sh +++ b/src/coreutils/chroot/build.sh @@ -1,2 +1,3 @@ #!/bin/sh -echo ./*.c $CFLAGS $OUTPUT | xargs $CC +project_dir=$(pwd) +echo ./*.c $CFLAGS -o $OUTPUT$(basename $project_dir) | xargs $CC diff --git a/src/coreutils/cmp/build.sh b/src/coreutils/cmp/build.sh index 3b2db38..6d8974b 100755 --- a/src/coreutils/cmp/build.sh +++ b/src/coreutils/cmp/build.sh @@ -1,2 +1,3 @@ #!/bin/sh -echo ./*.c $CFLAGS $OUTPUT | xargs $CC +project_dir=$(pwd) +echo ./*.c $CFLAGS -o $OUTPUT$(basename $project_dir) | xargs $CC diff --git a/src/coreutils/cp/build.sh b/src/coreutils/cp/build.sh index 3b2db38..6d8974b 100755 --- a/src/coreutils/cp/build.sh +++ b/src/coreutils/cp/build.sh @@ -1,2 +1,3 @@ #!/bin/sh -echo ./*.c $CFLAGS $OUTPUT | xargs $CC +project_dir=$(pwd) +echo ./*.c $CFLAGS -o $OUTPUT$(basename $project_dir) | xargs $CC diff --git a/src/coreutils/dirname/build.sh b/src/coreutils/dirname/build.sh index 3b2db38..6d8974b 100755 --- a/src/coreutils/dirname/build.sh +++ b/src/coreutils/dirname/build.sh @@ -1,2 +1,3 @@ #!/bin/sh -echo ./*.c $CFLAGS $OUTPUT | xargs $CC +project_dir=$(pwd) +echo ./*.c $CFLAGS -o $OUTPUT$(basename $project_dir) | xargs $CC diff --git a/src/coreutils/du/build.sh b/src/coreutils/du/build.sh index 3b2db38..6d8974b 100755 --- a/src/coreutils/du/build.sh +++ b/src/coreutils/du/build.sh @@ -1,2 +1,3 @@ #!/bin/sh -echo ./*.c $CFLAGS $OUTPUT | xargs $CC +project_dir=$(pwd) +echo ./*.c $CFLAGS -o $OUTPUT$(basename $project_dir) | xargs $CC diff --git a/src/coreutils/echo/build.sh b/src/coreutils/echo/build.sh index 3b2db38..6d8974b 100755 --- a/src/coreutils/echo/build.sh +++ b/src/coreutils/echo/build.sh @@ -1,2 +1,3 @@ #!/bin/sh -echo ./*.c $CFLAGS $OUTPUT | xargs $CC +project_dir=$(pwd) +echo ./*.c $CFLAGS -o $OUTPUT$(basename $project_dir) | xargs $CC diff --git a/src/coreutils/echo/echo.c b/src/coreutils/echo/echo.c index e26e766..ad8e362 100644 --- a/src/coreutils/echo/echo.c +++ b/src/coreutils/echo/echo.c @@ -64,7 +64,6 @@ void format(char *str) { int main(int argc, char **argv) { unsigned int n_flag = 0; - int i; for (i = 1; i < argc; i++) { if (argv[i][0] != '-') diff --git a/src/coreutils/env/build.sh b/src/coreutils/env/build.sh index 3b2db38..6d8974b 100755 --- a/src/coreutils/env/build.sh +++ b/src/coreutils/env/build.sh @@ -1,2 +1,3 @@ #!/bin/sh -echo ./*.c $CFLAGS $OUTPUT | xargs $CC +project_dir=$(pwd) +echo ./*.c $CFLAGS -o $OUTPUT$(basename $project_dir) | xargs $CC diff --git a/src/coreutils/false/build.sh b/src/coreutils/false/build.sh index 3b2db38..6d8974b 100755 --- a/src/coreutils/false/build.sh +++ b/src/coreutils/false/build.sh @@ -1,2 +1,3 @@ #!/bin/sh -echo ./*.c $CFLAGS $OUTPUT | xargs $CC +project_dir=$(pwd) +echo ./*.c $CFLAGS -o $OUTPUT$(basename $project_dir) | xargs $CC diff --git a/src/coreutils/head/build.sh b/src/coreutils/head/build.sh index 3b2db38..6d8974b 100755 --- a/src/coreutils/head/build.sh +++ b/src/coreutils/head/build.sh @@ -1,2 +1,3 @@ #!/bin/sh -echo ./*.c $CFLAGS $OUTPUT | xargs $CC +project_dir=$(pwd) +echo ./*.c $CFLAGS -o $OUTPUT$(basename $project_dir) | xargs $CC diff --git a/src/coreutils/id/build.sh b/src/coreutils/id/build.sh index 3b2db38..6d8974b 100755 --- a/src/coreutils/id/build.sh +++ b/src/coreutils/id/build.sh @@ -1,2 +1,3 @@ #!/bin/sh -echo ./*.c $CFLAGS $OUTPUT | xargs $CC +project_dir=$(pwd) +echo ./*.c $CFLAGS -o $OUTPUT$(basename $project_dir) | xargs $CC diff --git a/src/coreutils/ln/build.sh b/src/coreutils/ln/build.sh index 3b2db38..6d8974b 100755 --- a/src/coreutils/ln/build.sh +++ b/src/coreutils/ln/build.sh @@ -1,2 +1,3 @@ #!/bin/sh -echo ./*.c $CFLAGS $OUTPUT | xargs $CC +project_dir=$(pwd) +echo ./*.c $CFLAGS -o $OUTPUT$(basename $project_dir) | xargs $CC diff --git a/src/coreutils/logname/build.sh b/src/coreutils/logname/build.sh index 3b2db38..6d8974b 100755 --- a/src/coreutils/logname/build.sh +++ b/src/coreutils/logname/build.sh @@ -1,2 +1,3 @@ #!/bin/sh -echo ./*.c $CFLAGS $OUTPUT | xargs $CC +project_dir=$(pwd) +echo ./*.c $CFLAGS -o $OUTPUT$(basename $project_dir) | xargs $CC diff --git a/src/coreutils/ls/build.sh b/src/coreutils/ls/build.sh index 3b2db38..6d8974b 100755 --- a/src/coreutils/ls/build.sh +++ b/src/coreutils/ls/build.sh @@ -1,2 +1,3 @@ #!/bin/sh -echo ./*.c $CFLAGS $OUTPUT | xargs $CC +project_dir=$(pwd) +echo ./*.c $CFLAGS -o $OUTPUT$(basename $project_dir) | xargs $CC diff --git a/src/coreutils/mkdir/build.sh b/src/coreutils/mkdir/build.sh index 3b2db38..6d8974b 100755 --- a/src/coreutils/mkdir/build.sh +++ b/src/coreutils/mkdir/build.sh @@ -1,2 +1,3 @@ #!/bin/sh -echo ./*.c $CFLAGS $OUTPUT | xargs $CC +project_dir=$(pwd) +echo ./*.c $CFLAGS -o $OUTPUT$(basename $project_dir) | xargs $CC diff --git a/src/coreutils/mkfifo/build.sh b/src/coreutils/mkfifo/build.sh index 3b2db38..6d8974b 100755 --- a/src/coreutils/mkfifo/build.sh +++ b/src/coreutils/mkfifo/build.sh @@ -1,2 +1,3 @@ #!/bin/sh -echo ./*.c $CFLAGS $OUTPUT | xargs $CC +project_dir=$(pwd) +echo ./*.c $CFLAGS -o $OUTPUT$(basename $project_dir) | xargs $CC diff --git a/src/coreutils/mknod/build.sh b/src/coreutils/mknod/build.sh index 3b2db38..6d8974b 100755 --- a/src/coreutils/mknod/build.sh +++ b/src/coreutils/mknod/build.sh @@ -1,2 +1,3 @@ #!/bin/sh -echo ./*.c $CFLAGS $OUTPUT | xargs $CC +project_dir=$(pwd) +echo ./*.c $CFLAGS -o $OUTPUT$(basename $project_dir) | xargs $CC diff --git a/src/coreutils/mktemp/build.sh b/src/coreutils/mktemp/build.sh index 3b2db38..6d8974b 100755 --- a/src/coreutils/mktemp/build.sh +++ b/src/coreutils/mktemp/build.sh @@ -1,2 +1,3 @@ #!/bin/sh -echo ./*.c $CFLAGS $OUTPUT | xargs $CC +project_dir=$(pwd) +echo ./*.c $CFLAGS -o $OUTPUT$(basename $project_dir) | xargs $CC diff --git a/src/coreutils/mv/build.sh b/src/coreutils/mv/build.sh index 3b2db38..6d8974b 100755 --- a/src/coreutils/mv/build.sh +++ b/src/coreutils/mv/build.sh @@ -1,2 +1,3 @@ #!/bin/sh -echo ./*.c $CFLAGS $OUTPUT | xargs $CC +project_dir=$(pwd) +echo ./*.c $CFLAGS -o $OUTPUT$(basename $project_dir) | xargs $CC diff --git a/src/coreutils/nice/build.sh b/src/coreutils/nice/build.sh index 3b2db38..6d8974b 100755 --- a/src/coreutils/nice/build.sh +++ b/src/coreutils/nice/build.sh @@ -1,2 +1,3 @@ #!/bin/sh -echo ./*.c $CFLAGS $OUTPUT | xargs $CC +project_dir=$(pwd) +echo ./*.c $CFLAGS -o $OUTPUT$(basename $project_dir) | xargs $CC diff --git a/src/coreutils/nl/build.sh b/src/coreutils/nl/build.sh index 3b2db38..6d8974b 100755 --- a/src/coreutils/nl/build.sh +++ b/src/coreutils/nl/build.sh @@ -1,2 +1,3 @@ #!/bin/sh -echo ./*.c $CFLAGS $OUTPUT | xargs $CC +project_dir=$(pwd) +echo ./*.c $CFLAGS -o $OUTPUT$(basename $project_dir) | xargs $CC diff --git a/src/coreutils/nohup/build.sh b/src/coreutils/nohup/build.sh index 3b2db38..6d8974b 100755 --- a/src/coreutils/nohup/build.sh +++ b/src/coreutils/nohup/build.sh @@ -1,2 +1,3 @@ #!/bin/sh -echo ./*.c $CFLAGS $OUTPUT | xargs $CC +project_dir=$(pwd) +echo ./*.c $CFLAGS -o $OUTPUT$(basename $project_dir) | xargs $CC diff --git a/src/coreutils/nproc/build.sh b/src/coreutils/nproc/build.sh index 3b2db38..6d8974b 100755 --- a/src/coreutils/nproc/build.sh +++ b/src/coreutils/nproc/build.sh @@ -1,2 +1,3 @@ #!/bin/sh -echo ./*.c $CFLAGS $OUTPUT | xargs $CC +project_dir=$(pwd) +echo ./*.c $CFLAGS -o $OUTPUT$(basename $project_dir) | xargs $CC diff --git a/src/coreutils/printenv/build.sh b/src/coreutils/printenv/build.sh index 3b2db38..6d8974b 100755 --- a/src/coreutils/printenv/build.sh +++ b/src/coreutils/printenv/build.sh @@ -1,2 +1,3 @@ #!/bin/sh -echo ./*.c $CFLAGS $OUTPUT | xargs $CC +project_dir=$(pwd) +echo ./*.c $CFLAGS -o $OUTPUT$(basename $project_dir) | xargs $CC diff --git a/src/coreutils/pwd/build.sh b/src/coreutils/pwd/build.sh index 3b2db38..6d8974b 100755 --- a/src/coreutils/pwd/build.sh +++ b/src/coreutils/pwd/build.sh @@ -1,2 +1,3 @@ #!/bin/sh -echo ./*.c $CFLAGS $OUTPUT | xargs $CC +project_dir=$(pwd) +echo ./*.c $CFLAGS -o $OUTPUT$(basename $project_dir) | xargs $CC diff --git a/src/coreutils/renice/build.sh b/src/coreutils/renice/build.sh index 3b2db38..6d8974b 100755 --- a/src/coreutils/renice/build.sh +++ b/src/coreutils/renice/build.sh @@ -1,2 +1,3 @@ #!/bin/sh -echo ./*.c $CFLAGS $OUTPUT | xargs $CC +project_dir=$(pwd) +echo ./*.c $CFLAGS -o $OUTPUT$(basename $project_dir) | xargs $CC diff --git a/src/coreutils/rev/build.sh b/src/coreutils/rev/build.sh index 3b2db38..6d8974b 100755 --- a/src/coreutils/rev/build.sh +++ b/src/coreutils/rev/build.sh @@ -1,2 +1,3 @@ #!/bin/sh -echo ./*.c $CFLAGS $OUTPUT | xargs $CC +project_dir=$(pwd) +echo ./*.c $CFLAGS -o $OUTPUT$(basename $project_dir) | xargs $CC diff --git a/src/coreutils/rm/build.sh b/src/coreutils/rm/build.sh index 3b2db38..6d8974b 100755 --- a/src/coreutils/rm/build.sh +++ b/src/coreutils/rm/build.sh @@ -1,2 +1,3 @@ #!/bin/sh -echo ./*.c $CFLAGS $OUTPUT | xargs $CC +project_dir=$(pwd) +echo ./*.c $CFLAGS -o $OUTPUT$(basename $project_dir) | xargs $CC diff --git a/src/coreutils/seq/build.sh b/src/coreutils/seq/build.sh index 3b2db38..6d8974b 100755 --- a/src/coreutils/seq/build.sh +++ b/src/coreutils/seq/build.sh @@ -1,2 +1,3 @@ #!/bin/sh -echo ./*.c $CFLAGS $OUTPUT | xargs $CC +project_dir=$(pwd) +echo ./*.c $CFLAGS -o $OUTPUT$(basename $project_dir) | xargs $CC diff --git a/src/coreutils/shred/build.sh b/src/coreutils/shred/build.sh index 3b2db38..6d8974b 100755 --- a/src/coreutils/shred/build.sh +++ b/src/coreutils/shred/build.sh @@ -1,2 +1,3 @@ #!/bin/sh -echo ./*.c $CFLAGS $OUTPUT | xargs $CC +project_dir=$(pwd) +echo ./*.c $CFLAGS -o $OUTPUT$(basename $project_dir) | xargs $CC diff --git a/src/coreutils/sleep/build.sh b/src/coreutils/sleep/build.sh index 3b2db38..6d8974b 100755 --- a/src/coreutils/sleep/build.sh +++ b/src/coreutils/sleep/build.sh @@ -1,2 +1,3 @@ #!/bin/sh -echo ./*.c $CFLAGS $OUTPUT | xargs $CC +project_dir=$(pwd) +echo ./*.c $CFLAGS -o $OUTPUT$(basename $project_dir) | xargs $CC diff --git a/src/coreutils/sync/build.sh b/src/coreutils/sync/build.sh index 3b2db38..6d8974b 100755 --- a/src/coreutils/sync/build.sh +++ b/src/coreutils/sync/build.sh @@ -1,2 +1,3 @@ #!/bin/sh -echo ./*.c $CFLAGS $OUTPUT | xargs $CC +project_dir=$(pwd) +echo ./*.c $CFLAGS -o $OUTPUT$(basename $project_dir) | xargs $CC diff --git a/src/coreutils/tee/build.sh b/src/coreutils/tee/build.sh index 3b2db38..6d8974b 100755 --- a/src/coreutils/tee/build.sh +++ b/src/coreutils/tee/build.sh @@ -1,2 +1,3 @@ #!/bin/sh -echo ./*.c $CFLAGS $OUTPUT | xargs $CC +project_dir=$(pwd) +echo ./*.c $CFLAGS -o $OUTPUT$(basename $project_dir) | xargs $CC diff --git a/src/coreutils/time/build.sh b/src/coreutils/time/build.sh index 3b2db38..6d8974b 100755 --- a/src/coreutils/time/build.sh +++ b/src/coreutils/time/build.sh @@ -1,2 +1,3 @@ #!/bin/sh -echo ./*.c $CFLAGS $OUTPUT | xargs $CC +project_dir=$(pwd) +echo ./*.c $CFLAGS -o $OUTPUT$(basename $project_dir) | xargs $CC diff --git a/src/coreutils/touch/build.sh b/src/coreutils/touch/build.sh index 3b2db38..6d8974b 100755 --- a/src/coreutils/touch/build.sh +++ b/src/coreutils/touch/build.sh @@ -1,2 +1,3 @@ #!/bin/sh -echo ./*.c $CFLAGS $OUTPUT | xargs $CC +project_dir=$(pwd) +echo ./*.c $CFLAGS -o $OUTPUT$(basename $project_dir) | xargs $CC diff --git a/src/coreutils/true/build.sh b/src/coreutils/true/build.sh index 3b2db38..6d8974b 100755 --- a/src/coreutils/true/build.sh +++ b/src/coreutils/true/build.sh @@ -1,2 +1,3 @@ #!/bin/sh -echo ./*.c $CFLAGS $OUTPUT | xargs $CC +project_dir=$(pwd) +echo ./*.c $CFLAGS -o $OUTPUT$(basename $project_dir) | xargs $CC diff --git a/src/coreutils/tty/build.sh b/src/coreutils/tty/build.sh index 3b2db38..6d8974b 100755 --- a/src/coreutils/tty/build.sh +++ b/src/coreutils/tty/build.sh @@ -1,2 +1,3 @@ #!/bin/sh -echo ./*.c $CFLAGS $OUTPUT | xargs $CC +project_dir=$(pwd) +echo ./*.c $CFLAGS -o $OUTPUT$(basename $project_dir) | xargs $CC diff --git a/src/coreutils/uname/build.sh b/src/coreutils/uname/build.sh index 3b2db38..6d8974b 100755 --- a/src/coreutils/uname/build.sh +++ b/src/coreutils/uname/build.sh @@ -1,2 +1,3 @@ #!/bin/sh -echo ./*.c $CFLAGS $OUTPUT | xargs $CC +project_dir=$(pwd) +echo ./*.c $CFLAGS -o $OUTPUT$(basename $project_dir) | xargs $CC diff --git a/src/coreutils/wc/build.sh b/src/coreutils/wc/build.sh index 3b2db38..6d8974b 100755 --- a/src/coreutils/wc/build.sh +++ b/src/coreutils/wc/build.sh @@ -1,2 +1,3 @@ #!/bin/sh -echo ./*.c $CFLAGS $OUTPUT | xargs $CC +project_dir=$(pwd) +echo ./*.c $CFLAGS -o $OUTPUT$(basename $project_dir) | xargs $CC diff --git a/src/coreutils/wc/wc.c b/src/coreutils/wc/wc.c index e0180c8..9b64621 100644 --- a/src/coreutils/wc/wc.c +++ b/src/coreutils/wc/wc.c @@ -113,7 +113,7 @@ int main(int argc, char **argv) { else { int fd = open(argv[i], O_RDONLY); if (fd < 0) { - fprintf(stderr, "wc: %s\n", strerror(errno)); + fprintf(stderr, "wc: %s: %s\n", argv[i], strerror(errno)); return 1; } diff --git a/src/coreutils/whoami/build.sh b/src/coreutils/whoami/build.sh index 3b2db38..6d8974b 100755 --- a/src/coreutils/whoami/build.sh +++ b/src/coreutils/whoami/build.sh @@ -1,2 +1,3 @@ #!/bin/sh -echo ./*.c $CFLAGS $OUTPUT | xargs $CC +project_dir=$(pwd) +echo ./*.c $CFLAGS -o $OUTPUT$(basename $project_dir) | xargs $CC diff --git a/src/coreutils/yes/build.sh b/src/coreutils/yes/build.sh index 3b2db38..6d8974b 100755 --- a/src/coreutils/yes/build.sh +++ b/src/coreutils/yes/build.sh @@ -1,2 +1,3 @@ #!/bin/sh -echo ./*.c $CFLAGS $OUTPUT | xargs $CC +project_dir=$(pwd) +echo ./*.c $CFLAGS -o $OUTPUT$(basename $project_dir) | xargs $CC diff --git a/src/findutils/xargs/build.sh b/src/findutils/xargs/build.sh index 3b2db38..6d8974b 100755 --- a/src/findutils/xargs/build.sh +++ b/src/findutils/xargs/build.sh @@ -1,2 +1,3 @@ #!/bin/sh -echo ./*.c $CFLAGS $OUTPUT | xargs $CC +project_dir=$(pwd) +echo ./*.c $CFLAGS -o $OUTPUT$(basename $project_dir) | xargs $CC diff --git a/src/init/init/build.sh b/src/init/init/build.sh new file mode 100755 index 0000000..2b3bbae --- /dev/null +++ b/src/init/init/build.sh @@ -0,0 +1,5 @@ +#!/bin/sh +project_dir=$(pwd) +echo ./*.c $CFLAGS -o $OUTPUT$(basename $project_dir) | xargs $CC +mv reboot $OUTPUT/reboot +mv poweroff $OUTPUT/poweroff diff --git a/src/init/init/init.c b/src/init/init/init.c new file mode 100644 index 0000000..d38d6be --- /dev/null +++ b/src/init/init/init.c @@ -0,0 +1,68 @@ +#define INIT +#include +#include +#include +#include +#include +#include +#include +#include +#include "config.h" + +void poweroff(int sig) { + printf("Syncing...\n"); + sync(); + + if (sig == SIGUSR1) + reboot(RB_POWER_OFF); + + else if (sig == SIGKILL) + reboot(RB_AUTOBOOT); +} + +void execute(char *argv[], sigset_t *set) { + pid_t pid; + if ((pid = fork()) == 0) { + sigprocmask(SIG_UNBLOCK, set, NULL); + setsid(); + execvp(argv[0], argv); + + fprintf(stderr, "init: %s\n", strerror(errno)); + exit(1); + } + + int status = 0; + waitpid(pid, &status, 0); + + if (status != 0) { + fprintf(stderr, "init: Init script returned %d\nRebooting...", status); + poweroff(SIGKILL); + } +} + +int main(void) { + if (getpid() != 1) { + fprintf(stderr, "init: PID Must be 1\n"); + return 1; + } + + chdir("/"); + printf("%s\n", INIT_MSG); + + /* Start main service */ + sigset_t set; + sigprocmask(SIG_BLOCK, &set, NULL); + execute(INIT_START, &set); + + /* Sig handler */ + int sig = 0; + while (1) { + if (sigwait(&set, &sig) == 0) + if (sig == SIGKILL || sig == SIGUSR1) { + execute(INIT_POWEROFF, &set); + poweroff(sig); + } + } + + return 0; +} diff --git a/src/loginutils/nologin/build.sh b/src/loginutils/nologin/build.sh index 3b2db38..6d8974b 100755 --- a/src/loginutils/nologin/build.sh +++ b/src/loginutils/nologin/build.sh @@ -1,2 +1,3 @@ #!/bin/sh -echo ./*.c $CFLAGS $OUTPUT | xargs $CC +project_dir=$(pwd) +echo ./*.c $CFLAGS -o $OUTPUT$(basename $project_dir) | xargs $CC diff --git a/src/miscutils/spark/build.sh b/src/miscutils/spark/build.sh index 3b2db38..6d8974b 100755 --- a/src/miscutils/spark/build.sh +++ b/src/miscutils/spark/build.sh @@ -1,2 +1,3 @@ #!/bin/sh -echo ./*.c $CFLAGS $OUTPUT | xargs $CC +project_dir=$(pwd) +echo ./*.c $CFLAGS -o $OUTPUT$(basename $project_dir) | xargs $CC diff --git a/src/networking/hostname/build.sh b/src/networking/hostname/build.sh index 3b2db38..6d8974b 100755 --- a/src/networking/hostname/build.sh +++ b/src/networking/hostname/build.sh @@ -1,2 +1,3 @@ #!/bin/sh -echo ./*.c $CFLAGS $OUTPUT | xargs $CC +project_dir=$(pwd) +echo ./*.c $CFLAGS -o $OUTPUT$(basename $project_dir) | xargs $CC diff --git a/src/networking/nc/build.sh b/src/networking/nc/build.sh index 3b2db38..6d8974b 100755 --- a/src/networking/nc/build.sh +++ b/src/networking/nc/build.sh @@ -1,2 +1,3 @@ #!/bin/sh -echo ./*.c $CFLAGS $OUTPUT | xargs $CC +project_dir=$(pwd) +echo ./*.c $CFLAGS -o $OUTPUT$(basename $project_dir) | xargs $CC diff --git a/src/procps/kill/build.sh b/src/procps/kill/build.sh index 3b2db38..6d8974b 100755 --- a/src/procps/kill/build.sh +++ b/src/procps/kill/build.sh @@ -1,2 +1,3 @@ #!/bin/sh -echo ./*.c $CFLAGS $OUTPUT | xargs $CC +project_dir=$(pwd) +echo ./*.c $CFLAGS -o $OUTPUT$(basename $project_dir) | xargs $CC diff --git a/src/procps/uptime/build.sh b/src/procps/uptime/build.sh index 3b2db38..6d8974b 100755 --- a/src/procps/uptime/build.sh +++ b/src/procps/uptime/build.sh @@ -1,2 +1,3 @@ #!/bin/sh -echo ./*.c $CFLAGS $OUTPUT | xargs $CC +project_dir=$(pwd) +echo ./*.c $CFLAGS -o $OUTPUT$(basename $project_dir) | xargs $CC diff --git a/src/shell/rc/build.sh b/src/shell/rc/build.sh index 3b2db38..f72abe8 100755 --- a/src/shell/rc/build.sh +++ b/src/shell/rc/build.sh @@ -1,2 +1,3 @@ #!/bin/sh -echo ./*.c $CFLAGS $OUTPUT | xargs $CC +echo ./*.c $CFLAGS -o rc | xargs $CC +mv rc $OUTPUT/sh diff --git a/src/sysutils-linux/dmesg/build.sh b/src/sysutils-linux/dmesg/build.sh index 3b2db38..6d8974b 100755 --- a/src/sysutils-linux/dmesg/build.sh +++ b/src/sysutils-linux/dmesg/build.sh @@ -1,2 +1,3 @@ #!/bin/sh -echo ./*.c $CFLAGS $OUTPUT | xargs $CC +project_dir=$(pwd) +echo ./*.c $CFLAGS -o $OUTPUT$(basename $project_dir) | xargs $CC diff --git a/src/sysutils-linux/mount/build.sh b/src/sysutils-linux/mount/build.sh index 3b2db38..6d8974b 100755 --- a/src/sysutils-linux/mount/build.sh +++ b/src/sysutils-linux/mount/build.sh @@ -1,2 +1,3 @@ #!/bin/sh -echo ./*.c $CFLAGS $OUTPUT | xargs $CC +project_dir=$(pwd) +echo ./*.c $CFLAGS -o $OUTPUT$(basename $project_dir) | xargs $CC diff --git a/src/sysutils-linux/pivot_root/build.sh b/src/sysutils-linux/pivot_root/build.sh index 3b2db38..6d8974b 100755 --- a/src/sysutils-linux/pivot_root/build.sh +++ b/src/sysutils-linux/pivot_root/build.sh @@ -1,2 +1,3 @@ #!/bin/sh -echo ./*.c $CFLAGS $OUTPUT | xargs $CC +project_dir=$(pwd) +echo ./*.c $CFLAGS -o $OUTPUT$(basename $project_dir) | xargs $CC diff --git a/src/sysutils-linux/umount/build.sh b/src/sysutils-linux/umount/build.sh index 3b2db38..6d8974b 100755 --- a/src/sysutils-linux/umount/build.sh +++ b/src/sysutils-linux/umount/build.sh @@ -1,2 +1,3 @@ #!/bin/sh -echo ./*.c $CFLAGS $OUTPUT | xargs $CC +project_dir=$(pwd) +echo ./*.c $CFLAGS -o $OUTPUT$(basename $project_dir) | xargs $CC