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 |
|
---|
52 | if [[ -n "$pkg_ver" ]] ; then
|
---|
53 | (
|
---|
54 | cat << EOF
|
---|
55 | @touch \$(TRACKING_DIR)/${pkg_name#*-?-}-${pkg_ver}
|
---|
56 | EOF
|
---|
57 | ) >> $MKFILE.tmp
|
---|
58 | fi
|
---|
59 |
|
---|
60 | (
|
---|
61 | cat << EOF
|
---|
62 | @touch \$@ && \\
|
---|
63 | sleep .25 && \\
|
---|
64 | echo -e "\n\n "\$(BOLD)Target \$(BLUE)\$@ \$(BOLD)OK && \\
|
---|
65 | echo --------------------------------------------------------------------------------\$(WHITE)
|
---|
66 | EOF
|
---|
67 | ) >> $MKFILE.tmp
|
---|
68 | }
|
---|
69 |
|
---|
70 |
|
---|
71 | #----------------------------#
|
---|
72 | __write_entry() { #
|
---|
73 | #----------------------------#
|
---|
74 | local script_name=$1
|
---|
75 | local pkg_ver=$2
|
---|
76 |
|
---|
77 | echo -n "${tab_}${tab_} entry for <$script_name>"
|
---|
78 |
|
---|
79 | #--------------------------------------------------------------------#
|
---|
80 | # >>>>>>>> START BUILDING A Makefile ENTRY <<<<<<<< #
|
---|
81 | #--------------------------------------------------------------------#
|
---|
82 | #
|
---|
83 | # Drop in the name of the target on a new line, and the previous target
|
---|
84 | # as a dependency. Also call the echo_message function.
|
---|
85 | __wrt_target "${script_name}" "$PREV_PACKAGE"
|
---|
86 | __write_build_cmd
|
---|
87 |
|
---|
88 | # Include a touch of the target name so make can check
|
---|
89 | # if it's already been made.
|
---|
90 | __wrt_touch "${script_name}" "${pkg_ver}"
|
---|
91 | #
|
---|
92 | #--------------------------------------------------------------------#
|
---|
93 | # >>>>>>>> END OF Makefile ENTRY <<<<<<<< #
|
---|
94 | #--------------------------------------------------------------------#
|
---|
95 | echo " .. OK"
|
---|
96 | }
|
---|
97 |
|
---|
98 | #----------------------------#
|
---|
99 | __write_meta_pkg_touch() { #
|
---|
100 | #----------------------------#
|
---|
101 | local meta_pkg=$1
|
---|
102 | local pkg_ver=$(grep "^${meta_pkg}[[:space:]]" ../packages | cut -f3)
|
---|
103 | local gnome_core_ver=$(grep "^gnome-core[[:space:]]" ../packages | cut -f3)
|
---|
104 | local kde_core_ver=$(grep "^kde-core[[:space:]]" ../packages | cut -f3)
|
---|
105 | local kde_full_ver=$(grep "^kde-full[[:space:]]" ../packages | cut -f3)
|
---|
106 |
|
---|
107 | (
|
---|
108 | cat << EOF
|
---|
109 | 999-z-$meta_pkg: $PREV
|
---|
110 | @touch \$(TRACKING_DIR)/${meta_pkg}-${pkg_ver}
|
---|
111 | EOF
|
---|
112 | ) >> $MKFILE.tmp
|
---|
113 |
|
---|
114 | case $meta_pkg in
|
---|
115 | gnome-full )
|
---|
116 | (
|
---|
117 | cat << EOF
|
---|
118 | @touch \$(TRACKING_DIR)/gnome-core-${gnome_core_ver}
|
---|
119 | EOF
|
---|
120 | ) >> $MKFILE.tmp
|
---|
121 | ;;
|
---|
122 | kde-full )
|
---|
123 | (
|
---|
124 | cat << EOF
|
---|
125 | @touch \$(TRACKING_DIR)/kde-core-${kde_core_ver}
|
---|
126 | EOF
|
---|
127 | ) >> $MKFILE.tmp
|
---|
128 | ;;
|
---|
129 | kde-koffice )
|
---|
130 | (
|
---|
131 | cat << EOF
|
---|
132 | @touch \$(TRACKING_DIR)/kde-core-${kde_core_ver}
|
---|
133 | @touch \$(TRACKING_DIR)/kde-full-${kde_full_ver}
|
---|
134 | EOF
|
---|
135 | ) >> $MKFILE.tmp
|
---|
136 | ;;
|
---|
137 | esac
|
---|
138 |
|
---|
139 | (
|
---|
140 | cat << EOF
|
---|
141 | @touch \$@
|
---|
142 | EOF
|
---|
143 | ) >> $MKFILE.tmp
|
---|
144 |
|
---|
145 | }
|
---|
146 |
|
---|
147 | #----------------------------#
|
---|
148 | generate_Makefile () { #
|
---|
149 | #----------------------------#
|
---|
150 |
|
---|
151 |
|
---|
152 | echo "${tab_}Creating Makefile... ${BOLD}START${OFF}"
|
---|
153 |
|
---|
154 | # Start with a clean files
|
---|
155 | >$MKFILE
|
---|
156 | >$MKFILE.tmp
|
---|
157 |
|
---|
158 |
|
---|
159 | for package_script in scripts/* ; do
|
---|
160 | this_script=`basename $package_script`
|
---|
161 | pkg_ver=$(grep "^${this_script#*-?-}[[:space:]]" ../packages | cut -f3)
|
---|
162 | pkg_list="$pkg_list ${this_script}"
|
---|
163 | __write_entry "${this_script}" "${pkg_ver}"
|
---|
164 | PREV_PACKAGE=${this_script}
|
---|
165 | done
|
---|
166 |
|
---|
167 | PACKAGE=$(basename $PWD)
|
---|
168 |
|
---|
169 | case $PACKAGE in
|
---|
170 | alsa | \
|
---|
171 | gnome-core | \
|
---|
172 | gnome-full | \
|
---|
173 | kde-core | \
|
---|
174 | kde-full | \
|
---|
175 | kde-koffice | \
|
---|
176 | xorg7 ) __write_meta_pkg_touch "${PACKAGE}" ;;
|
---|
177 | esac
|
---|
178 |
|
---|
179 |
|
---|
180 | # Add a header, some variables and include the function file
|
---|
181 | # to the top of the real Makefile.
|
---|
182 | (
|
---|
183 | cat << EOF
|
---|
184 | $HEADER
|
---|
185 |
|
---|
186 | PACKAGE= $PACKAGE
|
---|
187 | TRACKING_DIR= $TRACKING_DIR
|
---|
188 |
|
---|
189 | BOLD= "[0;1m"
|
---|
190 | RED= "[1;31m"
|
---|
191 | GREEN= "[0;32m"
|
---|
192 | ORANGE= "[0;33m"
|
---|
193 | BLUE= "[1;34m"
|
---|
194 | WHITE= "[00m"
|
---|
195 |
|
---|
196 | define echo_message
|
---|
197 | @echo \$(BOLD)
|
---|
198 | @echo --------------------------------------------------------------------------------
|
---|
199 | @echo \$(BOLD)\$(1) target \$(BLUE)\$@\$(BOLD)
|
---|
200 | @echo \$(WHITE)
|
---|
201 | endef
|
---|
202 |
|
---|
203 |
|
---|
204 | define fin_message
|
---|
205 | @echo \$(BOLD)
|
---|
206 | @echo --------------------------------------------------------------------------------
|
---|
207 | @echo \$(BOLD) Build complete for the package \$(BLUE)\$(PACKAGE)\$(BOLD) and its dependencies
|
---|
208 | @echo \$(WHITE)
|
---|
209 | endef
|
---|
210 |
|
---|
211 | all : $pkg_list
|
---|
212 | @\$(call fin_message )
|
---|
213 | EOF
|
---|
214 | ) > $MKFILE
|
---|
215 |
|
---|
216 | cat $MKFILE.tmp >> $MKFILE
|
---|
217 | echo "${tab_}Creating Makefile... ${BOLD}DONE${OFF}"
|
---|
218 |
|
---|
219 | rm $MKFILE.tmp
|
---|
220 |
|
---|
221 | }
|
---|
222 |
|
---|
223 | generate_Makefile
|
---|
224 |
|
---|
225 | cp ../progress_bar.sh .
|
---|
226 |
|
---|
227 | mkdir -p logs
|
---|