Posted by hmontoliu Wed 28th Feb 2007 15:04 - Syntax is Bash - 159 views
Download | New Post | Modify | Show line numbers
Download | New Post | Modify | Show line numbers
# TODO BLQ-0 (bug_report_lib.sh) VARIABLES GLOBALES
BUGSQUAD_D=~/bugsquad_dir/
LAUNCHPAD_BUG_URL="https://launchpad.net/distros/ubuntu/+source/ubiquity/+bug/" # >bugnum
TMP_D=${BUGSQUAD_D}/tmp/
CWD=$TMP_D
bug_report_extract_crash_url () {
# Extrae la URL al crash_report(s) a partir del número de bug.
# Usage: -> bug_report_extract_crash_url "$BUGNUMBER"
# Input args:
local BUGNUMBER="$1" # numero de bug en Launchpad
# Output: Crash Report(s) URL(s)
# Returns: 0 always
# Global Vars: $LAUNCHPAD_BUG_URL >> url de los informes de error
local LAUNCHPADBUGURL=$LAUNCHPAD_BUG_URL
local CRASH_REPORT_URL # Output: URL1 URL2 URL3
CRASH_REPORT_URL="$(wget -q -O - "$LAUNCHPAD_BUG_URL/$BUGNUMBER" | sed -n '/
">/,/<\div>/ {s@.*\(http://librarian.launchpad.net/.[^" ]*crash\)\".*@\1 @gp}')"
echo $CRASH_REPORT_URL
return 0;
}
bug_report_dwl_crash_file () {
# Baja el fichero "Crash Report" desde su URL.
# Usage: -> bug_report_dwl_crash_file "$CRASH_URL" "$DEST"
# Input args:
local CRASH_URL="$1" # Crash report file, URL, or - (stdin)
local DEST="$2" # Destination (dir, filename, or - (stdout))
# Output: None
# Returns: 0 always
# Distinguir entre nombre de fichero destino y directorio
if [ -d "$DEST" ]; then
cd "$DEST"; wget "$CRASH_URL"
else
# curl ?
wget -O "$DEST" "$CRASH_URL"
fi
return 0;
}
bug_report_dwl_short_crash_file () {
# Igual que bug_report_dwl_crash_file pero corta la descarga al llegar al
# coredump.
# Usage: -> bug_report_dwl_short_crash_file "$CRASH_URL" "$DEST"
# Input args:
local CRASH_URL="$1" #
local DEST="$2" #
# Output: None
# Returns: 0 always
local TMPFILE WGETPID
TMPFILE=$(tempfile -p crashtmp)
WGETPIDFILE=$(tempfile -s pid)
# matamos a wget cuando empieze la descarga del coredump.
while :; do grep -q "Uname:" $TMPFILE && kill $(cat $WGETPIDFILE) && exit; sleep 1; done &
wget -O $TMPFILE $CRASH_URL & echo $! > $WGETPIDFILE
wait
# Salida a $DEST
if [ "$DEST" == "-" ]; then
sed -n '1,/^Uname:/ {p}' $TMPFILE
else
sed -n '1,/^Uname:/ {p}' $TMPFILE > "$DEST"
fi
# no es necesario 'ver man tmpfile', pero por si acaso:
[ -f "$TMPFILE" ] && rm -f "$TMPFILE"
[ -f "$WGETPIDFILE" ] && rm -f "$WGETPIDFILE"
return 0;
}
bug_report_unpack () {
# Crea el directorio de destino y desempaqueta el fichero crash_file.
# Realmente no hay que hacer nada, apport-unpack se encarga de crear el
# directorio de destino.
# TODO: handle compressed files
# Usage: -> bug_report_unpack "$CRASH_FILE" "$DEST_CRASH_REPORT_DIR"
# -> bug_report_unpack "-" "$DEST_CRASH_REPORT_DIR" # STDIN
# Input args:
local CRASH_FILE="$1" # Crash report file; "-" para stdin ;
local DEST_CRASH_REPORT_DIR="$2" # Dest dir to unpack crash report file
# Output: None
# Returns: 0 always
# wget -O - "${CRASH_URL}" | apport-unpack - $CRASHDIR
apport-unpack $CRASH_FILE $DEST_CRASH_REPORT_DIR
return 0;
}
bug_report_summary () {
# Crea la cabecera del informe del error
# Usage: -> bug_report_summary "$CRASH_REPORT_DIR"
# Input args:
local CRASH_REPORT_DIR="$1" # Full path to bug report directory
# Output: Bug Report Summary.
# Returns: 0 always
local PACKAGE PACKAGE_VER DISTRO_RELEASE SOURCE_PACKAGE
PACKAGE="$(cat $CRASH_REPORT_DIR/Package)"
eval $(awk '{print "PACKAGE="$1" PACKAGE_VER="$2}' $CRASH_REPORT_DIR/Package)
DISTRO_RELEASE="$(cat $CRASH_REPORT_DIR/DistroRelease)"
SOURCE_PACKAGE="$(cat $CRASH_REPORT_DIR/SourcePackage)"
cat <<- EOF
[Binary Package Hint: $PACKAGE]
From the Attached Crash Report:
Distro Release: $DISTRO_RELEASE
Package (version): $PACKAGE ($PACKAGE_VER)
Source Package: $SOURCE_PACKAGE
Original Description:
EOF
return 0;
}
echo $CRASH_REPORT_URL
return 0;
}
bug_report_dwl_crash_file () {
# Baja el fichero "Crash Report" desde su URL.
# Usage: -> bug_report_dwl_crash_file "$CRASH_URL" "$DEST"
# Input args:
local CRASH_URL="$1" # Crash report file, URL, or - (stdin)
local DEST="$2" # Destination (dir, filename, or - (stdout))
# Output: None
# Returns: 0 always
# Distinguir entre nombre de fichero destino y directorio
if [ -d "$DEST" ]; then
cd "$DEST"; wget "$CRASH_URL"
else
# curl ?
wget -O "$DEST" "$CRASH_URL"
fi
return 0;
}
bug_report_dwl_short_crash_file () {
# Igual que bug_report_dwl_crash_file pero corta la descarga al llegar al
# coredump.
# Usage: -> bug_report_dwl_short_crash_file "$CRASH_URL" "$DEST"
# Input args:
local CRASH_URL="$1" #
local DEST="$2" #
# Output: None
# Returns: 0 always
local TMPFILE WGETPID
TMPFILE=$(tempfile -p crashtmp)
WGETPIDFILE=$(tempfile -s pid)
# matamos a wget cuando empieze la descarga del coredump.
while :; do grep -q "Uname:" $TMPFILE && kill $(cat $WGETPIDFILE) && exit; sleep 1; done &
wget -O $TMPFILE $CRASH_URL & echo $! > $WGETPIDFILE
wait
# Salida a $DEST
if [ "$DEST" == "-" ]; then
sed -n '1,/^Uname:/ {p}' $TMPFILE
else
sed -n '1,/^Uname:/ {p}' $TMPFILE > "$DEST"
fi
# no es necesario 'ver man tmpfile', pero por si acaso:
[ -f "$TMPFILE" ] && rm -f "$TMPFILE"
[ -f "$WGETPIDFILE" ] && rm -f "$WGETPIDFILE"
return 0;
}
bug_report_unpack () {
# Crea el directorio de destino y desempaqueta el fichero crash_file.
# Realmente no hay que hacer nada, apport-unpack se encarga de crear el
# directorio de destino.
# TODO: handle compressed files
# Usage: -> bug_report_unpack "$CRASH_FILE" "$DEST_CRASH_REPORT_DIR"
# -> bug_report_unpack "-" "$DEST_CRASH_REPORT_DIR" # STDIN
# Input args:
local CRASH_FILE="$1" # Crash report file; "-" para stdin ;
local DEST_CRASH_REPORT_DIR="$2" # Dest dir to unpack crash report file
# Output: None
# Returns: 0 always
# wget -O - "${CRASH_URL}" | apport-unpack - $CRASHDIR
apport-unpack $CRASH_FILE $DEST_CRASH_REPORT_DIR
return 0;
}
bug_report_summary () {
# Crea la cabecera del informe del error
# Usage: -> bug_report_summary "$CRASH_REPORT_DIR"
# Input args:
local CRASH_REPORT_DIR="$1" # Full path to bug report directory
# Output: Bug Report Summary.
# Returns: 0 always
local PACKAGE PACKAGE_VER DISTRO_RELEASE SOURCE_PACKAGE
PACKAGE="$(cat $CRASH_REPORT_DIR/Package)"
eval $(awk '{print "PACKAGE="$1" PACKAGE_VER="$2}' $CRASH_REPORT_DIR/Package)
DISTRO_RELEASE="$(cat $CRASH_REPORT_DIR/DistroRelease)"
SOURCE_PACKAGE="$(cat $CRASH_REPORT_DIR/SourcePackage)"
cat <<- EOF
[Binary Package Hint: $PACKAGE]
From the Attached Crash Report:
Distro Release: $DISTRO_RELEASE
Package (version): $PACKAGE ($PACKAGE_VER)
Source Package: $SOURCE_PACKAGE
Original Description:
EOF
return 0;
}
PermaLink to this entry https://pastebin.co.uk/11166
Posted by hmontoliu Wed 28th Feb 2007 15:04 - Syntax is Bash - 159 views
Download | New Post | Modify | Show line numbers
Download | New Post | Modify | Show line numbers
Comments: 0