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

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

add original source

  • Property svn:executable set to *
File size: 2.3 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 source 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 [ "${LB_SOURCE}" != "true" ]
28then
29        exit 0
30fi
31
32if ! In_list virtual-hdd "${LB_SOURCE_IMAGES}"
33then
34        exit 0
35fi
36
37Echo_message "Begin building source virtual-hdd image..."
38
39# Requiring stage file
40Require_stagefile .build/config .build/source_debian
41
42# Checking stage file
43Check_stagefile .build/source_virtual-hdd
44
45# Checking lock file
46Check_lockfile .lock
47
48# Creating lock file
49Create_lockfile .lock
50
51if [ "${LB_BUILD_WITH_CHROOT}" = "true" ]
52then
53        case "${LB_BINARY_FILESYSTEM}" in
54                ext2|ext3|ext4)
55                        Check_package chroot/sbin/mkfs.${LB_BINARY_FILESYSTEM} e2fsprogs
56                        ;;
57        esac
58fi
59
60# Installing depends
61Install_package
62
63# Remove old source
64if [ -f source-virtual.img ]
65then
66        rm -f source-virtual.img
67fi
68
69# Everything which comes here needs to be cleaned up,
70DU_DIM="$(du -ms source | cut -f1)"
71REAL_DIM="$(Calculate_partition_size ${DU_DIM} ${LB_BINARY_FILESYSTEM})"
72dd if=/dev/zero of=source-virtual.img bs=1024k count=0 seek=${REAL_DIM}
73
74if [ "${LB_BUILD_WITH_CHROOT}" = "true" ]
75then
76        mv source-virtual.img chroot
77
78        case "${LB_BINARY_FILESYSTEM}" in
79                ext2|ext3|ext4)
80                        Chroot chroot "mkfs.${LB_BINARY_FILESYSTEM} -F -m 0 source-virtual.img"
81        esac
82
83        mv chroot/source-virtual.img ./
84else
85        case "${LB_BINARY_FILESYSTEM}" in
86                ext2|ext3|ext4)
87                        mkfs.${LB_BINARY_FILESYSTEM} -F -m 0 source-virtual.img
88                        ;;
89        esac
90fi
91
92mkdir -p source.tmp
93${LB_ROOT_COMMAND} mount -o loop source-virtual.img source.tmp
94cp -r source/* source.tmp
95
96${LB_ROOT_COMMAND} umount source.tmp
97rmdir source.tmp
98
99# Saving cache
100Save_cache cache/packages.binary
101
102# Removing depends
103Remove_package
104
105# Creating stage file
106Create_stagefile .build/source_virtual-hdd
Note: See TracBrowser for help on using the repository browser.