summaryrefslogtreecommitdiff
path: root/notepadpp/build-orig-tarball.sh
diff options
context:
space:
mode:
Diffstat (limited to 'notepadpp/build-orig-tarball.sh')
-rwxr-xr-xnotepadpp/build-orig-tarball.sh84
1 files changed, 84 insertions, 0 deletions
diff --git a/notepadpp/build-orig-tarball.sh b/notepadpp/build-orig-tarball.sh
new file mode 100755
index 0000000..80b2260
--- /dev/null
+++ b/notepadpp/build-orig-tarball.sh
@@ -0,0 +1,84 @@
+#!/bin/sh
+# Package: notepadpp
+# Startdate: 2019-12-28 11:01
+# Dependencies:
+# sudo apt-get install jq wget curl p7zip
+
+currdir="${PWD}"
+tmpfile1="$( mktemp )"
+
+# FUNCTIONS
+ferror() {
+ printf "%s\n" "$@" 1>&2
+}
+
+get() {
+ # get "https://example.com/example.zip"
+ # get "https://example.com/example.zip" "outputname.zip"
+ ___get_url="${1}"
+ ___get_outfile="${2}"
+ ___wget_options=""
+ test -n "${___get_outfile}" && ___wget_options="-o ${___get_outfile}"
+
+ test -n "${DEBUG}" && ferror "wget --quiet --content-disposition \"${___get_url}\" ${___wget_options}"
+ test -z "${DRYRUN}" && wget --quiet --content-disposition "${___get_url}" ${___wget_options}
+}
+
+to_filename() {
+ # call: to_filename "https://example.com/filename.ext"
+ # returns: "filename.ext"
+ printf "${1##*/}"
+}
+
+### Flow
+
+# check dependencies
+which jq 1>/dev/null 2>&1 || { echo "Please install jq! Aborted." ; exit 1; }
+
+## 1. learn latest version
+latest_version="$( curl -s "https://notepad-plus-plus.org/downloads/" | grep -oiE "Current Version [0-9\.]+" | grep -oE "[0-9\.a-zA-Z]+$" )"
+ferror "USING VERSION ${latest_version}"
+
+## 2. dl npp main version, 32 and 64
+get "https://github.com/notepad-plus-plus/notepad-plus-plus/releases/download/v${latest_version}/npp.${latest_version}.bin.7z"
+get "https://github.com/notepad-plus-plus/notepad-plus-plus/releases/download/v${latest_version}/npp.${latest_version}.bin.x64.7z"
+
+## 3. dl 32 plugins
+# fetch master list of plugins
+curl -L -s https://github.com/notepad-plus-plus/nppPluginList/raw/master/src/pl.x86.json > "${tmpfile1}"
+
+# Compare plugin
+url_current_plugin_32_Compare="$( cat "${tmpfile1}" | jq '.["npp-plugins"][] | select(."display-name" == "Compare") | .repository' -r )"
+file_current_plugin_32_Compare="$( to_filename "${url_current_plugin_32_Compare}" )"
+get "${url_current_plugin_32_Compare}"
+# TextFX plugin
+url_current_plugin_32_TextFX="$( cat "${tmpfile1}" | jq '.["npp-plugins"][] | select(."display-name" == "TextFX Characters") | .repository' -r )"
+file_current_plugin_32_TextFX="$( to_filename "${url_current_plugin_32_TextFX}" )"
+get "${url_current_plugin_32_TextFX}"
+
+## 4. dl 64 plugins
+curl -L -s https://github.com/notepad-plus-plus/nppPluginList/raw/master/src/pl.x64.json > "${tmpfile1}"
+
+# Compare plugin
+url_current_plugin_64_Compare="$( cat "${tmpfile1}" | jq '.["npp-plugins"][] | select(."display-name" == "Compare") | .repository' -r )"
+file_current_plugin_64_Compare="$( to_filename "${url_current_plugin_64_Compare}" )"
+get "${url_current_plugin_64_Compare}"
+
+## 5. assemble orig tarball
+test -n "${DEBUG}" && ferror "mkdir -p \"notepadpp-${latest_version}\" ; cd \"notepadpp-${latest_version}\""
+test -z "${DRYRUN}" && { mkdir -p "notepadpp-${latest_version}" ; cd "notepadpp-${latest_version}" ; }
+
+test -n "${DEBUG}" && ferror "mkdir -p notepadpp-bin32 notepadpp-bin64"
+test -z "${DRYRUN}" && { mkdir -p notepadpp-bin32 notepadpp-bin64 ; }
+
+test -n "${DEBUG}" && ferror "cd notepadpp-bin32 ; 7za -bd -aoa x ../../\"npp.${latest_version}.bin.7z\" ; cd plugins ; 7za -bd -aoa x ../../../\"${file_current_plugin_32_Compare}\" ; 7za -bd -aoa x ../../../\"${file_current_plugin_32_TextFX}\" ; cd ../.. "
+test -z "${DRYRUN}" && { cd notepadpp-bin32 ; 7za -bd -aoa x ../../"npp.${latest_version}.bin.7z" ; cd plugins ; 7za -bd -aoa x ../../../"${file_current_plugin_32_Compare}" ; 7za -bd -aoa x ../../../"${file_current_plugin_32_TextFX}" ; cd ../..; }
+test -n "${DEBUG}" && ferror "cd notepadpp-bin64 ; 7za -bd -aoa x ../../\"npp.${latest_version}.bin.x64.7z\" ; cd plugins ; 7za -bd -aoa x ../../../\"${file_current_plugin_64_Compare}\" ; cd ../.. "
+test -z "${DRYRUN}" && { cd notepadpp-bin64 ; 7za -bd -aoa x ../../"npp.${latest_version}.bin.x64.7z" ; cd plugins ; 7za -bd -aoa x ../../../"${file_current_plugin_64_Compare}" ; cd ../.. ; }
+test -n "${DEBUG}" && ferror "cd .."
+test -z "${DRYRUN}" && cd ..
+test -n "${DEBUG}" && ferror "tar -zcf \"notepadpp_${latest_version}.orig.tar.gz\" \"notepadpp-${latest_version}\""
+test -z "${DRYRUN}" && tar -zcf "notepadpp_${latest_version}.orig.tar.gz" "notepadpp-${latest_version}"
+
+# CLEAN UP
+rm -rf "${tmpfile1}" "notepadpp-${latest_version}/" "${file_current_plugin_32_Compare}" "${file_current_plugin_32_TextFX}" "${file_current_plugin_64_Compare}" "npp.${latest_version}.bin.7z" "npp.${latest_version}.bin.x64.7z"
bgstack15