aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlex Epifano <aepifano@gatech.edu>2016-12-27 19:43:15 -0500
committerAlex Epifano <aepifano@gatech.edu>2016-12-27 19:52:10 -0500
commitcb0125e15646bc663628023ff5862b26a1241dcd (patch)
tree0ddbbf9ccd7f95b500704d6f457ab6fea3895a26
parent12803ac6d2a0ce44523f2c005399dbcd169e855a (diff)
downloadlibc-database-cb0125e15646bc663628023ff5862b26a1241dcd.tar.gz
libc-database-cb0125e15646bc663628023ff5862b26a1241dcd.zip
Use mktemp for tmp dir
-rw-r--r--common/libc.sh13
1 files changed, 7 insertions, 6 deletions
diff --git a/common/libc.sh b/common/libc.sh
index b054595..7e2a760 100644
--- a/common/libc.sh
+++ b/common/libc.sh
@@ -1,6 +1,6 @@
#!/bin/bash
-mkdir -p tmp db
+mkdir -p db
die() {
echo >&2 $1
@@ -62,21 +62,22 @@ check_id() {
get_ubuntu() {
local url="$1"
local info="$2"
+ local tmp=`mktemp -d || mktemp -d -t "libc-database" || die "Cannot get temp dir"`
echo "Getting $info"
echo " -> Location: $url"
local id=`echo $url | perl -n -e '/(libc6[^\/]*)\./ && print $1'`
echo " -> ID: $id"
check_id $id || return
echo " -> Downloading package"
- rm -rf tmp/*
- wget $url 2>/dev/null -O tmp/pkg.deb || die "Failed to download package from $url"
+ wget $url 2>/dev/null -O $tmp/pkg.deb || die "Failed to download package from $url"
echo " -> Extracting package"
- cd tmp
+ pushd $tmp 1>/dev/null
ar x pkg.deb || die "ar failed"
tar xf data.tar.* || die "tar failed"
- cd ..
- local libc=`find tmp -name libc.so.6 || die "Cannot locate libc.so.6"`
+ popd 1>/dev/null
+ local libc=`find $tmp -name libc.so.6 || die "Cannot locate libc.so.6"`
process_libc $libc $id $info
+ rm -rf $tmp
}
get_current_ubuntu() {