summarylogtreecommitdiffstats
diff options
context:
space:
mode:
authorJesse Jaara2015-07-08 19:34:31 +0300
committerJesse Jaara2015-07-08 19:35:06 +0300
commit6c6c99f3284245c42fa9cbb24ff9bda3b13378e3 (patch)
treedd38d68e55194b2a6bb2c151e0e42a7de363f01a
downloadaur-6c6c99f3284245c42fa9cbb24ff9bda3b13378e3.tar.gz
Import trid to Aur4.
-rw-r--r--.SRCINFO29
-rw-r--r--PKGBUILD46
-rw-r--r--trid.install12
-rw-r--r--trid.sh11
-rw-r--r--tridupdate.py114
-rw-r--r--update-trid-defs.service8
-rw-r--r--update-trid-defs.sh13
-rw-r--r--update-trid-defs.timer9
8 files changed, 242 insertions, 0 deletions
diff --git a/.SRCINFO b/.SRCINFO
new file mode 100644
index 00000000000..abcd1bd06eb
--- /dev/null
+++ b/.SRCINFO
@@ -0,0 +1,29 @@
+pkgbase = trid
+ pkgdesc = An utility designed to identify file types from their binary signatures
+ pkgver = 2.20
+ pkgrel = 2
+ url = http://mark0.net/soft-trid-e.html
+ install = trid.install
+ arch = i686
+ arch = x86_64
+ license = CUSTOM
+ depends = ncurses
+ depends = libtinfo
+ depends = python2
+ source = trid.sh
+ source = update-trid-defs.sh
+ source = update-trid-defs.service
+ source = update-trid-defs.timer
+ source = triupdate-1.00.zip::http://mark0.net/download/tridupdate.zip
+ md5sums = 9e4849a0d14bb4df970dcbc1159c4007
+ md5sums = 6ef06da62edde6c84c9473f7a62969e6
+ md5sums = a78caa24cf0851d17b8d3798f9e776a3
+ md5sums = 2ea012671b50e0761cbc4bbec820952e
+ md5sums = fd7e042a50ee1c93ed3147f5bff6d876
+ source_i686 = trid-2.20-i686.zip::http://mark0.net/download/trid_linux.zip
+ md5sums_i686 = 07bab126d34993a1c725bf60d16e0829
+ source_x86_64 = trid-2.20-x86_64.zip::http://mark0.net/download/trid_linux_64.zip
+ md5sums_x86_64 = db0b1f4dfd0039c65e70ec559940cad7
+
+pkgname = trid
+
diff --git a/PKGBUILD b/PKGBUILD
new file mode 100644
index 00000000000..a2f0ddf660b
--- /dev/null
+++ b/PKGBUILD
@@ -0,0 +1,46 @@
+# Maintainer: Jesse Jaara <gmail.com: jesse.jaara>
+# Contributor: p2k <uni-ulm.de: Patrick.Schneider>
+
+pkgname=trid
+pkgver=2.20
+pkgrel=2
+pkgdesc="An utility designed to identify file types from their binary signatures"
+arch=('i686' 'x86_64')
+url="http://mark0.net/soft-trid-e.html"
+license=('CUSTOM')
+depends=('ncurses' 'libtinfo' 'python2')
+
+source=(trid.sh
+ update-trid-defs.sh
+ update-trid-defs.service
+ update-trid-defs.timer
+ triupdate-1.00.zip::http://mark0.net/download/tridupdate.zip)
+md5sums=('9e4849a0d14bb4df970dcbc1159c4007'
+ '6ef06da62edde6c84c9473f7a62969e6'
+ 'a78caa24cf0851d17b8d3798f9e776a3'
+ '2ea012671b50e0761cbc4bbec820952e'
+ 'fd7e042a50ee1c93ed3147f5bff6d876')
+md5sums_i686=('07bab126d34993a1c725bf60d16e0829')
+md5sums_x86_64=('db0b1f4dfd0039c65e70ec559940cad7')
+
+source_i686=(trid-${pkgver}-i686.zip::http://mark0.net/download/trid_linux.zip)
+source_x86_64=(trid-${pkgver}-x86_64.zip::http://mark0.net/download/trid_linux_64.zip)
+
+package() {
+ cd "${srcdir}"
+
+ install -D -m755 trid "${pkgdir}/usr/bin/trid.bin"
+ install -D -m755 trid.sh "${pkgdir}/usr/bin/trid"
+ install -D -m755 tridupdate.py "${pkgdir}/usr/share/trid/tridupdate.py"
+ install -D -m644 readme.txt "${pkgdir}/usr/share/trid/README"
+
+ install -d 755 "${pkgdir}/usr/share/licenses/trid"
+ ln -s /usr/share/trid/ "${pkgdir}/usr/share/licenses/trid/LICENSE"
+
+ install -D -m755 update-trid-defs.sh "${pkgdir}/usr/bin/update-trid-defs"
+ install -D -m644 update-trid-defs.service "${pkgdir}/usr/lib/systemd/system/update-trid-defs.service"
+ install -D -m644 update-trid-defs.timer "${pkgdir}/usr/lib/systemd/system/update-trid-defs.timer"
+
+ install -d -m755 "${pkgdir}/var/lib/trid"
+}
+
diff --git a/trid.install b/trid.install
new file mode 100644
index 00000000000..f86e5f81e84
--- /dev/null
+++ b/trid.install
@@ -0,0 +1,12 @@
+post_install() {
+ echo "To enable automatic defenitions database updating"
+ echo "run systemctl enable update-trid-defs.timer"
+}
+
+post_upgrade() {
+ post_install()
+}
+
+post_remove() {
+ echo "Don't forget to disable update-trid-defs.timer"
+}
diff --git a/trid.sh b/trid.sh
new file mode 100644
index 00000000000..4eccda94166
--- /dev/null
+++ b/trid.sh
@@ -0,0 +1,11 @@
+#!/usr/bin/sh
+
+if [ ! -e -/var/lib/trid/triddefs.trd ]; then
+ echo "Defenitions database not found!"
+ echo "Run update-trid-defs as root to download the database."
+ echo "You can enable automatic updates by enabling the update-trid-defs systemd service."
+
+ exit 200;
+fi
+
+/usr/bin/trid.bin -d:/var/lib/trid/triddefs.trd $*
diff --git a/tridupdate.py b/tridupdate.py
new file mode 100644
index 00000000000..a90bf58dfe0
--- /dev/null
+++ b/tridupdate.py
@@ -0,0 +1,114 @@
+#-------------------------------------------------------------------------------
+# Name: tridupdate.py
+# Purpose: TrID's definitions package updater
+#
+# Author: Marco Pontello
+#
+# Created: 20/05/2012
+# Copyright: (c) Mark 2012
+# Licence: public domain
+#-------------------------------------------------------------------------------
+#!/usr/bin/env python
+
+import os
+import sys
+import hashlib
+import argparse
+import urllib
+import zipfile
+import tempfile
+
+PROGRAM_VER = "1.00"
+
+
+def errexit(mess, errlev=1):
+ """Display an error and exit."""
+ print "%s: error: %s" % (os.path.split(sys.argv[0])[1], mess)
+ sys.exit(errlev)
+
+
+def chunked(file, chunk_size):
+ """Helper function to read files in chunks."""
+ return iter(lambda: file.read(chunk_size), '')
+
+
+def MD5digest(filename=None, data=None):
+ """Return an MD5 digest for a file or a string."""
+ h = hashlib.md5()
+ if filename:
+ f = open(filename, "rb")
+ for data in chunked(f, 1024*1024):
+ h.update(data)
+ f.close()
+ elif data:
+ h.update(data)
+ return h.hexdigest()
+
+
+def trdget(url_defs):
+ """Download & unzip a new TrID defs package"""
+ f = tempfile.TemporaryFile()
+ u = urllib.urlopen(url_defs)
+ for data in chunked(u, 1024*8):
+ f.write(data)
+ print "\r%dKB" % (f.tell() / 1024),
+ print "\r",
+ z = zipfile.ZipFile(f)
+ trd = z.read("triddefs.trd")
+ z.close()
+ f.close()
+ return trd
+
+
+def get_cmdline():
+ """Evaluate command line parameters, usage & help."""
+ parser = argparse.ArgumentParser(
+ description="TrID's definitions updater",
+ formatter_class=argparse.ArgumentDefaultsHelpFormatter,
+ prefix_chars='-/+',
+ version = "TrIDUpdate v%s - (C) 2012 M.Pontello" % PROGRAM_VER)
+ parser.add_argument("filename", action="store", nargs='?',
+ help = "TRD package filename.", default="triddefs.trd")
+ res = parser.parse_args()
+ return res
+
+
+def main():
+ res = get_cmdline()
+ trdfilename = res.filename
+
+ url_MD5 = "http://mark0.net/download/triddefs.trd.md5"
+ url_defs = "http://mark0.net/download/triddefs.zip"
+
+ if os.path.exists(trdfilename):
+ curdigest = MD5digest(filename=trdfilename)
+ print "MD5: %s" % (curdigest)
+ else:
+ curdigest = 0
+ print "File %s not found" % (trdfilename)
+
+ print "Checking last version online..."
+ f = urllib.urlopen(url_MD5)
+ newdigest = f.read()
+ f.close()
+ print "MD5: %s" % (newdigest)
+
+ if curdigest == newdigest:
+ print "Current defs are up-to-date."
+ sys.exit(0)
+
+ print "Downloading new defs..."
+ trdpack = trdget(url_defs)
+
+ print "Checking defs integrity..."
+ if MD5digest(data=trdpack) == newdigest:
+ f = open(trdfilename, "wb")
+ f.write(trdpack)
+ f.close()
+ print "OK."
+ else:
+ errexit("Digest don't match. Retry!")
+
+
+if __name__ == '__main__':
+ main()
diff --git a/update-trid-defs.service b/update-trid-defs.service
new file mode 100644
index 00000000000..99010aaacd7
--- /dev/null
+++ b/update-trid-defs.service
@@ -0,0 +1,8 @@
+[Unit]
+Description=trid defenitions database update
+RequiresMountsFor=/var/lib/trid
+After=network-online.target
+
+[Service]
+Type=oneshot
+ExecStart=/usr/bin/update-trid-defs
diff --git a/update-trid-defs.sh b/update-trid-defs.sh
new file mode 100644
index 00000000000..66b9c39bba1
--- /dev/null
+++ b/update-trid-defs.sh
@@ -0,0 +1,13 @@
+#!/usr/bin/sh
+
+if [ "$(id -u)" != "0" ]; then
+ echo "This script must be run as root" 1>&2
+ exit 1
+fi
+
+_PWD=$(pwd)
+
+cd /var/lib/trid/
+python2 /usr/share/trid/tridupdate.py
+
+cd ${_PWD}
diff --git a/update-trid-defs.timer b/update-trid-defs.timer
new file mode 100644
index 00000000000..444b2c744ef
--- /dev/null
+++ b/update-trid-defs.timer
@@ -0,0 +1,9 @@
+[Unit]
+Description=trid defenitions database update timer
+
+[Timer]
+OnCalendar=weekly
+Persistent=yes
+
+[Install]
+WantedBy=multi-user.target