source: common/libs/func_wrt_Makefile@ f5f857d

experimental
Last change on this file since f5f857d was f5f857d, checked in by Manuel Canales Esparcia <manuel@…>, 17 years ago

Set $TEST_LOG from inside the build scripts.
There is no need now to use the envars file.
Optimize support must be moved to an XSL-based code.

  • Property mode set to 100644
File size: 4.3 KB
Line 
1#!/bin/bash
2
3# $Id$
4
5#=== MAKEFILE HEADER ===
6
7#----------------------------------#
8wrt_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
18SHELL = /bin/bash
19
20SRC = /sources
21MOUNT_PT = $BUILDDIR
22PKG_LST = $PKG_LST
23LUSER = $LUSER
24LGROUP = $LGROUP
25LHOME = $LHOME
26SCRIPT_ROOT = $SCRIPT_ROOT
27
28BASEDIR = \$(MOUNT_PT)
29SRCSDIR = \$(BASEDIR)/sources
30CMDSDIR = \$(BASEDIR)/\$(SCRIPT_ROOT)/$PROGNAME-commands
31LOGDIR = \$(BASEDIR)/\$(SCRIPT_ROOT)/$LOGDIRBASE
32TESTLOGDIR = \$(BASEDIR)/\$(SCRIPT_ROOT)/$TESTLOGDIRBASE
33
34crCMDSDIR = /\$(SCRIPT_ROOT)/$PROGNAME-commands
35crLOGDIR = /\$(SCRIPT_ROOT)/$LOGDIRBASE
36crTESTLOGDIR = /\$(SCRIPT_ROOT)/$TESTLOGDIRBASE
37crFILELOGDIR = /\$(SCRIPT_ROOT)/$FILELOGDIRBASE
38
39SU_LUSER = su - \$(LUSER) -c
40LUSER_HOME = \$(LHOME)/\$(LUSER)
41
42ADD_REPORT = $REPORT
43ADD_CUSTOM_TOOLS = $CUSTOM_TOOLS
44ADD_BLFS_TOOLS = $BLFS_TOOL
45
46
47export PATH := \${PATH}:/usr/sbin
48
49include makefile-functions
50
51EOF
52) > $MKFILE
53}
54
55#=======================
56
57
58#==== TARGET HEADER ====
59
60#----------------------------------#
61LUSER_wrt_target() { # Create target
62#----------------------------------#
63 local i=$1
64 local PREV=$2
65(
66cat << EOF
67
68$i: $PREV
69 @\$(call echo_message, Building)
70 @export BASHBIN=\$(SHELL) && \$(SHELL) progress_bar.sh \$@ \$\$PPID &
71EOF
72) >> $MKFILE.tmp
73}
74
75#----------------------------------#
76CHROOT_wrt_target() { #
77#----------------------------------#
78 local i=$1
79 local PREV=$2
80(
81cat << EOF
82
83$i: $PREV
84 @\$(call echo_message, Building)
85 @export BASHBIN=\$(SHELL) && \$(SHELL) progress_bar.sh \$@ \$\$PPID &
86EOF
87) >> $MKFILE.tmp
88}
89
90#=======================
91
92
93#======== RUN AS =======
94
95#----------------------------------#
96wrt_RunAsRoot() { # Some scripts must be run as root..
97#----------------------------------#
98 local MOUNT_ENV
99 local file=$1
100
101 case ${PROGNAME} in
102 lfs ) MOUNT_ENV="LFS" ;;
103 clfs ) MOUNT_ENV="CLFS" ;;
104 clfs2 ) MOUNT_ENV="CLFS" ;;
105 clfs3 ) MOUNT_ENV="CLFS" ;;
106 hlfs ) MOUNT_ENV="HLFS" ;;
107 *) echo "undefined progname $PROGNAME"; exit 1 ;;
108 esac
109
110(
111cat << EOF
112 @export ${MOUNT_ENV}=\$(MOUNT_PT) && ${PROGNAME}-commands/`dirname $file`/\$@ > logs/\$@ 2>&1
113EOF
114) >> $MKFILE.tmp
115}
116
117#----------------------------------#
118LUSER_wrt_RunAsUser() { #
119#----------------------------------#
120 local file=$1
121
122(
123cat << EOF
124 @\$(CMDSDIR)/`dirname $file`/\$@ > logs/\$@ 2>&1
125EOF
126) >> $MKFILE.tmp
127}
128
129#----------------------------------#
130CHROOT_wrt_RunAsRoot() { #
131#----------------------------------#
132 local file=$1
133(
134cat << EOF
135 @\$(crCMDSDIR)/`dirname $file`/\$@ > logs/\$@ 2>&1
136EOF
137) >> $MKFILE.tmp
138
139}
140
141#=======================
142
143
144#====== COPY FSTAB =====
145
146#----------------------------------#
147LUSER_wrt_CopyFstab() { #
148#----------------------------------#
149(
150cat << EOF
151 @cp -v \$(MOUNT_PT)/sources/fstab \$(MOUNT_PT)/etc/fstab > logs/\$@ 2>&1
152EOF
153) >> $MKFILE.tmp
154}
155
156#----------------------------------#
157CHROOT_wrt_CopyFstab() { #
158#----------------------------------#
159(
160cat << EOF
161 @cp -v /sources/fstab /etc/fstab > logs/\$@ 2>&1
162EOF
163) >> $MKFILE.tmp
164}
165
166#=======================
167
168
169#==== INSTALLED FILES LOGS ====
170
171#----------------------------------#
172LUSER_wrt_TouchTimestamp() { #
173#----------------------------------#
174(
175cat << EOF
176 @\$(call touch_timestamp_LUSER)
177EOF
178) >> $MKFILE.tmp
179}
180
181#----------------------------------#
182CHROOT_wrt_TouchTimestamp() { #
183#----------------------------------#
184(
185cat << EOF
186 @\$(call touch_timestamp)
187EOF
188) >> $MKFILE.tmp
189}
190
191#----------------------------------#
192LUSER_wrt_LogNewFiles() { #
193#----------------------------------#
194 local name=$1
195(
196cat << EOF
197 @\$(call log_new_files_LUSER,$name)
198EOF
199) >> $MKFILE.tmp
200}
201
202#----------------------------------#
203CHROOT_wrt_LogNewFiles() { #
204#----------------------------------#
205 local name=$1
206(
207cat << EOF
208 @\$(call log_new_files,$name)
209EOF
210) >> $MKFILE.tmp
211}
212
213#=======================
214
215
216#======== TOUCH ========
217
218#----------------------------------#
219wrt_touch() { #
220#----------------------------------#
221(
222cat << EOF
223 @\$(call housekeeping)
224EOF
225) >> $MKFILE.tmp
226}
227
228#=======================
Note: See TracBrowser for help on using the repository browser.