Lines 14-19
Link Here
|
14 |
MAKE_GLOBALS_PATH=/etc/make.globals |
14 |
MAKE_GLOBALS_PATH=/etc/make.globals |
15 |
MAKE_PROFILE_PATH=/etc/make.profile |
15 |
MAKE_PROFILE_PATH=/etc/make.profile |
16 |
MAKE_CONF_BACKUP_PATH=/etc/make.conf.euse_backup |
16 |
MAKE_CONF_BACKUP_PATH=/etc/make.conf.euse_backup |
|
|
17 |
PACKAGE_USE_PATH=/etc/portage/package.use |
17 |
|
18 |
|
18 |
[ -z "${MODE}" ] && MODE="showhelp" # available operation modes: showhelp, showversion, showdesc, showflags, modify |
19 |
[ -z "${MODE}" ] && MODE="showhelp" # available operation modes: showhelp, showversion, showdesc, showflags, modify |
19 |
|
20 |
|
Lines 148-156
Link Here
|
148 |
print ' '.join(r)" |
149 |
print ' '.join(r)" |
149 |
} |
150 |
} |
150 |
|
151 |
|
|
|
152 |
# Similar to reduce_incrementals except converts lines from package atoms |
153 |
# in /etc/portage/package.use files to lines of "pkg [-]flag" |
154 |
reduce_package_use() { |
155 |
echo "${@}" | python -c "import sys,re |
156 |
h={}; getflags=re.compile(r'(-?[\w\d]+)') |
157 |
for x in sys.stdin.read().split('\n'): |
158 |
if not x: continue |
159 |
pkg,flags = x.split(' ',1) |
160 |
flags = getflags.findall(flags) |
161 |
if not pkg in h: |
162 |
h[pkg]=flags |
163 |
else: |
164 |
r=h[pkg] |
165 |
for x in flags: |
166 |
if x[0] == '-' and x[1:] in r: |
167 |
r.remove[x] |
168 |
r.append(x) |
169 |
elif x[0] != '-' and '-'+x in r: |
170 |
r.remove('-'+x) |
171 |
r.append(x) |
172 |
elif x == '-*': |
173 |
r = h[pkg] = ['-*'] |
174 |
elif x not in r: |
175 |
r.append(x) |
176 |
print '\n'.join([' %s %s ' % (pkg,f) for pkg,flgs in h.iteritems() for f in flgs])" |
177 |
} |
178 |
|
151 |
# the following function creates a bash array ACTIVE_FLAGS that contains the |
179 |
# the following function creates a bash array ACTIVE_FLAGS that contains the |
152 |
# global use flags, indexed by origin: 0: environment, 1: make.conf, |
180 |
# global use flags, indexed by origin: 0: environment, 1: make.conf, |
153 |
# 2: make.defaults, 3: make.globals |
181 |
# 2: make.defaults, 3: make.globals, 4: package.use |
154 |
get_useflags() { |
182 |
get_useflags() { |
155 |
# only calculate once as calling emerge is painfully slow |
183 |
# only calculate once as calling emerge is painfully slow |
156 |
[ -n "${USE_FLAGS_CALCULATED}" ] && return |
184 |
[ -n "${USE_FLAGS_CALCULATED}" ] && return |
Lines 175-180
Link Here
|
175 |
USE="${ACTIVE_FLAGS[0]}" |
203 |
USE="${ACTIVE_FLAGS[0]}" |
176 |
PORTDIR="${portdir_backup}" |
204 |
PORTDIR="${portdir_backup}" |
177 |
|
205 |
|
|
|
206 |
# Parse through /etc/portage/package.use |
207 |
if [[ -d ${PACKAGE_USE_PATH} ]]; then |
208 |
ACTIVE_FLAGS[4]=$( find ${PACKAGE_USE_PATH} -type f | xargs cat ) |
209 |
elif [[ -e ${PACKAGE_USE_PATH} ]]; then |
210 |
ACTIVE_FLAGS[4]=$( cat /${PACKAGE_USE_PATH} ) |
211 |
fi |
212 |
# Simplify ACTIVE_FLAGS[4] to be lines of pkg [-]flag |
213 |
ACTIVE_FLAGS[4]=$(reduce_package_use "${ACTIVE_FLAGS[4]}"); |
214 |
|
178 |
# get the currently active USE flags as seen by portage, this has to be after |
215 |
# get the currently active USE flags as seen by portage, this has to be after |
179 |
# restoring USE or portage won't see the original environment |
216 |
# restoring USE or portage won't see the original environment |
180 |
ACTIVE_FLAGS[9]="$(emerge --info | grep 'USE=' | cut -b 5- | sed -e 's:"::g')" #' |
217 |
ACTIVE_FLAGS[9]="$(emerge --info | grep 'USE=' | cut -b 5- | sed -e 's:"::g')" #' |
Lines 239-251
Link Here
|
239 |
# 3: echo value for positive (and as lowercase for negative) test result, |
276 |
# 3: echo value for positive (and as lowercase for negative) test result, |
240 |
# 4 (optional): echo value for "missing" test result, defaults to blank |
277 |
# 4 (optional): echo value for "missing" test result, defaults to blank |
241 |
get_flagstatus_helper() { |
278 |
get_flagstatus_helper() { |
242 |
if echo " ${ACTIVE_FLAGS[${2}]} " | grep " ${1} " > /dev/null; then |
279 |
if echo " ${ACTIVE_FLAGS[${2}]} " | grep " ${1} " | grep "${5} " > /dev/null; then |
243 |
echo -n "${3}" |
280 |
echo -n "${3}" |
244 |
elif echo " ${ACTIVE_FLAGS[${2}]} " | grep " -${1} " > /dev/null; then |
281 |
return 0 |
|
|
282 |
elif echo " ${ACTIVE_FLAGS[${2}]} " | grep " -${1} " | grep "${5} " > /dev/null; then |
245 |
echo -n "$(echo ${3} | tr [[:upper:]] [[:lower:]])" |
283 |
echo -n "$(echo ${3} | tr [[:upper:]] [[:lower:]])" |
|
|
284 |
return 0 |
246 |
else |
285 |
else |
247 |
echo -n "${4:- }" |
286 |
echo -n "${4:- }" |
248 |
fi |
287 |
fi |
|
|
288 |
return 1 |
249 |
} |
289 |
} |
250 |
|
290 |
|
251 |
# prints a status string for the given flag, each column indicating the presence |
291 |
# prints a status string for the given flag, each column indicating the presence |
Lines 256-262
Link Here
|
256 |
get_useflags |
296 |
get_useflags |
257 |
|
297 |
|
258 |
echo -n '[' |
298 |
echo -n '[' |
259 |
get_flagstatus_helper "${1}" 9 "+" "-" |
299 |
if [ "${SCOPE}" == "local" ]; then |
|
|
300 |
if ! get_flagstatus_helper "${1}" 4 "+" "-" "${2}" ; then |
301 |
echo -n -e "\b" |
302 |
get_flagstatus_helper "${1}" 9 "+" "-" |
303 |
fi |
304 |
else |
305 |
get_flagstatus_helper "${1}" 9 "+" "-" |
306 |
fi |
260 |
get_flagstatus_helper "${1}" 0 "E" |
307 |
get_flagstatus_helper "${1}" 0 "E" |
261 |
get_flagstatus_helper "${1}" 1 "C" |
308 |
get_flagstatus_helper "${1}" 1 "C" |
262 |
get_flagstatus_helper "${1}" 2 "D" |
309 |
get_flagstatus_helper "${1}" 2 "D" |
Lines 328-334
Link Here
|
328 |
pkg="$(echo $line | cut -d\| -f 1)" |
375 |
pkg="$(echo $line | cut -d\| -f 1)" |
329 |
flag="$(echo $line | cut -d\| -f 2)" |
376 |
flag="$(echo $line | cut -d\| -f 2)" |
330 |
desc="$(echo $line | cut -d\| -f 3)" |
377 |
desc="$(echo $line | cut -d\| -f 3)" |
331 |
get_flagstatus "${flag}" |
378 |
get_flagstatus "${flag}" "${pkg}" |
332 |
printf "%s (%s):\n%s\n\n" "${flag}" "${pkg}" "${desc}" |
379 |
printf "%s (%s):\n%s\n\n" "${flag}" "${pkg}" "${desc}" |
333 |
done |
380 |
done |
334 |
fi |
381 |
fi |