Running "./install-dependencies-debian" on Raspbian Stretch delete almost all packages

Hi!

I'm installing a rStudio on Raspbian Stretch on a Rasperry Pi 3 B, and when I execute de dependencies command for debian almost remove all the packages I had installed. Even remove r-base and so.

Can you help me?

This is the whole output in a gist
RAW: https://gist.githubusercontent.com/luisspuerto/0374557c98697c065c1b3aaca9ae1523/raw/04d9be9f5608e559d175a4e818030fabd9836b76/install-depencies-debian.log

Normal: https://gist.github.com/luisspuerto/0374557c98697c065c1b3aaca9ae1523

Towards the end in the RAW one you can see:

Reading state information...
libgstreamer-plugins-base0.10-0 is already the newest version (0.10.36-2).
libgstreamer-plugins-base0.10-0 set to manually installed.
The following packages were automatically installed and are no longer required:
  cracklib-runtime db-util db5.3-util libcrack2 libpam-cracklib rc
Use 'sudo apt autoremove' to remove them.
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
Reading package lists...
Building dependency tree...
Reading state information...
The following packages were automatically installed and are no longer required:
  aspell aspell-en bluealsa cdbs coinor-libcbc3 coinor-libcgl1 coinor-libclp1
  coinor-libcoinmp1v5 coinor-libcoinutils3v5 coinor-libipopt1v5
  coinor-libosi1v5 cracklib-runtime cups-bsd cups-client cups-common db-util
  db5.3-util dconf-gsettings-backend dconf-service dictionaries-common
  emacsen-common epiphany-browser-data erlang-base erlang-crypto
  erlang-syntax-tools fontconfig-infinality fonts-freefont-ttf fonts-lato
  fonts-opensymbol fonts-piboto gconf-service gconf2 gconf2-common
  geany-common gir1.2-atk-1.0 gir1.2-gmenu-3.0 glib-networking
  glib-networking-common glib-networking-services gnome-desktop3-data
  gnome-menus gsettings-desktop-schemas gsfonts gsfonts-x11 gstreamer0.10-alsa
  hicolor-icon-theme jackd libaa1 libabw-0.1-1 libaspell15 libatk-bridge2.0-0
  libatk1.0-0 libatk1.0-data libatspi2.0-0 libavahi-client3 libavahi-glib1
  libavahi-gobject0 libavc1394-0 libblas-dev libbluetooth3
  libboost-date-time1.61.0 libboost-date-time1.62.0 libboost-filesystem1.61.0
  libboost-iostreams1.61.0 libboost-system1.61.0 libboost-thread1.62.0
  libcanberra0 libcdio-cdda1 libcdio-paranoia1 libcdio13 libcdr-0.1-1
  libclucene-contribs1v5 libclucene-core1v5 libcmis-0.5-5v5 libcolamd2
  libcolord2 libcompfaceg1 libcrack2 libcups2 libcupsimage2 libdc1394-22
  libdca0 libdconf1 libde265-0 libdouble-conversion1 libdv4 libdvdnav4
  libdvdread4 libe-book-0.1-1 libenchant1c2a libeot0 libetonyek-0.1-1
  libetpan17 libexif12 libexttextcat-2.0-0 libfaad2 libfltk1.3 libfluidsynth1
  libfm-data libfm-extra4 libfm-gtk-data libfm4 libfreehand-0.1-1 libgconf-2-4
  libgdata-common libgdata22 libgdk-pixbuf2.0-common libgif7 libgltf-0.0-0v5
  libgmime-2.6-0 libgnome-keyring-common libgnome-keyring0 libgnome-menu-3-0
  libgoa-1.0-0b libgoa-1.0-common libgpgme11 libgphoto2-port12 libgtk-3-common
  libgtk2.0-common libgtop-2.0-10 libgtop2-common libhsqldb1.8.0-java
  libhunspell-1.4-0 libhyphen0 libid3tag0 libiec61883-0 libilmbase12
  libimobiledevice6 libjavascriptcoregtk-3.0-0 libjavascriptcoregtk-4.0-18
  libjbig0 libjson-glib-1.0-0 libjson-glib-1.0-common libkate1
  liblangtag-common liblangtag1 liblapack-dev liblcms2-2 libldb1
  liblightdm-gobject-1-0 liblilv-0-0 liblockfile-bin liblockfile1 liblzma-dev
  libmad0 libmenu-cache-bin libmenu-cache3 libmhash2 libmikmod3
  libmjpegutils-2.1-0 libmms0 libmodplug1 libmotif-common libmpcdec6
  libmpeg2encpp-2.1-0 libmplex2-2.1-0 libmspub-0.1-1 libmumps-seq-4.10.0
  libmwaw-0.3-3 libmythes-1.2-0 libncurses5-dev libneon27-gnutls libnfs8
  libnspr4 libnss3 liboauth0 libobt2v5 libodfgen-0.1-1 libofa0 libopenal-data
  libopenal1 libopencv-flann2.4v5 libopencv-video2.4v5 libopenexr22
  liborcus-0.11-0 libossp-uuid16 libpackagekit-glib2-18 libpagemaker-0.0-0
  libpam-cracklib libpango1.0-0 libpangox-1.0-0 libpaper-utils libpaper1
  libpisock9 libplist3 libportaudio2 libportmidi0 libproxy1v5
  libqt5concurrent5 libqt5core5a libqt5dbus5 libqt5network5
  libqt5scintilla2-l10n libqt5xml5 libraptor2-0 librasqal3 libraw1394-11
  librdf0 librest-0.7-0 librevenge-0.0-0 librtimulib-dev librtimulib-utils
  librtimulib7 libruby2.3 libsbc1 libscsynth1 libsctp1 libsdl-mixer1.2
  libsdl-ttf2.0-0 libserd-0-0 libservlet3.1-java libshout3 libsmbclient
  libsndio6.1 libsord-0-0 libsoundtouch1 libsoup-gnome2.4-1 libsoup2.4-1
  libsratom-0-0 libsrtp0 libstartup-notification0 libsuitesparseconfig4
  libtag1v5 libtag1v5-vanilla libtdb1 libtevent0 libusbmuxd4 libv4l2rds0
  libvisio-0.1-1 libvo-aacenc0 libvo-amrwbenc0 libvte-common libwebpdemux2
  libwebrtc-audio-processing1 libwildmidi-config libwildmidi2 libwnck-3-common
  libwnck-common libwpd-0.10-10 libwpg-0.3-3 libwps-0.4-4 libxcb-icccm4
  libxcb-image0 libxcb-keysyms1 libxcb-randr0 libxcb-render-util0 libxcb-util0
  libxcb-xinerama0 libxcb-xkb1 libxfce4util-bin libxfce4util-common
  libxfce4util7 libxfconf-0-2 libxkbcommon-x11-0 libxkbcommon0 libxklavier16
  libxres1 libyajl2 libyaml-0-2 lp-solve lxde-common lxhotkey-core lxmenu-data
  lxpanel-data lxsession-data netsurf-common packagekit point-rpi poppler-data
  python-cairo python-gobject python-gobject-2 python-rtimulib python-talloc
  python3-rtimulib qttranslations5-l10n r-doc-html rake rc realpath
  rpd-plym-splash rpd-wallpaper ruby ruby-did-you-mean ruby-minitest
  ruby-net-telnet ruby-power-assert ruby-test-unit ruby2.3
  rubygems-integration samba-libs squeak-plugins-scratch supercollider-server
  uuid xfconf xinput zenity-common
