-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
bbea718
commit 7bbd92e
Showing
5 changed files
with
152 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,130 @@ | ||
#!/usr/bin/env bash | ||
set -x | ||
#-------------------------------------------------------# | ||
#Sanity Checks | ||
if [ "${BUILD}" != "YES" ] || \ | ||
[ -z "${BINDIR}" ] || \ | ||
[ -z "${GIT_TERMINAL_PROMPT}" ] || \ | ||
[ -z "${GIT_ASKPASS}" ] || \ | ||
[ -z "${GITHUB_TOKEN}" ] || \ | ||
[ -z "${SYSTMP}" ] || \ | ||
[ -z "${TMPDIRS}" ]; then | ||
#exit | ||
echo -e "\n[+]Skipping Builds...\n" | ||
exit 1 | ||
fi | ||
#-------------------------------------------------------# | ||
|
||
#-------------------------------------------------------# | ||
##Main | ||
export SKIP_BUILD="NO" | ||
if [ "$SKIP_BUILD" == "NO" ]; then | ||
#mullvad-browser : Unarchiver | ||
export BIN="mullvad-browser" | ||
export SOURCE_URL="https://github.com/mullvad/mullvad-browser" | ||
echo -e "\n\n [+] (Building | Fetching) $BIN :: $SOURCE_URL\n" | ||
#-------------------------------------------------------# | ||
#https://github.com/mullvad/mullvad-browser/issues/11 | ||
###Fetch (NO --exclude-pre-releases) | ||
# pushd "$($TMPDIRS)" >/dev/null 2>&1 | ||
# RELEASE_TAG="$(gh release list --repo "${SOURCE_URL}" --order "desc" --exclude-drafts --json "tagName" | jq -r '.[0].tagName | gsub("\\s+"; "")' | tr -d '[:space:]')" && export RELEASE_TAG="${RELEASE_TAG}" | ||
# gh release view "${RELEASE_TAG}" --repo "${SOURCE_URL}" --json "assets" \ | ||
# --jq '.assets[].name' | grep -P 'linux.*aarch.*64.*\.tar\.xz$' | xargs -I "{}" \ | ||
# gh release download --repo "${SOURCE_URL}" "${RELEASE_TAG}" --clobber --pattern "{}" \ | ||
# --output "${BINDIR}/mullvad-browser.tar.xz" | ||
##Meta | ||
# if [[ -f "${BINDIR}/mullvad-browser.tar.xz" ]] && [[ $(stat -c%s "${BINDIR}/mullvad-browser.tar.xz") -gt 1024 ]]; then | ||
# PKG_VERSION="$(echo ${RELEASE_TAG})" && export PKG_VERSION="${PKG_VERSION}" | ||
# echo "${PKG_VERSION}" > "${BINDIR}/mullvad-browser.tar.xz.version" | ||
# fi | ||
#-------------------------------------------------------# | ||
##Create AppImage | ||
pushd "$($TMPDIRS)" >/dev/null 2>&1 | ||
nix bundle --bundler "github:ralismark/nix-appimage" "nixpkgs#mullvad-browser" --log-format bar-with-logs | ||
#Copy | ||
sudo rsync -av --copy-links "./mullvad-browser.AppImage" "./mullvad-browser.AppImage.tmp" | ||
sudo chown -R "$(whoami):$(whoami)" "./mullvad-browser.AppImage.tmp" && chmod -R 755 "./mullvad-browser.AppImage.tmp" | ||
du -sh "./mullvad-browser.AppImage.tmp" && file "./mullvad-browser.AppImage.tmp" | ||
##Extract | ||
APPIMAGE="$(realpath .)/mullvad-browser.AppImage.tmp" && export APPIMAGE="${APPIMAGE}" | ||
"${APPIMAGE}" --appimage-extract >/dev/null && rm -f "${APPIMAGE}" | ||
OWD="$(realpath .)" && export OWD="${OWD}" | ||
APPIMAGE_EXTRACT="$(realpath "./squashfs-root")" && export APPIMAGE_EXTRACT="${APPIMAGE_EXTRACT}" | ||
##Patch | ||
if [ -d "${APPIMAGE_EXTRACT}" ] && [ "$(find "${APPIMAGE_EXTRACT}" -mindepth 1 -print -quit 2>/dev/null)" ]; then | ||
#Media | ||
cd "${APPIMAGE_EXTRACT}" | ||
mkdir -p "./usr/share/applications" && mkdir -p "./usr/share/metainfo" | ||
SHARE_DIR="$(find "${APPIMAGE_EXTRACT}" -path '*share/*mullvad-browser*' | awk '{ print length, $0 }' | sort -n | cut -d" " -f2- | head -n 1 | awk -F'/share/' '{print $1}')/share" && export SHARE_DIR="${SHARE_DIR}" | ||
#usr/{applications,bash-completion,icons,metainfo,mullvad-browser,zsh} | ||
rsync -av --copy-links \ | ||
--include="*/" \ | ||
--include="*.desktop" \ | ||
--include="*.png" \ | ||
--include="*.svg" \ | ||
--include="*.xml" \ | ||
--exclude="*" \ | ||
"${SHARE_DIR}/" "./usr/share/" && ls "./usr/share/" | ||
#Icon | ||
find "${APPIMAGE_EXTRACT}" \( -path '*128x128/apps/*.png' -o -path '*256x256/apps/*.png' \) | awk '{ print length, $0 }' | sort -n | cut -d" " -f2- | head -n 1 | xargs -I {} convert {} -resize "128x128" "./mullvad-browser.png" | ||
find "${APPIMAGE_EXTRACT}" -maxdepth 1 -type f -name '*.png' -exec sh -c 'convert "$0" -resize "128x128" "${0%.svg}.png"' {} \; 2>/dev/null | ||
cp "./mullvad-browser.png" "./.DirIcon" | ||
##Desktop | ||
find "${APPIMAGE_EXTRACT}" -path '*mullvad-browser*.desktop' | awk '{ print length, $0 }' | sort -n | cut -d" " -f2- | head -n 1 | xargs -I {} sh -c 'cp {} "./mullvad-browser.desktop"' | ||
sed 's/Icon=[^ ]*/Icon=mullvad-browser/' -i "./mullvad-browser.desktop" 2>/dev/null | ||
##Perms | ||
find "${APPIMAGE_EXTRACT}" -maxdepth 1 -type f -exec chmod "u=rx,go=rx" {} + | ||
##Purge Bloatware | ||
echo -e "\n[+] Purging Bloatware...\n" | ||
O_SIZE="$(du -sh "${APPIMAGE_EXTRACT}" 2>/dev/null | awk '{print $1}' 2>/dev/null)" && export "O_SIZE=${O_SIZE}" | ||
#Headers | ||
find "${APPIMAGE_EXTRACT}" -type d -path "*/include*" -print -exec rm -rf {} 2>/dev/null \; 2>/dev/null | ||
#docs & manpages | ||
find "${APPIMAGE_EXTRACT}" -type d -path "*doc/share*" ! -name "*mullvad-browser*" -print -exec rm -rf {} 2>/dev/null \; 2>/dev/null | ||
find "${APPIMAGE_EXTRACT}" -type d -path "*/share/docs*" ! -name "*mullvad-browser*" -print -exec rm -rf {} 2>/dev/null \; 2>/dev/null | ||
find "${APPIMAGE_EXTRACT}" -type d -path "*/share/man*" ! -name "*mullvad-browser*" -print -exec rm -rf {} 2>/dev/null \; 2>/dev/null | ||
#static libs | ||
find "${APPIMAGE_EXTRACT}" -type f -name "*.a" -print -exec rm -f {} 2>/dev/null \; 2>/dev/null | ||
#systemd (need .so) | ||
find "${APPIMAGE_EXTRACT}" -type d -name "*systemd*" -exec find {} -type f ! -name "*.so*" -delete \; | ||
P_SIZE="$(du -sh "${APPIMAGE_EXTRACT}" 2>/dev/null | awk '{print $1}' 2>/dev/null)" && export "P_SIZE=${P_SIZE}" | ||
echo -e "\n[+] Shaved off ${O_SIZE} --> ${P_SIZE}\n" | ||
#(Re)Pack | ||
cd "${OWD}" | ||
curl -qfsSL "https://github.com/AppImage/appimagetool/releases/download/continuous/appimagetool-$(uname -m).AppImage" -o "./appimagetool" && chmod +x "./appimagetool" | ||
ARCH="$(uname -m)" "./appimagetool" --comp "zstd" \ | ||
--mksquashfs-opt -root-owned \ | ||
--mksquashfs-opt -no-xattrs \ | ||
--mksquashfs-opt -noappend \ | ||
--mksquashfs-opt -b --mksquashfs-opt "1M" \ | ||
--mksquashfs-opt -mkfs-time --mksquashfs-opt "0" \ | ||
--mksquashfs-opt -Xcompression-level --mksquashfs-opt "22" \ | ||
"${APPIMAGE_EXTRACT}" "${BINDIR}/mullvad-browser.AppImage" | ||
#clean | ||
unset APPIMAGE APPIMAGE_EXTRACT OFFSET OWD SHARE_DIR ; popd >/dev/null 2>&1 | ||
fi | ||
#-------------------------------------------------------# | ||
#Meta | ||
if [[ -f "${BINDIR}/mullvad-browser.AppImage" ]] && [[ $(stat -c%s "${BINDIR}/mullvad-browser.AppImage") -gt 1024 ]]; then | ||
PKG_VERSION="$(nix derivation show "nixpkgs#mullvad-browser" 2>&1 | grep '"version"' | awk -F': ' '{print $2}' | tr -d '"')" && export PKG_VERSION="${PKG_VERSION}" | ||
echo "${PKG_VERSION}" > "${BINDIR}/mullvad-browser.AppImage.version" | ||
fi | ||
#End | ||
#realpath "${BINDIR}/mullvad-browser.tar.xz" | xargs -I {} sh -c 'file {}; b3sum {}; sha256sum {}; du -sh {}' | ||
realpath "${BINDIR}/mullvad-browser.AppImage" | xargs -I {} sh -c 'file {}; b3sum {}; sha256sum {}; du -sh {}' | ||
LOG_PATH="${BINDIR}/mullvad-browser.log" && export LOG_PATH="${LOG_PATH}" | ||
popd >/dev/null 2>&1 | ||
fi | ||
#-------------------------------------------------------# | ||
|
||
#-------------------------------------------------------# | ||
##Cleanup | ||
unset SKIP_BUILD ; export BUILT="YES" | ||
#In case of zig polluted env | ||
unset AR CC CFLAGS CXX CPPFLAGS CXXFLAGS DLLTOOL HOST_CC HOST_CXX LDFLAGS LIBS OBJCOPY RANLIB | ||
#In case of go polluted env | ||
unset GOARCH GOOS CGO_ENABLED CGO_CFLAGS | ||
#PKG Config | ||
unset PKG_CONFIG_PATH PKG_CONFIG_LIBDIR PKG_CONFIG_SYSROOT_DIR PKG_CONFIG_SYSTEM_INCLUDE_PATH PKG_CONFIG_SYSTEM_LIBRARY_PATH | ||
set +x | ||
#-------------------------------------------------------# |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
name: "mullvad-browser" | ||
bin_name: "mullvad-browser" | ||
bins: | ||
- "mullvad-browser.AppImage" | ||
category: | ||
- "anonymity" | ||
- "browser" | ||
- "privacy" | ||
- "tor" | ||
description: "Privacy-focused browser for Linux, macOS and Windows" | ||
note: "This PKG has Multiple Formats (CI_VERIFIED: https://gitlab.torproject.org/tpo/applications/mullvad-browser/-/pipelines)" | ||
web_url: "https://mullvad.net/en/browser" | ||
path: "/" | ||
src_url: "https://gitlab.torproject.org/tpo/applications/mullvad-browser/" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters