[Frugalware-darcs] setup-current: 0.0.7

VMiklos mamajom at axelero.hu
Thu Mar 16 17:56:58 CET 2006


[0.0.7
VMiklos <mamajom at axelero.hu>**20050401222912] {
hunk ./en 13
-# rootdev dection
+# rootdev section
hunk ./en 43
+
+# linux partitions section
+
+sellinuxpartst="Select other Linux partitions for /etc/fstab"
+sellinuxpartsd="You seem to have more than one partition tagged as type Linux. You may use these to distribute your Linux system across more than one partition.  Currently, you have only mounted your / partition. You might want to mount directories such as /home or /usr/local on separate partitions.  You should not try to mount /etc, /sbin, or /bin on their own partitions since they contain utilities needed to bring the system up and mount partitions.  Also, do not reuse a partition that you've already entered before.  Please select one of the Linux partitions listed below, or if you're done, hit <$continue>"
+inuse="in use"
+askwherelt="Select mount point for"
+askwhereld="You need to specify where you want the new partition mounted. For example, if you want to put it under /usr/local, then respond: /usr/local\n\n Where would you like to mount this partition?"
+
+# dos partitions section
+
+seldospartst="Select partition to add to /etc/fstab"
+seldospartsd="In order to make these partitions visible from Linux, we need to add them to your /etc/fstab.  Please pick a partition to add to /etc/fstab, or if you're done, hit <$continue>"
hunk ./setup.sh 6
+target=/mnt/target
hunk ./setup.sh 9
+#mkfs!!!
hunk ./setup.sh 22
+rootdevbacktitle="$rootdevstring - FrugalWare `cat /etc/frugalware-release |cut -d ' ' -f 2` $setup"
hunk ./setup.sh 24
+# linux partitions section
+towhere=
+miscdevbacktitle="$miscdevstring - FrugalWare `cat /etc/frugalware-release |cut -d ' ' -f 2` $setup"
+
hunk ./setup.sh 76
+# rootdev dection
+
+lstparts()
+{
+	for i in `fdisk -l|grep 'Linux$'|cut -d ' ' -f 1`
+	do
+		size=`fdisk -s $i`
+		unset altname
+		if grep -q $i $prefstab; then
+			# added already
+			on=`grep $i $prefstab |tr -s ' ' |cut -f 2 -d ' '`
+			altname="$i $on Linux ${size}K"
+		fi
+		if [ -z "$altname" ]; then
+			echo "\"$i\" \"Linux ${size}K\" \\" >>$1
+		else
+			echo "\"($inuse)\" \"$altname\" \\" >>$1
+		fi
+	done
+}
+
+selrootdev()
+{
+	[ -z "$prefstab" ] && prefstab=`mktemp`
+	selrootpart=`mktemp`
+	chmod +x $selrootpart
+	rootpartf=`mktemp`
+	echo "dialog --backtitle \"$rootdevbacktitle\" --title \"$selrootdevt\" \\" >$selrootpart
+	echo "--ok-label \"$select\" --menu \"$selrootdevd\" 0 0 0 \\">>$selrootpart
+	lstparts $selrootpart
+	echo "2>$rootpartf">>$selrootpart
+	$selrootpart || exit 1 # aborted when choosing root device
+	rm $selrootpart
+	rootdev=`cat $rootpartf`
+	rm $rootpartf
+}
+
+mkfss() # $1 which device, $2 which fs, $3 how: $formatt or $checkt
+{
+	[ "$3" = "$checkt" ] && opts="-c"
+	dialog --backtitle "$miscdevbacktitle" \
+		--title "$duringformatt" \
+		--infobox "$formatdevicestring $1 \n \
+		$formatfsstring $2" 0 0
+	mount|grep -q $1 && umount $1
+	if [ "$2" = "ext2" ]; then
+		mke2fs $opts $1 >$logdev 2>&1
+	elif [ "$2" = "reiserfs" ]; then
+		echo y | mkreiserfs $1 >$logdev 2>&1
+	elif [ "$2" = "ext3" ]; then
+		echo mke2fs -j $opts $1 >$logdev 2>&1
+	elif [ "$2" = "jfs" ]; then
+		mkfs.jfs -q $opts $1 >$logdev 2>&1
+	elif [ "$2" = "xfs" ]; then
+		mkfs.xfs -f $1 >$logdev 2>&1
+	fi
+}
+
+formatdev() # $1: which device
+{
+	junk=`mktemp`
+	dialog --backtitle "$miscdevbacktitle" --title "$formatpart $1" \
+	--menu "$wantformatq" 0 0 0 \
+	"$formatt" "$fromatd" "$checkt" "$checkd" "$nofromatt" "$noformatd" 2>$junk || exit 1 # aborted when choosing format mode
+	howformat=`cat $junk`
+	rm $junk
+	if [ "$howformat" != "$nofromatt" ]; then
+		unset ext2desc reiserdesc ex3desc jfsdesc xfsdesc
+		grep ext2 -q /proc/filesystems && \
+			ext2desc=$ext2predesc && default=ext2
+		grep reiserfs -q /proc/filesystems && \
+			reiserdesc=$reiserpredesc && default=reiserfs
+		grep ext3 -q /proc/filesystems && \
+			ext3desc=$ext3predesc && default=ext3
+		grep jfs -q /proc/filesystems && \
+			jfsdesc=$jfspredesc && default=jfs
+		grep ' xfs' -q /proc/filesystems && \
+			xfsdesc=$xfspredesc && default=xfs
+		selfsf=`mktemp`
+		chmod +x $selfsf
+		echo "dialog --backtitle \"$miscdevbacktitle\" \
+		--title \"$selectfst $1\" --default-item \"$default\" \
+		--menu \"$selectfsd \\">$selfsf
+		echo "$ext2desc $reiserdesc $ext3desc $jfsdesc $xfsdesc\" \
+			0 0 0 \\">>$selfsf
+		[ -z "$ext2desc" ] || echo "\"ext2\" \
+			\"$ext2shortdesc\" \\" >>$selfsf
+		[ -z "$reiserdesc" ] || echo "\"reiserfs\" \
+			\"$reisershortdesc\" \\" >>$selfsf
+		[ -z "$ext3desc" ] || echo "\"ext3\" \
+			\"$ext3shortdesc\" \\" >>$selfsf
+		[ -z "$jfsdesc" ] || echo "\"jfs\" \
+			\"$jfsshortdesc\" \\" >>$selfsf
+		[ -z "$xfsdesc" ] || echo "\"xfs\" \
+			\"$xfsshortdesc\" \\" >>$selfsf
+		junk=`mktemp`
+		echo "2>$junk">>$selfsf
+		$selfsf || exit 1 # aborted when choosing fs
+		rm $selfsf
+		mkfss $1 `cat $junk` $howformat
+		rm $junk
+	fi
+}
+
+mountdev() # $1: which device $2: mount point
+{
+	[ -d $target/$2 ] || mkdir -p $target/$2
+	mount $1 $target/$2 >$logdev 2>&1
+	sleep 1
+	type=`mount | grep ^$1 | cut -f 5 -d ' '`
+	printf "%-16s %-16s %-11s %-16s %-3s %s\n" "$1" "$2" "$type" "defaults" "1" "1" >> $prefstab
+}
+
+# linux partitions section
+
+askwhere() # $1: which device
+{
+	askwheref=`mktemp`
+	dialog --backtitle "$miscdevbacktitle" --title "$askwherelt $1" \
+		--inputbox "$askwhereld" 0 0 2>$askwheref || return 1
+	towhere=`cat $askwheref`
+	rm $askwheref
+	# cosmetics
+	[ "$towhere" = "" ] && return 1
+	[ "`echo "$towhere" | cut -b1`" = " " ] && return 1
+	[ "`echo "$towhere" | cut -b1`" = "/" ] || towhere="/$towhere"
+}
+
+setup_linux() {
+	[ "`fdisk -l|grep Linux$|wc -l`" != 1 ] || return 1
+	while /bin/true
+	do
+		sellinuxparts=`mktemp`
+		chmod +x $sellinuxparts
+		linuxpartsf=`mktemp`
+		echo "dialog --backtitle \"$miscdevbacktitle\" --title \"$sellinuxpartst\" \\" >$sellinuxparts
+		echo "--ok-label \"$select\" --cancel-label "$continue" --menu \"$sellinuxpartsd\" 0 0 0 \\">>$sellinuxparts
+		lstparts $sellinuxparts
+		echo "2>$linuxpartsf">>$sellinuxparts
+		$sellinuxparts || break; # aborted when choosing linux parts
+		rm $sellinuxparts
+		linuxpart=`cat $linuxpartsf`
+		rm $linuxpartsf
+		if [ "$linuxpart" != "($inuse)" ]; then
+			formatdev $linuxpart
+			askwhere $linuxpart || continue
+			mountdev $linuxpart $towhere
+		fi
+	done
+	rm $sellinuxparts
+	rm $linuxpartsf
+}
+
+# dos partitions section
+
+lstdosparts()
+{
+	for i in `fdisk -l|egrep 'Win95 F|Win98 F|HPFS|W95 F|FAT12|FAT16'|cut -d ' ' -f 1`
+	do
+		size=`fdisk -s $i`
+		unset altname
+		if grep -q $i $prefstab; then
+			# added already
+			on=`grep $i $prefstab |tr -s ' ' |cut -f 2 -d ' '`
+			altname="$i $on Linux ${size}K"
+		fi
+		if [ -z "$altname" ]; then
+			echo "\"$i\" \"Linux ${size}K\" \\" >>$1
+		else
+			echo "\"($inuse)\" \"$altname\" \\" >>$1
+		fi
+	done
+}
+
+setup_dos() {
+	[ "`fdisk -l|egrep 'Win95 F|Win98 F|HPFS|W95 F|FAT12|FAT16'|wc -l`" != 0 ] || return 1
+	while /bin/true
+	do
+		seldosparts=`mktemp`
+		chmod +x $seldosparts
+		dospartsf=`mktemp`
+		echo "dialog --backtitle \"$miscdevbacktitle\" --title \"$seldospartst\" \\" >$seldosparts
+		echo "--ok-label \"$select\" --cancel-label "$continue" --menu \"$seldospartsd\" 0 0 0 \\">>$seldosparts
+		lstdosparts $seldosparts
+		echo "2>$dospartsf">>$seldosparts
+		$seldosparts || break; # aborted when choosing dos parts
+		rm $seldosparts
+		dospart=`cat $dospartsf`
+		rm $dospartsf
+		if [ "$dospart" != "($inuse)" ]; then
+			askwhere $dospart || continue
+			mountdev $dospart $towhere
+		fi
+	done
+	rm $seldosparts
+	rm $dospartsf
+}
+
hunk ./setup.sh 403
-# main
+### main
+# swap section
hunk ./setup.sh 407
+
+# rootdev section
+selrootdev #root device now in $rootdev
+formatdev $rootdev
+mountdev $rootdev /
+[ -d $target/etc ] || mkdir $target/etc
+mv -f $prefstab $target/etc/fstab
+prefstab=$target/etc/fstab
+
+# linux partitions section
+setup_linux
+
+# dos partitions section
+setup_dos
+
+# packages section
+cd $target
}


More information about the Frugalware-darcs mailing list