Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100755 360 lines (336 sloc) 8.969 kB
b9097b6 @azman Update Commit
authored
1 #!/bin/sh
2
3 # INFO FOR PROGRAM TO BE BUILT
4 THIS_NAME="$(basename $0)"
5 THIS_PATH="$(dirname $0)"
6 PROG_NAME=${PROG_NAME:="$(basename $THIS_NAME .${THIS_NAME##*.})"}
7 PROG_VERS=${PROG_VERS:="1.6.2"} # CHANGE TO WHAT WE NEED
8 PROG_FULL="$PROG_NAME-$PROG_VERS" # SHOULD BE TOP FOLDER'S NAME
9 PROG_BALL="$PROG_FULL.tar.gz" # CAN BE OTHER THAN $PROG_FULL
10 # PLACE URL ACCORDINGLY!
11 PROG_PATH="http://geda.seul.org/release/v${PROG_VERS%.*}/$PROG_VERS/"
12 PROG_LOAD="${PROG_PATH}${PROG_BALL}"
13 # ASSIGN DOCS ACCORDINGLY!
14 PROG_DOCS="AUTHORS COPYING ChangeLog INSTALL NEWS README"
f7b644f @azman Update Commit
authored
15 # DEPS LIST? (build-time?)
16 PROG_DEPS=""
b9097b6 @azman Update Commit
authored
17 # CHECK MACHINE ARCH!
18 if [[ "$ARCH" == "" ]]; then
19 ARCH="$(uname -m)"
20 case "$ARCH" in
21 i?86) ARCH="i486" ;;
22 arm*) ARCH="arm" ;;
23 esac
24 fi
25 # OUTPUT PACKAGE PARAMS
26 BUILD_TAG=${BUILD_TAG:="1_my1"}
27 PACK_TYPE=${PACK_TYPE:="tgz"}
28 PACK_ARCH=${PACK_ARCH:="$ARCH"}
29 PACK_PATH=${PACK_PATH:="/tmp"}
30 PACK_BALL=${PACK_BALL:="$PROG_NAME-$PROG_VERS-$PACK_ARCH-$BUILD_TAG.$PACK_TYPE"}
31 # BUILD-RELATED PATH
32 CURR_PATH=$(cd $THIS_PATH; pwd)
33 TEMP_PATH=${TEMP_PATH:="/tmp/my1/slackbuild"}
34 DEST_PATH=$TEMP_PATH/package-$PROG_NAME
35 # COMMAND-LINE OPTIONS
36 CHK_DOWNLOAD=${CHK_DOWNLOAD:="NO"}
37 CHK_LOADONLY=${CHK_LOADONLY:="NO"}
38 CHK_MOVEPACK=${CHK_MOVEPACK:="NO"}
39
40 function prepare_source()
41 {
42 # PREPARE SOURCE MANUALLY
43 return
44 }
45
46 function do_build()
47 {
48 # ACTUAL BUILD PROCESS
49 CFLAGS="$SLACKCFLAGS" \
50 CXXFLAGS="$SLACKCFLAGS" \
51 ./configure --prefix=/usr \
52 --sysconfdir=/etc \
53 --localstatedir=/var \
54 --libdir=/usr/lib${LIBDIRSUFFIX} \
55 --mandir=/usr/man \
56 --docdir=/usr/doc/$PROG_FULL \
57 --build=$PACK_ARCH-slackware-linux$ARCHQUADLET
58 make
59 make install DESTDIR=$DEST_PATH
60 }
61
62 function do_pre_build()
63 {
64 # PLACE FIX/PRE-BUILD SCRIPT HERE!
65 return
66 }
67
68 function do_post_build()
69 {
70 # PLACE FIX/POST-BUILD SCRIPT HERE!
71 return
72 }
73
74 function do_install_stuff()
75 {
76 # COPY INSTALLATION-RELATED FILE(S)
77 mkdir -p $DEST_PATH/install
78 RULER_SPC="$(printf "%*s" ${#PROG_NAME} "")";
79 THIS_SLACKDESC=$(cat <<SLACK-DESC
80 # HOW TO EDIT THIS FILE:
81 # The "handy ruler" below makes it easier to edit a package description. Line
82 # up the first '|' above the ':' following the base package name, and the '|'
83 # on the right side marks the last column you can put a character in. You must
84 # make exactly 11 lines for the formatting to be correct. It's also
85 # customary to leave one space after the ':'.
86
87 ${RULER_SPC}|-----handy-ruler------------------------------------------------------|
88 geda-gaf: gEDA (gnu EDA base package)
89 geda-gaf:
f7b644f @azman Update Commit
authored
90 geda-gaf: gEDA/gaf: Schematic capture, netlister, symbols, symbol checker,
b9097b6 @azman Update Commit
authored
91 geda-gaf: and utils. This is the base package for the gnu EDA toolset.
92 geda-gaf:
93 geda-gaf: gschem is the schematic captur tool.
94 geda-gaf: gnetlist is for creating netlists.
95 geda-gaf: gattrib allows the batch updating of attributes.
96 geda-gaf:
97 geda-gaf: http://www.gpleda.org/
98 geda-gaf:
99 SLACK-DESC
100 )
101 echo "$THIS_SLACKDESC" > $DEST_PATH/install/slack-desc
102 THIS_DOINSTSH=$(cat <<DOINSTSH
103 if [ -x /usr/bin/update-desktop-database ]; then
104 /usr/bin/update-desktop-database -q usr/share/applications
105 fi
106
107 if [ -x /usr/bin/update-mime-database ]; then
108 /usr/bin/update-mime-database usr/share/mime >/dev/null 2>&1
109 fi
110
111 if [ -e usr/share/icons/hicolor/icon-theme.cache ]; then
112 if [ -x /usr/bin/gtk-update-icon-cache ]; then
113 /usr/bin/gtk-update-icon-cache usr/share/icons/hicolor >/dev/null 2>&1
114 fi
115 fi
116 DOINSTSH
117 )
118 echo "$THIS_DOINSTSH" > $DEST_PATH/install/doinst.sh
119 }
120
a43a3d7 @azman Update Commit
authored
121 function do_post_package()
122 {
123 # PLACE POST-PACKAGE SCRIPT HERE!
124 show_deps
125 }
126
b9097b6 @azman Update Commit
authored
127 # ONLY TEMPLATES BELOW THIS LINE
128
a43a3d7 @azman Update Commit
authored
129 function show_deps()
130 {
131 if [[ "$PROG_DEPS" != "" ]] ; then
132 echo -n "This software '$PROG_NAME' requires: "
133 for dep in "$PROG_DEPS" ; do
134 echo -n "$dep "
135 dep="$(cd ${THIS_PATH};pwd)/${dep}.SlackBuild"
136 if [[ -r "$dep" ]] ; then
137 echo -n "($dep)"
138 else
139 echo -n "(not found!)"
140 fi
141 done
142 echo
143 fi
144 }
145
b9097b6 @azman Update Commit
authored
146 function check_param()
147 {
148 while [[ "$1" != "" ]]; do
149 case $1 in
150 --load )
151 CHK_DOWNLOAD="YES"
152 ;;
153 --load-only )
154 CHK_DOWNLOAD="YES"
155 CHK_LOADONLY="YES"
156 ;;
157 --move-here )
1907db9 @azman Update Commit
authored
158 MOVE_PATH=$CURR_PATH
b9097b6 @azman Update Commit
authored
159 CHK_MOVEPACK="YES"
160 ;;
1907db9 @azman Update Commit
authored
161 --move )
162 shift
163 MOVE_PATH=$1
164 CHK_MOVEPACK="YES"
165 [[ ! -d "$MOVE_PATH" ]] &&
166 echo "Invalid '--move' path ($MOVE_PATH)!" && exit 1
167 MOVE_PATH=$(cd $MOVE_PATH;pwd)
168 ;;
f7b644f @azman Update Commit
authored
169 --show-deps )
a43a3d7 @azman Update Commit
authored
170 show_deps
171 exit 0
f7b644f @azman Update Commit
authored
172 ;;
b9097b6 @azman Update Commit
authored
173 * )
174 echo "Unknown parameter ($1)!" && exit 1
175 ;;
176 esac
177 shift
178 done
179 # set these as early as possible?
180 set -e # exit immediately when non-zero exit status
181 trap 'echo "$0 FAILED at line $LINENO!"' ERR
182 }
183
184 function do_download()
185 {
186 local fname="$1"
187 local label="$2"
6a659fd @azman Update Commit
authored
188 local cpath="$(pwd)"
b9097b6 @azman Update Commit
authored
189 [[ "$fname" == "" ]] && exit 1 # shouldn't be here?
190 [[ "$label" == "" ]] && label="$fname"
191 echo -n "Downloading $label: "
192 wget --progress=dot "$fname" 2>&1 | grep --line-buffered "%" | \
193 sed -u -e "s,\.,,g" | awk '{printf("\b\b\b\b%4s", $2)}'
194 echo -ne "\b\b\b\b DONE!\n"
6a659fd @azman Update Commit
authored
195 [[ ! -r "$label" ]] &&
196 echo "Cannot download source $cpath/$label!" && exit 1
197 local chk_perm=$(get_userngrp $cpath)
198 [[ "$chk_perm" != "" ]] && chown $chk_perm $cpath/$label
b9097b6 @azman Update Commit
authored
199 }
200
201 function check_source()
202 {
203 local chk_path="$(pwd)"
204 cd $CURR_PATH
205 if [[ ! -r "$PROG_BALL" ]]; then
206 if [[ "$CHK_DOWNLOAD" == "YES" ]]; then
207 do_download $PROG_LOAD $PROG_BALL
208 else
209 echo "Source $CURR_PATH/$PROG_BALL not found!" && exit 1
210 fi
211 fi
212 cd $chk_path
213 [[ "$CHK_LOADONLY" == "YES" ]] && exit 0
214 return 0
215 }
216
217 function check_buildenv()
218 {
219 # CHECK ENVIRONMENT!
220 case "$PACK_ARCH" in
221 "i486")
222 SLACKCFLAGS="-O2 -march=i486 -mtune=i686"
223 LIBDIRSUFFIX=""
224 ARCHQUADLET=""
225 ;;
226 "i686")
227 SLACKCFLAGS="-O2 -march=i686 -mtune=i686"
228 LIBDIRSUFFIX=""
229 ARCHQUADLET=""
230 ;;
231 "x86_64")
232 SLACKCFLAGS="-O2 -fPIC"
233 LIBDIRSUFFIX="64"
234 ARCHQUADLET=""
235 ;;
236 "arm")
237 SLACKCFLAGS="-O2 -march=armv4t"
238 LIBDIRSUFFIX=""
239 ARCHQUADLET="-gnueabi"
240 ;;
241 *)
242 SLACKCFLAGS="-O2"
243 LIBDIRSUFFIX=""
244 ARCHQUADLET=""
245 ;;
246 esac
247 }
248
249 function prepare_build()
250 {
f7b644f @azman Update Commit
authored
251 rm -rf $DEST_PATH
b9097b6 @azman Update Commit
authored
252 mkdir -p $TEMP_PATH $DEST_PATH $PACK_PATH
253 cd $TEMP_PATH
f7b644f @azman Update Commit
authored
254 rm -rf $PROG_FULL
255 tar xvf $CURR_PATH/$PROG_BALL
b9097b6 @azman Update Commit
authored
256 if [[ -d $PROG_FULL ]]; then
257 cd $PROG_FULL
258 elif [[ -d $PROG_NAME ]]; then
259 cd $PROG_NAME
260 else
261 echo "Cannot find path '$PROG_FULL' or '$PROG_NAME'! Aborting!"
262 exit 1
263 fi
f7b644f @azman Update Commit
authored
264 chown -R root:root .
265 chmod -R u+r+w,go+r-w,a+X-s-t .
b9097b6 @azman Update Commit
authored
266 }
267
268 function strip_binaries()
269 {
270 find $DEST_PATH | xargs file | grep -e "executable" | grep ELF \
271 | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null || true
272 find $DEST_PATH | xargs file | grep -e "shared object" | grep ELF \
273 | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null || true
274 }
275
276 function check_manual_info()
277 {
278 # PREPARE MAN PAGES?
279 if [[ -d $DEST_PATH/usr/man ]]; then
280 find $DEST_PATH/usr/man -type f -exec gzip -9 {} \;
281 for i in $(find $DEST_PATH/usr/man -type l) ; do
282 ln -s $( readlink $i ).gz $i.gz
283 rm $i
284 done
285 fi
286 # PREPARE INFO PAGES?
287 if [[ -d $DEST_PATH/usr/info ]]; then
288 gzip -9 $DEST_PATH/usr/info/*.info
289 rm -f $DEST_PATH/usr/info/dir
290 fi
291 }
292
293 function check_documentation()
294 {
295 mkdir -p $DEST_PATH/usr/doc/$PROG_FULL
296 cat $CURR_PATH/$THIS_NAME > $DEST_PATH/usr/doc/$PROG_FULL/$THIS_NAME
297 [[ "$the_docs" == "" ]] && return
298 cp -a $PROG_DOCS $DEST_PATH/usr/doc/$PROG_FULL
299 }
300
1907db9 @azman Update Commit
authored
301 function get_userngrp()
302 {
303 local chk_this=$1
304 local chk_path
305 local chk_user chk_grpn
306 [[ "$chk_this" == "." ]] && chk_this=$(pwd)
307 [[ "$chk_this" == ".." ]] && chk_this=$(cd .. ;pwd)
308 [[ ! -r "$chk_this" ]] && echo -e "Cannot read '$chk_this'!" 1>&2 && return
309 chk_path=$(cd $(dirname $chk_this);pwd)
310 chk_this=$(basename $chk_this)
311 chk_user=$(ls -l "${chk_path}/" | grep -e "${chk_this}$")
312 set -- $chk_user
313 chk_user=$3
314 chk_grpn=$4
315 echo -n "$chk_user:$chk_grpn"
316 }
317
b9097b6 @azman Update Commit
authored
318 function make_slackpkg()
319 {
320 cd $DEST_PATH
321 /sbin/makepkg -l y -c n $PACK_PATH/$PACK_BALL
322 if [[ "$CHK_MOVEPACK" == "YES" ]]; then
1907db9 @azman Update Commit
authored
323 local chk_perm=$(get_userngrp $MOVE_PATH)
324 [[ "$chk_perm" != "" ]] && chown $chk_perm $PACK_PATH/$PACK_BALL
325 mv $PACK_PATH/$PACK_BALL $MOVE_PATH/
326 echo -e "\nPackage $PACK_PATH/$PACK_BALL moved to $MOVE_PATH!\n"
b9097b6 @azman Update Commit
authored
327 fi
328 }
329
330 # CHECK COMMAND-LINE PARAMETER - TEMPLATE
331 check_param $@
f7b644f @azman Update Commit
authored
332 # ONLY ROOT CAN BUILD!
333 [[ $UID -ne 0 ]] && echo "[ERROR] Must run as root! Aborting!" && exit 1
b9097b6 @azman Update Commit
authored
334 # IN CASE SOURCE FROM REPO - CUSTOM (OPTIONAL)
335 prepare_source
336 # CHECK IF SOURCE EXISTS - TEMPLATE
337 check_source
338 # CHECK THE BUILD ENVIRONMENT - TEMPLATE
339 check_buildenv
340 # PREPARE FOR THE BUILD - TEMPLATE
341 prepare_build
342 # EXTRA STUFF - CUSTOM (OPTIONAL)
343 do_pre_build
344 # ACTUAL BUILD PROCESS - CUSTOM (STANDARD)
345 do_build
346 # EXTRA STUFF - CUSTOM (OPTIONAL)
347 do_post_build
348 # STRIP SIZE OF BINARIES - TEMPLATE
349 strip_binaries
350 # PREPARE MAN & INFO PAGES - TEMPLATE
351 check_manual_info
352 # COPY DOCUMENTATION FILE(S) - TEMPLATE
353 check_documentation
354 # PREP FOR INSTALLATION - CUSTOM (STANDARD)
355 do_install_stuff
356 # MAKE SLACKWARE PACKAGE - TEMPLATE
357 make_slackpkg
a43a3d7 @azman Update Commit
authored
358 # EXTRA POST-PACKAGING - CUSTOM (OPTIONAL)
359 do_post_package
Something went wrong with that request. Please try again.