diff --git a/packages/flameshot/nixappimage.nixpkgs.unstable.yaml b/packages/flameshot/nixappimage.nixpkgs.unstable.yaml new file mode 100644 index 00000000..376d0ca3 --- /dev/null +++ b/packages/flameshot/nixappimage.nixpkgs.unstable.yaml @@ -0,0 +1,139 @@ +#!/SBUILD ver @v1.0.0 +#SELF: https://raw.githubusercontent.com/pkgforge/soarpkgs/refs/heads/main/packages/flameshot/nixappimage.nixpkgs.unstable.yaml +_disabled: false + +pkg: "flameshot" +pkg_id: "nixpkgs.flameshot" +pkg_type: "nixappimage" +app_id: "org.flameshot.Flameshot" +category: + - "Utility" +description: "Powerful and simple to use screenshot software" +distro_pkg: + alpine: + - "flameshot" + archlinux: + aur: + - "flameshot-git" + extra: + - "flameshot" + debian: + - "flameshot" + gnuguix: + - "flameshot" + homebrew: + - "flameshot" + nixpkgs: + - "flameshot" +homepage: + - "https://flameshot.org" + - "https://github.com/flameshot-org/flameshot" +license: + - id: "GPL-3.0" + url: "https://github.com/flameshot-org/flameshot/raw/3fafcf4aa9ae3d620ff691cba3a1a2195d592914/LICENSE" +maintainer: + - "Azathothas (https://github.com/Azathothas)" +note: + - "[DO NOT RUN] (Meant for pkgforge CI Only)" + - "Built Using Nixpkgs. Check/Report @ https://github.com/NixOS/nixpkgs" + - "Packed Using NixAppImage. Check/Report @ https://github.com/pkgforge/nix-appimage" + - "Learn more @ https://docs.pkgforge.dev/formats/packages/nixappimage" + - "[PORTABLE] (Works on AnyLinux)" +provides: + - "flameshot" +repology: + - "flameshot" +src_url: + - "https://github.com/flameshot/flameshot" +tag: + - "screenshot" +x_exec: + host: + - "aarch64-Linux" + - "x86_64-Linux" + shell: "bash" + pkgver: | + nix derivation show "nixpkgs#flameshot" --impure --refresh --quiet 1>&1 2>/dev/null | sed -n '/^[[:space:]]*{/,$p' | jq -r '.. | objects | (select(has("version")).version, (select(has("env")) | select(.env.__json != null) | .env.__json | fromjson | select(has("version")).version) | select(.))' | tr -d '[:space:]' + run: | + #Build + echo -e "\n" ; nix-instantiate --eval --expr "builtins.toJSON (with import {}; ${PKG}.meta)" --quiet 2>/dev/null | jq -r fromjson 2>/dev/null ; echo -e "\n" + nix bundle --impure --bundler "github:pkgforge/nix-appimage?ref=main" "nixpkgs#flameshot" --cores "$(($(nproc)+1))" --max-jobs "$(($(nproc)+1))" --log-format bar-with-logs --out-link "${SBUILD_TMPDIR}/nixappimage" + sudo rsync -achLv --no-relative "${SBUILD_TMPDIR}/nixappimage" "${SBUILD_TMPDIR}/${PKG}.nixappimage.tmp" + sudo chown -Rv "$(whoami):$(whoami)" "${SBUILD_TMPDIR}" && chmod -Rv 755 "${SBUILD_TMPDIR}" + chmod -v +x "${SBUILD_TMPDIR}/${PKG}.nixappimage.tmp" + #Debloat & Fix things + pushd "${SBUILD_TMPDIR}" >/dev/null 2>&1 && \ + "./${PKG}.nixappimage.tmp" --appimage-extract >/dev/null && rm -rvf "./${PKG}.nixappimage.tmp" + if [ ! -d "./squashfs-root" ] || [ "$(du -s "./squashfs-root" | cut -f1)" -le 100 ]; then + echo -e "\n [X] FATAL: Building/Extraction probably Failed\n" + exit 1 + fi + #De-Nix + pushd "${SBUILD_TMPDIR}" >/dev/null 2>&1 || exit 1 + mkdir -pv "./squashfs-root/usr/share/applications" && mkdir -pv "./squashfs-root/usr/share/metainfo" + ENTRYPOINT_DIR="$(readlink -f "./squashfs-root/entrypoint" | sed -E 's|^(/nix/store/[^/]+).*|\1|' | tr -d '[:space:]')" + ENTRYPOINT_DIR="$(echo "${SBUILD_TMPDIR}/squashfs-root/${ENTRYPOINT_DIR}" | sed 's|//|/|g')" && export ENTRYPOINT_DIR="${ENTRYPOINT_DIR}" + [ -d "${ENTRYPOINT_DIR}" ] && [[ "${ENTRYPOINT_DIR}" == "/tmp/"*"/nix/store/"* ]] || exit 1 + #Copy License + [[ -s "${SBUILD_OUTDIR}/LICENSE" ]] || ( askalono --format "json" crawl --follow "${SBUILD_TMPDIR}/squashfs-root" | jq -r ".. | objects | .path? // empty" | head -n 1 | xargs -I "{}" cp -fv "{}" "${SBUILD_OUTDIR}/LICENSE" ) 2>/dev/null + #Fix Symlinks + rm -rvf "./squashfs-root/usr" 2>/dev/null + ln -sfn "$(realpath --relative-to="$(dirname "./squashfs-root/usr")" "${ENTRYPOINT_DIR}")" "./squashfs-root/usr" + find "./squashfs-root" -maxdepth 1 -type l ! -name '*entrypoint*' -exec test -f "{}" \; -exec rsync -achvL --remove-source-files "{}" "{}.tmp" \; -exec mv "{}.tmp" "{}" \; + #Icon + if [[ ! -s "${SBUILD_OUTDIR}/${PKG}.png" && ! -s "${SBUILD_OUTDIR}/${PKG}.svg" ]]; then + find -L "./squashfs-root/usr" -type f,l -regex '.*\.\(png\|svg\)' \ + -not -regex '.*\(favicon\|/\(16x16\|22x22\|24x24\|32x32\|36x36\|48x48\|64x64\|72x72\|96x96\)/\).*' \ + | awk '{print length, $0}' | sort -n | awk 'NR==1 {print $2}' | xargs -I "{}" cp -fv "{}" "./squashfs-root/${PKG}.png" + if [[ ! -f "./squashfs-root/${PKG}.png" || $(stat -c%s "./squashfs-root/${PKG}.png") -le 3 ]]; then + find -L "./squashfs-root/usr" -regex ".*\(128x128/apps\|256x256\)/.*${PKG}.*\.\(png\|svg\)" -printf "%s %p\n" -quit | sort -n | awk 'NR==1 {print $2}' | xargs -I "{}" cp -fv "{}" "./squashfs-root/${PKG}.png" + fi + cp -fv "./squashfs-root/${PKG}.png" "./squashfs-root/.DirIcon" + else + cp -fv "${SBUILD_OUTDIR}/${PKG}.png" "./squashfs-root/${PKG}.png" || cp -fv "${SBUILD_OUTDIR}/${PKG}.svg" "./squashfs-root/${PKG}.svg" + cp "./squashfs-root/${PKG}.png" "./squashfs-root/.DirIcon" || cp "./squashfs-root/${PKG}.svg" "./squashfs-root/.DirIcon" + fi + #Desktop + if [[ ! -s "${SBUILD_OUTDIR}/${PKG}.desktop" ]]; then + find -L "./squashfs-root/usr" -name "*.desktop" -printf "%s %p\n" -quit | sort -n | awk 'NR==1 {print $2}' | xargs -I "{}" sh -c 'cp -fv "{}" "./squashfs-root/${PKG}.desktop"' + else + cp -fv "${SBUILD_OUTDIR}/${PKG}.desktop" "./squashfs-root/${PKG}.desktop" + fi + sed -E 's/\s+setup\s+/ /Ig' -i "./squashfs-root/${PKG}.desktop" + sed "s/Icon=[^ ]*/Icon=${PKG}/" -i "./squashfs-root/${PKG}.desktop" + #Perms + find "./squashfs-root" -maxdepth 1 -type f -exec chmod "u=rx,go=rx" "{}" + + #Purge Bloatware + echo -e "\n[+] Purging Bloatware...\n" + O_SIZE="$(du -sh "./squashfs-root" 2>/dev/null | awk '{print $1}' 2>/dev/null)" && export "O_SIZE=${O_SIZE}" + #Locale/fonts/man + find "./squashfs-root" -type d -regex '.*share/\(locale\(s\)?\|font\(s\)?\|man\).*' -print0 | xargs -0 -I "{}" sh -c 'rm -rvf "{}" 2>/dev/null && ln -s "/usr/share/locale" "{}" 2>/dev/null' + mkdir -pv "./squashfs-root/usr/share" + for dir in font fonts locale man; do + rm -rvf "./squashfs-root/usr/share/${dir}" 2>/dev/null + ln -sfv "/usr/share/${dir}" "./squashfs-root/usr/share/${dir}" 2>/dev/null + done + #Static Files + find "./squashfs-root" -type f -regex ".*\.\(a\|cmake\|jmod\|gz\|md\|mk\|prf\|rar\|tar\|xz\|zip\)$" -print0 -exec sh -c 'rm -rvf "$1" 2>/dev/null' _ "{}" \; + find "./squashfs-root" -type f -regex '.*\(LICENSE\|LICENSE\.md\|Makefile\)' -print0 -exec sh -c 'rm -rvf "$1" 2>/dev/null' _ "{}" \; + #Static Dirs + find "./squashfs-root" -type d -regex ".*\(doc/share\|/include\|/nix-support\|share/docs\|share/locale\|share/locales\|share/man\).*" ! -name "*${PKG%%-*}*" -print -exec rm -rvf "{}" + 2>/dev/null + find "./squashfs-root" -type d -regex '.*/\(ensurepip\|example\|examples\|gcc\|i18n\|mkspecs\|__pycache__\|__pyinstaller\|test\|tests\|translation\|translations\|unit_test\|unit_tests\)' -print0 -exec sh -c 'rm -rvf "$1" 2>/dev/null' _ "{}" \; + #llvm (need .so) + find "./squashfs-root" -type d -name "*llvm*" -exec find "{}" -type f ! -name "*.so*" -delete \; + #perl (need .so) + find "./squashfs-root" -type d -name "*perl*" -exec find "{}" -type f ! -name "*.so*" -delete \; + #systemd (need .so) + find "./squashfs-root" -type d -name "*systemd*" -exec find "{}" -type f ! -name "*.so*" -delete \; + P_SIZE="$(du -sh "./squashfs-root" 2>/dev/null | awk '{print $1}' 2>/dev/null)" && export "P_SIZE=${P_SIZE}" + echo -e "\n[+] Shaved off ${O_SIZE} --> ${P_SIZE}\n" + #Repack + unset SOURCE_DATE_EPOCH + cd "${SBUILD_OUTDIR}" && 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" \ + --no-appstream "${SBUILD_TMPDIR}/squashfs-root" "${SBUILD_OUTDIR}/${PKG}" \ No newline at end of file