1 |
Author: vapier |
2 |
Date: 2008-02-23 01:08:54 +0000 (Sat, 23 Feb 2008) |
3 |
New Revision: 9370 |
4 |
|
5 |
Modified: |
6 |
main/trunk/bin/emerge-webrsync |
7 |
Log: |
8 |
tighten up output from script |
9 |
|
10 |
Modified: main/trunk/bin/emerge-webrsync |
11 |
=================================================================== |
12 |
--- main/trunk/bin/emerge-webrsync 2008-02-23 00:57:06 UTC (rev 9369) |
13 |
+++ main/trunk/bin/emerge-webrsync 2008-02-23 01:08:54 UTC (rev 9370) |
14 |
@@ -14,8 +14,20 @@ |
15 |
# gpg --homedir /etc/portage/gnupg --edit-key $KEY_ID trust |
16 |
# |
17 |
|
18 |
+# XXX: all output should prob be converted to e* funcs ... |
19 |
+ |
20 |
+# Only echo if in verbose mode |
21 |
+vvecho() { [[ ${do_verbose} -eq 1 ]] && echo "$@" ; } |
22 |
+# Only echo if not in verbose mode |
23 |
+nvecho() { [[ ${do_verbose} -eq 0 ]] && echo "$@" ; } |
24 |
+# warning echos |
25 |
+wecho() { echo "${argv0}: warning: $*" 1>&2 ; } |
26 |
+# error echos |
27 |
+eecho() { echo "${argv0}: error: $*" 1>&2 ; } |
28 |
+ |
29 |
+argv0=$0 |
30 |
if ! type portageq > /dev/null ; then |
31 |
- echo "$0: could not find 'portageq'; aborting" 1>&2 |
32 |
+ eecho "could not find 'portageq'; aborting" |
33 |
exit 1 |
34 |
fi |
35 |
eval $(portageq envvar -v FEATURES FETCHCOMMAND GENTOO_MIRRORS \ |
36 |
@@ -34,6 +46,7 @@ |
37 |
source "${PORTAGE_BIN_PATH}"/isolated-functions.sh || exit 1 |
38 |
|
39 |
do_verbose=0 |
40 |
+do_debug=0 |
41 |
|
42 |
if hasq webrsync-gpg ${FEATURES} ; then |
43 |
WEBSYNC_VERIFY_SIGNATURE=1 |
44 |
@@ -41,7 +54,7 @@ |
45 |
WEBSYNC_VERIFY_SIGNATURE=0 |
46 |
fi |
47 |
if [ ${WEBSYNC_VERIFY_SIGNATURE} != 0 -a -z "${PORTAGE_GPG_DIR}" ]; then |
48 |
- echo "Error: Please set PORTAGE_GPG_DIR in make.conf" |
49 |
+ eecho "please set PORTAGE_GPG_DIR in make.conf" |
50 |
exit 1 |
51 |
fi |
52 |
|
53 |
@@ -81,25 +94,17 @@ |
54 |
local opts |
55 |
|
56 |
if [ "${FETCHCOMMAND/wget/}" != "${FETCHCOMMAND}" ]; then |
57 |
- opts="--continue" |
58 |
- |
59 |
- [ "${do_verbose}" == 0 ] && opts="$opts -q" |
60 |
+ opts="--continue $(nvecho -q)" |
61 |
elif [ "${FETCHCOMMAND/curl/}" != "${FETCHCOMMAND}" ]; then |
62 |
- opts="--continue-at -" |
63 |
- |
64 |
- [ "${do_verbose}" == 0 ] && opts="$opts -s -f" |
65 |
+ opts="--continue-at - $(nvecho -s -f)" |
66 |
else |
67 |
rm -f "${FILE}" |
68 |
fi |
69 |
|
70 |
- echo "Fetching file ${FILE}..." |
71 |
- |
72 |
- #already set DISTDIR= |
73 |
- if [ "${do_verbose}" == 0 ] ; then |
74 |
- eval "${FETCHCOMMAND}" ${opts} > /dev/null && [ -s "${FILE}" ] |
75 |
- else |
76 |
- eval "${FETCHCOMMAND}" ${opts} && [ -s "${FILE}" ] |
77 |
- fi |
78 |
+ vecho "Fetching file ${FILE}..." |
79 |
+ # already set DISTDIR= |
80 |
+ eval "${FETCHCOMMAND}" ${opts} |
81 |
+ [ -s "${FILE}" ] |
82 |
} |
83 |
|
84 |
check_file_digest() { |
85 |
@@ -107,15 +112,14 @@ |
86 |
local file="$2" |
87 |
local r=1 |
88 |
|
89 |
- echo "Checking digest..." |
90 |
+ vecho "Checking digest..." |
91 |
|
92 |
if type -P md5sum > /dev/null; then |
93 |
md5sum -c $digest && r=0 |
94 |
elif type -P md5 > /dev/null; then |
95 |
[ "$(md5 -q $file)" == "$(cut -d \ -f 1 \"$digest\")" ] && r=0 |
96 |
else |
97 |
- echo "Error: Cannot check digest" |
98 |
- echo "No suitable md5/md5sum binaries found" |
99 |
+ eecho "cannot check digest: no suitable md5/md5sum binaries found" |
100 |
fi |
101 |
|
102 |
return "${r}" |
103 |
@@ -128,13 +132,12 @@ |
104 |
|
105 |
if [ ${WEBSYNC_VERIFY_SIGNATURE} != 0 ]; then |
106 |
|
107 |
- echo "Checking signature..." |
108 |
+ vecho "Checking signature..." |
109 |
|
110 |
if type -p gpg > /dev/null; then |
111 |
gpg --homedir "${PORTAGE_GPG_DIR}" --verify "$signature" "$file" && r=0 |
112 |
else |
113 |
- echo "Error: Cannot check signature" |
114 |
- echo "gpg binary not found" |
115 |
+ eecho "cannot check signature: gpg binary not found" |
116 |
fi |
117 |
else |
118 |
r=0 |
119 |
@@ -152,21 +155,19 @@ |
120 |
sync_local() { |
121 |
local file="$1" |
122 |
|
123 |
- echo "Syncing local tree..." |
124 |
+ vecho "Syncing local tree..." |
125 |
|
126 |
if type -P tarsync &> /dev/null; then |
127 |
if [ "${do_verbose}" != 0 ] ; then |
128 |
tarsync_verbose=-v |
129 |
fi |
130 |
if ! tarsync $tarsync_verbose -s 1 -o portage -g portage -e /distfiles -e /packages -e /local "${file}" "${PORTDIR}"; then |
131 |
- echo "Error: tarsync failed; tarball is corrupt? (${file})" |
132 |
+ eecho "tarsync failed; tarball is corrupt? (${file})" |
133 |
return 1 |
134 |
fi |
135 |
else |
136 |
- echo "Note: tarsync was not found, you may consider emerge it..." |
137 |
- |
138 |
if ! tar jxf "${file}"; then |
139 |
- echo "Error: tar failed to extract the image. tarball is corrupt? (${file})" |
140 |
+ eecho "tar failed to extract the image. tarball is corrupt? (${file})" |
141 |
rm -fr portage |
142 |
return 1 |
143 |
fi |
144 |
@@ -182,12 +183,12 @@ |
145 |
--exclude='/local' ${PORTAGE_RSYNC_EXTRA_OPTS} . "${PORTDIR%%/}" |
146 |
cd .. |
147 |
|
148 |
- echo "Cleaning up..." |
149 |
+ vecho "Cleaning up..." |
150 |
rm -fr portage |
151 |
fi |
152 |
|
153 |
if hasq metadata-transfer ${FEATURES} ; then |
154 |
- echo "Updating cache..." |
155 |
+ vecho "Updating cache..." |
156 |
emerge --metadata |
157 |
fi |
158 |
[ -x /etc/portage/bin/post_sync ] && /etc/portage/bin/post_sync |
159 |
@@ -207,7 +208,7 @@ |
160 |
local have_files=0 |
161 |
local mirror |
162 |
|
163 |
- echo "Trying to retrieve ${date} snapshot..." |
164 |
+ vecho "Trying to retrieve ${date} snapshot..." |
165 |
|
166 |
for mirror in ${GENTOO_MIRRORS} ; do |
167 |
|
168 |
@@ -231,12 +232,12 @@ |
169 |
# |
170 |
if [ ${have_files} != 0 ]; then |
171 |
|
172 |
- echo "Getting snapshot timetasmp..." |
173 |
+ vecho "Getting snapshot timetasmp..." |
174 |
local snapshot_timestamp=$(get_snapshot_timestamp "${file}") |
175 |
|
176 |
if [ ${ignore_timestamp} == 0 ]; then |
177 |
if [ ${snapshot_timestamp} -lt $(get_portage_timestamp) ]; then |
178 |
- echo "Warning: Portage is newer than snapshot" |
179 |
+ wecho "portage is newer than snapshot" |
180 |
have_files=0 |
181 |
fi |
182 |
else |
183 |
@@ -249,7 +250,7 @@ |
184 |
if [ ${snapshot_timestamp} -lt ${utc_seconds} ] || \ |
185 |
[ ${snapshot_timestamp} -gt $((${utc_seconds}+ 2*86400)) ]; then |
186 |
|
187 |
- echo "Warning: Snapshot timestamp is not in acceptable period." |
188 |
+ wecho "snapshot timestamp is not in acceptable period" |
189 |
have_files=0 |
190 |
fi |
191 |
fi |
192 |
@@ -269,7 +270,7 @@ |
193 |
if [ ${have_files} != 0 ]; then |
194 |
sync_local "${file}" && r=0 |
195 |
else |
196 |
- echo "Warning: ${date} snapshot was not found." |
197 |
+ vecho "${date} snapshot was not found" |
198 |
fi |
199 |
|
200 |
rm -f "${file}" "${digest}" "${signature}" |
201 |
@@ -280,7 +281,7 @@ |
202 |
local attempts=-1 |
203 |
local r=1 |
204 |
|
205 |
- echo "Fetching most recent snapshot..." |
206 |
+ vecho "Fetching most recent snapshot..." |
207 |
|
208 |
while (( ${attempts} < 40 )) ; do |
209 |
local day |
210 |
@@ -298,10 +299,9 @@ |
211 |
utc_midnight=$(get_date_part $(expr ${utc_attempt} - ${utc_attempt} % 86400) "%s") |
212 |
|
213 |
if [ ${utc_midnight} -lt $(($(get_portage_timestamp)-86400)) ]; then |
214 |
- echo "Note: Portage content is newer than available snapshots" |
215 |
- echo "use --revert option to overide." |
216 |
+ wecho "portage content is newer than available snapshots (use --revert option to overide)" |
217 |
r=0 |
218 |
- break; |
219 |
+ break |
220 |
fi |
221 |
|
222 |
if do_snapshot 0 "${year}${month}${day}"; then |
223 |
@@ -343,7 +343,7 @@ |
224 |
local v=${arg#*=} |
225 |
case ${arg} in |
226 |
-h|--help) usage ;; |
227 |
- -q|--quiet) do_quiet=1 ;; |
228 |
+ -q|--quiet) PORTAGE_QUIET=1 ;; |
229 |
-v|--verbose) do_verbose=1 ;; |
230 |
-x|--debug) do_debug=1 ;; |
231 |
--revert=*) revert_date=${v} ;; |
232 |
|
233 |
-- |
234 |
gentoo-commits@l.g.o mailing list |