#!/bin/bash ############################################################################### # # # IPFire.org - A linux based firewall # # Copyright (C) 2008 Michael Tremer & Christian Schmidt # # # # This program is free software: you can redistribute it and/or modify # # it under the terms of the GNU General Public License as published by # # the Free Software Foundation, either version 3 of the License, or # # (at your option) any later version. # # # # This program is distributed in the hope that it will be useful, # # but WITHOUT ANY WARRANTY; without even the implied warranty of # # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # # GNU General Public License for more details. # # # # You should have received a copy of the GNU General Public License # # along with this program. If not, see . # # # ############################################################################### usage() { cat doc/make.sh-usage exit 1 } case "$1" in build) # check for prerequisites check_build # check for sanity of code check_sanity # compile the distro right now build # beeps when finished echo -ne '\a' ;; shell) shift # enter a shell inside LFS chroot # may be used to change kernel settings prepareenv entershell $@ ;; batch) # build the distro in background case "$2" in cron) cron_run ;; start) batch_start $3 ;; _run) batch_run ;; attach|watch) batch_attach ;; *) usage ;; esac ;; buildspy|bs) # control buildspy case "$2" in start) build_spy start ;; stop) build_spy exit ;; *) usage ;; esac ;; ccache) # ccache options case "$2" in stats) ccache_stats ;; esac ;; config) # config options case "$2" in kernel) prepareenv entershell bash /usr/src/src/scripts/edit-kernel-config ;; *) usage ;; esac ;; distcc|distccd) # distcc(d) commands case "$2" in start) distccd_start ;; stop) distccd_stop ;; restart) distccd_restart ;; stats|mon) distcc_mon ;; esac ;; clean) for i in $(mount | grep $BASEDIR | cut -d " " -f 1); do umount $i done stdumount WHAT=${TARGET} [ "$2" = "--all" ] && WHAT="${POSSIBLE_TARGETS}" for i in ${WHAT}; do echo -ne "Cleaning ${BOLD}$i${NORMAL} buildtree" rm -rf $BASEDIR/build_$i rm -rf $BASEDIR/log_$i rm -rf $BASEDIR/packages_$i beautify message DONE done echo -ne "Removing ${BOLD}general files${NORMAL}" rm -f $FAILED $RUNNING 2>/dev/null beautify message DONE ;; source|src) LOGFILE=$BASEDIR/log_${TARGET}/_build.00-preparation.log case "$2" in get|pull|download) getsource ;; put|push|upload) putsource ;; list) pkg_list_packages | tee -a $BASEDIR/doc/packages-list.txt ;; esac ;; toolchain) case "$2" in get|pull|download) gettoolchain ;; put|push|upload) puttoolchain ;; ""|-*) prepareenv # Check if host can build the toolchain check_toolchain toolchain_build stdumount echo -ne "\ntarball creation " [ -d $BASEDIR/cache/toolchains ] || mkdir $BASEDIR/cache/toolchains cd $BASEDIR && tar cj --exclude='log_${TARGET}/_build.*.log' \ --file=cache/toolchains/$TOOLCHAINNAME.tar.bz2 \ build_${TARGET} log_${TARGET} >> $LOGFILE beautify message DONE echo `ls -sh cache/toolchains/$TOOLCHAINNAME.tar.bz2` stdumount [ "$2" = "--put" ] && puttoolchain ;; *) usage ;; esac ;; toolchains) for i in $(check_supported_targets); do TARGET=$i $0 clean TARGET=$i $0 toolchain --put done ;; target) case "$2" in put|push|upload) puttarget ;; *) usage ;; esac ;; check) case "$2" in cpu) [ -z "$3" ] && usage if check_cpu $3; then echo -n "CPU has flag $3" beautify message DONE else dialogerror "CPU hasn't got flag $3" exit 1 fi ;; sanity) check_sanity $3 ;; target*) check_supported_targets ;; *) usage ;; esac ;; g[iu]t) COMMAND=$2 shift 2 case "$COMMAND" in update|pull) git_pull $* ;; commit|ci) git_commit $* ;; dist|export|archive) git_export $* ;; push) git_push $* ;; diff|di) git_diff $* ;; log) git_log $* ;; gc) git_gc ;; shortlog|slog) git_shortlog ;; put-key) ssh_cert $* ;; *) # If no command matches run git directly git $* ;; esac ;; package*|pkg) case "$2" in list|show|ls) pkg_list_packages ;; file*) for i in $BASEDIR/lfs/*; do pkg_files $i done ;; info) shift 2 format_desc() { MAX_LENGTH=38 INPUT=$@ LINE="" LENGTH=0 for word in $INPUT; do LENGTH=$(expr $LENGTH + ${#word}) if [ "$LENGTH" -ge "$MAX_LENGTH" ]; then printf "$LINE\n" LINE=" ${word} " LENGTH=${#word} else LINE="$LINE${word} " fi #echo "-- ($word) $LINE" done printf "$LINE\n" } for pkg in $@; do ( eval "$(pkg_info ${pkg})" echo "############################################################" echo -e "# ${CLR_BOLD_RED}PACKAGE INFO${NORMAL}" echo "############################################################" for val in NAME VERSION RELEASE break GROUP MAINTAINER break URL LICENSE; do if [ "${val}" == "break" ]; then echo " ---------------------------------------- " else printf "${CLR_BOLD_RED}%-12s${NORMAL}: ${!val}\n" ${val} fi done for val in SHORT DESC; do printf "${CLR_BOLD_RED}%-12s${NORMAL}: " ${val} format_desc ${!val} done ) done ;; group*) echo "====== All available groups of packages in ${NAME}-${VERSION} ======" echo for group in $(pkg_list_groups); do echo " * ${group}" done ;; raw) pkg_info $3 ;; wikiinfo) shift 2 pkg_info_wiki $@ ;; wikilist) pkg_list_packages_wiki ;; *) usage ;; esac ;; push) putsource git_push ;; pull) LOGFILE=$BASEDIR/log_${TARGET}/_build.00-preparation.log git_pull check_sanity getsource ;; rootfiles|rf) case "$2" in check|ch) rootfiles_check $3 ;; commit|ci|update|up) rootfiles_commit ;; copy|cp) shift 2 rootfiles_copy $@ ;; fix) rootfiles_check --fix ;; *) usage ;; esac ;; vm|qemu) case "$2" in boot|start|run) shift 2 qemu_start $* ;; clean) rm -rf $BASEDIR/vm ;; esac ;; *) usage ;; esac