aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLucas C. Villa Real <lucasvr@gmail.com>2017-01-02 22:05:39 -0200
committerLucas C. Villa Real <lucasvr@gmail.com>2017-01-02 22:05:39 -0200
commit8a8da53a71e64d736b19f808eca6f48c425ee80f (patch)
tree0cbe5a38312ea3110b89f75c8e12e690b374171f
parente7660d9ccd5330bca286989f12a62638a3e09155 (diff)
downloadThirdPartyInstallers-8a8da53a71e64d736b19f808eca6f48c425ee80f.tar.xz
Introduce support for the installation of DEB files. One caveat is that
.deb control files do not include licensing information, per https://www.debian.org/doc/debian-policy/ch-controlfields.html.
-rw-r--r--Functions/DEB72
-rwxr-xr-xbin/ThirdPartyInstaller28
2 files changed, 70 insertions, 30 deletions
diff --git a/Functions/DEB b/Functions/DEB
index 4c25e37..f2cebec 100644
--- a/Functions/DEB
+++ b/Functions/DEB
@@ -7,53 +7,101 @@ function thirdparty_backend() {
}
function thirdparty_arch() {
- false
+ local debfile="$1"
+ local arch=$(dpkg-deb --field "$debfile" "Architecture")
+ if [ "$arch" = "amd64" ]
+ then echo "x86_64"
+ elif [ "$arch" = "all" ]
+ then echo "noarch"
+ else echo "$arch"
+ fi
}
function thirdparty_distribution() {
- false
+ local debfile="$1"
+ local distro=$(dpkg-deb --field "$debfile" "Distribution")
+ if [ -z "$distro" ]
+ then echo "Debian based (guessed)"
+ else echo "$distro"
+ fi
}
function thirdparty_dependencies() {
- false
+ local debfile="$1"
+ dpkg-deb --field "$debfile" "Depends"
}
function thirdparty_description() {
- false
+ local debfile="$1"
+ dpkg-deb --field "$debfile" "Description"
}
function thirdparty_filenames() {
- false
+ local debfile="$1"
+ local contents=$(dpkg-deb --contents "$debfile")
+
+ # The output of --contents looks like this:
+ #
+ # drwxr-xr-x root/root 0 2016-12-20 12:55 ./
+ # drwxr-xr-x root/root 0 2016-12-20 12:55 ./etc/
+ # ...
+ # lrwxrwxrwx root/root 0 2016-12-20 12:55 ./opt/application/lib/libavfilter.so -> libavfilter.so.3.90.100
+ #
+ # We only want the path component. The sed below uses ./ as delimiter to account for
+ # spaces in file names. Symbolic link targets are filtered out.
+
+ echo "$contents" | sed 's,.*\./\(.*\),/\1,g' | grep -v "^/$" | sed -e 's,/$,,g' -e 's, -> .*,,g'
}
function thirdparty_license() {
- false
+ local debfile="$1"
+ echo "Please visit the project website for licensing information."
}
function thirdparty_name() {
- false
+ local debfile="$1"
+ dpkg-deb --field "$debfile" "Package"
}
function thirdparty_version() {
- false
+ local debfile="$1"
+ local version=$(dpkg-deb --field "$debfile" "Version")
+ # The format is: [epoch:]upstream_version[-debian_revision]
+ # We want to output the [epoch:]upstream_version part
+ echo "$version" | cut -d: -f1-2 | rev | cut -d- -f2- | rev
}
function thirdparty_release() {
- false
+ local debfile="$1"
+ local version=$(dpkg-deb --field "$debfile" "Version")
+ # The format is: [epoch:]upstream_version[-debian_revision]
+ # We want to output the [-debian_revision] part
+ # The absence of a debian_revision is equivalent to a debian_revision of 0.
+ if echo "$version" | grep -q -- "-"
+ then echo "$version" | rev | cut -d- -f1 | rev
+ else echo "0"
+ fi
}
function thirdparty_summary() {
- false
+ local debfile="$1"
+ dpkg-deb --field "$debfile" "Description"
}
function thirdparty_url() {
- false
+ local debfile="$1"
+ dpkg-deb --field "$debfile" "Homepage"
}
function thirdparty_search_remotedb() {
+ local path="$1"
+ local arch="$2"
+ local distro="$3"
false
}
function thirdparty_uncompress() {
- false
+ local debfile="$1"
+ Log_Normal "Extracting DEB payload."
+ dpkg-deb --extract "$debfile" .
}
diff --git a/bin/ThirdPartyInstaller b/bin/ThirdPartyInstaller
index 131a31e..eab5ab1 100755
--- a/bin/ThirdPartyInstaller
+++ b/bin/ThirdPartyInstaller
@@ -305,7 +305,7 @@ function take_dependency_from_path() {
# the dependency currently linked on /System/Index.
#
# Note that when iterating over installed programs we skip those entries whose
- # Resources/Architecture do not match the output of $(rpminfo --arch).
+ # Resources/Architecture do not match the output of $(thirdparty_arch).
depname=$(echo "$fullpath" | cut -d/ -f3)
depversion=$(echo "$fullpath" | cut -d/ -f4)
@@ -441,33 +441,25 @@ then verbose="--verbose"
else verbose=
fi
+# Sanity checks, then import the backend to handle the input package(s)
+if echo "$@" | grep -q "\.rpm" && echo "$@" | grep -q "\.deb"
+then Die "Error: cannot handle both RPM and DEB files in one shot."
+elif echo "$@" | grep -q "\.rpm"
+then Import RPM
+else Import DEB
+fi
+
# The inputfiles array holds the full path of all RPM/DEB input files
# The inputnames array holds the package name of all RPM/DEB input files
inputfiles=()
inputnames=()
-rpmcount=0
-debcount=0
eval `Args_To_Array inputfiles_`
for entry in "${inputfiles_[@]}"
do
inputfiles+=( "$(readlink -f ${entry} || echo ${entry})" )
- inputnames+=( "$(rpminfo --name $entry)" )
- echo "$entry" | grep -qi "\.deb" && let debcount=debcount+1
- echo "$entry" | grep -qi "\.rpm" && let rpmcount=rpmcount+1
+ inputnames+=( "$(thirdparty_name $entry)" )
done
-# Sanity checks, then import the backend to handle the package format
-if [ $rpmcount -gt 0 ] && [ $debcount -gt 0 ]
-then
- Die "Error: cannot handle both RPM and DEB files in a single shot."
-elif [ $rpmcount -gt 0 ]
-then
- Import RPM
-elif [ $debcount -gt 0 ]
-then
- Import DEB
-fi
-
# These will be set by prepare_program_entry()
unset programname
unset programversion