X-Git-Url: https://hackdaworld.org/gitweb/?p=outofuni%2Fdib.git;a=blobdiff_plain;f=build.sh;fp=build.sh;h=703a6048efeca442b879c50cb32fad87e9c407bf;hp=770d170b8e3a44ab9638333ae1a997366b3746b2;hb=8ca5fd464d9ca8192102a0f248f860a70d95ea42;hpb=eb78aa2bc635b01b33bffb87a9d003c23e4518cb diff --git a/build.sh b/build.sh index 770d170..703a604 100755 --- a/build.sh +++ b/build.sh @@ -5,7 +5,7 @@ function check_prereq() { # read config - [ -f ./config.build ] && . ./config.build + [ -f ./build.config ] && . ./build.config # check tc="gcc-`echo $MAKEOPT | sed 's/.*\ CROSS_COMPILE=\(.*\)-.*/\1/'`" deps=0 @@ -34,7 +34,7 @@ function umount_if_mounted() { function build_all { # read config - [ -f ./config.build ] && . ./config.build + [ -f ./build.config ] && . ./build.config # build stage 1 if [ -f .build_stage1 ]; then echo "stage one already done, skipping ..." @@ -69,7 +69,7 @@ function build_all { fi # copy myself cp -v ./build.sh ./rootfs.mnt - cp -v ./config.build ./rootfs.mnt + cp -v ./build.config ./rootfs.mnt if [ ! -f .build_stage2 ]; then # prepare/run second stage modprobe binfmt_misc @@ -90,13 +90,13 @@ function build_all { touch .build_stage2 # cleanup rm -v ./rootfs.mnt/build.sh - rm -v ./rootfs.mnt/config.build + rm -v ./rootfs.mnt/build.config fi } function build_in_chroot { # read config - [ -f ./config.build ] && . ./config.build + [ -f ./build.config ] && . ./build.config # build second stage echo "building debian image, second stage ..." [ -f /debootstrap/debootstrap ] && \ @@ -141,38 +141,111 @@ function build_in_chroot { # function build_uboot() { - [ -f ./config.build ] && . ./config.build - git clone $UBSRC + echo "building u-boot ..." + echo " argv: $@" + nopatch=0 + noget=0 + update=0 + nocheckout=0 + noclean=0 + no2all=0 + while [ "$1" ]; do + case "$1" in + -nopatch) nopatch=1; shift;; + -noget) noget=1; shift;; + -update) update=1; shift;; + -nocheckout) nocheckout=1; shift;; + -noclean) noclean=1; shift;; + -no2all) no2all=1; shift;; + *) shift;; + esac + done + if [ "$no2all" = "1" ]; then + nopatch=1 + noget=1 + nocheckout=1 + noclean=1 + fi + [ -f ./build.config ] && . ./build.config + if [ "$noget" = "0" ]; then + rm -rf u-boot + git clone $UBSRC + fi + if [ "$update" = "1" ]; then + cd u-boot + git pull + cd .. + fi cd u-boot - if [ ! -z "$UBVER" ]; then - git checkout $UBVER + if [ "$nocheckout" = "0" ]; then + if [ ! -z "$UBVER" ]; then + git checkout $UBVER + fi + fi + if [ "$nopatch" = "0" ]; then + if [ ! -z "$UBPATCH" ]; then + for patch in $UBPATCH; do + patch -Nfp1 < ../patches/$patch + done + fi fi - if [ ! -z "$UBPATCH" ]; then - patch -Nfp1 < ../patches/$UBPATCH + if [ "$noclean" = "0" ]; then + make $MAKEOPT distclean fi - make $MAKEOPT distclean make $MAKEOPT $UBCONF make $MAKEOPT cd .. } function build_kernel() { - [ -f ./config.build ] && . ./config.build + nopatch=0 + noget=0 + nohook=0 + noclean=0 + no2all=0 + while [ "$1" ]; do + case "$1" in + -nopatch) nopatch=1; shift;; + -noget) noget=1; shift;; + -nohook) nohook=1; shift;; + -noclean) noclean=1; shift;; + -no2all) no2all=1; shift;; + *) shift;; + esac + done + if [ "$no2all" = "1" ]; then + nopatch=1 + noget=1 + nohook=1 + noclean=1 + fi + [ -f ./build.config ] && . ./build.config KV=`echo $KERVER | awk -F. '{ if($1=="3") print "3.x" else print$1 "." $2 }'` - KERSRC="https://www.kernel.org/pub/linux/kernel/" - KERSRC="$KERSRC/v$KV/linux-${KERVER}.tar.bz2" - wget $KERSRC - tar xfj linux-${KERVER}.tar.bz2 + if [ "$noget" = "0" ]; then + rm -rf linux-${KERVER}* + KERSRC="https://www.kernel.org/pub/linux/kernel/" + KERSRC="$KERSRC/v$KV/linux-${KERVER}.tar.bz2" + wget $KERSRC + tar xfj linux-${KERVER}.tar.bz2 + fi cd linux-$KERVER - if [ ! -z "$KERPATCH" ]; then - patch -Nfp1 < ../patches/$PATCH + if [ "$nopatch" = "0" ]; then + if [ ! -z "$KERPATCH" ]; then + for patch in $KERPATCH; do + patch -Nfp1 < ../patches/$patch + done + fi + fi + if [ "$noclean" = "0" ]; then + make $MAKEOPT mrproper fi - make $MAKEOPT mrproper - if [ ! -z "$KERHOOK" ]; then - $KERHOOK + if [ "$nohook" = "0" ]; then + if [ ! -z "$KERHOOK" ]; then + $KERHOOK + fi fi if [ ! -z "$KERCONF" ]; then make $MAKEOPT $KERCONF @@ -192,24 +265,24 @@ function build_sdcard() { # # configuration -if [ ! -f ./config.build ]; then +if [ ! -f ./build.config ]; then echo "no configuration found, aborting ..." else - . ./config.build + . ./build.config fi # debootstrap if [ -z $1 ]; then check_prereq - build_all > ./build.log 2>&1 + build_all | tee ./build.log 2>&1 elif [ "$1" = "chroot" ]; then - build_in_chroot > ./build_in_chroot.log 2>&1 + build_in_chroot | tee ./build_in_chroot.log 2>&1 elif [ "$1" = "uboot" ]; then check_prereq - build_uboot > ./build_uboot.log 2>&1 + build_uboot $@ | tee ./build_uboot.log 2>&1 elif [ "$1" = "kernel" ]; then check_prereq - build_kernel > ./build_kernel.log 2>&1 + build_kernel $@ | tee ./build_kernel.log 2>&1 else echo "unknown option: '$1'" fi