source: hybrid/branches/releng-10/nanobsd/tools/package-build.inc.sh@ 12882

Last change on this file since 12882 was 10833, checked in by rick, 13 years ago

Just a failsafe, in trying to debug why the new packages do not get a symlink in ./pkg/All

  • Property svn:eol-style set to LF
  • Property svn:executable set to *
File size: 1.9 KB
Line 
1# Make sure to only load this file ones, even if sourced from multiple
2# locations, preventing weird and wonderfull errors of relative paths.
3if [ -n "$PACKAGE_BUILD_INC_SH" ]; then
4 return
5fi
6PACKAGE_BUILD_INC_SH=true
7
8# Used to store profile data
9TIME_FILE=$(dirname $0)/eta-times.txt
10
11p_list () {
12echo "$*" | sed -e 's/ /|## /g' -e 's/^/## /g'
13}
14
15p_info () {
16 echo "$*" | tr '|' '\n' | sed 's/^/# /'
17}
18
19p_warn () {
20 echo "$*" | tr '|' '\n' | sed 's/^/#WARN: /'
21}
22
23p_err () {
24 echo "$*" | tr '|' '\n' | sed 's/^/#ERR: /'
25}
26
27p_sleep() {
28 SLEEP=${1-5}
29 while [ "${SLEEP}" -gt 0 ]; do
30 printf '.'
31 sleep 1
32 SLEEP=`expr ${SLEEP} - 1`
33 done
34 printf '\n'
35}
36
37# Print estimation on how long it normally if going to take
38f_time() {
39 COMMAND="$*"
40 ETA_TIME=` grep "${COMMAND}$" ${TIME_FILE} 2>/dev/null | awk '{print $1}'`
41 if [ -z "${ETA_TIME}" ]; then
42 ETA_TIME="NaN"
43 fi
44
45 p_info Last run of "'${COMMAND}'" took ${ETA_TIME}
46 p_info Start time: `date`
47
48 # Execute command
49 START_TIME=`date "+%s"`
50 $COMMAND
51 RETVAL=$?
52 STOP_TIME=`date "+%s"`
53
54 p_info End time: `date`
55 # Calculate time it took
56 TOTAL_TIME=`expr ${STOP_TIME} - ${START_TIME}`
57 HUMAN_FMT=`date -ur ${TOTAL_TIME} "+%H:%M:%S"`
58
59 # Store new time if command is succesfull
60 if [ "${RETVAL}" -eq 0 ]; then
61 grep -v "${COMMAND}$" ${TIME_FILE} > ${TIME_FILE}.tmp 2>/dev/null
62 echo "${HUMAN_FMT} ${COMMAND}" >> ${TIME_FILE}.tmp
63 mv ${TIME_FILE}.tmp ${TIME_FILE}
64 fi
65
66 # Return the command it's output
67 return ${RETVAL}
68}
69
70f_check_root() {
71 # No Root, no fun
72 if [ `id -u` -ne 0 ]; then
73 print_err Root only
74 exit 1
75 fi
76}
77
78# Find object directory
79BASEDIR=`dirname $0`
80
81# Load the NanoBSD Configuration entries
82NANO_CFG_FILE="${BASEDIR}/../cfg/nanobsd.wleiden"
83customize_cmd() { return; }
84late_customize_cmd() { return; }
85. $NANO_CFG_FILE
86
87OBJDIR="/usr/obj/nanobsd.${NANO_NAME}"
88
Note: See TracBrowser for help on using the repository browser.