Commit bc5ceb76 authored by Ricardo Tavares de Oliveira's avatar Ricardo Tavares de Oliveira Committed by Vinicius Ruoso

integrity/prd_packs{,.po}: Changed the way to download and check packs

As explained before, we will have two different packs bases: one
for "normal" schools and another for "testing" ones.
We changed prd_packs to indicate what base the school will download, and
prd_packs.po to recive this indication and process it according to it.
Also, we are commentig the actions we perform to fix problems.
Signed-off-by: default avatarRicardo Tavares de Oliveira <rto07@c3sl.ufpr.br>
parent 35a3e4e3
......@@ -53,8 +53,8 @@ function try_solve_error_2_4()
export ERRORPACKS="$ERRORPACKS $pack"
# Try to fix!
else
rm -f /var/lib/apt/lists/prdmirror*
/usr/local/sbin/prd-faz-upgrade --force &>/dev/null
#rm -f /var/lib/apt/lists/prdmirror*
#/usr/local/sbin/prd-faz-upgrade --force &>/dev/null
# If the pau continua
if [[ \
"$(dpkg -l $pack 2> /dev/null | tail -1 | awk '{print $3}')" != \
......@@ -83,14 +83,17 @@ function verify_packs()
# base format:
# prd-interface 0.4.144
# prd-extra 0.0.11
# | prd-kernel-opteron 1.4.20 prd-kernel-xeon 1.40.20
LBASE=$(mktemp)
LVERSION=$(mktemp)
KEY=$(date +%s)
rm -f /tmp/.packs_base
printf "PRD_PACKS+prd_packs_prequest.st&Y\n"
if ! grep -q prdtesting /etc/apt/sources.list; then
printf "PRD_PACKS+prd_packs_prequest.st&Y&n\n"
else
printf "PRD_PACKS+prd_packs_prequest.st&Y&t\n"
fi
waitsendfile "/tmp/.packs_base"
......@@ -113,10 +116,10 @@ function verify_packs()
">=" "0.1.40" && \
[[ "$(cat ${LVERSION})" == "$(cat /etc/prd_version)" ]]; then
sleep 0
rm -f /var/lib/apt/lists/prdmirror*
apt-get --quiet -y --force-yes update &>/dev/null
apt-get --quiet -y --force-yes install prd-auto-upgrade \
&>/dev/null
#rm -f /var/lib/apt/lists/prdmirror*
#apt-get --quiet -y --force-yes update &>/dev/null
#apt-get --quiet -y --force-yes install prd-auto-upgrade \
# &>/dev/null
fi
ALOG=/var/log/prd/prd-auto-upgrade.log
......@@ -149,86 +152,50 @@ function verify_packs()
INSTALLED=$(mktemp)
dpkg -l | awk 'NR >= 6 {print $1" "$2" "$3}' > $INSTALLED
testing=""
PROB=0
perror1=0
perror2=0
perror3=0
perror4=0
while read pack version; do
# Only lines starting with @ (at)
if [[ "$pack" == "@" ]]; then
read packk versionn <<< "$version"
testing="${testing} ${packk}"
# Olny lines starting with | (pipe)
# ==========
elif [[ "$pack" == "|" ]]; then
read pack1 version1 pack2 version2 <<< "$version"
if ! grep -q "ii $pack1 " $INSTALLED && ! grep -q "ii $pack2" \
$INSTALLED; then
# Packages not installed
printf \
"PRD_PACKS+prd_packs_perror1.st&Y&${KEY}&${pack1} | ${pack2}\n"
perror1=1
PROB=1
export ERRORPACKS="$ERRORPACKS $pack1 $pack2"
elif ! grep -q "$pack1 $version1" $INSTALLED && \
! grep -q "$pack2 $version2" $INSTALLED; then
# Packages with wrong version
if grep -q " $pack1 " $INSTALLED; then
WRONG_PACK=$pack1
WRONG_VERSION=$version1
else
WRONG_PACK=$pack2
WRONG_VERSION=$version2
fi
try_solve_error_2_4 $WRONG_PACK $WRONG_VERSION
fi
sed -i "/ $pack1 /d" $INSTALLED
sed -i "/ $pack2 /d" $INSTALLED
# ==========
else
if ! grep -q "ii $pack " $INSTALLED; then
# Packages not installed
# Trying to fix
if [[ "$(cat ${LVERSION})" == \
"$(cat /etc/prd_version)" ]]; then
rm -f /var/lib/apt/lists/prdmirror*
apt-get --quiet -y --force-yes update &>/dev/null
apt-get --quiet -y --force-yes install ${pack} \
&>/dev/null
if [[ \
if ! grep -q "ii $pack " $INSTALLED; then
# Packages not installed
# Trying to fix
if [[ "$(cat ${LVERSION})" == \
"$(cat /etc/prd_version)" ]]; then
#rm -f /var/lib/apt/lists/prdmirror*
#apt-get --quiet -y --force-yes update &>/dev/null
#apt-get --quiet -y --force-yes install ${pack} \
#&>/dev/null
if [[ \
"$(dpkg -l $pack 2> /dev/null | tail -1 | cut -d' ' -f1)" != \
"ii" ]]; then
printf \
"PRD_PACKS+prd_packs_perror1.st&Y&${KEY}&${pack}\n"
perror1=1
PROB=1
export ERRORPACKS="$ERRORPACKS $pack"
fi
"ii" ]]; then
printf \
"PRD_PACKS+prd_packs_perror1.st&Y&${KEY}&${pack}\n"
perror1=1
PROB=1
export ERRORPACKS="$ERRORPACKS $pack"
fi
elif ! grep -q "$pack $version" $INSTALLED; then
# Package with wrong version
try_solve_error_2_4 $pack $version
fi # error no. 2
sed -i "/ $pack /d" $INSTALLED
fi
fi
elif ! grep -q "$pack $version" $INSTALLED; then
# Package with wrong version
try_solve_error_2_4 $pack $version
fi # error no. 2
sed -i "/ $pack /d" $INSTALLED
done < $LBASE
for packk in $testing; do
sed -i "/$packk/d" $INSTALLED
done
# UNTIL UPON
EXTRA="$(awk '$1 ~ /^ii$/ {print $2}' $INSTALLED)"
if [[ "$EXTRA" != "" ]]; then
PROB=1
for pack in $EXTRA; do
printf "PRD_PACKS+prd_packs_perror3.st&Y&${KEY}&${pack}\n"
perror3=1
export ERRORPACKS="$ERRORPACKS $pack"
if [[ "$pack" != "prd-kernel-xeon" ]] &&\
[[ "$pack" != "prd-kernel-opteron" ]]; then
PROB=1
printf "PRD_PACKS+prd_packs_perror3.st&Y&${KEY}&${pack}\n"
perror3=1
export ERRORPACKS="$ERRORPACKS $pack"
fi
done
fi
......
......@@ -32,7 +32,13 @@ function prd_packs_www()
if [[ "$ERR" == "prd_packs_prequest.st" ]] && \
[[ "$YN" == "Y" ]]; then
# Send the corefile to the host
sendfile -f MAINBASEFILE \
type=$(cut -d'&' -f3 <<< $PS)
if [[ "$type" == "n" ]]; then
file=MAINBASEFILEN
else
file=MAINBASEFILET
fi
sendfile -f $file \
-d /tmp/.packs_base -l 82 $HOST
fi
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment