user-agent-switcher-revived: initial ebuild with new mozilla-webext eclass

This commit is contained in:
blshkv 2018-01-06 08:26:05 +08:00
parent 360c577aa2
commit 4b53ab581b
No known key found for this signature in database
GPG key ID: 273E3E90D1A6294F
4 changed files with 115 additions and 39 deletions

View file

@ -0,0 +1,94 @@
# Copyright 1999-2018 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# @ECLASS: mozilla-webext.eclass
# @MAINTAINER:
# Anton Bolshakov <blshkv@pentoo.ch>
# @BLURB: Eclass for installing firefox addons.
# @DESCRIPTION:
# Install web extensions for firefox
# @ECLASS-VARIABLE: WEXT_GUID
# @REQUIRED
# @DEFAULT_UNSET
# @DESCRIPTION:
# GUID for the web extension
# A string formatted like an email address:
# WEXT_GUID=extensionname@example.org
# @ECLASS-VARIABLE: WEXT_FILEID
# @REQUIRED
# @DEFAULT_UNSET
# @DESCRIPTION:
# FILEID for the web extension
# A set of digets formatted like:
# WEXT_FILEID=759731
# @ECLASS-VARIABLE: WEXT_API_PATH
# @DESCRIPTION:
# Path to download API content. Default is ${WORKDIR/${PN}.xml.
: ${MEXT_API_PATH:=${WORKDIR}/${PN}.xml}
# This eclass supports all EAPIs
EXPORT_FUNCTIONS src_unpack src_install
SRC_URI="https://addons.mozilla.org/downloads/file/${WEXT_FILEID} -> ${P}.xpi"
RDEPEND=" || ( >=www-client/firefox-57.0.0 >=www-client/firefox-bin-57.0.0 )"
S="${WORKDIR}"
# @FUNCTION: mozilla-webext_getemid
# @DESCRIPTION:
# Parses api xml file
# Avoid using awk with this dummy parser function
mozilla-webext_getguid() {
local line
while read line; do
if echo -n "${line}" | grep -Eq '<guid>[^<]+</guid>'; then
WEXT_GUID="$(echo -n "${line}" | sed -r 's#^.*<guid>([^<]+)</guid>.*$#\1#')"
break
fi
done < "${MEXT_API_PATH}"
[[ -n "${WEXT_GUID}" ]] || die "$FUNCNAME could not find guid!"
echo -n "${WEXT_GUID}"
}
# @FUNCTION: mozilla-webext_getfileid
# @DESCRIPTION:
# Parses api xml file
# Avoid using awk with this dummy parser function
mozilla-webext_getfileid() {
local line
while read line; do
if echo -n "${line}" | grep -Eq 'https.*xpi'; then
WEXT_FILEID="$(echo -n "${line}" | sed -r 's#^.*https://.*/([0-9]+)/.*xpi.*$#\1#')"
break
fi
done < "${MEXT_API_PATH}"
[[ -n "${WEXT_FILEID}" ]] || die "$FUNCNAME could not find guid!"
echo -n "${WEXT_FILEID}"
}
# @FUNCTION: mozilla-webext_src_unpack
# @DESCRIPTION:
# Default src_unpack function for firefox addons
mozilla-webext_src_unpack() {
echo
#this is probably illegal, commet out for now
# wget https://services.addons.mozilla.org/en-US/firefox/api/1.5/addon/${PN} -O ${MEXT_API_PATH}
}
# @FUNCTION: mozilla-web_src_install
# @DESCRIPTION:
# Default install function for firefox addons
mozilla-webext_src_install() {
# local guid
# guid="$(mozilla-webext_getguid)"
# install to global installation folder
insinto "/usr/share/mozilla/extensions/{ec8030f7-c20a-464f-9b0e-13a3a9e97384}/"
newins "${DISTDIR}/${P}".xpi ${WEXT_GUID}.xpi
}

View file

@ -0,0 +1 @@
DIST user-agent-switcher-revived-0.2.0.xpi 102711 SHA256 4a879d0d22235ed9b77badd44533d8dbbb0d0fe9d49e25bacc59b39cf1fe898f SHA512 2b412eac8d95e1f55620080abac5ff3fd705ec6a1b0951406f278e6046c3327a64863058e10e222044317d07794e0d5577ae33874e35fe04cf8acc9a2ce27e35 WHIRLPOOL 2add7b5feee1367f1f14ef4042466926310d9e9ef6614c0b7ddb3a647c017dc74e8f1eb86be4694be10fa154cc8096fafece3c29285906322d90bc7cafd13396

View file

@ -0,0 +1,20 @@
# Copyright 1999-2018 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
EAPI=6
#https://services.addons.mozilla.org/en-US/firefox/api/1.5/addon/user-agent-switcher-revived
#<install
WEXT_FILEID="759731"
#<guid>
WEXT_GUID="{75afe46a-7a50-4c6b-b866-c43a1075b071}"
inherit mozilla-webext
DESCRIPTION="Adds a menu and a toolbar button to switch the user agent of firefox"
HOMEPAGE="https://mybrowseraddon.com/useragent-switcher.html"
LICENSE="GPL-3"
SLOT="0"
KEYWORDS="~amd64 ~x86"
IUSE=""

View file

@ -1,39 +0,0 @@
# Copyright 1999-2014 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: $
EAPI=5
inherit mozilla-addon
MOZ_ADDON_ID=59
DESCRIPTION="Adds a menu and a toolbar button to switch the user agent of firefox"
HOMEPAGE="http://chrispederick.com/work/user-agent-switcher"
SRC_URI="https://addons.mozilla.org/downloads/latest/${MOZ_ADDON_ID} -> ${P}.xpi"
LICENSE="GPL-3"
SLOT="0"
KEYWORDS=""
IUSE="+symlink_all_targets target_firefox target_firefox-bin"
RDEPEND="
!symlink_all_targets? (
target_firefox? ( www-client/firefox )
target_firefox-bin? ( www-client/firefox-bin )
)"
src_install() {
# symlink all possible target paths if this is set
if use symlink_all_targets; then
MZA_TARGETS="firefox firefox-bin"
else
use target_firefox && MZA_TARGETS+=" firefox"
use target_firefox-bin && MZA_TARGETS+=" firefox-bin"
fi
mozilla-addon_src_install
}
pkg_postinst() {
ewarn "This ebuild installs the latest STABLE version !"
ewarn "It is used by the maintainer to check for new versions ..."
}