Remove hard-coded temporary file from functions

This commit is contained in:
Marty Oehme 2019-03-11 19:43:24 +01:00
parent da527a2534
commit 36292574c3

View file

@ -119,7 +119,8 @@ getpackagegrouplink() {
# can be called with as many csv files filled with packages as necessary # can be called with as many csv files filled with packages as necessary
# appends them all to one temporary file for the installation # appends them all to one temporary file for the installation
gatherpackages() { gatherpackages() {
concfile=/tmp/progs.csv concfile=$1
shift
touch $concfile touch $concfile
for progs in "$@"; do for progs in "$@"; do
([ -f "$progs" ] && cat "$progs" >> $concfile) || curl -Ls "$progs" | sed '/^#/d' >> $concfile ([ -f "$progs" ] && cat "$progs" >> $concfile) || curl -Ls "$progs" | sed '/^#/d' >> $concfile
@ -127,7 +128,7 @@ gatherpackages() {
} }
installationloop() { \ installationloop() { \
total=$(wc -l < /tmp/progs.csv) total=$(wc -l < $1)
aurinstalled=$(pacman -Qm | awk '{print $1}') aurinstalled=$(pacman -Qm | awk '{print $1}')
while IFS=, read -r tag program comment; do while IFS=, read -r tag program comment; do
n=$((n+1)) n=$((n+1))
@ -137,7 +138,7 @@ installationloop() { \
"A") aurinstall "$program" "$comment" ;; "A") aurinstall "$program" "$comment" ;;
"G") gitmakeinstall "$program" "$comment" ;; "G") gitmakeinstall "$program" "$comment" ;;
esac esac
done < /tmp/progs.csv ;} done < $1 ;}
dotfiles() { \ dotfiles() { \
gpath=$1 gpath=$1
@ -237,14 +238,15 @@ getpackagegrouplink $targetdeployment
# only use the custom packages if forced with -F # only use the custom packages if forced with -F
[ ! "$exclusivepkgfiles" ] && pkgfiles="$(curl -Ls $pkggroup | cat ) $pkgfiles" [ ! "$exclusivepkgfiles" ] && pkgfiles="$(curl -Ls $pkggroup | cat ) $pkgfiles"
tmpfile=/tmp/pkgs.csv
# actually gather the individual package installation lines from the various links and files # actually gather the individual package installation lines from the various links and files
gatherpackages $pkgfiles gatherpackages $tmpfile $pkgfiles
# The command that does all the installing. Reads the progs.csv file and # The command that does all the installing. Reads the progs.csv file and
# installs each needed program the way required. Be sure to run this only after # installs each needed program the way required. Be sure to run this only after
# the user has been created and has privileges to run sudo without a password # the user has been created and has privileges to run sudo without a password
# and all build dependencies are installed. # and all build dependencies are installed.
installationloop installationloop $tmpfile
# Install the dotfiles in the user's home directory # Install the dotfiles in the user's home directory
putgitrepo "$dotfilesrepo" "/home/$name" putgitrepo "$dotfilesrepo" "/home/$name"