mirror of
https://github.com/davegallant/davegallant.github.io.git
synced 2025-08-07 00:58:13 +00:00
Update pygments
This commit is contained in:
@@ -105,81 +105,93 @@ As of right now, the latest AUR is <code>4.2.2-1</code>.</p>
|
||||
<p>These steps highlight how to get it working with <code>Python3.8</code> by making a 1 line modification to AppGate source code.</p>
|
||||
<h1 id="packaging">Packaging</h1>
|
||||
<p>We already know the community package is currently out of date, so let’s clone it:</p>
|
||||
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-shell" data-lang="shell"><span style="display:flex;"><span>git clone https://aur.archlinux.org/appgate-sdp.git
|
||||
</span></span><span style="display:flex;"><span>cd appgate-sdp
|
||||
</span></span></code></pre></div><p>You’ll likely notice that the version is not what we want, so let’s modify the <code>PKGBUILD</code> to the following:</p>
|
||||
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-shell" data-lang="shell"><span style="display:flex;"><span><span style="color:#75715e"># Maintainer: Pawel Mosakowski <pawel at mosakowski dot net></span>
|
||||
</span></span><span style="display:flex;"><span>pkgname<span style="color:#f92672">=</span>appgate-sdp
|
||||
</span></span><span style="display:flex;"><span>conflicts<span style="color:#f92672">=(</span><span style="color:#e6db74">'appgate-sdp-headless'</span><span style="color:#f92672">)</span>
|
||||
</span></span><span style="display:flex;"><span>pkgver<span style="color:#f92672">=</span>4.3.2
|
||||
</span></span><span style="display:flex;"><span>_download_pkgver<span style="color:#f92672">=</span>4.3
|
||||
</span></span><span style="display:flex;"><span>pkgrel<span style="color:#f92672">=</span><span style="color:#ae81ff">1</span>
|
||||
</span></span><span style="display:flex;"><span>epoch<span style="color:#f92672">=</span>
|
||||
</span></span><span style="display:flex;"><span>pkgdesc<span style="color:#f92672">=</span><span style="color:#e6db74">"Software Defined Perimeter - GUI client"</span>
|
||||
</span></span><span style="display:flex;"><span>arch<span style="color:#f92672">=(</span><span style="color:#e6db74">'x86_64'</span><span style="color:#f92672">)</span>
|
||||
</span></span><span style="display:flex;"><span>url<span style="color:#f92672">=</span><span style="color:#e6db74">"https://www.cyxtera.com/essential-defense/appgate-sdp/support"</span>
|
||||
</span></span><span style="display:flex;"><span>license<span style="color:#f92672">=(</span><span style="color:#e6db74">'custom'</span><span style="color:#f92672">)</span>
|
||||
</span></span><span style="display:flex;"><span><span style="color:#75715e"># dependecies calculated by namcap</span>
|
||||
</span></span><span style="display:flex;"><span>depends<span style="color:#f92672">=(</span><span style="color:#e6db74">'gconf'</span> <span style="color:#e6db74">'libsecret'</span> <span style="color:#e6db74">'gtk3'</span> <span style="color:#e6db74">'python'</span> <span style="color:#e6db74">'nss'</span> <span style="color:#e6db74">'libxss'</span> <span style="color:#e6db74">'nodejs'</span> <span style="color:#e6db74">'dnsmasq'</span><span style="color:#f92672">)</span>
|
||||
</span></span><span style="display:flex;"><span>source<span style="color:#f92672">=(</span><span style="color:#e6db74">"https://sdpdownloads.cyxtera.com/AppGate-SDP-</span><span style="color:#e6db74">${</span>_download_pkgver<span style="color:#e6db74">}</span><span style="color:#e6db74">/clients/</span><span style="color:#e6db74">${</span>pkgname<span style="color:#e6db74">}</span><span style="color:#e6db74">_</span><span style="color:#e6db74">${</span>pkgver<span style="color:#e6db74">}</span><span style="color:#e6db74">_amd64.deb"</span>
|
||||
</span></span><span style="display:flex;"><span> <span style="color:#e6db74">"appgatedriver.service"</span><span style="color:#f92672">)</span>
|
||||
</span></span><span style="display:flex;"><span>options<span style="color:#f92672">=(</span>staticlibs<span style="color:#f92672">)</span>
|
||||
</span></span><span style="display:flex;"><span>prepare<span style="color:#f92672">()</span> <span style="color:#f92672">{</span>
|
||||
</span></span><span style="display:flex;"><span> tar -xf data.tar.xz
|
||||
</span></span><span style="display:flex;"><span><span style="color:#f92672">}</span>
|
||||
</span></span><span style="display:flex;"><span>package<span style="color:#f92672">()</span> <span style="color:#f92672">{</span>
|
||||
</span></span><span style="display:flex;"><span> cp -dpr <span style="color:#e6db74">"</span><span style="color:#e6db74">${</span>srcdir<span style="color:#e6db74">}</span><span style="color:#e6db74">"</span>/<span style="color:#f92672">{</span>etc,lib,opt,usr<span style="color:#f92672">}</span> <span style="color:#e6db74">"</span><span style="color:#e6db74">${</span>pkgdir<span style="color:#e6db74">}</span><span style="color:#e6db74">"</span>
|
||||
</span></span><span style="display:flex;"><span> mv -v <span style="color:#e6db74">"</span>$pkgdir<span style="color:#e6db74">/lib/systemd/system"</span> <span style="color:#e6db74">"</span>$pkgdir<span style="color:#e6db74">/usr/lib/systemd/"</span>
|
||||
</span></span><span style="display:flex;"><span> rm -vrf <span style="color:#e6db74">"</span>$pkgdir<span style="color:#e6db74">/lib"</span>
|
||||
</span></span><span style="display:flex;"><span> cp -v <span style="color:#e6db74">"</span>$srcdir<span style="color:#e6db74">/appgatedriver.service"</span> <span style="color:#e6db74">"</span>$pkgdir<span style="color:#e6db74">/usr/lib/systemd/system/appgatedriver.service"</span>
|
||||
</span></span><span style="display:flex;"><span> mkdir -vp <span style="color:#e6db74">"</span>$pkgdir<span style="color:#e6db74">/usr/share/licenses/appgate-sdp"</span>
|
||||
</span></span><span style="display:flex;"><span> cp -v <span style="color:#e6db74">"</span>$pkgdir<span style="color:#e6db74">/usr/share/doc/appgate/copyright"</span> <span style="color:#e6db74">"</span>$pkgdir<span style="color:#e6db74">/usr/share/licenses/appgate-sdp"</span>
|
||||
</span></span><span style="display:flex;"><span> cp -v <span style="color:#e6db74">"</span>$pkgdir<span style="color:#e6db74">/usr/share/doc/appgate/LICENSE.github"</span> <span style="color:#e6db74">"</span>$pkgdir<span style="color:#e6db74">/usr/share/licenses/appgate-sdp"</span>
|
||||
</span></span><span style="display:flex;"><span> cp -v <span style="color:#e6db74">"</span>$pkgdir<span style="color:#e6db74">/usr/share/doc/appgate/LICENSES.chromium.html.bz2"</span> <span style="color:#e6db74">"</span>$pkgdir<span style="color:#e6db74">/usr/share/licenses/appgate-sdp"</span>
|
||||
</span></span><span style="display:flex;"><span><span style="color:#f92672">}</span>
|
||||
</span></span><span style="display:flex;"><span>md5sums<span style="color:#f92672">=(</span><span style="color:#e6db74">'17101aac7623c06d5fbb95f50cf3dbdc'</span>
|
||||
</span></span><span style="display:flex;"><span> <span style="color:#e6db74">'002644116e20b2d79fdb36b7677ab4cf'</span><span style="color:#f92672">)</span>
|
||||
</span></span></code></pre></div><p>Let’s first make sure we have some dependencies. If you do not have <a href="https://github.com/Jguer/yay">yay</a>, check it out.</p>
|
||||
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-shell" data-lang="shell"><span style="display:flex;"><span>yay -S dnsmasq gconf
|
||||
</span></span></code></pre></div><p>Now, let’s install it:</p>
|
||||
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-shell" data-lang="shell"><span style="display:flex;"><span>makepkg -si
|
||||
</span></span></code></pre></div><h1 id="running-the-client">Running the client</h1>
|
||||
<pre><code class="language-shell">git clone https://aur.archlinux.org/appgate-sdp.git
|
||||
cd appgate-sdp
|
||||
</code></pre>
|
||||
<p>You’ll likely notice that the version is not what we want, so let’s modify the <code>PKGBUILD</code> to the following:</p>
|
||||
<pre><code class="language-shell"># Maintainer: Pawel Mosakowski <pawel at mosakowski dot net>
|
||||
pkgname=appgate-sdp
|
||||
conflicts=('appgate-sdp-headless')
|
||||
pkgver=4.3.2
|
||||
_download_pkgver=4.3
|
||||
pkgrel=1
|
||||
epoch=
|
||||
pkgdesc="Software Defined Perimeter - GUI client"
|
||||
arch=('x86_64')
|
||||
url="https://www.cyxtera.com/essential-defense/appgate-sdp/support"
|
||||
license=('custom')
|
||||
# dependecies calculated by namcap
|
||||
depends=('gconf' 'libsecret' 'gtk3' 'python' 'nss' 'libxss' 'nodejs' 'dnsmasq')
|
||||
source=("https://sdpdownloads.cyxtera.com/AppGate-SDP-${_download_pkgver}/clients/${pkgname}_${pkgver}_amd64.deb"
|
||||
"appgatedriver.service")
|
||||
options=(staticlibs)
|
||||
prepare() {
|
||||
tar -xf data.tar.xz
|
||||
}
|
||||
package() {
|
||||
cp -dpr "${srcdir}"/{etc,lib,opt,usr} "${pkgdir}"
|
||||
mv -v "$pkgdir/lib/systemd/system" "$pkgdir/usr/lib/systemd/"
|
||||
rm -vrf "$pkgdir/lib"
|
||||
cp -v "$srcdir/appgatedriver.service" "$pkgdir/usr/lib/systemd/system/appgatedriver.service"
|
||||
mkdir -vp "$pkgdir/usr/share/licenses/appgate-sdp"
|
||||
cp -v "$pkgdir/usr/share/doc/appgate/copyright" "$pkgdir/usr/share/licenses/appgate-sdp"
|
||||
cp -v "$pkgdir/usr/share/doc/appgate/LICENSE.github" "$pkgdir/usr/share/licenses/appgate-sdp"
|
||||
cp -v "$pkgdir/usr/share/doc/appgate/LICENSES.chromium.html.bz2" "$pkgdir/usr/share/licenses/appgate-sdp"
|
||||
}
|
||||
md5sums=('17101aac7623c06d5fbb95f50cf3dbdc'
|
||||
'002644116e20b2d79fdb36b7677ab4cf')
|
||||
|
||||
</code></pre>
|
||||
<p>Let’s first make sure we have some dependencies. If you do not have <a href="https://github.com/Jguer/yay">yay</a>, check it out.</p>
|
||||
<pre><code class="language-shell">yay -S dnsmasq gconf
|
||||
</code></pre>
|
||||
<p>Now, let’s install it:</p>
|
||||
<pre><code class="language-shell">makepkg -si
|
||||
</code></pre>
|
||||
<h1 id="running-the-client">Running the client</h1>
|
||||
<p>Ok, let’s run the client by executing <code>appgate</code>.</p>
|
||||
<p>It complains about not being able to connect.</p>
|
||||
<p>Easy fix:</p>
|
||||
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-shell" data-lang="shell"><span style="display:flex;"><span>sudo systemctl start appgatedriver.service
|
||||
</span></span></code></pre></div><p>Now we should be connected… but DNS is not working?</p>
|
||||
<pre><code class="language-shell">sudo systemctl start appgatedriver.service
|
||||
</code></pre>
|
||||
<p>Now we should be connected… but DNS is not working?</p>
|
||||
<h1 id="fixing-the-dns">Fixing the DNS</h1>
|
||||
<p>Running <code>resolvectl</code> should display that something is not right.</p>
|
||||
<p>Why is the DNS not being set by appgate?</p>
|
||||
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-shell" data-lang="shell"><span style="display:flex;"><span>$ head -3 /opt/appgate/linux/set_dns
|
||||
</span></span><span style="display:flex;"><span><span style="color:#75715e">#!/usr/bin/env python3</span>
|
||||
</span></span><span style="display:flex;"><span><span style="color:#e6db74">''</span><span style="color:#960050;background-color:#1e0010">'</span>
|
||||
</span></span><span style="display:flex;"><span>This is used to set and unset the DNS.
|
||||
</span></span></code></pre></div><p>It seems like python3 is required for the DNS setting to happen.
|
||||
<pre><code class="language-shell">$ head -3 /opt/appgate/linux/set_dns
|
||||
#!/usr/bin/env python3
|
||||
'''
|
||||
This is used to set and unset the DNS.
|
||||
</code></pre>
|
||||
<p>It seems like python3 is required for the DNS setting to happen.
|
||||
Let’s try to run it.</p>
|
||||
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-shell" data-lang="shell"><span style="display:flex;"><span>$ sudo /opt/appgate/linux/set_dns
|
||||
</span></span><span style="display:flex;"><span>/opt/appgate/linux/set_dns:88: SyntaxWarning: <span style="color:#e6db74">"is"</span> with a literal. Did you mean <span style="color:#e6db74">"=="</span>?
|
||||
</span></span><span style="display:flex;"><span> servers <span style="color:#f92672">=</span> <span style="color:#f92672">[(</span> socket.AF_INET <span style="color:#66d9ef">if</span> x.version is <span style="color:#ae81ff">4</span> <span style="color:#66d9ef">else</span> socket.AF_INET6, map<span style="color:#f92672">(</span>int, x.packed<span style="color:#f92672">))</span> <span style="color:#66d9ef">for</span> x in servers<span style="color:#f92672">]</span>
|
||||
</span></span><span style="display:flex;"><span>Traceback <span style="color:#f92672">(</span>most recent call last<span style="color:#f92672">)</span>:
|
||||
</span></span><span style="display:flex;"><span> File <span style="color:#e6db74">"/opt/appgate/linux/set_dns"</span>, line 30, in <module>
|
||||
</span></span><span style="display:flex;"><span> import dbus
|
||||
</span></span><span style="display:flex;"><span>ModuleNotFoundError: No module named <span style="color:#e6db74">'dbus'</span>
|
||||
</span></span></code></pre></div><p>Ok, let’s install it:</p>
|
||||
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-shell" data-lang="shell"><span style="display:flex;"><span>$ sudo python3.8 -m pip install dbus-python
|
||||
</span></span></code></pre></div><p>Will it work now? Not yet. There’s another issue:</p>
|
||||
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-shell" data-lang="shell"><span style="display:flex;"><span>$ sudo /opt/appgate/linux/set_dns
|
||||
</span></span><span style="display:flex;"><span>/opt/appgate/linux/set_dns:88: SyntaxWarning: <span style="color:#e6db74">"is"</span> with a literal. Did you mean <span style="color:#e6db74">"=="</span>?
|
||||
</span></span><span style="display:flex;"><span> servers <span style="color:#f92672">=</span> <span style="color:#f92672">[(</span> socket.AF_INET <span style="color:#66d9ef">if</span> x.version is <span style="color:#ae81ff">4</span> <span style="color:#66d9ef">else</span> socket.AF_INET6, map<span style="color:#f92672">(</span>int, x.packed<span style="color:#f92672">))</span> <span style="color:#66d9ef">for</span> x in servers<span style="color:#f92672">]</span>
|
||||
</span></span><span style="display:flex;"><span>module <span style="color:#e6db74">'platform'</span> has no attribute <span style="color:#e6db74">'linux_distribution'</span>
|
||||
</span></span></code></pre></div><p>This is a breaking change in Python3.8.</p>
|
||||
<pre><code class="language-shell">$ sudo /opt/appgate/linux/set_dns
|
||||
/opt/appgate/linux/set_dns:88: SyntaxWarning: "is" with a literal. Did you mean "=="?
|
||||
servers = [( socket.AF_INET if x.version is 4 else socket.AF_INET6, map(int, x.packed)) for x in servers]
|
||||
Traceback (most recent call last):
|
||||
File "/opt/appgate/linux/set_dns", line 30, in <module>
|
||||
import dbus
|
||||
ModuleNotFoundError: No module named 'dbus'
|
||||
</code></pre>
|
||||
<p>Ok, let’s install it:</p>
|
||||
<pre><code class="language-shell">$ sudo python3.8 -m pip install dbus-python
|
||||
</code></pre>
|
||||
<p>Will it work now? Not yet. There’s another issue:</p>
|
||||
<pre><code class="language-shell">$ sudo /opt/appgate/linux/set_dns
|
||||
/opt/appgate/linux/set_dns:88: SyntaxWarning: "is" with a literal. Did you mean "=="?
|
||||
servers = [( socket.AF_INET if x.version is 4 else socket.AF_INET6, map(int, x.packed)) for x in servers]
|
||||
module 'platform' has no attribute 'linux_distribution'
|
||||
</code></pre>
|
||||
<p>This is a breaking change in Python3.8.</p>
|
||||
<p>So what is calling <code>platform.linux_distribution</code>?</p>
|
||||
<p>Let’s search for it:</p>
|
||||
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-shell" data-lang="shell"><span style="display:flex;"><span>$ sudo grep -r <span style="color:#e6db74">'linux_distribution'</span> /opt/appgate/linux/
|
||||
</span></span><span style="display:flex;"><span>/opt/appgate/linux/nm.py: <span style="color:#66d9ef">if</span> platform.linux_distribution<span style="color:#f92672">()[</span>0<span style="color:#f92672">]</span> !<span style="color:#f92672">=</span> <span style="color:#e6db74">'Fedora'</span>:
|
||||
</span></span></code></pre></div><p>Aha! So this is in the local AppGate source code. This should be an easy fix. Let’s just replace this line with:</p>
|
||||
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-python" data-lang="python"><span style="display:flex;"><span><span style="color:#66d9ef">if</span> <span style="color:#66d9ef">True</span>: <span style="color:#75715e"># Since we are not using Fedora :)</span>
|
||||
</span></span></code></pre></div><h1 id="wrapping-up">Wrapping up</h1>
|
||||
<pre><code class="language-shell">$ sudo grep -r 'linux_distribution' /opt/appgate/linux/
|
||||
/opt/appgate/linux/nm.py: if platform.linux_distribution()[0] != 'Fedora':
|
||||
</code></pre>
|
||||
<p>Aha! So this is in the local AppGate source code. This should be an easy fix. Let’s just replace this line with:</p>
|
||||
<pre><code class="language-python">if True: # Since we are not using Fedora :)
|
||||
</code></pre>
|
||||
<h1 id="wrapping-up">Wrapping up</h1>
|
||||
<p>It turns out there are <a href="https://docs.python.org/3.7/library/platform.html#platform.linux_distribution">breaking changes</a> in Python3.8.</p>
|
||||
<p>The docs say <code>Deprecated since version 3.5, will be removed in version 3.8: See alternative like the distro package.</code></p>
|
||||
<p>I suppose this highlights one of the caveats of relying upon the system’s python, rather than having an isolated, dedicated environment for all dependencies.</p></section>
|
||||
|
Reference in New Issue
Block a user