From 5cce275c26e610d9bd317a4a29d9b08265f1594c Mon Sep 17 00:00:00 2001 From: V3n3RiX Date: Fri, 6 Apr 2018 19:15:10 +0100 Subject: supercharge local csv generation (~300 times faster) --- src/helpers/make_local_csv_post | 21 ++++----------------- src/helpers/make_local_csv_pre | 21 ++++----------------- src/helpers/make_spmsync_csv | 21 ++++----------------- 3 files changed, 12 insertions(+), 51 deletions(-) (limited to 'src/helpers') diff --git a/src/helpers/make_local_csv_post b/src/helpers/make_local_csv_post index b6f7200..5e44670 100755 --- a/src/helpers/make_local_csv_post +++ b/src/helpers/make_local_csv_post @@ -1,21 +1,8 @@ #!/usr/bin/env bash -collect_local_portage_database() { - for i in $(qlist -ICv); do - pushd /var/db/pkg/$i > /dev/null 2>&1 - echo "$(> /tmp/local_packages_post.csv - popd > /dev/null 2>&1 - done - mv /tmp/local_packages_post.csv /var/lib/sisyphus/csv/ +makecsv() { + qlist -ICScv|sed -e "s/\//\,/" -e "s/[\t ]/\,/" -e "s/\:/\,/" >> "/tmp/local_packages_post.csv" + mv "/tmp/local_packages_post.csv" "/var/lib/sisyphus/csv/" } -clean_temporary_files() { - rm -rf /tmp/local_packages_post.csv -} - -main() { - collect_local_portage_database - clean_temporary_files -} - -main +makecsv diff --git a/src/helpers/make_local_csv_pre b/src/helpers/make_local_csv_pre index f6b5cfc..2fb9099 100755 --- a/src/helpers/make_local_csv_pre +++ b/src/helpers/make_local_csv_pre @@ -1,21 +1,8 @@ #!/usr/bin/env bash -collect_local_portage_database() { - for i in $(qlist -ICv); do - pushd /var/db/pkg/$i > /dev/null 2>&1 - echo "$(> /tmp/local_packages_pre.csv - popd > /dev/null 2>&1 - done - mv /tmp/local_packages_pre.csv /var/lib/sisyphus/csv/ +makecsv() { + qlist -ICScv|sed -e "s/\//\,/" -e "s/[\t ]/\,/" -e "s/\:/\,/" >> "/tmp/local_packages_pre.csv" + mv "/tmp/local_packages_pre.csv" "/var/lib/sisyphus/csv/" } -clean_temporary_files() { - rm -rf /tmp/local_packages_pre.csv -} - -main() { - collect_local_portage_database - clean_temporary_files -} - -main +makecsv diff --git a/src/helpers/make_spmsync_csv b/src/helpers/make_spmsync_csv index baf419c..8174cd9 100755 --- a/src/helpers/make_spmsync_csv +++ b/src/helpers/make_spmsync_csv @@ -1,21 +1,8 @@ #!/usr/bin/env bash -collect_local_portage_database() { - for i in $(qlist -ICv); do - pushd /var/db/pkg/$i > /dev/null 2>&1 - echo "$(> /tmp/portage_spmsync.csv - popd > /dev/null 2>&1 - done - mv /tmp/portage_spmsync.csv /var/lib/sisyphus/csv/ +makecsv() { + qlist -ICScv|sed -e "s/\//\,/" -e "s/[\t ]/\,/" -e "s/\:/\,/" >> "/tmp/portage_spmsync.csv" + mv "/tmp/portage_spmsync.csv" "/var/lib/sisyphus/csv/" } -clean_temporary_files() { - rm -rf /tmp/portage_spmsync.csv -} - -main() { - collect_local_portage_database - clean_temporary_files -} - -main +makecsv -- cgit v1.2.3