source: live-build/trunk/fuentes/scripts/build/lb_binary_virtual-hdd @ 900

Last change on this file since 900 was 900, checked in by kbut, 4 years ago

add original source

  • Property svn:executable set to *
File size: 2.4 KB
Line 
1#!/bin/sh
2
3## live-build(7) - System Build Scripts
4## Copyright (C) 2006-2012 Daniel Baumann <daniel@debian.org>
5##
6## This program comes with ABSOLUTELY NO WARRANTY; for details see COPYING.
7## This is free software, and you are welcome to redistribute it
8## under certain conditions; see COPYING for details.
9
10
11set -e
12
13# Including common functions
14( . "${LIVE_BUILD}/scripts/build.sh" > /dev/null 2>&1 || true ) || . /usr/lib/live/build.sh
15
16# Setting static variables
17DESCRIPTION="$(Echo 'build binary image')"
18HELP=""
19USAGE="${PROGRAM} [--force]"
20
21Arguments "${@}"
22
23# Reading configuration files
24Read_conffiles config/all config/common config/bootstrap config/chroot config/binary config/source
25Set_defaults
26
27if ! In_list virtual-hdd "${LB_BINARY_IMAGES}"
28then
29        exit 0
30fi
31
32Echo_message "Begin building binary virtual-hdd image..."
33
34# Requiring stage file
35Require_stagefile .build/config .build/bootstrap .build/chroot_proc
36
37# Checking stage file
38Check_stagefile .build/binary_virtual-hdd
39
40# Checking lock file
41Check_lockfile .lock
42
43# Creating lock file
44Create_lockfile .lock
45
46if [ "${LB_BUILD_WITH_CHROOT}" = "true" ]
47then
48        case "${LB_BINARY_FILESYSTEM}" in
49                ext2|ext3|ext4)
50                        Check_package chroot/sbin/mkfs.${LB_BINARY_FILESYSTEM}  e2fsprogs
51                        ;;
52        esac
53fi
54
55# Restoring cache
56Restore_cache cache/packages.binary
57
58# Installing depends
59Install_package
60
61# Remove old binary
62if [ -f binary-virtual.img ]
63then
64        rm -f binary-virtual.img
65fi
66
67Echo_message "Creating virtual disk image..."
68dd if=/dev/zero of=binary-virtual.img bs=1024k count=0 seek=${LB_HDD_SIZE}
69
70if [ "${LB_BUILD_WITH_CHROOT}" = "true" ]
71then
72        mv binary-virtual.img chroot
73
74        # hack to recreate mtab from chroot_hacks if its gone for some reason
75        if ! Chroot chroot "test -s /etc/mtab"
76        then
77                Chroot chroot "rm -f /etc/mtab"
78                Chroot chroot "ln -s /proc/mounts /etc/mtab"
79        fi
80
81        case "${LB_BINARY_FILESYSTEM}" in
82                ext2|ext3|ext4)
83                        Chroot chroot "mkfs.${LB_BINARY_FILESYSTEM} -F binary-virtual.img"
84                        ;;
85        esac
86
87        mv chroot/binary-virtual.img ./
88else
89        case "${LB_BINARY_FILESYSTEM}" in
90                ext2|ext3|ext4)
91                        mkfs.${LB_BINARY_FILESYSTEM} . -F binary-virtual.img
92                        ;;
93        esac
94fi
95
96mkdir -p binary.tmp
97${LB_ROOT_COMMAND} mount -o loop binary-virtual.img binary.tmp
98cp -a binary/* binary.tmp
99cp -af binary/.disk* binary.tmp
100
101${LB_ROOT_COMMAND} umount binary.tmp
102rmdir binary.tmp
103
104# Saving cache
105Save_cache cache/packages.binary
106
107# Removing depends
108Remove_package
109
110# Creating stage file
111Create_stagefile .build/binary_virtual-hdd
Note: See TracBrowser for help on using the repository browser.