1 | #!/bin/bash
|
---|
2 |
|
---|
3 | # $Id$
|
---|
4 |
|
---|
5 | #=== MAKEFILE HEADER ===
|
---|
6 |
|
---|
7 | #----------------------------------#
|
---|
8 | wrt_Makefile_header() { #
|
---|
9 | #----------------------------------#
|
---|
10 | (
|
---|
11 | cat << EOF
|
---|
12 | # This file is automatically generated by jhalfs
|
---|
13 | # DO NOT EDIT THIS FILE MANUALLY
|
---|
14 | #
|
---|
15 | # Generated on `date "+%F %X %Z"`
|
---|
16 |
|
---|
17 |
|
---|
18 | SHELL = /bin/bash
|
---|
19 |
|
---|
20 | MOUNT_PT = $BUILDDIR
|
---|
21 | SCRIPT_ROOT = $SCRIPT_ROOT
|
---|
22 | CMDSDIR = $PROGNAME-commands
|
---|
23 | SRC = /sources
|
---|
24 | SRCSDIR = \$(MOUNT_PT)\$(SRC)
|
---|
25 | FILELOGDIR = /\$(SCRIPT_ROOT)/$FILELOGDIRBASE
|
---|
26 |
|
---|
27 | LUSER = $LUSER
|
---|
28 | LGROUP = $LGROUP
|
---|
29 | LHOME = $LHOME
|
---|
30 | LUSER_HOME = \$(LHOME)/\$(LUSER)
|
---|
31 | SU_LUSER = su - \$(LUSER) -c
|
---|
32 |
|
---|
33 | ADD_REPORT = $REPORT
|
---|
34 | ADD_CUSTOM_TOOLS = $CUSTOM_TOOLS
|
---|
35 | ADD_BLFS_TOOLS = $BLFS_TOOL
|
---|
36 |
|
---|
37 |
|
---|
38 | export PATH := \${PATH}:/usr/sbin
|
---|
39 |
|
---|
40 | include makefile-functions
|
---|
41 |
|
---|
42 | EOF
|
---|
43 | ) > $MKFILE
|
---|
44 | }
|
---|
45 |
|
---|
46 | #=======================
|
---|
47 |
|
---|
48 |
|
---|
49 | #==== TARGET HEADER ====
|
---|
50 |
|
---|
51 | #----------------------------------#
|
---|
52 | wrt_target() { # Create target
|
---|
53 | #----------------------------------#
|
---|
54 | local i=$1
|
---|
55 | local PREV=$2
|
---|
56 | (
|
---|
57 | cat << EOF
|
---|
58 |
|
---|
59 | $i: $PREV
|
---|
60 | @\$(call echo_message, Building)
|
---|
61 | @export BASHBIN=\$(SHELL) && \$(SHELL) progress_bar.sh \$@ \$\$PPID &
|
---|
62 | EOF
|
---|
63 | ) >> $MKFILE.tmp
|
---|
64 | }
|
---|
65 |
|
---|
66 | #=======================
|
---|
67 |
|
---|
68 |
|
---|
69 | #======== RUN THE SCRIPT =======
|
---|
70 |
|
---|
71 | #----------------------------------#
|
---|
72 | wrt_RunAsRoot() { # Some not-chroot scripts must be run as root..
|
---|
73 | #----------------------------------#
|
---|
74 | local MOUNT_ENV
|
---|
75 | local file=$1
|
---|
76 |
|
---|
77 | case ${PROGNAME} in
|
---|
78 | lfs ) MOUNT_ENV="LFS" ;;
|
---|
79 | clfs ) MOUNT_ENV="CLFS" ;;
|
---|
80 | clfs2 ) MOUNT_ENV="CLFS" ;;
|
---|
81 | clfs3 ) MOUNT_ENV="CLFS" ;;
|
---|
82 | hlfs ) MOUNT_ENV="HLFS" ;;
|
---|
83 | *) echo "undefined progname $PROGNAME"; exit 1 ;;
|
---|
84 | esac
|
---|
85 |
|
---|
86 | (
|
---|
87 | cat << EOF
|
---|
88 | @export ${MOUNT_ENV}=\$(MOUNT_PT) && \$(CMDSDIR)/`dirname $file`/\$@ > $LOGDIRBASE/\$@ 2>&1
|
---|
89 | EOF
|
---|
90 | ) >> $MKFILE.tmp
|
---|
91 | }
|
---|
92 |
|
---|
93 | #----------------------------------#
|
---|
94 | wrt_RunScript() { #
|
---|
95 | #----------------------------------#
|
---|
96 | local file=$1
|
---|
97 |
|
---|
98 | (
|
---|
99 | cat << EOF
|
---|
100 | @\$(CMDSDIR)/`dirname $file`/\$@ > $LOGDIRBASE/\$@ 2>&1
|
---|
101 | EOF
|
---|
102 | ) >> $MKFILE.tmp
|
---|
103 | }
|
---|
104 |
|
---|
105 | #=======================
|
---|
106 |
|
---|
107 |
|
---|
108 | #====== COPY FSTAB =====
|
---|
109 |
|
---|
110 | #----------------------------------#
|
---|
111 | LUSER_wrt_CopyFstab() { # Needed for CLFS Sysroot and Embedded
|
---|
112 | #----------------------------------#
|
---|
113 | (
|
---|
114 | cat << EOF
|
---|
115 | @cp -v \$(MOUNT_PT)/sources/fstab \$(MOUNT_PT)/etc/fstab > $LOGDIRBASE/\$@ 2>&1
|
---|
116 | EOF
|
---|
117 | ) >> $MKFILE.tmp
|
---|
118 | }
|
---|
119 |
|
---|
120 | #----------------------------------#
|
---|
121 | wrt_CopyFstab() { #
|
---|
122 | #----------------------------------#
|
---|
123 | (
|
---|
124 | cat << EOF
|
---|
125 | @cp -v /sources/fstab /etc/fstab > $LOGDIRBASE/\$@ 2>&1
|
---|
126 | EOF
|
---|
127 | ) >> $MKFILE.tmp
|
---|
128 | }
|
---|
129 |
|
---|
130 | #=======================
|
---|
131 |
|
---|
132 |
|
---|
133 | #==== INSTALLED FILES LOGS ====
|
---|
134 |
|
---|
135 | #----------------------------------#
|
---|
136 | LUSER_wrt_TouchTimestamp() { # Needed for CLFS Sysroot and Embedded
|
---|
137 | #----------------------------------#
|
---|
138 | (
|
---|
139 | cat << EOF
|
---|
140 | @\$(call touch_timestamp_LUSER)
|
---|
141 | EOF
|
---|
142 | ) >> $MKFILE.tmp
|
---|
143 | }
|
---|
144 |
|
---|
145 | #----------------------------------#
|
---|
146 | wrt_TouchTimestamp() { #
|
---|
147 | #----------------------------------#
|
---|
148 | (
|
---|
149 | cat << EOF
|
---|
150 | @\$(call touch_timestamp)
|
---|
151 | EOF
|
---|
152 | ) >> $MKFILE.tmp
|
---|
153 | }
|
---|
154 |
|
---|
155 | #----------------------------------#
|
---|
156 | LUSER_wrt_LogNewFiles() { # Needed for CLFS Sysroot and Embedded
|
---|
157 | #----------------------------------#
|
---|
158 | local name=$1
|
---|
159 | (
|
---|
160 | cat << EOF
|
---|
161 | @\$(call log_new_files_LUSER,$name)
|
---|
162 | EOF
|
---|
163 | ) >> $MKFILE.tmp
|
---|
164 | }
|
---|
165 |
|
---|
166 | #----------------------------------#
|
---|
167 | wrt_LogNewFiles() { #
|
---|
168 | #----------------------------------#
|
---|
169 | local name=$1
|
---|
170 | (
|
---|
171 | cat << EOF
|
---|
172 | @\$(call log_new_files,$name)
|
---|
173 | EOF
|
---|
174 | ) >> $MKFILE.tmp
|
---|
175 | }
|
---|
176 |
|
---|
177 | #=======================
|
---|
178 |
|
---|
179 |
|
---|
180 | #======== TOUCH ========
|
---|
181 |
|
---|
182 | #----------------------------------#
|
---|
183 | wrt_touch() { #
|
---|
184 | #----------------------------------#
|
---|
185 | (
|
---|
186 | cat << EOF
|
---|
187 | @\$(call housekeeping)
|
---|
188 | EOF
|
---|
189 | ) >> $MKFILE.tmp
|
---|
190 | }
|
---|
191 |
|
---|
192 | #=======================
|
---|