#!/bin/bash

## This file download all JKArch dependencies and puts it in a folder with repo created, ready to use

#Force sudo
if [[ $(/usr/bin/id -u) != "0" ]];then
sudo ${0} $@
exit
fi

rm -rf trydeps/
rm -rf repoofflinejkarch/
mkdir trydeps
#Only pacstrap for the essential packages for download the rest, pacman, and mirrorlist. Base added to pacman -Sw of later
pacstrap -d trydeps pacman jkarch-mirrorlist
cp /etc/pacman.conf trydeps/etc/pacman.conf

arch-chroot trydeps/ /usr/bin/pacman -Sw base base-devel yaourt btrfs-progs exfat-utils jkarch-mirrorlist jka-toolkit git wget netctl iw wpa_supplicant dialog sudo alsa-utils dosfstools \
ntfs-3g bash-completion reflector ntp \
mesa libva-vdpau-driver mesa-libgl libva-mesa-driver mesa-vdpau libva-intel-driver libvdpau-va-gl virtualbox-guest-utils virtualbox-guest-modules-arch xf86-input-vmmouse open-vm-tools \
firefox google-chrome chromium opera otter-browser flashplugin \
libreoffice-fresh abiword gnumeric wps-office leafpad gedit notepadqq \
vlc qt4 smplayer totem clementine \
gimp inkscape pinta krita \
noto-fonts noto-fonts-cjk noto-fonts-emoji ttf-dejavu ttf-liberation ttf-ms-fonts ttf-google-fonts-git \
evince ristretto librsvg gnome-calculator gnome-disk-utility file-roller lrzip p7zip unace unrar tumbler poppler-glib ffmpegthumbnailer libgsf \
cups cups-filters hplip bluez bluez-utils bluez-cups bluez-firmware bluez-libs blueberry \
dropbox megasync geary k3b jre8-openjdk wine-staging wine_gecko winetricks lib32-libpng lib32-libldap lib32-gnutls lib32-mpg123 lib32-libpulse lib32-ncurses lib32-openal lib32-alsa-lib lib32-gst-plugins-base-libs bleachbit \
sublime-text-dev sublime-text visual-studio-code jdk8-openjdk eclipse-java monodevelop brackets atom-editor-bin gdevelop poedit arduino \
xorg-server xorg-xinit xorg-server-common xf86-input-libinput xterm lightdm lightdm-gtk-greeter gvfs gvfs-mtp gvfs-afc gvfs-smb udisks networkmanager network-manager-applet gnome-keyring xdialog \
jkarch-appearance lxterminal ttf-inconsolata octopi octopi-notifier gksu pulseaudio pavucontrol xdg-user-dirs xfce4-power-manager \
lxappearance lxappearance-obconf lxde-common lxinput lxpanel lxrandr lxsession lxtask lxterminal openbox pcmanfm xfce4-notifyd \
xfce4 cinnamon gnome-extra gnome mate-extra mate gtk-engine-murrine plasma gtk-engine-aurora faenza-icon-theme \
efibootmgr dosfstools refind-efi grub os-prober --noconfirm

arch-chroot trydeps/ /usr/bin/pacman -Sw $(pacman -Ssq xf86-video-*) --noconfirm
mkdir repoofflinejkarch
mv trydeps/var/cache/pacman/pkg/* repoofflinejkarch/
rm -rf trydeps/
cd repoofflinejkarch/
repo-add localjkarch.db.tar.gz *.pkg.*
rm localjkarch.files
rm localjkarch.db
mv localjkarch.files.tar.gz localjkarch.files
mv localjkarch.db.tar.gz localjkarch.db
rm -f *.old
rm -f *.log
rm -f .log
cd ..
#Permisos
chmod 777 repoofflinejkarch/
chmod 666 repoofflinejkarch/*
