Skip to content

Commit c6a31af

Browse files
committed
[update] : Added stdout mode
1 parent f08d571 commit c6a31af

1 file changed

Lines changed: 21 additions & 6 deletions

File tree

tools/allpkglist.sh

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,17 +18,19 @@ _help() {
1818
echo
1919
echo " General options:"
2020
echo " -o | --out Specify the output dir"
21+
echo " -s | --stdout Output to stdout (Ignore -o)"
2122
echo " -h | --help This help message"
2223
}
2324

2425
script_path="$( cd -P "$( dirname "$(readlink -f "$0")" )" && cd .. && pwd )"
2526
tools_dir="${script_path}/tools"
2627
out_dir=""
28+
stdout=false
2729

2830
# Parse options
2931
ARGUMENT="${@}"
30-
opt_short="o:h"
31-
opt_long="out:,help"
32+
opt_short="o:hs"
33+
opt_long="out:,help,stdout"
3234
OPT=$(getopt -o ${opt_short} -l ${opt_long} -- ${ARGUMENT})
3335
[[ ${?} != 0 ]] && exit 1
3436
eval set -- "${OPT}"
@@ -40,6 +42,10 @@ while true; do
4042
out_dir="${2}"
4143
shift 2
4244
;;
45+
-s | --stdout)
46+
stdout=true
47+
shift 1
48+
;;
4349
-h | --help)
4450
_help
4551
exit 0
@@ -56,7 +62,11 @@ done
5662
share_dir="${script_path}/channels/share"
5763
extra_dir="${script_path}/channels/share-extra"
5864

59-
mkdir -p "${out_dir}"
65+
if [[ -z "${out_dir}" ]] || [[ "${stdout}" = true ]]; then
66+
stdout=true
67+
else
68+
mkdir -p "${out_dir}"
69+
fi
6070

6171
for arch in "x86_64" "i686" "i486"; do
6272
for channel in $("${tools_dir}/channel.sh" show -a "${arch}" -b -d -k zen -f); do
@@ -76,11 +86,16 @@ for arch in "x86_64" "i686" "i486"; do
7686
pkglist_opts+=" -e"
7787
fi
7888

79-
if [[ -z "${out_dir}" ]]; then
80-
"${tools_dir}/pkglist.sh" ${pkglist_opts}
89+
if [[ "${stdout}" = true ]]; then
90+
pkglist+=($("${tools_dir}/pkglist.sh" ${pkglist_opts}))
8191
else
82-
"${tools_dir}/pkglist.sh" ${pkglist_opts} 1> "${out_dir}/$(basename "${channel}").${arch}"
92+
"${tools_dir}/pkglist.sh" -d ${pkglist_opts} 1> "${out_dir}/$(basename "${channel}").${arch}"
8393
fi
8494

8595
done
8696
done
97+
98+
if [[ "${stdout}" = true ]]; then
99+
pkglist=($(printf "%s\n" "${pkglist[@]}" | sort |uniq))
100+
printf "%s\n" "${pkglist[@]}"
101+
fi

0 commit comments

Comments
 (0)