Use 'sudo apt autoremove' to remove them.
The following packages will be REMOVED:
  adwaita-icon-theme alacarte chromium-browser claws-mail claws-mail-i18n
  desktop-base dillo epiphany-browser galculator geany giblib1
  gir1.2-gdkpixbuf-2.0 gir1.2-gtk-3.0 gksu gnome-icon-theme
  gnome-themes-standard gpicview gstreamer1.0-plugins-bad
  gstreamer1.0-plugins-good gtk-update-icon-cache gtk2-engines
  gtk2-engines-clearlookspix gtk2-engines-pixbuf gvfs-backends leafpad
  libcanberra-gtk3-0 libcupsfilters1 libfm-gtk4 libfm-modules libgd3
  libgdk-pixbuf2.0-0 libgksu2-0 libgnome-desktop-3-12 libgphoto2-6 libgtk-3-0
  libgtk2.0-0 libgtk2.0-bin libimlib2 libjpeg-dev libjpeg62-turbo
  libjpeg62-turbo-dev libkeybinder0 libnotify4 libobrender32v5
  libopencv-calib3d2.4v5 libopencv-features2d2.4v5 libopencv-highgui2.4-deb0
  libopencv-objdetect2.4v5 libpoppler64 libqt5gui5 libqt5opengl5
  libqt5printsupport5 libqt5scintilla2-12v5 libqt5svg5 libqt5widgets5
  libqt5x11extras5 libqwt-qt5-6 libraw15 libreoffice
  libreoffice-avmedia-backend-gstreamer libreoffice-base libreoffice-base-core
  libreoffice-base-drivers libreoffice-calc libreoffice-core libreoffice-draw
  libreoffice-gtk libreoffice-gtk2 libreoffice-impress libreoffice-math
  libreoffice-report-builder-bin libreoffice-sdbc-hsqldb libreoffice-systray
  libreoffice-writer librsvg2-2 librsvg2-common libsdl-image1.2 libspandsp2
  libtiff5 libunique-1.0-0 libv4l-0 libv4lconvert0 libvte9
  libwebkit2gtk-4.0-37 libwebkitgtk-3.0-0 libwnck-3-0 libwnck22 libxm4
  libzbar0 lightdm lightdm-gtk-greeter lxappearance lxappearance-obconf lxde
  lxde-core lxhotkey-gtk lxinput lxkeymap lxpanel lxplug-bluetooth
  lxplug-ejecter lxplug-network lxplug-volume lxpolkit lxrandr lxsession
  lxsession-edit lxsession-logout lxtask lxterminal netsurf-gtk nuscratch
  openbox openbox-lxde-session pcmanfm pi-greeter pi-package pi-package-data
  pi-package-session piclone pimixer pipanel pishutdown poppler-utils
  python-gtk2 python-pil python-pygame python-sense-emu python-sense-hat
  python-xklavier python3-pgzero python3-pil python3-pygame python3-sense-emu
  python3-sense-hat python3-uno qjackctl qt5-gtk-platformtheme r-base
  r-base-core r-base-dev r-base-html r-cran-boot r-cran-class r-cran-cluster
  r-cran-codetools r-cran-foreign r-cran-kernsmooth r-cran-lattice r-cran-mass
  r-cran-matrix r-cran-mgcv r-cran-nlme r-cran-nnet r-cran-rpart
  r-cran-spatial r-cran-survival r-recommended raspberrypi-ui-mods rc-gui
  rpd-icons rpi-chromium-mods scratch scratch2 scrot sense-emu-tools sense-hat
  smartsim sonic-pi squeak-vm v4l-utils wolfram-engine xarchiver xpdf zenity
The following NEW packages will be installed:
  libjpeg62
