[<--] Indice [-->]

From "c1cc10@ecn.org" <c1cc10@ecn.org>
Date Tue, 07 Mar 2006 16:56:01 +0100
Subject Re: [Hackmeeting] Zen Room

ZoD wrote:

> Arclele wrote:
>
>> io tempo fa ho cercato di fare una cosa simile (solo su carta,
>> ops byte ovviamente) pero' mi sono letto un po' tutto linux
>
>> from scratch  e la documentazione di dynebolic ma mi sono 
>
>> un po' perso...  Pero' l'idea di base mi interessava, poter fare 
>
>> una mini
>> distro live a tema :o)
>
>
> Il documento e` interessante, realizzare una minidistro, 

> sopratutto in ambito multimediale, e` da sempre un'idea che 

> cerco di realizzare.
>
> cia`

Bella :^)

ho trovato i file su cui stavo lavorando fino a giugno 2005. Alcuni
sono vecchi, insomma sono da considerare
come spunti. Ricordo che funzionavano. Man mano che trovo
materiale, continuo a postarlo.
Visto che parliamo di 56Kb di testo in totale, mi limito a postare
singoli file in 4 diverse mail.
Mi scuso in anticipo con chi ha una linea a 56K e avra' rallentamenti,
ma spero che questa frammentazione non blocchi nessuno. Inoltre
trovo molto utile che negli archivi della lista ci sia traccia di queste
informazioni.

I files sono cosi' composti:
- buildSDK.5 = Man page del rispettivo comando
- buildSDK = Il comando, nella versione PPC
- buildSDK-100205 & buildSDK-180205 = versioni differenti
    (poco differenti) del comando, nel flavour x86.

Saludos (spero di essere nei 72 chars ;^)

c1cc10
#!/bin/sh
#
# dyne:bolic software development kit - the commandline tool
#
# Copyright (C) 2004  Federico Prando bomboclat@malasystem.com
#                     Francesco Rana  c1cc10@malasystem.com
#                     Andrea Marchesini bakunin@autistici.org
# * Revised on the 01-2005 by Francesco Rana                   
#
# This source code is free software; you can redistribute it and/or
# modify it under the terms of the GNU Public License as published 
# by the Free Software Foundation; either version 2 of the License,
# or (at your option) any later version.
#
# This source code 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.
# Please refer to the GNU Public License for more details.
#
# You should have received a copy of the GNU Public License along with
# this source code; if not, write to:
# Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#
########################################################################
# standard output message routines
# it's always useful to wrap them, in case we change behaviour later
#

# For DEBUGGING purpose...
#set -x

notice() { echo -e "\033[32m\a [*] \033[37m $1 "; }
act() { echo -e "\033[32m\a . \033[37m $1 "; }
error() { echo -e "\033[31m\a\a [!] \033[37m $1"; exit 1; }
func() { if [ $DEBUG ]; then echo -e "\033[32m [D] \033[37m $1"; fi }
### END


# some checks
if [ "`echo $UID`" != "0" ]; then
    error "you must be ROOT on your machine to use dyne:bolic SDK"
fi

#[ "$1" == "-c" -o "$1" == "-a" ] || CBSOPTS="$1" && CBSOPTS=""
CBSOPTS="$1"
CURRENTDIR=`pwd`
STAGEFILE="stage1-x86-2004.3.tar.bz2"
WORKINGDIR=$CURRENTDIR/dynebolic

#######################################################################
# BASIC FUNCTIONS
#######################################################################
function check_program () {
  for i in `echo $PATH | sed "s/:/ /g"`; do
    if test -f "$i/$1"; then
      return 0; 
    fi
  done
  return 1
}

function check_programs () {
  for i in "ls mv cat grep umount tar wget chroot tail head"; do
    check_program $i || error "$i not found!"
  done
}

function basic_steps() {
	# did you already try with no success? let's check
	if [ `cat /proc/mounts | grep dynebolic | wc -l` != "0" ] ; then
		act "umounting proc and dev from previous attempt"
		umount $WORKINGDIR/proc &> /dev/null
		umount $WORKINGDIR/dev &> /dev/null
	fi

	[ -d $WORKINGDIR ] && notice "going to remove '${WORKINGDIR}'. proceed?[S/n]"
	read -t 5 SINO
	[ "${SINO}" == 'n' ] || rm -fr $WORKINGDIR
	
	# start from an empty dir
	[ -d $WORKINGDIR ] || mkdir $WORKINGDIR
	act "creating $WORKINGDIR"

	if ! [ -f $WORKINGDIR/etc/gentoo-release ] ; then
		if ! [ -f $CURRENTDIR/$STAGEFILE ] ; then
			notice "do you have a valid stage1 ?\nPlease provide '/ full / path / to / it.bz2'\nor leave blank to download a brand new"
			read -t 5  GIVE_PATH
			if [ -z $GIVE_PATH ] ; then
				wget ftp://ftp.belnet.be/mirror/rsync.gentoo.org/gentoo/releases/x86/2004.3/stages/x86/$STAGEFILE || error "Download error :/"

			elif ! [ `file $GIVE_PATH | cut -d" " -f2` != "bzip2" ] ; then
				error "wrong path!"
				act "Proceding to download.."
				wget ftp://ftp.belnet.be/mirror/rsync.gentoo.org/gentoo/releases/x86/2004.1/stages/x86/stage1-x86-2004.1.tar.bz2 || error "Download error :/"
			fi
		fi
 		act "found downloaded stage1. proceding to untar $GIVE_PATH into $WORKINGDIR"
		tar xvjf $CURRENTDIR/$STAGEFILE -C $WORKINGDIR &> /dev/null 
                ! [ -d $WORKINGDIR/home/the_root ] && mkdir -p $WORKINGDIR/home/the_root
	fi
		
}

function get_ready_chroot() {
		if [ `cat /proc/mounts | grep dynebolic | wc -l` == "0" ] ; then
                	! [ -d $WORKINGDIR/proc ] && mkdir $WORKINGDIR/proc
			 mount -o bind /proc $WORKINGDIR/proc
                	! [ -d $WORKINGDIR/dev ] && mkdir $WORKINGDIR/dev
			 mount -o bind /dev $WORKINGDIR/dev
		fi
		[ -f $WORKINGDIR/etc/resolv.conf ] || cp -a /etc/resolv.conf $WORKINGDIR/etc/

#############################################################
#     	START OF INNER SCRIPT "createbasesystem.sh"         #
#############################################################
		[ -f $WORKINGDIR/sbin/createbasesystem.sh ] || cat > $WORKINGDIR/sbin/createbasesystem.sh << E0F


#!/bin/sh
# createbasesystem.sh
# dyne:bolic software development kit - the commandline tool
#
# Copyright (C) 2004  Federico Prando bomboclat@malasystem.com
#                     Francesco Rana  c1cc10@malasystem.com
#                     Andrea Marchesini bakunin@autistici.org
#                  
#
# This source code is free software; you can redistribute it and/or
# modify it under the terms of the GNU Public License as published 
# by the Free Software Foundation; either version 2 of the License,
# or (at your option) any later version.
#
# This source code 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.
# Please refer to the GNU Public License for more details.
#
# You should have received a copy of the GNU Public License along with
# this source code; if not, write to:
# Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#

INSTDIR=/home/the_root
if ! [ -d "\${INSTDIR}/var/dynebolic" ]; then
	mkdir -p "\${INSTDIR}/var/dynebolic"
fi
CHECKPATH=\${INSTDIR}/var/dynebolic
LS="ls --color=no"

########################################################################
# standard output message routines
# it's always useful to wrap them, in case we change behaviour later
#
notice() { echo -e "\033[31m [*] \$1\033[37m"; }
act() { echo -e "\033[32m . \$1\033[37m"; }
error() { echo -e "\033[31m [!] \$1\033[37m"; exit 1; }
func() { if [ \$DEBUG ]; then echo -e "\033[32m [D] \$1\033[31m"; fi }

function debug() {
	echo -e "\a\a\a\$?"
}

########################################################################
# MAIN FUNCTIONS
########################################################################

function set_flags() {
	notice "choose which CFLAG to set. default: '-O2 -mcpu=i586 -fomit-frame-pointer -pipe'"
	read -t 15 CFLAG_SET
	[ -z \$CFLAG_SET ] && export CFLAG_SET="-O2 -mcpu=i586 -fomit-frame-pointer -pipe" 
	act "\$CFLAG_SET  ...ok! modifying /etc/make.conf"

cat > /etc/make.conf << EOF
# These settings were set by the catalyst build script that automatically built this stage
# Please consult /etc/make.conf.example for a more detailed example
CFLAGS="\$CFLAG_SET"
# This should automatically change!
CHOST="i586-pc-linux-gnu" 
CXXFLAGS="\${CFLAGS}"
EOF

}

# baselayout-db.tgz has been changed into the base HFS. basically the /<dirs>.
function install_configuration_files(){
	if ! [ -f \$WORKINGDIR/baselayout-db.tgz ] ; then
		wget http://www.autistici.org/bolic1/baselayout-db.tgz 
	fi
	tar -C $INSTDIR -zxvf baselayout-db.tgz 
}

function check_step() {
	if ! [ -f "\${CHECKPATH}"/."\${CHECK}" ]; then
		error "something wicked happened. my checkpath is '\$CHECKPATH' and my check is '\$CHECK'\n"
	fi
	act "my checkpath is '\$CHECKPATH' and my check is '\$CHECK'. going to unset"
	unset \$CHECK
}


# get portage and bootstrap your compiling env
function initrd_root() {
	act "entering initrd_root"
	if [ -d /usr/portage ] ; then
		notice "there is already a dir '/usr/portage'. Should I use it?(N/s)"
		read -t 5 YESNO
		if ! [ "\${YESNO}" == "s" -o "\${YESNO}" == "S" ] ; then
			emerge sync || error "Emerge error :/"
		fi
	else 
		emerge sync || error "Emerge error :/"
	fi

	if ! [ -d /var/tmp/portage/ ] ; then
		/usr/portage/scripts/bootstrap.sh
	else 
		notice "esiste gia' /var/tmp/portage. hai gia' compilato il bootstrap?(S/n)"
		read -t 5 YESNO
		if  [ "\${YESNO}" == "n" ] ; then
			/usr/portage/scripts/bootstrap.sh
		fi
	fi
# AAAA: is it necessary? or double compiling?
#	emerge gentoolkit || error "Emerge error :/"

	[ -d "\${INSTDIR}" ] || mkdir "\${INSTDIR}" && act "'\${INSTDIR}' exist."
	cp -a /var/db \$INSTDIR/var && act "copy var/db in the_root ..success!" 

	touch "\${CHECKPATH}"/.initrd_root
	CHECK="initrd_root" ; act "setting check flag to \$CHECK"
}


# install the base sources to have a 1 level FSH ready for becoming an initrd

function install_initrd_pkg () {
	check_step
	cat > /tmp/.initrd.lst << EOF
linux-headers
devfsd
glibc
ncurses
bash
coreutils
iputils
net-tools
glib
expat
grep
gawk
less
zlib
util-linux
gpm
EOF
	for PKG in \`cat /tmp/.initrd.lst\` ; do
# This is intended to be an alfa form of the future module mechanism bakunin is
# developing by now (Mon Feb 14 19:29:48 EST 2005).
#		echo -e "Prova DEBUG"
		echo -e "Installing '\${PKG}' ... May I? [Y/n]"
		read -t 5 YESNO
		if  ! [ "\${YESNO}" == "n" -o "\${YESNO}" == "N" ] ; then
			ROOT="\${INSTDIR}" emerge "\${PKG}" || error "Emerge '\${PKG}' error :/";	
		fi
	done
	rm /tmp/.initrd.lst 
	touch "\${CHECKPATH}"/.install_initrd_pkg ;
	export CHECK="install_initrd_pkg"
}


function build_xfree() {
	check_step
	
	ROOT=/home/the_root/ USE='mmx sse 3dfx 3dnow' emerge xorg-x11 || error "Emerge 'X' error :/"
#	act "Configuring Xfree86..."
#       XFREECONFIGFILE=`X -configure 2>&1 | grep "test the server" | awk '{print $8}'` && notice "done with Xfree86 autoconfiguration." || error "something wrong with Xfree86 autoconfiguration."

	ROOT=\$INSTDIR USE='mmx sse 3dfx 3dnow' emerge windowmaker || error "Emerge 'windowmaker' error :/"
	touch \${CHECKPATH}/.build_xfree
	export CHECK="build_xfree"
}

function build_userland() {
	check_step
	
	touch \${CHECKPATH}/.build_userland
	export CHECK="build_userland"
}

function install_configuration_files(){
	check_step
	if ! [ -f \$WORKINGDIR/baselayout-db.tgz ] ; then
		wget http://www.autistici.org/bolic1/baselayout-db.tgz 
	fi
	tar -zxvf baselayout-db.tgz 
}

###############################################################################

##############################################################################
# Let's GO!
##############################################################################
# siamo dentro lo stage1. e' dove decidiamo i CFLAGS, per costruire prima l'ambiente di compilazione
# gentoo da cui poi deriviamo in /home/the_root la dynebolic.
# ogni aspetto l'abbiamo infilato in una funzione per auspicare uno sviluppo di ciascun passaggio


	case \$1 in
		-d)	
			CHECK="initrd_root" ; [ -f \`\$LS "\${CHECKPATH}"/."\${CHECK}"\` ] || error "\$CHECK not complete!"
			CHECK="install_initrd_pkg" ; [ -f \`\$LS "\${CHECKPATH}"/."\${CHECK}"\` ] || error "\$CHECK not complete!"
			CHECK="build_xfree" ; [ -f \`\$LS "\${CHECKPATH}"/."\${CHECK}"\` ] || error "\$CHECK not complete!"
	
			INITRD_ROOT_V=no
			INSTALL_INITRD_PKG_V=no
			BUILD_XFREE_V=no
			;;
		-f)	set_flags 
			exit 0
			;;
	
		-i)	
			CHECK="initrd_root" ; [ -f \`\$LS "\${CHECKPATH}"/."\${CHECK}"\` ] || error "\$CHECK not complete!"
	
			INITR_ROOT_V=no
			INSTALL_INITRD_PKG_V=yes
			BUILD_XFREE_V=yes
			;;
		-x)	
			CHECK="initrd_root" ; [ -f \`\$LS "\${CHECKPATH}"/."\${CHECK}"\` ] || error "\$CHECK not complete!"
			CHECK="install_initrd_pkg" ; [ -f \`\$LS "\${CHECKPATH}"/."\${CHECK}"\` ] || error "\$CHECK not complete!"
	
			INITRD_ROOT_V=no
			INSTALL_INITRD_PKG_V=no
			BUILD_XFREE_V=yes
			;;
		-v)	head -n 22 \$0 | tail -n 21 ;;
		-a)	INITRD_ROOT_V=yes;
			INSTALL_INITRD_PKG_V=yes
			BUILD_XFREE_V=yes
			;;
		*)	error "read help with -h or --help!" 
			;;
		-h|--help)
			act "-h show this help"
			act "-d restart from configuration files (baselayout-db)" 
		 	act "-f set flags"
			act "-i restart from initrd" 
			act "-x restart from xfree"
			exit 1
			;;
	esac

env-update

source /etc/profile

set_flags

if [ "\${INITRD_ROOT_V}" == "yes" ] ; then
	echo "DEBUG: initrd_root"
	initrd_root && notice "done with initrd_root." || error "something wrong with initrd_root."
fi

if [ "\${INSTALL_INITRD_PKG_V}" == "yes" ] ; then
	install_initrd_pkg && notice "install_initrd_pkg complete." || error "something wrong with install_initrd_pkg."
	install_configuration_files && notice "installation complete. now launch mkinitrd" || error "something wrong with baselayout-db" 
fi

if [ "\${BUILD_XFREE_V}" == "yes" ] ; then
	build_xfree  && notice "build_xfree complete." || error "something wrong with build_xfree."
fi

################################################################# 
#  	      END OF SCRIPT "createbasesystem.sh"		#
#################################################################
E0F
		chmod 740 "${WORKINGDIR}"/sbin/createbasesystem.sh		
		if [ "${CBSOPTS}" == "-f" -o "${CBSOPTS}" == "-x" -o "${CBSOPTS}" == "-i" -o "${CBSOPTS}" == "-d" ] ; then
			chroot "${WORKINGDIR}" ./sbin/createbasesystem.sh "${CBSOPTS}"
		elif [ "${CBSOPTS}" == "-c" ] ; then
			chroot "${WORKINGDIR}" /bin/bash
		else
			notice "No option for createbasesystem.sh... Starting all the d::b process from the beginning!"	
			act "${CBSOPTS}"
			chroot "${WORKINGDIR}" ./sbin/createbasesystem.sh -a
		fi
}

######################################################################
# HERE WE GO!
######################################################################

case $1 in
	-a) # Get the stage1 for your compiling environment
		act "check the software"
		check_programs
		act "entering basic_steps"
		basic_steps
		act "entering get_ready_chroot"
		get_ready_chroot 
		;;
	-c) # Done with basic stuff, let's get into the chroot for compiling
		act "check the software"
		check_programs
		act "entering get_ready_chroot"
		get_ready_chroot -c
		;;
	-h|--help)
		act "COMMON TASKS:"
	 	act "-h show this help"
	      	act "-a start the entire process from beginning (WARN! will delete previous attempts)"
	      	act "-c already downloaded and untarred. chroot me!"
	 	act "-v show details"
		act "particular purpose commands:"
	 	act "-f set flags (you must have allready an sdk installed)"
		act "-i restart from initrd" 
	 	act "-x build Xfree86 (you must have allready an sdk installed)"
		act "-d get latest baselayout-db and build it (you must have allready an sdk installed)" 
		;;
		# options to pass to createbasesystem.sh
	-d)	get_ready_chroot -d 
		;;
	-f)	get_ready_chroot -f 
		;;
	-i)	get_ready_chroot -i 
		;;
	-x)	get_ready_chroot -x 
		;;
	-v)     head -n 22 $0 | tail -n 21 
		;;
	*)	error "read help with -h or --help!" 
		;;
esac

_______________________________________________
Hackmeeting mailing list
Hackmeeting@inventati.org
https://www3.autistici.org/mailman/listinfo/hackmeeting

[<--] Indice [-->]