Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[+] Provide an example build script for an example program for Toolpacks #5

Closed
Azathothas opened this issue Sep 7, 2024 · 1 comment

Comments

@Azathothas
Copy link

Azathothas commented Sep 7, 2024

Hello, you have often shoved pelf right at me, but sadly I never took pelf seriously, for which I am genuinely sorry.
But after the chain of events of, as documented well in: Azathothas/Toolpacks#28 , I would like to give pelfs a chance.

So could you submit (in the replies) an example build script which would pack, let's say mpv using pelf to an AppBundle.
I know you are a massive alpine fan, so please use the templates like this:
Another example: https://github.com/Azathothas/Toolpacks/blob/main/.github/scripts/x86_64_Linux/bins/xdotool.sh (this uses ppkg in alpine)

Edit: Sourced from TG Texts

#!/usr/bin/env bash

#-------------------------------------------------------#
#Sanity Checks
if [ "$BUILD" != "YES" ] || \
   [ -z "$BINDIR" ] || \
   [ -z "$EGET_EXCLUDE" ] || \
   [ -z "$EGET_TIMEOUT" ] || \
   [ -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" #YES, in case of deleted repos, broken builds etc
if [ "$SKIP_BUILD" == "NO" ]; then
    #mpv : 🎥 Command line video player
     export BIN="mpv"
     export SOURCE_URL="https://github.com/mpv-player/mpv"
     echo -e "\n\n [+] (Building | Fetching) $BIN :: $SOURCE_URL\n"
      ##Build:
       pushd "$($TMPDIRS)" >/dev/null 2>&1
       docker stop "alpine-builder" 2>/dev/null ; docker rm "alpine-builder" 2>/dev/null
       docker run --privileged --net="host" --name "alpine-builder" "azathothas/alpine-builder:latest" \
        bash -c '
        #Setup ENV
         mkdir -p "/build-bins" && pushd "$(mktemp -d)" >/dev/null 2>&1
        #Install Deps
         curl -qfsSL "https://raw.githubusercontent.com/xplshn/pelf/master/pelf" -o "/usr/local/bin/pelf" && chmod +x "/usr/local/bin/pelf"
         apk update --no-interactive 2>/dev/null
         apk add "mpv" --latest --upgrade --no-interactive 2>/dev/null
        #Get Media
         #Icon
          apk info -L "mpv" | grep "share/icons.*\.png" | sort -n | head -n 1 | xargs -I {} realpath /{} | xargs -I {} sh -c "cp {} ./mpv.png"
         #Desktop
          apk info -L "mpv" | grep "share/.*\.desktop" | sort -n | head -n 1 | xargs -I {} realpath /{} | xargs -I {} sh -c "cp {} ./mpv.desktop"
          sed -e "s/^TryExec=.*/TryExec=mpv.AppBundle/" -e "s/^Exec=[^ ]*/Exec=mpv.AppBundle/" -i "./mpv.desktop"
        #Generate AppBundle
         pelf --main-bin "$(which mpv)" --output-to "/build-bins/mpv.AppBundle" \
         --add-metadata "$(find . -name "*.png" -exec realpath {} \; | head -n 1)" \
         --add-metadata "$(find . -name "*.desktop" -exec realpath {} \; | head -n 1)" \
         --add-ld-and-libc "$(find /lib -name "ld-musl*.so*" -exec realpath {} \; | head -n 1)" \
         "$(find /lib -name "libc*$(uname -m)*.so*" -exec realpath {} \; | head -n 1)"
         popd >/dev/null 2>&1
        '
      #Copy & Meta
       docker cp "alpine-builder:/build-bins/." "$(pwd)/"
       find "." -maxdepth 1 -type f -exec file -i "{}" \; | cut -d":" -f1 | xargs realpath
       #Meta
       find "." -maxdepth 1 -type f -exec sh -c 'file "{}"; du -sh "{}"' \;
       sudo rsync -av --copy-links --exclude="*/" "./." "$BINDIR"
      #Delete Containers
       docker stop "alpine-builder" 2>/dev/null ; docker rm "alpine-builder"
       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
#-------------------------------------------------------#
@xplshn
Copy link
Owner

xplshn commented Sep 7, 2024

Do I close this issue?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants