#!/bin/sh

# for use with debian_chroot based sandboxes:
# this script will configure external repo for xpra software suite

# add public key from http://winswitch.org/gpg.asc
apt-key add - 2>&1 <<KEY_EOF
-----BEGIN PGP PUBLIC KEY BLOCK-----
Version: GnuPG v1.4.13 (GNU/Linux)

mQGiBEYmgxkRBACyNmGV+4jBL8Mgaa4WnUptHAyiE3uQio1gNJvMKtDsEQFUN+p7
E9LHUPJfo1NHyNm7rdC4NO7wwLmC5wzAH9Hhs5Pap0KIQzNxFjbePy5lNY1457VB
tuLxcTBrsV6OjRRgK/701KxsrjrKQuI+ygXS+XlkvMv8gB1ZkDX1Gr1lKwCggMi0
PQXgGex9Hp1rqP5ahtBQNIcD/jDhz4SP9CDGrOk/VdAEMlKFwLxWfEIVXyncLiLL
gP21Lf9Se5fCq2a/Xjc2acqkG/igEPmmcGZA9ciE93AMh6nDCc5Zf2VCNwJZBLVI
Yni01cu8zjIdvYnzNUE4OWTxLdgBFLmoJM3nSo7Uhc/S8j1gC0Ejl5k2s0REJ159
3LqMA/4uZrO3pQEzLjSkMk65YueULgwi9i/FlI7ZnkZhAUHkOCa6USIyOEO+HOR5
sTFB0LhyowWyoDhyJ+rfX8jfsxxRK5e77iGabsvNB4mR8vX2hq4dGRObEKN7XvD2
NIgjXzAnbJOwOhGdtDWIKgGUqDDnTobUtZsp8FarXECx7aNTLLQmQW50b2luZSBN
YXJ0aW4gPGFudG9pbmVAbmFnYWZpeC5jby51az6IZgQTEQIAJgIbAwYLCQgHAwIE
FQIIAwQWAgMBAh4BAheABQJRhgKdBQkUxYD4AAoJEBitsxzxita7j2IAnRUcL6VI
eDJQm7vstHpleTyxRqIIAJ0UP32YOuBg/MpJ5KGJnYK/IT0cb4hmBBMRAgAmBQJG
JoMZAhsDBQkDwmcABgsJCAcDAgQVAggDBBYCAwECHgECF4AACgkQGK2zHPGK1rvx
KQCfc20bFtc2+X6Q5h3AMH/Qxuv7H90An0kokp81GOXOhQgqs00I9KimzVGViEYE
EBECAAYFAkvfHlM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Ce8BVhTeGP4Zlm9EG3u
bVMluQINBEYmgxwQCAClLg3hwPT17HMLDorNIdf/BhZeV7qjSNUdQ6WayHf4rdmy
H7Qx+e0rPCFoZbyKnFFG2cbRSgdbYOjD9Zu4Mg5GO+4wxKy1EOPKQmQcwGqrB0kh
nQFsi88xuWQ9dbBHjXKORwI6GU+/sz8pQeyIB34eOWpLRbWMNDJWMTQ/6wAr4+74
woD0k0RGowcO5OHBKLSY8t8EHCqwwIWeR5TKROggtlsWqXUIyvIFC0cWTkKGjZU1
rf9kt1bKMvSMZra/5d9BkHWojAROLX4u+KRR2jKyGSTK2wFa1XCbVVB9Yc3sq/bT
Wifq1WorTgeX5KqpMeqX2QZKI8sTrzoXZkJpjclTAAMFB/47N5X+f0oB7TAAyO6Z
YrJ9deNFvt2DnLFbtk/WO8B/XeeFq9oq2blkxNVWUTVy0PykwyyFwJSe69hWhZEk
RULXitLMBfB59k635PmPtD6b/JHHkwrNvvVC6MOi7dpccyulDslXIqCeGysBZQ+j
THHvf/DyFSPPdt4w//xSVpwNr7gwNqqVDaQP/r3h+NSW1WRFjKdfVGb8UlQXgnmq
o3+oEDiT9IiMxHQvv4aEqPRmxpOoyZclLSL4ICx8nXbOWW/Cz/89xP+d5GZi7ZQK
N8IbfkOmO4eBh18m94x8U0sYxyYuTG6IpiIPvK1mR28CTQMhEWYg7+b6TJgPD2KR
6pgdiE8EGBECAA8CGwwFAlGGAq0FCRTFgQ0ACgkQGK2zHPGK1rvppwCfb5CySyrq
PAw9diD5haXNafx901kAn3OCHt+OCvLyTdxEzODgZUMS4K4n
=C92s
-----END PGP PUBLIC KEY BLOCK-----
KEY_EOF
[ "$?" != "0" ] && echo "apt-key failed!" && exit 1

# detect debian codename
codename=`lsb_release -cs`
[ -z "$codename" ] && echo "failed to detect os codename!" && exit 1

# detect\test sources.list.d directory location
sources_list_dir="/etc/apt/sources.list.d/"
sources_list_dir_exec=`2>/dev/null apt-config shell sources_list_dir Dir::Etc::sourceparts/d`
[ ! -z "$sources_list_dir_exec" ] && eval "$sources_list_dir_exec"
[ ! -d "$sources_list_dir" ] && echo "failed to detect or test Dir::Etc::sourceparts directory from apt-config!" && exit 1

# write xpra.list
echo "deb http://xpra.org $codename main" > "$sources_list_dir/xpra.list"
[ "$?" != "0" ] && echo "failed to write file: $sources_list_dir/xpra.list" && exit 1

# run apt-get update
apt-get update
