Gfx Stack Update
[nyanlinux.git] / builders / linux-amd / release.sh
blobde523f217d35f97f32e92b45373080358815eff5
1 #!/bin/sh
2 # we are heading towards a RCS (Reduced Command Set), expect much more verbosity and simplicity
3 printf "NYAN:RELEASE.SH -- START\n" >&2
4 # OUTPUT ON STDOUT THE KERNEL RELEASE
5 nyan_root=$1
6 linux_config=$2
7 patched_linux_dir=$3
9 if test -z "$nyan_root"; then
10 printf 'NYAN:ERROR:missing nyan root\n' >&2
11 exit 1
12 else
13 printf "NYAN:using nyan_root \"$nyan_root\"\n" >&2
15 if test -z "$linux_config"; then
16 printf 'NYAN:ERROR:missing linux_config\n' >&2
17 exit 1
18 else
19 printf "NYAN:using linux_config \"$linux_config\"\n" >&2
21 if test ! -d "$patched_linux_dir"; then
22 printf 'NYAN:ERROR:missing patched linux directory\n' >&2
23 exit 1
24 else
25 printf "NYAN:using patched linux directory \"$patched_linux_dir\"\n" >&2
28 . $nyan_root/conf.sh
29 . $nyan_root/utils.sh
31 cleanup()
33 if test -e /bin/bash.HIDDEN; then
34 printf 'NYAN:detected hidden bash, restoring\n' >&2
35 mv /bin/bash.HIDDEN /bin/bash >&2
37 if test $false_installed; then
38 printf 'NYAN:detected installed /bin/false, removing\n' >&2
39 rm -f /bin/false >&2
41 if test $bracket_installed; then
42 printf 'NYAN:detected installed /bin/[, removing\n' >&2
43 rm -f '/bin/[' >&2
45 rmdir /bin || true >&2
46 printf "NYAN:RELEASE.SH -- END\n" >&2
48 trap cleanup EXIT
49 ################################################################################
50 if test -e /bin/bash;then
51 printf 'NYAN:detected /bin/bash, hidding\n' >&2
52 mv /bin/bash /bin/bash.HIDDEN >&2
54 mkdir -p /bin >&2
55 export PATH="\
56 /opt/toolchains/x64/elf/binutils-gcc/current/bin:\
57 /nyan/make/current/bin:\
58 /nyan/flex/current/bin:\
59 /nyan/bison/current/bin:\
60 $PATH\
62 # linux sdk wants direct sh invocation
63 if ! command -v sh >/dev/null 2>/dev/null; then
64 printf 'NYAN:ERROR:no direct invocation of sh found, linux SDK will fail, exiting\n' >&2
65 exit 1;
67 # linux sdk wants false in /bin
68 if test ! -e /bin/false; then
69 printf 'NYAN:you are missing the false utility in /bin, using the one in PATH\n' >&2
70 find_in_path false
71 if test ! $r; then
72 printf 'NYAN:no false utility found in PATH, linux SDK will fail, exiting\n' >&2
73 exit 1
75 printf 'NYAN:linking %s to /bin/false, will be removed on exiting\n' $r >&2
76 ln -s $r /bin/false >&2
77 false_installed=1
79 if test ! -x /bin/false; then
80 printf 'NYAN:ERROR:/bin/false not executable, linux SDK will fail, exiting\n' >&2
81 exit 1
83 # linux sdk wants [ in /bin
84 if test ! -e '/bin/['; then
85 printf 'NYAN:you are missing the "[" utility in /bin, using "test" in PATH\n' >&2
86 find_in_path test
87 if test ! $r; then
88 printf 'NYAN:ERROR:no test utility found in PATH, linux SDK will fail, exiting\n' >&2
89 exit 1
91 printf 'NYAN:linking %s to /bin/[, will be removed on exiting\n' $r >&2
92 ln -s $r '/bin/[' >&2
93 bracket_installed=1
95 if test ! -x '/bin/['; then
96 printf 'NYAN:ERROR:/bin/[ not executable, linux SDK will fail, exiting\n' >&2
97 exit 1
99 export "KCONFIG_CONFIG=$linux_config"
100 export "HOSTCC=gcc"
101 export "HOSTCFLAGS=-isystem /nyan/glibc/current/include -isystem /nyan/linux-headers/current/include -O2 -pipe -fPIC -static-libgcc"
102 export "HOSTLDFLAGS=-B/nyan/glibc/current/lib -L/nyan/glibc/current/lib -static-libgcc"
103 export ARCH=x86_64
104 cd $patched_linux_dir
105 # HOSTCC environment variable seems ignored, overridding the makefile variable
106 make oldconfig "HOSTCC=$HOSTCC" >&2
107 make -s kernelrelease "HOSTCC=$HOSTCC"
108 make clean >&2