build_chrome_appimage.sh 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. #!/bin/bash
  2. # Exit on any error
  3. set -e
  4. # Configuration
  5. IMAGE_NAME="chrome-builder"
  6. OUTPUT_DIR="$(pwd)/out"
  7. mkdir -p "$OUTPUT_DIR"
  8. echo "Building the 'Nicole Edition' Chrome AppImage..."
  9. # 1. Create the Dockerfile
  10. cat <<EOF > Dockerfile.chrome
  11. FROM ubuntu:22.04
  12. ENV DEBIAN_FRONTEND=noninteractive
  13. # Install essential build tools and dependencies
  14. RUN apt-get update && apt-get install -y \\
  15. wget curl file binutils desktop-file-utils \\
  16. libglib2.0-bin fakeroot libnss3 libatk1.0-0 \\
  17. libatk-bridge2.0-0 libcups2 libdrm2 libgbm1 \\
  18. libasound2 libpangocairo-1.0-0 libxkbcommon0 \\
  19. libgtk-3-0 squashfs-tools zsync ca-certificates
  20. # Grab the modern appimagetool
  21. RUN curl -L https://github.com/AppImage/AppImageKit/releases/download/continuous/appimagetool-x86_64.AppImage -o /usr/local/bin/appimagetool \\
  22. && chmod +x /usr/local/bin/appimagetool
  23. WORKDIR /build
  24. # The Build Logic:
  25. # 1. Download the latest deb
  26. # 2. Extract version and contents
  27. # 3. Relocate binary from /opt to /usr/bin
  28. # 4. Grab the 256px logo from the new Google path
  29. # 5. Create AppRun with the banner-killer flag (--test-type)
  30. CMD wget -q https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb -O chrome.deb && \\
  31. CHROME_VERSION=\$(dpkg-deb -f chrome.deb Version | cut -d- -f1) && \\
  32. echo "Fucking version found: \$CHROME_VERSION" && \\
  33. mkdir -p Chrome.AppDir/usr/bin && \\
  34. dpkg-deb -x chrome.deb Chrome.AppDir/ && \\
  35. cp -r Chrome.AppDir/opt/google/chrome/* Chrome.AppDir/usr/bin/ && \\
  36. # Fix the Icon: New location is inside the opt/google/chrome folder
  37. cp Chrome.AppDir/opt/google/chrome/product_logo_256.png Chrome.AppDir/google-chrome.png || touch Chrome.AppDir/google-chrome.png && \\
  38. # Create the AppRun with banner-suppression
  39. printf '#!/bin/sh\nHERE=\$(dirname \$(readlink -f "\${0}"))\nexport LD_LIBRARY_PATH="\${HERE}"/usr/lib:\$LD_LIBRARY_PATH\nexec "\${HERE}"/usr/bin/google-chrome --no-sandbox --test-type --no-first-run --password-store=basic "\$@"' > Chrome.AppDir/AppRun && \\
  40. chmod +x Chrome.AppDir/AppRun && \\
  41. # Create the Desktop entry
  42. printf "[Desktop Entry]\nName=Google Chrome\nExec=google-chrome\nIcon=google-chrome\nType=Application\nCategories=Network;WebBrowser;" > Chrome.AppDir/google-chrome.desktop && \\
  43. # Squash the bastard
  44. /usr/local/bin/appimagetool --appimage-extract-and-run Chrome.AppDir "/out/Google_Chrome-\${CHROME_VERSION}-x86_64.AppImage"
  45. EOF
  46. # 2. Build the Docker Image
  47. docker build -t "$IMAGE_NAME" -f Dockerfile.chrome .
  48. # 3. Run and map output
  49. # Mapping current out dir to container /out
  50. docker run --rm -v "$OUTPUT_DIR:/out" "$IMAGE_NAME"
  51. # 4. Cleanup
  52. rm Dockerfile.chrome
  53. echo "------------------------------------------------"
  54. echo "Build complete! Check the /out folder."
  55. echo "Remember to: chmod +x $OUTPUT_DIR/Google_Chrome-*.AppImage"
  56. ls -lh "$OUTPUT_DIR"