Skip to content

Instantly share code, notes, and snippets.

@prurigro
Created October 12, 2023 15:49
Show Gist options
  • Save prurigro/7daf3f86a19638fdd1c5f032d0eb0d61 to your computer and use it in GitHub Desktop.
Save prurigro/7daf3f86a19638fdd1c5f032d0eb0d61 to your computer and use it in GitHub Desktop.
pkgname=ipscan
pkgver=3.9.1
pkgrel=3
pkgdesc='Fast and friendly network scanner'
arch=('i686' 'x86_64')
license=('GPL2')
url='https://angryip.org'
depends=('java-runtime')
makedepends=('jre17-openjdk' 'jdk17-openjdk' 'git')
source=(
"git+https://github.com/angryip/${pkgname}.git#tag=${pkgver}"
'build.gradle.patch'
'google-analytics-removal.patch'
"${pkgname}.sh"
"${pkgname}.desktop"
)
sha512sums=(
'SKIP'
'0858ea8747b9339da3d22d3a8176da25bffce1eac54d6b3ee5d6ced549c76db48f9479594ee57130b14aef2cc213abf06c286e389c058ef73ef1ccd24d08fda5'
'c494b4a29547e122805053645df948f9ad80d3ecfe7638eeb45f38dec983cb5221888713649311ea55a9c3ebcf87e72903990ff9b2796f07721f444bfdce9afa'
'9f0227b7b607bda5773a157c566bed3373654b89e665a69ac48bec48556277fd64d65d56af2ec421c59d983fa93903f2c4b191835b58731664389d254a004c59'
'0e3e47dc0bc97695221977a077548e8ada397d264581411d9018e562b782113a1dbde9d0b017ae61418d61e0e6e9182feca04e88c335f942926164b0acbc09f8'
)
prepare() {
cd "${srcdir}/${pkgname}"
patch < ../build.gradle.patch
git apply ../google-analytics-removal.patch
sed -i "s|^version = .*|version = '${pkgver}'|" build.gradle
sed -i -E "s|^( *'Version':) version,|\1 '${pkgver}',|g" build.gradle
}
build() {
cd "${srcdir}/${pkgname}"
unset _JAVA_OPTIONS
export PATH=/usr/lib/jvm/default/bin:$PATH
export PATH=/usr/lib/jvm/java-17-openjdk/bin:$PATH
GRADLE_USER_HOME="${srcdir}" ./gradlew current
}
package() {
cd "${srcdir}/${pkgname}"
install -Dm755 "../${pkgname}.sh" "${pkgdir}/usr/bin/${pkgname}"
install -Dm644 "../${pkgname}.desktop" "${pkgdir}/usr/share/applications/${pkgname}.desktop"
install -Dm644 resources/images/icon256.png "${pkgdir}/usr/share/pixmaps/${pkgname}.png"
install -Dm644 build/libs/ipscan-*-${pkgver}.jar "${pkgdir}/opt/${pkgname}/${pkgname}.jar"
}
@prurigro
Copy link
Author

build.gradle.patch:

