#!/bin/sh
set -e

# comment out external sources
sed -i "s/^/#/g" /etc/apt/sources.list.d/* || true
apt clean
find /var/lib/apt/lists -type f | xargs rm -fv


### Update and upgrade yirmibir ### 

# write yirmibir sources
SOURCE_LIST=/etc/apt/sources.list
cp -fv $SOURCE_LIST $SOURCE_LIST.debsave21
cat > $SOURCE_LIST.21 <<EOF
# Pardus Yirmibir
deb http://depo.pardus.org.tr/pardus yirmibir main contrib non-free
# deb-src http://depo.pardus.org.tr/pardus yirmibir main contrib non-free

deb http://depo.pardus.org.tr/guvenlik yirmibir main contrib non-free
# deb-src http://depo.pardus.org.tr/guvenlik yirmibir main contrib non-free
EOF
mv -fv $SOURCE_LIST.21 $SOURCE_LIST

DEBIAN_FRONTEND=noninteractive apt update
DEBIAN_FRONTEND=noninteractive apt -yq -o Dpkg::Options::="--force-confnew" full-upgrade

### Update and upgrade yirmibir ###

apt clean
find /var/lib/apt/lists -type f | xargs rm -fv

### Dist upgrade to yirmiuc ### 

# write yirmiuc sources
SOURCE_LIST=/etc/apt/sources.list
cp -fv $SOURCE_LIST $SOURCE_LIST.debsave23
cat > $SOURCE_LIST.23 <<EOF
### The Official Pardus Package Repositories ###

## Pardus
deb http://depo.pardus.org.tr/pardus yirmiuc main contrib non-free non-free-firmware
# deb-src http://depo.pardus.org.tr/pardus yirmiuc main contrib non-free non-free-firmware

## Pardus Deb
deb http://depo.pardus.org.tr/pardus yirmiuc-deb main contrib non-free non-free-firmware
# deb-src http://depo.pardus.org.tr/pardus yirmiuc-deb main contrib non-free non-free-firmware

## Pardus Security Deb
deb http://depo.pardus.org.tr/guvenlik yirmiuc-deb main contrib non-free non-free-firmware
# deb-src http://depo.pardus.org.tr/guvenlik yirmiuc-deb main contrib non-free non-free-firmware
EOF
mv -fv $SOURCE_LIST.23 $SOURCE_LIST


DEBIAN_FRONTEND=noninteractive apt update
DEBIAN_FRONTEND=noninteractive apt -yq -o Dpkg::Options::="--force-confnew" full-upgrade

### Dist upgrade to yirmiuc ### 


exit 0
