Moved platform-dependant code to their respective targets

This commit is contained in:
Pierre Pronchery 2008-09-03 11:42:12 +00:00
parent 784ce25a62
commit 3a6184dcf3
3 changed files with 79 additions and 8 deletions

View File

@ -1,5 +1,3 @@
[ -z "$KERNEL" ] && KERNEL="/vmlinuz"
[ -z "$MKFS" ] && MKFS="mke2fs -F"
[ -z "$MOUNT" ] && MOUNT="$SUDO mount -o loop"
[ -z "$TUNE2FS" ] && TUNE2FS="tune2fs"
[ -z "$UMOUNT" ] && UMOUNT="$SUDO umount"

View File

@ -17,15 +17,24 @@ source "`dirname $0`/Apps/Devel/src/scripts/targets/Linux"
#functions
target_image()
#private
_create_directories()
{
echo
echo -n "Creating missing directories:"
for i in /bin /etc /lib; do
echo -n " $i"
$MKDIR "$DESTDIR$i"
while true; do
echo -n " $1"
$MKDIR "$DESTDIR/$1" || exit 2
shift || break
done
echo
}
#public
target_image()
{
_create_directories 'bin' 'dev' 'etc' 'lib'
echo
echo -n "Fixing installation paths:"
@ -35,6 +44,14 @@ target_image()
done
echo
echo
echo -n "Creating device nodes:"
for i in std pty console input fb; do
echo -n " $i"
(cd "$DESTDIR/dev" && $SUDO sh /sbin/MAKEDEV "$i")
done
echo
if [ ! -z "$KERNEL_MODULES" ]; then
echo
echo "Installing kernel modules:"
@ -50,7 +67,31 @@ target_image()
echo
echo "Building tarball:"
OLDPWD="$PWD"
(cd "$DESTDIR" && $TAR -czf "$OLDPWD/DeforaOS-rootfs.tar.gz" .) \
|| exit 2
(cd "$DESTDIR" && $TAR -cvzf "$OLDPWD/DeforaOS-rootfs.tar.gz" .) \
| while read filename; do
echo -en "\r$filename"
done || (echo && exit 2)
echo -en "\r"
$DU DeforaOS-rootfs.tar.gz
}
target_ramdisk()
{
target "install" || exit 2
_create_directories 'dev' 'proc' 'mnt/cdrom' 'sbin'
echo
echo -n "Building ramdisk image:"
$MKFS "$RAMDISK_IMAGE" || exit 2
echo
$DU "$RAMDISK_IMAGE"
echo
echo -n "Compressing ramdisk:"
$GZIP "$RAMDISK_IMAGE" || exit 2
$MV "$RAMDISK_IMAGE.gz" "$RAMDISK_IMAGE" || exit 2
echo
$DU "$RAMDISK_IMAGE"
}

View File

@ -2,6 +2,11 @@
#variables
[ -z "$MKFS" ] && MKFS="mke2fs -F"
[ -z "$TUNE2FS" ] && TUNE2FS="tune2fs"
#includes
source "`dirname $0`/Apps/Devel/src/scripts/targets/Linux"
@ -45,3 +50,30 @@ EOF
-boot-load-size 4 -boot-info-table \
-o "$CDROM_IMAGE" "$DESTDIR"
}
target_ramdisk()
{
[ -z "$MOUNTPOINT" ] && error "MOUNTPOINT needs to be set"
$UMOUNT "$MOUNTPOINT"
$MKDIR "$MOUNTPOINT"
$DD if="$DEVZERO" of="$RAMDISK_IMAGE" count="$RAMDISK_SIZE"|| exit 2
$MKFS "$RAMDISK_IMAGE" || exit 2
[ ! -z "$TUNE2FS" ] && $TUNE2FS -i 0 "$RAMDISK_IMAGE"
$MOUNT "$RAMDISK_IMAGE" "$MOUNTPOINT" || exit 2
SUBDIRS="Apps/Unix/src/others/tools" target linuxrc || exit 2
DESTDIR="$MOUNTPOINT" _create_directories 'dev' 'proc' 'mnt/cdrom' \
'sbin'
$LN "../mnt/cdrom/usr/bin/sh" "$MOUNTPOINT/sbin/init"
$CP "Apps/Unix/src/others/tools/linuxrc" "$MOUNTPOINT" || exit 2
$UMOUNT "$MOUNTPOINT"
echo
echo -n "Compressing ramdisk:"
$GZIP "$RAMDISK_IMAGE" || exit 2
$MV "$RAMDISK_IMAGE.gz" "$RAMDISK_IMAGE" || exit 2
echo
$DU "$RAMDISK_IMAGE"
}