@@ -200,8 +200,8 @@ function ask() {
200200 reply=$default
201201 fi
202202 case "$reply" in
203- Y*|y*) export answer=1;;
204- N*|n*) export answer=0;;
203+ Y*|y*) export answer=1; return 0; ;
204+ N*|n*) export answer=0; return 1; ;
205205 esac
206206}
207207if [[ -z $PACSTALL_REMOVE ]] && [[ -z $PACSTALL_INSTALL ]]; then
@@ -290,19 +290,15 @@ if ! checks; then
290290 return 1
291291fi
292292
293- if [[ -n " $build_depends " ]]; then
294- fancy_message info " ${BLUE} $name ${NC} requires ${CYAN} $( echo -e " $build_depends " ) ${NC} to install"
295- ask " Do you want to remove them after installing ${BLUE} $name ${NC} " N
296- if [[ $answer -eq 1 ]]; then
297- NOBUILDDEP=0
298- fi
299- else
300- NOBUILDDEP=1
301- fi
302-
303293# Trap Crtl+C just before the point cleanup is first needed
304294trap " trap_ctrlc" 2
305295
296+ if [[ -n " $ppa " ]]; then
297+ for i in " ${ppa[@]} " ; do
298+ # Add ppa, but ppa bad I guess
299+ sudo add-apt-repository ppa:" $i "
300+ done
301+ fi
306302
307303if [[ -n " $pacdeps " ]]; then
308304 for i in " ${pacdeps[@]} " ; do
@@ -319,25 +315,25 @@ if [[ -n "$pacdeps" ]]; then
319315 done
320316fi
321317
322- if echo -n " $depends " > /dev/null 2>&1 ; then
323- if [[ -n " $breaks " ]] ; then
324- if dpkg-query -W -f=' ${Status}' " ${breaks } " 2> /dev/null | grep " ^install ok installed" > /dev/null 2>&1 ; then
318+ if [[ -n " $breaks " ]] ; then
319+ for pkg in $breaks ; do
320+ if dpkg-query -W -f=' ${Status} ${Section} ' " ${pkg } " 2> /dev/null | grep " ^install ok installed" | grep -v " Pacstall " > /dev/null 2>&1 ; then
325321 # Check if anything in breaks variable is installed already
326- fancy_message error " ${RED} $name ${NC} breaks $breaks , which is currently installed by apt"
322+ fancy_message error " ${RED} $name ${NC} breaks $pkg , which is currently installed by apt"
327323 error_log 13 " install $PACKAGE "
328324 fancy_message info " Cleaning up"
329325 cleanup
330326 return 1
331327 fi
332- if [[ $( pacstall -L) == $breaks ]] ; then
328+ if [[ " ${pkg} " != " ${name} " ]] && pacstall -L | grep " ${pkg} " > /dev/null 2>&1 ; then
333329 # Same thing, but check if anything is installed with pacstall
334- fancy_message error " ${RED} $name ${NC} breaks $breaks , which is currently installed by pacstall"
330+ fancy_message error " ${RED} $name ${NC} breaks $pkg , which is currently installed by pacstall"
335331 error_log 13 " install $PACKAGE "
336332 fancy_message info " Cleaning up"
337333 cleanup
338334 return 1
339335 fi
340- fi
336+ done
341337fi
342338
343339if [[ -n $replace ]]; then
@@ -353,14 +349,25 @@ if [[ -n $replace ]]; then
353349 fi
354350fi
355351
356- if [[ -n " $ppa " ]]; then
357- for i in " ${ppa[@]} " ; do
358- # Add ppa, but ppa bad I guess
359- sudo add-apt-repository ppa:" $i "
360- done
361- fi
352+ # Get all uninstalled build depends
353+ for build_dep in $build_depends ; do
354+ if dpkg-query -W -f=' ${Status}' " ${build_dep} " 2> /dev/null | grep " ^install ok installed" > /dev/null 2>&1 ; then
355+ build_depends=${build_depends/ " ${build_dep} " / } ;
356+ fi ;
357+ done
358+
359+ build_depends=$( echo " $build_depends " | tr -s ' ' | awk ' {gsub(/^ +| +$/,"")} {print $0}' )
360+
361+ # This echo makes it ignore empty strigs
362+ if [[ -n " $build_depends " ]]; then
363+ fancy_message info " ${BLUE} $name ${NC} requires ${CYAN} $( echo -e " $build_depends " ) ${NC} to install"
364+ ask " Do you want to remove them after installing ${BLUE} $name ${NC} " N
365+ if [[ $answer -eq 0 ]]; then
366+ NOBUILDDEP=0
367+ else
368+ NOBUILDDEP=1
369+ fi
362370
363- if [[ $NOBUILDDEP -eq 0 ]]; then
364371 if ! sudo apt-get install -y -qq -o=Dpkg::Use-Pty=0 $build_depends ; then
365372 fancy_message error " Failed to install build dependencies"
366373 error_log 8 " install $PACKAGE "
@@ -527,8 +534,8 @@ if ! install; then
527534 exit 1
528535fi
529536
530- if [[ $REMOVE_DEPENDS = y ]]; then
531- sudo apt-get remove $build_depends
537+ if [[ $NOBUILDDEP -eq 1 ]]; then
538+ sudo apt-get remove -y " $build_depends "
532539fi
533540
534541cd " $HOME " 2> /dev/null || ( error_log 1 " install $PACKAGE " ; fancy_message warn " Could not enter into ${HOME} " )
0 commit comments