0 upgraded, 1 newly installed, 175 to remove and 0 not upgraded.
Need to get 73.2 kB of archives.
After this operation, 1,581 MB disk space will be freed.
Get:1 http://mirrordirector.raspbian.org/raspbian stretch/main armhf libjpeg62 armhf 1:6b2-2 [73.2 kB]
Fetched 73.2 kB in 10s (6,986 B/s)
(Reading database ... 
(Reading database ... 5%
(Reading database ... 10%
(Reading database ... 15%
(Reading database ... 20%
(Reading database ... 25%
(Reading database ... 30%
(Reading database ... 35%
(Reading database ... 40%
(Reading database ... 45%
(Reading database ... 50%
(Reading database ... 55%
(Reading database ... 60%
(Reading database ... 65%
(Reading database ... 70%
(Reading database ... 75%
(Reading database ... 80%
(Reading database ... 85%
(Reading database ... 90%
(Reading database ... 95%
(Reading database ... 100%
(Reading database ... 134276 files and directories currently installed.)
Removing pi-package (0.3) ...
Removing pi-package-session (0.3) ...
Removing pi-package-data (0.3) ...
Removing epiphany-browser (1:3.8.2.0-0rpi28) ...
Removing rc-gui (1.13) ...
Removing alacarte (3.11.91-2+rpi5) ...
Removing scratch2 (0.17) ...
Removing rpi-chromium-mods (20171017) ...
Removing chromium-browser (60.0.3112.89-0ubuntu0.14.04.1.1010) ...
update-alternatives: using /usr/bin/dillo to provide /usr/bin/x-www-browser (x-www-browser) in auto mode
Removing claws-mail-i18n (3.14.1-3) ...
Removing claws-mail (3.14.1-3) ...
Removing desktop-base (9.0.2+deb9u1) ...
Removing dillo (3.0.5-3) ...
Removing lxde (9+rpi1) ...
Removing galculator (2.1.4-1) ...
Removing geany (1.29-1) ...
Removing scrot (0.8-18) ...
Removing giblib1:armhf (1.2.4-11) ...
Removing gir1.2-gtk-3.0:armhf (3.22.11-1+rpi3) ...
Removing gir1.2-gdkpixbuf-2.0:armhf (2.36.5-2+deb9u1) ...
Removing gksu (2.0.2-9) ...
Removing gnome-icon-theme (3.12.0-2) ...
update-alternatives: using /usr/share/icons/gnome/scalable/places/gnome-foot.svg to provide /usr/share/icons/gnome/scalable/places/start-here.svg (start-here.svg) in auto mode
update-alternatives: warning: skip creation of /usr/share/icons/gnome/256x256/places/start-here.png because associated file /usr/share/icons/gnome/256x256/places/gnome-foot.png (of link group start-here.svg) doesn't exist
Removing gnome-themes-standard:armhf (3.22.2-2) ...
Removing gpicview (0.2.5-2) ...
Removing gstreamer1.0-plugins-bad:armhf (1.10.4-1) ...
Removing gstreamer1.0-plugins-good:armhf (1.10.4-1) ...
Removing rpd-icons (0.10) ...
Removing nuscratch (20170112) ...
Removing 'diversion of /usr/bin/scratch to /usr/bin/scratch.old by nuscratch'
Removing 'diversion of /usr/bin/squeak to /usr/bin/squeak.old by nuscratch'
Removing 'diversion of /usr/share/scratch/locale/ja_HIRA.po to /usr/share/scratch/locale/ja_HIRA.po.old by nuscratch'
Removing 'diversion of /usr/share/scratch/locale/ja.po to /usr/share/scratch/locale/ja.po.old by nuscratch'
Removing scratch (1.4.0.6~dfsg1-5) ...
Removing libgtk2.0-bin (2.24.31-2) ...
Removing gtk2-engines:armhf (1:2.20.2-3) ...
Removing gtk2-engines-clearlookspix:armhf (1:2.20.4) ...
Removing gtk2-engines-pixbuf:armhf (2.24.31-2) ...
Removing gvfs-backends (1.30.4-1) ...
Removing leafpad (0.8.18.1-5) ...
Removing libcanberra-gtk3-0:armhf (0.30-3+b2) ...
Removing libcupsfilters1:armhf (1.11.6-3+rpi1) ...
Removing raspberrypi-ui-mods (1.20170725) ...
update-alternatives: using /usr/bin/startlxde to provide /usr/bin/x-session-manager (x-session-manager) in auto mode
update-alternatives: using /usr/share/libgksu/debian/gconf-defaults.libgksu-su to provide /usr/share/gconf/defaults/10_libgksu (libgksu-gconf-defaults) in auto mode
Removing lxde-core (9+rpi1) ...
Removing pcmanfm (1.2.5-3+rpi2) ...
Removing lxplug-volume (0.7) ...
Removing lxplug-network (0.5) ...
Removing libgphoto2-6:armhf (2.5.12-1) ...
Removing libgd3:armhf (2.2.4-2+deb9u2) ...
Removing pishutdown (0.8) ...
Removing 'diversion of /usr/bin/lxde-pi-shutdown-helper to /usr/bin/lxde-pi-shutdown-helper.old by pishutdown'
Removing pi-greeter (0.6) ...
update-alternatives: using /usr/share/xgreeters/lightdm-gtk-greeter.desktop to provide /usr/share/xgreeters/lightdm-greeter.desktop (lightdm-greeter) in auto mode
Removing libgksu2-0 (2.0.13~pre1-9) ...
update-alternatives: using /usr/share/libgksu/debian/gconf-defaults.libgksu-sudo to provide /usr/share/gconf/defaults/10_libgksu (libgksu-gconf-defaults) in auto mode
Removing libgnome-desktop-3-12:armhf (3.22.2-1) ...
Removing pipanel (20170707~125920) ...
Removing openbox-lxde-session (0.99.2-3) ...
update-alternatives: using /usr/bin/lxsession to provide /usr/bin/x-session-manager (x-session-manager) in auto mode
Removing openbox (3.6.1-4+rpi3) ...
Removing lxappearance-obconf (0.2.3-1) ...
Removing libobrender32v5 (3.6.1-4+rpi3) ...
Removing libimlib2:armhf (1.4.8-1) ...
Removing r-base-dev (3.3.3-1) ...
Removing libjpeg-dev (1:1.5.1-2) ...
Removing python3-pgzero (1.1-1) ...
Removing python3-pygame (1.9.3+dfsg-2) ...
Removing python-pygame (1.9.3+dfsg-2) ...
Removing libjpeg62-turbo-dev:armhf (1:1.5.1-2) ...
Removing lxplug-ejecter (0.3) ...
Removing zenity (3.22.0-1) ...
Removing libwebkit2gtk-4.0-37:armhf (2.16.6-0+deb9u1+rpi1) ...
Removing libnotify4:armhf (0.7.7-2) ...
Removing libopencv-calib3d2.4v5:armhf (2.4.9.1+dfsg1-2) ...
Removing libopencv-features2d2.4v5:armhf (2.4.9.1+dfsg1-2) ...
Removing libopencv-objdetect2.4v5:armhf (2.4.9.1+dfsg1-2) ...
Removing libopencv-highgui2.4-deb0:armhf (2.4.9.1+dfsg1-2) ...
Removing xpdf (3.04-4) ...
Removing poppler-utils (0.48.0-2) ...
Removing libpoppler64:armhf (0.48.0-2) ...
Removing sonic-pi (1:3.0.1) ...
Removing qt5-gtk-platformtheme:armhf (5.7.1+dfsg-3+rpi1) ...
Removing libqwt-qt5-6 (6.1.2-6) ...
Removing libqt5opengl5:armhf (5.7.1+dfsg-3+rpi1) ...
Removing libqt5scintilla2-12v5 (2.9.3+dfsg-4) ...
Removing libqt5printsupport5:armhf (5.7.1+dfsg-3+rpi1) ...
Removing libqt5svg5:armhf (5.7.1~20161021-2) ...
Removing qjackctl (0.4.4-1) ...
Removing libqt5widgets5:armhf (5.7.1+dfsg-3+rpi1) ...
Removing libqt5x11extras5:armhf (5.7.1~20161021-2) ...
Removing wolfram-engine (11.0.1+2017071100) ...
Removing libraw15:armhf (0.17.2-6+deb9u1) ...
Removing libreoffice (1:5.2.7-1+rpi1) ...
Removing libreoffice-avmedia-backend-gstreamer (1:5.2.7-1+rpi1) ...
Removing libreoffice-report-builder-bin (1:5.2.7-1+rpi1) ...
Removing libreoffice-base (1:5.2.7-1+rpi1) ...
Removing 'diversion of /usr/lib/libreoffice/share/basic/dialog.xlc to /usr/lib/libreoffice/share/basic/dialog.xlc.noaccess by libreoffice-base'
Removing 'diversion of /usr/lib/libreoffice/share/basic/script.xlc to /usr/lib/libreoffice/share/basic/script.xlc.noaccess by libreoffice-base'
Removing libreoffice-writer (1:5.2.7-1+rpi1) ...
Removing libreoffice-calc (1:5.2.7-1+rpi1) ...
Removing libreoffice-base-core (1:5.2.7-1+rpi1) ...
Removing libreoffice-base-drivers (1:5.2.7-1+rpi1) ...
Removing python3-uno (1:5.2.7-1+rpi1) ...
Removing libreoffice-gtk (1:5.2.7-1+rpi1) ...
Removing libreoffice-systray (1:5.2.7-1+rpi1) ...
Removing libreoffice-impress (1:5.2.7-1+rpi1) ...
Removing libreoffice-draw (1:5.2.7-1+rpi1) ...
Removing libreoffice-gtk2 (1:5.2.7-1+rpi1) ...
Removing libreoffice-math (1:5.2.7-1+rpi1) ...
Removing libreoffice-sdbc-hsqldb (1:5.2.7-1+rpi1) ...
Removing smartsim (1.2.1-4) ...
Removing netsurf-gtk (3.6-3.1) ...
Removing libsdl-image1.2:armhf (1.2.12-5+b2) ...
Removing libspandsp2:armhf (0.0.6+dfsg-0.1) ...
Removing r-base (3.3.3-1) ...
Removing r-recommended (3.3.3-1) ...
Removing r-cran-rpart (4.1-10-2) ...
Removing r-cran-survival (2.40-1-1) ...
Removing r-cran-spatial (7.3-11-1) ...
Removing r-cran-nnet (7.3-12-1) ...
Removing sense-hat (1.2) ...
Removing python3-sense-hat (2.2.0-1) ...
Removing lxsession (0.5.3-2) ...
Removing lxpolkit (0.5.3-2) ...
Removing libunique-1.0-0 (1.1.6-5) ...
Removing v4l-utils (1.12.3-1) ...
Removing libzbar0:armhf (0.10+doc-10.1) ...
Removing libv4l-0:armhf (1.12.3-1) ...
Removing libv4lconvert0:armhf (1.12.3-1) ...
Removing squeak-vm (1:4.10.2.2614-4.1) ...
Removing lxterminal (0.3.0-2+rpi1) ...
Removing libvte9 (1:0.28.2-5) ...
Removing libwebkitgtk-3.0-0:armhf (2.4.11-3+rpi1) ...
Removing libwnck-3-0:armhf (3.20.1-3) ...
Removing lxplug-bluetooth (0.4) ...
Removing libxm4:armhf (2.3.4-13) ...
Removing lightdm (1.18.3-1) ...
Removing lightdm-gtk-greeter (2.0.2-1) ...
Removing lxappearance (0.6.3-1) ...
Removing lxhotkey-gtk (0.1.0-1) ...
Removing lxinput (0.3.5-1+rpi2) ...
Removing lxkeymap (0.8.0~bzr25-1+rpi3) ...
Removing lxrandr (0.3.1-1) ...
Removing lxsession-edit (0.5.3-2) ...
Removing lxsession-logout (0.5.3-2) ...
Removing lxtask (0.1.8-1) ...
Removing piclone (0.7) ...
Removing pimixer (0.20170803~152204) ...
Removing python-gtk2 (2.24.0-5.1) ...
Removing python-sense-hat (2.2.0-1) ...
Removing python-sense-emu (1.0) ...
Removing python-pil:armhf (4.0.0-4) ...
Removing python-xklavier (0.4-4) ...
Removing sense-emu-tools (1.0) ...
Removing python3-sense-emu (1.0) ...
Removing r-base-html (3.3.3-1) ...
Removing r-cran-boot (1.3-18-2) ...
Removing r-cran-class (7.3-14-1) ...
Removing r-cran-cluster (2.0.5-1) ...
Removing r-cran-codetools (0.2-15-1) ...
Removing r-cran-foreign (0.8.67-1) ...
Removing r-cran-kernsmooth (2.23-15-2) ...
Removing r-cran-mgcv (1.8-16-1) ...
Removing r-cran-matrix (1.2-7.1-1) ...
Removing r-cran-nlme (3.1.129-1) ...
Removing r-cran-lattice (0.20-34-1) ...
Removing r-cran-mass (7.3-45-1) ...
Removing xarchiver (1:0.5.4-7) ...
Removing libgtk-3-0:armhf (3.22.11-1+rpi3) ...
Removing lxpanel (0.9.3-1+rpi4) ...
Removing libkeybinder0 (0.3.1-1) ...
Removing libqt5gui5:armhf (5.7.1+dfsg-3+rpi1) ...
Removing libreoffice-core (1:5.2.7-1+rpi1) ...
Removing r-base-core (3.3.3-1) ...
Removing python3-pil:armhf (4.0.0-4) ...
Removing libwnck22:armhf (2.30.7-5.1) ...
Removing libfm-modules:armhf (1.2.5-1+rpi2) ...
Removing libfm-gtk4:armhf (1.2.5-1+rpi2) ...
Removing libgtk2.0-0:armhf (2.24.31-2) ...
Removing adwaita-icon-theme (3.22.0-1+deb9u1) ...
Removing gtk-update-icon-cache (3.22.11-1+rpi3) ...
Removing librsvg2-common:armhf (2.40.16-1) ...
Removing librsvg2-2:armhf (2.40.16-1) ...
Removing libgdk-pixbuf2.0-0:armhf (2.36.5-2+deb9u1) ...
Removing libtiff5:armhf (4.0.8-2+deb9u1) ...
Removing libjpeg62-turbo:armhf (1:1.5.1-2) ...
Selecting previously unselected package libjpeg62:armhf.
(Reading database ... 
(Reading database ... 5%
(Reading database ... 10%
(Reading database ... 15%
(Reading database ... 20%
(Reading database ... 25%
(Reading database ... 30%
(Reading database ... 35%
(Reading database ... 40%
(Reading database ... 45%
(Reading database ... 50%
(Reading database ... 55%
(Reading database ... 60%
(Reading database ... 65%
(Reading database ... 70%
(Reading database ... 75%
(Reading database ... 80%
(Reading database ... 85%
(Reading database ... 90%
(Reading database ... 95%
(Reading database ... 100%
(Reading database ... 86166 files and directories currently installed.)
Preparing to unpack .../libjpeg62_1%3a6b2-2_armhf.deb ...
Unpacking libjpeg62:armhf (1:6b2-2) ...
Processing triggers for gconf2 (3.2.6-4) ...
Setting up libjpeg62:armhf (1:6b2-2) ...
Processing triggers for tex-common (6.06) ...
Processing triggers for mime-support (3.60) ...
Processing triggers for desktop-file-utils (0.23-1) ...
Processing triggers for libglib2.0-0:armhf (2.50.3-2) ...
Processing triggers for libc-bin (2.24-11+deb9u1) ...
Processing triggers for udev (232-25+deb9u1) ...
Processing triggers for man-db (2.7.6.1-2) ...
Processing triggers for shared-mime-info (1.8-1) ...
Processing triggers for gnome-menus (3.13.3-9) ...
Processing triggers for hicolor-icon-theme (0.15-1) ...
Reading package lists...
Building dependency tree...
Reading state information...
The following packages were automatically installed and are no longer required:
  aspell aspell-en bluealsa cdbs coinor-libcbc3 coinor-libcgl1 coinor-libclp1
  coinor-libcoinmp1v5 coinor-libcoinutils3v5 coinor-libipopt1v5
  coinor-libosi1v5 cracklib-runtime cups-bsd cups-client cups-common db-util
  db5.3-util dconf-gsettings-backend dconf-service dictionaries-common
  emacsen-common epiphany-browser-data erlang-base erlang-crypto
  erlang-syntax-tools fontconfig-infinality fonts-freefont-ttf fonts-lato
  fonts-opensymbol fonts-piboto gconf-service gconf2 gconf2-common
  geany-common gir1.2-atk-1.0 gir1.2-gmenu-3.0 glib-networking
  glib-networking-common glib-networking-services gnome-desktop3-data
  gnome-menus gsettings-desktop-schemas gsfonts gsfonts-x11 gstreamer0.10-alsa
  hicolor-icon-theme jackd libaa1 libabw-0.1-1 libaspell15 libatk-bridge2.0-0
  libatk1.0-0 libatk1.0-data libatspi2.0-0 libavahi-client3 libavahi-glib1
  libavahi-gobject0 libavc1394-0 libblas-dev libbluetooth3
  libboost-date-time1.61.0 libboost-date-time1.62.0 libboost-filesystem1.61.0
  libboost-iostreams1.61.0 libboost-system1.61.0 libboost-thread1.62.0
  libcanberra0 libcdio-cdda1 libcdio-paranoia1 libcdio13 libcdr-0.1-1
  libclucene-contribs1v5 libclucene-core1v5 libcmis-0.5-5v5 libcolamd2
  libcolord2 libcompfaceg1 libcrack2 libcups2 libcupsimage2 libdc1394-22
  libdca0 libdconf1 libde265-0 libdouble-conversion1 libdv4 libdvdnav4
  libdvdread4 libe-book-0.1-1 libenchant1c2a libeot0 libetonyek-0.1-1
  libetpan17 libexif12 libexttextcat-2.0-0 libfaad2 libfltk1.3 libfluidsynth1
  libfm-data libfm-extra4 libfm-gtk-data libfm4 libfreehand-0.1-1 libgconf-2-4
  libgdata-common libgdata22 libgdk-pixbuf2.0-common libgif7 libgltf-0.0-0v5
  libgmime-2.6-0 libgnome-keyring-common libgnome-keyring0 libgnome-menu-3-0
  libgoa-1.0-0b libgoa-1.0-common libgpgme11 libgphoto2-port12 libgtk-3-common
  libgtk2.0-common libgtop-2.0-10 libgtop2-common libhsqldb1.8.0-java
  libhunspell-1.4-0 libhyphen0 libid3tag0 libiec61883-0 libilmbase12
  libimobiledevice6 libjavascriptcoregtk-3.0-0 libjavascriptcoregtk-4.0-18
  libjbig0 libjson-glib-1.0-0 libjson-glib-1.0-common libkate1
  liblangtag-common liblangtag1 liblapack-dev liblcms2-2 libldb1
  liblightdm-gobject-1-0 liblilv-0-0 liblockfile-bin liblockfile1 liblzma-dev
  libmad0 libmenu-cache-bin libmenu-cache3 libmhash2 libmikmod3
  libmjpegutils-2.1-0 libmms0 libmodplug1 libmotif-common libmpcdec6
  libmpeg2encpp-2.1-0 libmplex2-2.1-0 libmspub-0.1-1 libmumps-seq-4.10.0
  libmwaw-0.3-3 libmythes-1.2-0 libncurses5-dev libneon27-gnutls libnfs8
  libnspr4 libnss3 liboauth0 libobt2v5 libodfgen-0.1-1 libofa0 libopenal-data
  libopenal1 libopencv-flann2.4v5 libopencv-video2.4v5 libopenexr22
  liborcus-0.11-0 libossp-uuid16 libpackagekit-glib2-18 libpagemaker-0.0-0
  libpam-cracklib libpango1.0-0 libpangox-1.0-0 libpaper-utils libpaper1
  libpisock9 libplist3 libportaudio2 libportmidi0 libproxy1v5
  libqt5concurrent5 libqt5core5a libqt5dbus5 libqt5network5
  libqt5scintilla2-l10n libqt5xml5 libraptor2-0 librasqal3 libraw1394-11
  librdf0 librest-0.7-0 librevenge-0.0-0 librtimulib-dev librtimulib-utils
  librtimulib7 libruby2.3 libsbc1 libscsynth1 libsctp1 libsdl-mixer1.2
  libsdl-ttf2.0-0 libserd-0-0 libservlet3.1-java libshout3 libsmbclient
  libsndio6.1 libsord-0-0 libsoundtouch1 libsoup-gnome2.4-1 libsoup2.4-1
  libsratom-0-0 libsrtp0 libstartup-notification0 libsuitesparseconfig4
  libtag1v5 libtag1v5-vanilla libtdb1 libtevent0 libusbmuxd4 libv4l2rds0
  libvisio-0.1-1 libvo-aacenc0 libvo-amrwbenc0 libvte-common libwebpdemux2
  libwebrtc-audio-processing1 libwildmidi-config libwildmidi2 libwnck-3-common
  libwnck-common libwpd-0.10-10 libwpg-0.3-3 libwps-0.4-4 libxcb-icccm4
  libxcb-image0 libxcb-keysyms1 libxcb-render-util0 libxcb-util0
  libxcb-xinerama0 libxcb-xkb1 libxfce4util-bin libxfce4util-common
  libxfce4util7 libxfconf-0-2 libxkbcommon-x11-0 libxkbcommon0 libxklavier16
  libxres1 libyajl2 libyaml-0-2 lp-solve lxde-common lxhotkey-core lxmenu-data
  lxpanel-data lxsession-data netsurf-common packagekit point-rpi poppler-data
  python-cairo python-gobject python-gobject-2 python-rtimulib python-talloc
  python3-rtimulib qttranslations5-l10n r-doc-html rake rc realpath
  rpd-plym-splash rpd-wallpaper ruby ruby-did-you-mean ruby-minitest
  ruby-net-telnet ruby-power-assert ruby-test-unit ruby2.3
  rubygems-integration samba-libs squeak-plugins-scratch supercollider-server
  uuid xfconf xinput zenity-common
Use 'sudo apt autoremove' to remove them.

Thanks!

I can't imagine why all these packages would get uninstalled. All we're doing in these dependency scripts is various calls to e.g.

sudo apt-get install -y <package>

It seems as though our attempt to install the libjpeg62 package is triggering an uninstall of everything else, but I don't understand why that would happen.

If you manually try to install that package with e.g.

sudo apt-get install libjpeg62

does that also prompt you to uninstall all of the other packages?

yes

pi@raspberrypi:~ $ sudo apt-get install libjpeg62
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages were automatically installed and are no longer required:
  cgroup-bin cgroup-tools coinor-libcoinmp1v5 coinor-libipopt1v5 cracklib-runtime cups-bsd cups-client cups-common
  db-util db5.3-util dconf-gsettings-backend dconf-service epiphany-browser-data erlang-base erlang-crypto
  erlang-syntax-tools evince-common fontconfig-infinality fonts-freefont-ttf fonts-lato fonts-opensymbol fonts-piboto
  gcj-6-jre-lib gconf-service gconf2 gconf2-common geany-common geoclue-2.0 gir1.2-atk-1.0 gir1.2-gmenu-3.0
  glib-networking glib-networking-common glib-networking-services gnome-accessibility-themes gnome-desktop3-data
  gnome-menus gnome-mime-data gsettings-desktop-schemas gsfonts gsfonts-x11 gstreamer0.10-alsa hicolor-icon-theme
  iio-sensor-proxy jackd libaa1 libabw-0.1-1 libapache-poi-java libart-2.0-2 libatk-bridge2.0-0 libatk1.0-0
  libatk1.0-data libatspi2.0-0 libavahi-client3 libavahi-glib1 libavahi-gobject0 libavc1394-0 libbase-java
  libbcmail-java libbcpkix-java libbcprov-java libblas-dev libbonobo2-0 libbonobo2-common libbonoboui2-common
  libboost-date-time1.61.0 libboost-date-time1.62.0 libboost-filesystem1.61.0 libboost-iostreams1.61.0
  libboost-system1.61.0 libboost-thread1.62.0 libbsh-java libcanberra0 libcdio-cdda1 libcdio-paranoia1 libcdio13
  libcdr-0.1-1 libcgroup1 libclucene-contribs1v5 libclucene-core1v5 libcmis-0.5-5v5 libcolamd2 libcolord2
  libcommons-codec-java libcommons-collections3-java libcompfaceg1 libcrack2 libcups2 libcupsimage2 libdc1394-22
  libdca0 libdconf1 libde265-0 libdjvulibre-text libdom4j-java libdouble-conversion1 libdv4 libdvdnav4 libdvdread4
  libe-book-0.1-1 libehcache-java libenchant1c2a libeot0 libetonyek-0.1-1 libetpan17 libexif12 libexttextcat-2.0-0
  libfaad2 libfltk1.3 libfluidsynth1 libflute-java libfm-data libfm-extra4 libfm-gtk-data libfm4 libfonts-java
  libformula-java libfreehand-0.1-1 libgcj-bc libgcj-common libgcj17 libgconf-2-4 libgdata-common libgdata22
  libgdk-pixbuf2.0-common libgeoclue-2-0 libgif7 libgltf-0.0-0v5 libgmime-2.6-0 libgnome-2-0 libgnome-keyring-common
  libgnome-keyring0 libgnome-menu-3-0 libgnome2-common libgnomecanvas2-common libgnomeui-common libgnomevfs2-0
  libgnomevfs2-common libgnomevfs2-extra libgoa-1.0-0b libgoa-1.0-common libgpgme11 libgphoto2-l10n libgphoto2-port12
  libgs9-common libgtk-3-common libgtk2.0-common libgtop-2.0-10 libgtop2-common libhsqldb1.8.0-java libhunspell-1.4-0
  libhyphen0 libid3tag0 libiec61883-0 libijs-0.35 libilmbase12 libimobiledevice6 libisorelax-java libitext-java
  libjavascriptcoregtk-3.0-0 libjavascriptcoregtk-4.0-18 libjaxen-java libjbig0 libjbig2dec0 libjcommon-java
  libjdom1-java libjson-glib-1.0-0 libjson-glib-1.0-common libkate1 libkpathsea6 liblangtag-common liblangtag1
  liblapack-dev liblayout-java liblcms2-2 libldb1 liblightdm-gobject-1-0 liblilv-0-0 libloader-java liblockfile-bin
  liblockfile1 liblzma-dev libmad0 libmbim-glib4 libmbim-proxy libmenu-cache-bin libmenu-cache3 libmhash2 libmikmod3
  libmjpegutils-2.1-0 libmm-glib0 libmms0 libmodplug1 libmotif-common libmpcdec6 libmpeg2encpp-2.1-0 libmplex2-2.1-0
  libmspub-0.1-1 libmsv-java libmumps-seq-4.10.0 libmwaw-0.3-3 libmythes-1.2-0 libncurses5-dev libneon27-gnutls
  libnfs8 libnspr4 libnss3 liboauth0 libobt2v5 libodfgen-0.1-1 libofa0 libopenal-data libopenal1 libopencv-flann2.4v5
  libopencv-video2.4v5 libopenexr22 liborbit-2-0 liborcus-0.11-0 libossp-uuid16 libpackagekit-glib2-18
  libpagemaker-0.0-0 libpam-cracklib libpam-gnome-keyring libpango1.0-0 libpangox-1.0-0 libpaper-utils libpaper1
  libpentaho-reporting-flow-engine-java libpisock9 libpixie-java libplist3 libportaudio2 libportmidi0 libpq5
  libproxy1v5 libqmi-glib5 libqmi-proxy libqt5concurrent5 libqt5core5a libqt5dbus5 libqt5network5
  libqt5scintilla2-l10n libqt5xml5 libraptor2-0 librasqal3 libraw1394-11 librdf0 librelaxng-datatype-java
  librepository-java librest-0.7-0 librevenge-0.0-0 librtimulib-dev librtimulib-utils librtimulib7 libruby2.3
  libsac-java libsac-java-gcj libsaxonhe-java libscsynth1 libsctp1 libsdl-mixer1.2 libsdl-ttf2.0-0 libserd-0-0
  libserializer-java libservlet3.1-java libshout3 libsmbclient libsndio6.1 libsord-0-0 libsoundtouch1
  libsoup-gnome2.4-1 libsoup2.4-1 libsratom-0-0 libsrtp0 libstartup-notification0 libsuitesparseconfig4 libtag1v5
  libtag1v5-vanilla libtdb1 libtevent0 libturbojpeg0 libusbmuxd4 libv4l2rds0 libvisio-0.1-1 libvo-aacenc0
  libvo-amrwbenc0 libvte-common libwebpdemux2 libwebrtc-audio-processing1 libwildmidi-config libwildmidi2
  libwnck-3-common libwnck-common libwpd-0.10-10 libwpg-0.3-3 libwps-0.4-4 libxcb-icccm4 libxcb-image0 libxcb-keysyms1
  libxcb-render-util0 libxcb-util0 libxcb-xinerama0 libxcb-xkb1 libxerces2-java libxfce4util-bin libxfce4util-common
  libxfce4util7 libxfconf-0-2 libxkbcommon-x11-0 libxkbcommon0 libxklavier16 libxml-commons-external-java libxml-java
  libxmlbeans-java libxom-java libxpp2-java libxpp3-java libxres1 libyajl2 libyaml-0-2 lp-solve lxde-common
  lxhotkey-core lxhotkey-data lxmenu-data lxpanel-data lxsession-data modemmanager netsurf-common p11-kit
  p11-kit-modules p7zip p7zip-full packagekit point-rpi poppler-data python-cairo python-gobject python-gobject-2
  python-rtimulib python-talloc python3-rtimulib qttranslations5-l10n r-doc-html rake rc realpath rpd-plym-splash
  rpd-wallpaper ruby ruby-did-you-mean ruby-minitest ruby-net-telnet ruby-power-assert ruby-test-unit ruby2.3
  rubygems-integration samba-libs squeak-plugins-scratch supercollider-server uuid xfconf xinput yelp-xsl
  zenity-common
Use 'sudo apt autoremove' to remove them.
The following packages will be REMOVED:
  adwaita-icon-theme alacarte chromium-browser claws-mail claws-mail-i18n desktop-base dillo epiphany-browser evince
  galculator gcr geany giblib1 gir1.2-gdkpixbuf-2.0 gir1.2-gtk-3.0 gksu gnome-icon-theme gnome-keyring
  gnome-themes-standard gnome-user-guide gpicview gstreamer1.0-plugins-bad gstreamer1.0-plugins-good
  gtk-update-icon-cache gtk2-engines gtk2-engines-clearlookspix gtk2-engines-pixbuf gvfs-backends leafpad
  libbonoboui2-0 libcanberra-gtk3-0 libcanberra-gtk3-module libcupsfilters1 libdjvulibre21 libevdocument3-4
  libevview3-3 libfm-gtk4 libfm-modules libgail-common libgail18 libgcr-ui-3-1 libgd3 libgdk-pixbuf2.0-0 libgksu2-0
  libglade2-0 libgnome-desktop-3-12 libgnomecanvas2-0 libgnomeui-0 libgphoto2-6 libgs9 libgtk-3-0 libgtk-3-bin
  libgtk2.0-0 libgtk2.0-bin libgxps2 libimlib2 libjpeg-dev libjpeg-turbo-progs libjpeg62-turbo libjpeg62-turbo-dev
  libkeybinder0 libnautilus-extension1a libnotify4 libobrender32v5 libopencv-calib3d2.4v5 libopencv-features2d2.4v5
  libopencv-highgui2.4-deb0 libopencv-objdetect2.4v5 libpoppler-glib8 libpoppler64 libqt5gui5 libqt5opengl5
  libqt5printsupport5 libqt5scintilla2-12v5 libqt5svg5 libqt5widgets5 libqt5x11extras5 libqwt-qt5-6 libraw15
  libreoffice libreoffice-avmedia-backend-gstreamer libreoffice-base libreoffice-base-core libreoffice-base-drivers
  libreoffice-calc libreoffice-core libreoffice-draw libreoffice-gtk libreoffice-gtk2 libreoffice-impress
  libreoffice-librelogo libreoffice-math libreoffice-nlpsolver libreoffice-ogltrans libreoffice-pdfimport
  libreoffice-report-builder libreoffice-report-builder-bin libreoffice-script-provider-bsh
  libreoffice-script-provider-js libreoffice-script-provider-python libreoffice-sdbc-hsqldb
  libreoffice-sdbc-postgresql libreoffice-systray libreoffice-wiki-publisher libreoffice-writer librsvg2-2
  librsvg2-common libsdl-image1.2 libspandsp2 libspectre1 libtiff5 libunique-1.0-0 libv4l-0 libv4lconvert0 libvte9
  libwebkit2gtk-4.0-37 libwebkitgtk-3.0-0 libwnck-3-0 libwnck22 libxm4 libyelp0 libzbar0 lightdm lightdm-gtk-greeter
  lxappearance lxappearance-obconf lxde lxde-core lxhotkey-gtk lxinput lxkeymap lxpanel lxplug-bluetooth
  lxplug-ejecter lxplug-network lxplug-volume lxpolkit lxrandr lxsession lxsession-edit lxsession-logout lxtask
  lxterminal netsurf-gtk notification-daemon nuscratch obconf openbox openbox-lxde-session pcmanfm pi-greeter
  pi-package pi-package-data pi-package-session piclone pimixer pinentry-gnome3 pipanel pishutdown poppler-utils
  python-gtk2 python-pil python-pygame python-sense-emu python-sense-hat python-xklavier python3-pgzero python3-pil
  python3-pygame python3-sense-emu python3-sense-hat python3-uno qjackctl qt5-gtk-platformtheme r-base r-base-core
  r-base-dev r-base-html r-cran-boot r-cran-class r-cran-cluster r-cran-codetools r-cran-foreign r-cran-kernsmooth
  r-cran-lattice r-cran-mass r-cran-matrix r-cran-mgcv r-cran-nlme r-cran-nnet r-cran-rpart r-cran-spatial
  r-cran-survival r-recommended raspberrypi-ui-mods rc-gui rpd-icons rpi-chromium-mods scratch scratch2 scrot
  sense-emu-tools sense-hat smartsim sonic-pi squeak-vm v4l-utils wolfram-engine xarchiver xpdf xscreensaver
  xscreensaver-data yelp zenity
The following NEW packages will be installed:
  libjpeg62
0 upgraded, 1 newly installed, 214 to remove and 0 not upgraded.
Need to get 0 B/73.2 kB of archives.
After this operation, 1,676 MB disk space will be freed.
Do you want to continue? [Y/n] n
Abort.

Do you know why? or any idea of how to avoid this and install the package.

Thanks

Just for you to know, if I try to install any other package that doesn't happen.

For example:

pi@raspberrypi:~ $ sudo apt-get install megatools
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following NEW packages will be installed:
  megatools
0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
Need to get 120 kB of archives.
After this operation, 944 kB of additional disk space will be used.
Get:1 http://mirrordirector.raspbian.org/raspbian stretch/main armhf megatools armhf 1.9.98-1 [120 kB]
Fetched 120 kB in 10s (11.4 kB/s)
Selecting previously unselected package megatools.
(Reading database ... 160340 files and directories currently installed.)
Preparing to unpack .../megatools_1.9.98-1_armhf.deb ...
Unpacking megatools (1.9.98-1) ...
Setting up megatools (1.9.98-1) ...
Processing triggers for man-db (2.7.6.1-2) ...

It doesn't even trigger the The following packages were automatically installed and are no longer required: response.

I think libjpeg62 is the issue. It seems Debian replaces libjpeg62 with libjpeg62-turbo. Installing libjepg62 would remove all packages depends on libjpeg62-turbo.

I got similar issues in Deepin 15.4, which is based on Debian sid.

Here is what I got from Debian website.
https://packages.debian.org/search?keywords=libjpeg62

It looks like you're correct. Is there a way we could easily detect whether libjpeg62 vs. libjpeg62-turbo should be used? If so, we could try to accommodate for that in our dependency installer script.

As I know, Debian provides the method of conditional dependencies.

Hope it works. I haven't tried it by myself.

Hey,

Sorry I haven't reply sooner...

I've haven't tried again and had the project a little bit abandoned, but I want to try again and see if I can successfully compile last version of R and RStudio in a Raspberry Pi.

I'll try to do it first on DietPi, since it's a little bit more slim distro of debian for boards, and I'm not able to I'll try to do it with raspbian lite/server/headless.

Thanks for your help!