#!/bin/bash

#set -x
ACTION=”$1″

TEMP_SOURCES_BASE=”/tmp/mx-testrepo-apt-sources.list.d-temp.$USER”
TEMP_SOURCES_LIST_D=”${TEMP_SOURCES_BASE}.$$.$RANDOM$RANDOM”
TEMP_SOURCES_LIST=$TEMP_SOURCES_LIST_D/temp_source.list

rm -fr ${TEMP_SOURCES_BASE}.*
mkdir $TEMP_SOURCES_LIST_D

echo -e “\n## /etc/apt/sources.list.d/mx.list” | tee $TEMP_SOURCES_LIST
echo -e “## mx-testrepo” | tee -a $TEMP_SOURCES_LIST
cat /etc/apt/sources.list.d/mx.list | grep -m1 -E “^#[[:space:]]+(deb https?.mx/testrepo.)” | grep -o -E “(deb https?.mx/testrepo.)” | tee -a $TEMP_SOURCES_LIST

APT_OPTION=”-o Dir::Etc::sourcelist=$TEMP_SOURCES_LIST”
[ “$ACTION” = “update” ] && APT_OPTION=”-o Dir::Etc::sourceparts=- -o APT::Get::List-Cleanup=0 $APT_OPTION”

echo sudo apt $APT_OPTION “${@}”
sudo apt $APT_OPTION “${@}”

################################################
exit
################################################