# #
###############################################################################
+usage() {
+ cat doc/make.sh-usage
+ exit 1
+}
+
case "$1" in
build)
# check for prerequisites
- . $BASEDIR/tools/make-check && check_build
+ 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
+ entershell $@
;;
batch)
# build the distro in background
- . $BASEDIR/tools/make-batch
case "$2" in
+ cron)
+ cron_run
+ ;;
start)
- batch_start
+ batch_start $3
;;
_run)
batch_run
attach|watch)
batch_attach
;;
+ *)
+ usage
+ ;;
esac
;;
-stats)
- # show some stats about the compiler(s)
- . $BASEDIR/tools/make-compilers
-
+buildspy|bs)
+ # control buildspy
case "$2" in
- ccache)
+ start)
+ build_spy start
+ ;;
+ stop)
+ build_spy exit
+ ;;
+ *)
+ usage
+ ;;
+ esac
+ ;;
+
+ccache)
+ # ccache options
+ case "$2" in
+ stats)
ccache_stats
;;
- distcc)
+ 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)
- echo -ne "Cleaning ${BOLD}$MACHINE${NORMAL} buildtree"
- for i in `mount | grep $BASEDIR | sed 's/^.*loop=\(.*\))/\1/'`
- do
- $LOSETUP -d $i 2>/dev/null
- done
- for i in `mount | grep $BASEDIR | cut -d " " -f 1`
- do
+clean)
+ for i in $(mount | grep $BASEDIR | cut -d " " -f 1); do
umount $i
done
stdumount
-
- for i in `seq 0 7`
- do
- if ( losetup /dev/loop${i} 2>/dev/null | grep -q "/install/images" ); then
- umount /dev/loop${i} 2>/dev/null;
- losetup -d /dev/loop${i} 2>/dev/null;
- fi;
- done
- rm -rf $BASEDIR/build_${MACHINE}
- rm -rf $BASEDIR/log_${MACHINE}
- rm -rf $BASEDIR/packages
-
- if [ -h $TOOLS_DIR ]; then
- rm -f $TOOLS_DIR
- fi
+ 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
;;
-
-downloadsrc)
- LOGFILE=$BASEDIR/log_${MACHINE}/_build.preparation.log
-
- if [ ! -d $BASEDIR/cache ]; then
- mkdir $BASEDIR/cache
- fi
- mkdir -p $BASEDIR/log_${MACHINE}
- echo -e "${BOLD}Preload all source files${NORMAL}" | tee -a $LOGFILE
- cd $BASEDIR/lfs
- for i in *; do
- if [ -f "$i" -a "$i" != "Config" ]; then
- echo -ne "Loading $i"
- make -s -f $i LFS_BASEDIR=$BASEDIR MESSAGE="$i\t" download >> $LOGFILE 2>&1
- if [ $? -ne 0 ]; then
- beautify message FAIL
- else
- beautify message DONE
- fi
- fi
- done
- cd - >/dev/null 2>&1
+
+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)
- prepareenv
- # Check if host can build the toolchain
- . tools/make-check
- check_toolchain
-
- toolchain_build
-
- stdumount
- echo -ne "\ntarball creation "
- [ -d $BASEDIR/cache/toolchains ] || mkdir $BASEDIR/cache/toolchains
- cd $BASEDIR && tar cj \
- --exclude='log_${MACHINE}/_build.*.log' \
+ 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_${MACHINE} \
- log_${MACHINE} >> $LOGFILE
- beautify message DONE
- echo `ls -sh cache/toolchains/$TOOLCHAINNAME.tar.bz2`
- md5sum cache/toolchains/$TOOLCHAINNAME.tar.bz2 \
- > cache/toolchains/$TOOLCHAINNAME.md5
+ build_${TARGET} log_${TARGET} >> $LOGFILE
+ beautify message DONE
+ echo `ls -sh cache/toolchains/$TOOLCHAINNAME.tar.bz2`
- stdumount
+ 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
;;
-
-gettoolchain)
- if [ ! -f $BASEDIR/cache/toolchains/$TOOLCHAINNAME.tar.bz2 ]; then
- URL_TOOLCHAIN=`grep URL_TOOLCHAIN lfs/Config | awk '{ print $3 }'`
- test -d $BASEDIR/cache/toolchains || mkdir $BASEDIR/cache/toolchains
- echo "Loading toolchain for $MACHINE"
- cd $BASEDIR/cache/toolchains
- wget -c -nv $URL_TOOLCHAIN/$TOOLCHAINNAME.tar.bz2 $URL_TOOLCHAIN/$TOOLCHAINNAME.md5
- if [ $? -ne 0 ]; then
- echo -n "ERROR: Downloading toolchain for $MACHINE machine"
- beautify message FAIL
- echo "Precompiled toolchain not always available for every machine"
- else
- if [ "`md5sum $TOOLCHAINNAME.tar.bz2 | awk '{print $1}'`" = "`cat $TOOLCHAINNAME.md5 | awk '{print $1}'`" ]; then
+
+check)
+ case "$2" in
+ cpu)
+ [ -z "$3" ] && usage
+ if check_cpu $3; then
+ echo -n "CPU has flag $3"
beautify message DONE
- echo "Toolchain md5 ok"
else
- exiterror "$TOOLCHAINNAME.md5 did not match, check downloaded package"
+ dialogerror "CPU hasn't got flag $3"
+ exit 1
fi
- fi
- else
- echo -n "Toolchain for $MACHINE is already existing"
- beautify message SKIP
- fi
- ;;
-
-othersrc)
- prepareenv
- echo -ne "`date -u '+%b %e %T'`: Build sources iso for $MACHINE" | tee -a $LOGFILE
- chroot $LFS /tools/bin/env -i HOME=/root \
- TERM=$TERM PS1='\u:\w\$ ' \
- PATH=/usr/local/bin:/bin:/usr/bin:/sbin:/usr/sbin \
- VERSION=$VERSION NAME="$NAME" SNAME="$SNAME" MACHINE=$MACHINE \
- /bin/bash -x -c "cd /usr/src/lfs && make -f sources-iso LFS_BASEDIR=/usr/src install" >>$LOGFILE 2>&1
- mv $LFS/install/images/ipfire-* $BASEDIR >> $LOGFILE 2>&1
- if [ $? -eq "0" ]; then
- beautify message DONE
- else
- beautify message FAIL
- fi
- stdumount
+ ;;
+ sanity)
+ check_sanity $3
+ ;;
+ target*)
+ check_supported_targets
+ ;;
+ *)
+ usage
+ ;;
+ esac
;;
-
-git)
- . $BASEDIR/tools/make-git
- case "$2" in
+
+g[iu]t)
+ COMMAND=$2
+ shift 2
+ case "$COMMAND" in
update|pull)
- git_pull
+ git_pull $*
;;
commit|ci)
- shift 2
- clear
git_commit $*
;;
dist|export|archive)
- git_export
+ git_export $*
;;
push)
- git_push
+ git_push $*
;;
diff|di)
- git_diff
+ git_diff $*
;;
log)
- git_log
+ git_log $*
+ ;;
+ gc)
+ git_gc
+ ;;
+ shortlog|slog)
+ git_shortlog
+ ;;
+ put-key)
+ ssh_cert $*
+ ;;
+ *) # If no command matches run git directly
+ git $*
;;
esac
;;
-
-welcome)
- clear
- #. $BASEDIR/tools/make-git
-
- echo -ne "
-###############################################################################
-#
-# ${FAIL}$NAME${NORMAL} $VERSION
-#
-###############################################################################
-#
-# ${BOLD}You are:${NORMAL} $(git config user.name) <$(git config user.email)>
-#
-# ${BOLD}You are on branch:${NORMAL}
-#
-$(git branch --color)
-#
-###############################################################################
-#
-$(git diff --stat --color)
-#
-###############################################################################
-"
-
- ;;
-
-uploadsrc)
- PWD=`pwd`
- cd $BASEDIR/cache/
- echo -e "Uploading cache to ftp server:"
- for i in *; do
- echo "${i}" | fgrep -q .md5 && continue
- [ -e ${i}.md5 ] && continue
- md5sum ${i} | tee ${i}.md5
- done
- ncftpls -u $FTP_CACHE_USER -p $FTP_CACHE_PASS ftp://$FTP_CACHE_URL/$FTP_CACHE_PATH/ > /tmp/ftplist
- for i in *; do
- if [ "$(basename $i)" == "toolchains" ]; then continue; fi
- grep -q $(basename $i) /tmp/ftplist
- if [ "$?" -ne "0" ]; then
- echo -ne "$(basename $i)"
- ncftpput -u $FTP_CACHE_USER -p $FTP_CACHE_PASS $FTP_CACHE_URL $FTP_CACHE_PATH/ $(basename $i)
- if [ "$?" -ne "0" ]; then
- beautify message FAIL
- fi
- fi
- done
- rm -f /tmp/ftplist
- cd $PWD
- exit 0
- ;;
-
-upload)
- FTP_ISO_PORT=`echo "$FTP_ISO_URL" | awk -F: '{ print $2 }'`
- FTP_ISO_URL=`echo "$FTP_ISO_URL" | awk -F: '{ print $1 }'`
- if [ -z $FTP_ISO_PORT ]; then
- FTP_ISO_PORT=21
- fi
- cat <<EOF > .ftp-commands
-mkdir -p $FTP_ISO_PATH$SVN_REVISION
-mkdir -p $FTP_ISO_PATH$SVN_REVISION/paks
-quit
-EOF
- ncftp -u $FTP_ISO_USER -p $FTP_ISO_PASS -P $FTP_ISO_PORT $FTP_ISO_URL < .ftp-commands
- rm -f .ftp-commands
-
+
+package*|pkg)
case "$2" in
- iso)
- echo -e "Uploading the iso to $FTP_ISO_PATH/$SVN_REVISION."
+ 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=$@
- md5sum ipfire-$VERSION.$MACHINE-full.iso > ipfire-$VERSION.$MACHINE-full.iso.md5
- for i in svn_status ipfire-source-r$SVN_REVISION.tar.gz ipfire-$VERSION.$MACHINE-full.iso ipfire-$VERSION.$MACHINE-full.iso.md5 ipfire-$VERSION.$MACHINE-devel.iso ipfire-$VERSION.$MACHINE-devel.iso.md5; do
- if [ -e "$i" ]; then
- ncftpput -u $FTP_ISO_USER -p $FTP_ISO_PASS -P $FTP_ISO_PORT $FTP_ISO_URL $FTP_ISO_PATH$SVN_REVISION/ $i
- if [ "$?" -eq "0" ]; then
- echo "The file with name $i was successfully uploaded to $FTP_ISO_URL$FTP_ISO_PATH$SVN_REVISION/."
+ 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
- echo "There was an error while uploading the file $i to the ftp server."
- exit 1
+ LINE="$LINE${word} "
fi
- fi
- done
- rm -f ipfire-$VERSION.$MACHINE-full.iso.md5
- if [ "$3" = "--with-sources-cd" ]; then
- ncftpput -u $FTP_ISO_USER -p $FTP_ISO_PASS -P $FTP_ISO_PORT $FTP_ISO_URL $FTP_ISO_PATH/$SVN_REVISION/ ipfire-sources-cd-$VERSION.$MACHINE.iso
- fi
- ;;
- paks)
- ncftpput -u $FTP_ISO_USER -p $FTP_ISO_PASS -P $FTP_ISO_PORT $FTP_ISO_URL $FTP_ISO_PATH$SVN_REVISION/paks packages/*
- if [ "$?" -eq "0" ]; then
- echo -e "The packages were successfully uploaded to $FTP_ISO_URL$FTP_ISO_PATH$SVN_REVISION/."
- else
- echo -e "There was an error while uploading the packages to the ftp server."
- exit 1
- 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
;;
-
+
*)
- cat doc/make.sh-usage
+ usage
;;
-
+
esac