diff --git a/build.gradle b/build.gradle
index 61753185..95ca0696 100644
--- a/build.gradle
+++ b/build.gradle
@@ -253,8 +253,6 @@ def macLauncher(def platform) {
 }
 
 packageTask('linux64') {
-    deb('linux64', 'amd64')
-    rpm('linux64', 'x86_64')
 }
 
 packageTask('any') {

google-analytics-removal.patch:

diff --git a/src/net/azib/ipscan/Main.java b/src/net/azib/ipscan/Main.java
index 3e06a31e..8d1a82ba 100644
--- a/src/net/azib/ipscan/Main.java
+++ b/src/net/azib/ipscan/Main.java
@@ -10,7 +10,6 @@ import net.azib.ipscan.di.Injector;
 import net.azib.ipscan.gui.GUI;
 import net.azib.ipscan.gui.InfoDialog;
 import net.azib.ipscan.gui.MacApplicationMenu;
-import net.azib.ipscan.util.GoogleAnalytics;
 
 import java.io.File;
 import java.nio.file.Files;
@@ -67,7 +66,6 @@ public class Main {
 		}
 		catch (UnsatisfiedLinkError e) {
 			e.printStackTrace();
-			new GoogleAnalytics().report(e);
 			showFallbackError("Failed to load native code for Java " +
 					System.getProperty("java.runtime.version") + " on " + System.getProperty("os.arch") +
 					"\nProbably you are using a binary built for wrong OS or CPU.\n\n" + e.getMessage());
@@ -80,7 +78,6 @@ public class Main {
 		}
 		catch (NoClassDefFoundError e) {
 			e.printStackTrace();
-			new GoogleAnalytics().report(e);
 			showFallbackError("SWT GUI toolkit not available: " + e + "\n\nIf you are using platform-neutral build, make sure you provide SWT built for your platform manually (e.g. install libswt packages), or please use a platform specific binary.");
 		}
 		catch (Throwable e) {
@@ -90,7 +87,6 @@ public class Main {
 
 	private static void handleFatalError(GUI gui, Throwable e) {
 		e.printStackTrace();
-		new GoogleAnalytics().report(e);
 		if (gui != null)
 			gui.showMessage(0, "Fatal Error", e + "\nPlease submit a bug report mentioning your OS and what exactly were you doing.");
 		else
diff --git a/src/net/azib/ipscan/gui/GUI.java b/src/net/azib/ipscan/gui/GUI.java
index c2f46fda..4ad7ed02 100644
--- a/src/net/azib/ipscan/gui/GUI.java
+++ b/src/net/azib/ipscan/gui/GUI.java
@@ -4,7 +4,6 @@ import net.azib.ipscan.config.LoggerFactory;
 import net.azib.ipscan.config.Version;
 import net.azib.ipscan.core.UserErrorException;
 import net.azib.ipscan.di.Injector;
-import net.azib.ipscan.util.GoogleAnalytics;
 import org.eclipse.swt.SWT;
 import org.eclipse.swt.SWTError;
 import org.eclipse.swt.SWTException;
@@ -33,11 +32,9 @@ public class GUI implements AutoCloseable {
 		catch (SWTError e) {
 			if (e.getMessage().contains("gtk_init_check")) {
 				System.err.println(e.toString() + ": probably you are running as `root` and/or don't have access to the X Server. Please run as normal user or with sudo.");
-				new GoogleAnalytics().report(e);
 			}
 			else if (e.getMessage().contains("Invalid thread access")) {
 				System.err.println(e.toString() + ": you need to start Java with -XstartOnFirstThread on a Mac");
-				new GoogleAnalytics().report(e);
 			}
 			else throw e;
 		}
@@ -62,9 +59,6 @@ public class GUI implements AutoCloseable {
 				String localizedMessage = getLocalizedMessage(e);
 				showMessage(e instanceof UserErrorException ? SWT.ICON_WARNING : SWT.ICON_ERROR,
 					getLabel(e instanceof UserErrorException ? "text.userError" : "text.error"), localizedMessage);
-
-				if (!(e instanceof UserErrorException) || e.getCause() != null)
-					new GoogleAnalytics().report(e);
 			}
 		}
 	}
diff --git a/src/net/azib/ipscan/gui/Startup.java b/src/net/azib/ipscan/gui/Startup.java
index ad705d3d..5689a892 100644
--- a/src/net/azib/ipscan/gui/Startup.java
+++ b/src/net/azib/ipscan/gui/Startup.java
@@ -5,7 +5,6 @@ import net.azib.ipscan.config.Labels;
 import net.azib.ipscan.config.Platform;
 import net.azib.ipscan.config.Version;
 import net.azib.ipscan.gui.actions.HelpMenuActions.CheckVersion;
-import net.azib.ipscan.util.GoogleAnalytics;
 import org.eclipse.swt.widgets.Display;
 import org.eclipse.swt.widgets.Shell;
 
@@ -22,7 +21,6 @@ public class Startup {
 
 	public void onStart() {
 		if (guiConfig.isFirstRun) {
-			new GoogleAnalytics().asyncReport("First run");
 			Display.getCurrent().asyncExec(() -> {
 				GettingStartedDialog dialog = new GettingStartedDialog();
 				if (Platform.CRIPPLED_WINDOWS)
@@ -35,11 +33,9 @@ public class Startup {
 			});
 		}
 		else if (!Version.getVersion().equals(guiConfig.lastRunVersion)) {
-			new GoogleAnalytics().asyncReport("Update " + guiConfig.lastRunVersion + " to " + Version.getVersion());
 			guiConfig.lastRunVersion = Version.getVersion();
 		}
 		else if (guiConfig.versionCheckEnabled && System.currentTimeMillis() - guiConfig.lastVersionCheck > 30L * 24 * 3600 * 1000) {
-			new GoogleAnalytics().asyncReport("Version check " + Version.getVersion());
 			checkForLatestVersion();
 		}
 	}

ipscan.desktop:

[Desktop Entry]
Type=Application
Version=1.0
Name=Angry IP Scanner
Comment=Fast and friendly network scanner
Exec=ipscan
Icon=ipscan
Terminal=false
Categories=Network;Monitor;

ipscan.sh:

#!/usr/bin/env bash

java -jar "/opt/ipscan/ipscan.jar" "$@"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment