1 | #!/bin/bash
|
---|
2 | #
|
---|
3 | # $Id$
|
---|
4 | #
|
---|
5 | set -e
|
---|
6 |
|
---|
7 | # TEMPORARY VARIABLES.. development use only
|
---|
8 | declare MKFILE=Makefile
|
---|
9 | declare PREV_PACKAGE=""
|
---|
10 | declare BUILD_SCRIPTS=scripts
|
---|
11 | declare TRACKING_DIR=tracking-dir
|
---|
12 |
|
---|
13 | HEADER="# This file is automatically generated by jhalfs
|
---|
14 | # YOU MAY NEED TO EDIT THIS FILE MANUALLY
|
---|
15 | #
|
---|
16 | # Generated on `date \"+%F %X %Z\"`"
|
---|
17 |
|
---|
18 |
|
---|
19 | #----------------------------------#
|
---|
20 | __wrt_target() { # Create target and initialize log file
|
---|
21 | #----------------------------------#
|
---|
22 | local i=$1
|
---|
23 | local PREV=$2
|
---|
24 | (
|
---|
25 | cat << EOF
|
---|
26 |
|
---|
27 | $i: $PREV
|
---|
28 | @\$(call echo_message, Building)
|
---|
29 | @./progress_bar.sh \$@ &
|
---|
30 | EOF
|
---|
31 | ) >> $MKFILE.tmp
|
---|
32 | }
|
---|
33 |
|
---|
34 |
|
---|
35 |
|
---|
36 | #----------------------------------#
|
---|
37 | __write_build_cmd() { #
|
---|
38 | #----------------------------------#
|
---|
39 | (
|
---|
40 | cat << EOF
|
---|
41 | @source ../envars.conf && ${BUILD_SCRIPTS}/\$@ >logs/\$@ 2>&1
|
---|
42 | EOF
|
---|
43 | ) >> $MKFILE.tmp
|
---|
44 | }
|
---|
45 |
|
---|
46 | #----------------------------------#
|
---|
47 | __wrt_touch() { #
|
---|
48 | #----------------------------------#
|
---|
49 | local pkg_name=$1
|
---|
50 | local pkg_ver=$2
|
---|
51 | local alsa_ver=$(grep "^alsa[[:space:]]" ../packages | cut -f3)
|
---|
52 | local kde_core_ver=$(grep "^kde-core[[:space:]]" ../packages | cut -f3)
|
---|
53 | local xorg7_ver=$(grep "^xorg7[[:space:]]" ../packages | cut -f3)
|
---|
54 |
|
---|
55 | if [[ -n "$pkg_ver" ]] ; then
|
---|
56 | (
|
---|
57 | cat << EOF
|
---|
58 | @touch \$(TRACKING_DIR)/${pkg_name#*-?-}-${pkg_ver}
|
---|
59 | EOF
|
---|
60 | ) >> $MKFILE.tmp
|
---|
61 | fi
|
---|
62 |
|
---|
63 | case $pkg_name in
|
---|
64 | *-alsa-lib ) #this the unique mandatory package for ALSA support.
|
---|
65 | (
|
---|
66 | cat << EOF
|
---|
67 | @touch \$(TRACKING_DIR)/alsa-${alsa_ver}
|
---|
68 | EOF
|
---|
69 | ) >> $MKFILE.tmp
|
---|
70 | ;;
|
---|
71 | *-kdebase )
|
---|
72 | (
|
---|
73 | cat << EOF
|
---|
74 | @touch \$(TRACKING_DIR)/kde-core-${kde_core_ver}
|
---|
75 | EOF
|
---|
76 | ) >> $MKFILE.tmp
|
---|
77 | ;;
|
---|
78 | *-xorg7-driver ) # xtrerm2 and rman are optional
|
---|
79 | (
|
---|
80 | cat << EOF
|
---|
81 | @touch \$(TRACKING_DIR)/xorg7-${xorg7_ver}
|
---|
82 | EOF
|
---|
83 | ) >> $MKFILE.tmp
|
---|
84 | ;;
|
---|
85 | esac
|
---|
86 |
|
---|
87 | (
|
---|
88 | cat << EOF
|
---|
89 | @touch \$@ && \\
|
---|
90 | sleep .25 && \\
|
---|
91 | echo -e "\n\n "\$(BOLD)Target \$(BLUE)\$@ \$(BOLD)OK && \\
|
---|
92 | echo --------------------------------------------------------------------------------\$(WHITE)
|
---|
93 | EOF
|
---|
94 | ) >> $MKFILE.tmp
|
---|
95 | }
|
---|
96 |
|
---|
97 |
|
---|
98 | #----------------------------#
|
---|
99 | __write_entry() { #
|
---|
100 | #----------------------------#
|
---|
101 | local script_name=$1
|
---|
102 | local pkg_ver=$2
|
---|
103 |
|
---|
104 | echo -n "${tab_}${tab_} entry for <$script_name>"
|
---|
105 |
|
---|
106 | #--------------------------------------------------------------------#
|
---|
107 | # >>>>>>>> START BUILDING A Makefile ENTRY <<<<<<<< #
|
---|
108 | #--------------------------------------------------------------------#
|
---|
109 | #
|
---|
110 | # Drop in the name of the target on a new line, and the previous target
|
---|
111 | # as a dependency. Also call the echo_message function.
|
---|
112 | __wrt_target "${script_name}" "$PREV_PACKAGE"
|
---|
113 | __write_build_cmd
|
---|
114 |
|
---|
115 | # Include a touch of the target name so make can check
|
---|
116 | # if it's already been made.
|
---|
117 | __wrt_touch "${script_name}" "${pkg_ver}"
|
---|
118 | #
|
---|
119 | #--------------------------------------------------------------------#
|
---|
120 | # >>>>>>>> END OF Makefile ENTRY <<<<<<<< #
|
---|
121 | #--------------------------------------------------------------------#
|
---|
122 | echo " .. OK"
|
---|
123 | }
|
---|
124 |
|
---|
125 | #----------------------------#
|
---|
126 | __write_meta_pkg_touch() { #
|
---|
127 | #----------------------------#
|
---|
128 | local meta_pkg=$1
|
---|
129 | local pkg_ver=$(grep "^${meta_pkg}[[:space:]]" ../packages | cut -f3)
|
---|
130 | local gnome_core_ver=$(grep "^gnome-core[[:space:]]" ../packages | cut -f3)
|
---|
131 | local kde_full_ver=$(grep "^kde-full[[:space:]]" ../packages | cut -f3)
|
---|
132 |
|
---|
133 | (
|
---|
134 | cat << EOF
|
---|
135 |
|
---|
136 | 999-z-$meta_pkg: $PREV_PACKAGE
|
---|
137 | @touch \$(TRACKING_DIR)/${meta_pkg}-${pkg_ver}
|
---|
138 | EOF
|
---|
139 | ) >> $MKFILE.tmp
|
---|
140 |
|
---|
141 | case $meta_pkg in
|
---|
142 | gnome-full )
|
---|
143 | (
|
---|
144 | cat << EOF
|
---|
145 | @touch \$(TRACKING_DIR)/gnome-core-${gnome_core_ver}
|
---|
146 | EOF
|
---|
147 | ) >> $MKFILE.tmp
|
---|
148 | ;;
|
---|
149 | kde-koffice )
|
---|
150 | (
|
---|
151 | cat << EOF
|
---|
152 | @touch \$(TRACKING_DIR)/kde-full-${kde_full_ver}
|
---|
153 | EOF
|
---|
154 | ) >> $MKFILE.tmp
|
---|
155 | ;;
|
---|
156 | esac
|
---|
157 |
|
---|
158 | (
|
---|
159 | cat << EOF
|
---|
160 | @touch \$@
|
---|
161 | EOF
|
---|
162 | ) >> $MKFILE.tmp
|
---|
163 |
|
---|
164 | }
|
---|
165 |
|
---|
166 | #----------------------------#
|
---|
167 | generate_Makefile () { #
|
---|
168 | #----------------------------#
|
---|
169 |
|
---|
170 |
|
---|
171 | echo "${tab_}Creating Makefile... ${BOLD}START${OFF}"
|
---|
172 |
|
---|
173 | # Start with a clean files
|
---|
174 | >$MKFILE
|
---|
175 | >$MKFILE.tmp
|
---|
176 |
|
---|
177 |
|
---|
178 | for package_script in scripts/* ; do
|
---|
179 | this_script=`basename $package_script`
|
---|
180 | pkg_ver=$(grep "^${this_script#*-?-}[[:space:]]" ../packages | cut -f3)
|
---|
181 | pkg_list="$pkg_list ${this_script}"
|
---|
182 | __write_entry "${this_script}" "${pkg_ver}"
|
---|
183 | PREV_PACKAGE=${this_script}
|
---|
184 | done
|
---|
185 |
|
---|
186 | PACKAGE=$(basename $PWD)
|
---|
187 |
|
---|
188 | # alsa, kde-core and xorg7 are also available dependencies, thus handled
|
---|
189 | # in another way.
|
---|
190 | case $PACKAGE in
|
---|
191 | gnome-core | \
|
---|
192 | gnome-full | \
|
---|
193 | kde-full | \
|
---|
194 | kde-koffice ) pkg_list="$pkg_list 999-z-${PACKAGE}"
|
---|
195 | __write_meta_pkg_touch "${PACKAGE}"
|
---|
196 | ;;
|
---|
197 | esac
|
---|
198 |
|
---|
199 |
|
---|
200 | # Add a header, some variables and include the function file
|
---|
201 | # to the top of the real Makefile.
|
---|
202 | (
|
---|
203 | cat << EOF
|
---|
204 | $HEADER
|
---|
205 |
|
---|
206 | PACKAGE= $PACKAGE
|
---|
207 | TRACKING_DIR= $TRACKING_DIR
|
---|
208 |
|
---|
209 | BOLD= "[0;1m"
|
---|
210 | RED= "[1;31m"
|
---|
211 | GREEN= "[0;32m"
|
---|
212 | ORANGE= "[0;33m"
|
---|
213 | BLUE= "[1;34m"
|
---|
214 | WHITE= "[00m"
|
---|
215 |
|
---|
216 | define echo_message
|
---|
217 | @echo \$(BOLD)
|
---|
218 | @echo --------------------------------------------------------------------------------
|
---|
219 | @echo \$(BOLD)\$(1) target \$(BLUE)\$@\$(BOLD)
|
---|
220 | @echo \$(WHITE)
|
---|
221 | endef
|
---|
222 |
|
---|
223 |
|
---|
224 | define fin_message
|
---|
225 | @echo \$(BOLD)
|
---|
226 | @echo --------------------------------------------------------------------------------
|
---|
227 | @echo \$(BOLD) Build complete for the package \$(BLUE)\$(PACKAGE)\$(BOLD) and its dependencies
|
---|
228 | @echo \$(WHITE)
|
---|
229 | endef
|
---|
230 |
|
---|
231 | all : $pkg_list
|
---|
232 | @\$(call fin_message )
|
---|
233 | EOF
|
---|
234 | ) > $MKFILE
|
---|
235 |
|
---|
236 | cat $MKFILE.tmp >> $MKFILE
|
---|
237 | echo "${tab_}Creating Makefile... ${BOLD}DONE${OFF}"
|
---|
238 |
|
---|
239 | rm $MKFILE.tmp
|
---|
240 |
|
---|
241 | }
|
---|
242 |
|
---|
243 | generate_Makefile
|
---|
244 |
|
---|
245 | cp ../progress_bar.sh .
|
---|
246 |
|
---|
247 | mkdir -p logs
|
---|