Added .git-template to the project
authorHugo Monteiro <hugo.monteiro@fct.unl.pt>
Thu, 3 Feb 2011 17:19:49 +0000 (17:19 +0000)
committerHugo Monteiro <hugo.monteiro@fct.unl.pt>
Thu, 3 Feb 2011 17:19:49 +0000 (17:19 +0000)
Added get-debs.sh script

MFM: 0 days
Bug-ID: none

.git-template [new file with mode: 0644]
get-debs.sh [new file with mode: 0755]

diff --git a/.git-template b/.git-template
new file mode 100644 (file)
index 0000000..813dc80
--- /dev/null
@@ -0,0 +1,20 @@
+# All tags are optional. Your actual commit message goes ABOVE this line.
+
+# MFM: X days
+#   (Merge-From-Master)
+#   After how many days should this fix be merged into the RELENG_* branch?
+#   I.e. large enouph to allow people to test this commit in master but
+#   remember that a typo doesn't need a month of stress testing.
+#MFM:
+#
+# Bug-ID: XXXXXXXX
+#   ID from the SF tracker when this commit is related to a certain bug. 
+#Bug-ID:
+#
+# Bug-Reported-By: Name <email>
+#   Name and email of the reporter of the bug (see SF tracker).
+#Bug-Reported-By:
+#
+# Security: reference
+#   Reference to a CVE, SecurityFocus, CERT or similar ID
+#Security:
diff --git a/get-debs.sh b/get-debs.sh
new file mode 100755 (executable)
index 0000000..778b879
--- /dev/null
@@ -0,0 +1,76 @@
+#!/bin/bash
+
+function usage() {
+cat << EOF
+Usage:
+
+       $0 <package name> <directory full path>
+
+Ex:
+       $0 php5-cli /tmp/downloads
+
+EOF
+exit 1
+}
+
+function mkdirfail() {
+       echo "There was a problem creating the target directory."
+       if [ -n "$1" ]
+       then
+               echo $1
+       fi
+       exit 1
+}
+
+PKG=$1
+DIR=$2 
+
+if [ -z $PKG ] || [ -z $DIR ]
+then
+       usage
+fi
+
+if [ ${DIR:0:1} != "/" ]
+then
+       DIR="`pwd`/${DIR}"
+fi
+
+if [ -f ${DIR} ]
+then
+       mkdirfail "File already exists."
+fi
+
+if [ -d ${DIR} ]
+then
+       while [ -z ${answer} ]
+       do
+               read -p "Target directory already exists. Overwrite?(y/n) " answer;
+       done
+       if [ ${answer} != "y" ]
+       then
+               exit 0
+       fi
+fi
+
+mkdir -p "${DIR}/partial" || mkdirfail "Check you have write permission on the parent dirs and that the path is correct."
+
+FULL_DEPS=""
+
+TO_GET="$1 `apt-cache depends $1|grep Depends|egrep -v "<|>|debconf"|awk '{print $2}'`"
+TO_GET=`echo ${TO_GET}|tr " " "\n"|sort|uniq|tr "\n" " "`
+
+while [ "${TO_GET}" != "${FULL_DEPS}" ]
+do
+       FULL_DEPS="${TO_GET}"
+       for package in ${FULL_DEPS}; do
+               TO_GET="${package} ${TO_GET} `apt-cache depends ${package}|grep Depends|egrep -v "<|>|debconf"|awk '{print $2}'`"
+               TO_GET=`echo ${TO_GET}|tr " " "\n"|sort|uniq|tr "\n" " "`
+       done
+done
+
+apt-get install -o Dir::Cache::Archives="${DIR}" -d --reinstall ${TO_GET}
+
+rmdir "${DIR}/partial"
+rm "${DIR}/lock"
+
+exit 0