Skip to content

Commit

Permalink
Update AppImage build script #566
Browse files Browse the repository at this point in the history
    * We will use Python from python-appimage

Signed-off-by: Jono Yang <jyang@nexb.com>
  • Loading branch information
JonoYang committed Jan 27, 2023
1 parent 7da4250 commit a21f57e
Show file tree
Hide file tree
Showing 7 changed files with 77 additions and 23 deletions.
6 changes: 3 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,6 @@ policies.yml

# AppImage and AppImage building workspace
/etc/scripts/appimage-build/out/
/etc/scripts/appimage-build/scancodeio
/etc/scripts/appimage-build/pkg2appimage.AppImage
/etc/scripts/appimage-build/Python-Linux-support
/etc/scripts/appimage-build/scancodeio/
/etc/scripts/appimage-build/*.AppImage
/etc/scripts/appimage-build/*.AppDir
1 change: 0 additions & 1 deletion etc/scripts/appimage-build/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ RUN wget https://github.com/AppImageCommunity/pkg2appimage/releases/download/con
cd /opt && /tmp/pkg2appimage.AppImage --appimage-extract || true && \
mv squashfs-root pkg2appimage.AppDir && \
ln -s /opt/pkg2appimage.AppDir/AppRun /usr/bin/pkg2appimage && \
sed 's|AI\x02|\x00\x00\x00|g' -i /opt/pkg2appimage.AppDir/usr/bin/appimagetool && \
rm /tmp/pkg2appimage.AppImage

WORKDIR /
19 changes: 12 additions & 7 deletions etc/scripts/appimage-build/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ ENV_FILE=.env
PKG2APPIMAGE_FILE=pkg2appimage.AppImage
PYTHON_LINUX_SUPPORT_DIR=Python-Linux-support
BUILT_PYTHON_ARCHIVE=Python-3.10-linux-x86_64-support.custom.tar.gz
PYTHON_APPIMAGE=python3.10.9-cp310-cp310-manylinux2014_x86_64.AppImage

envfile:
@echo "-> Create the .env file and generate a secret key"
Expand All @@ -37,17 +38,21 @@ envfile:

python:
@echo "-> Build Python"
@if ! test -f ${BUILT_PYTHON_ARCHIVE}; then \
mkdir ${PYTHON_LINUX_SUPPORT_DIR} \
&& wget https://github.com/beeware/Python-Linux-support/archive/refs/heads/main.tar.gz -O - | tar xzv --directory ${PYTHON_LINUX_SUPPORT_DIR} --strip-components=1 \
&& cp resources/${PYTHON_LINUX_SUPPORT_DIR}/Makefile resources/${PYTHON_LINUX_SUPPORT_DIR}/exclude.list ${PYTHON_LINUX_SUPPORT_DIR} \
&& cd ${PYTHON_LINUX_SUPPORT_DIR} && $(MAKE) && cd .. \
&& cp ${PYTHON_LINUX_SUPPORT_DIR}/dist/${BUILT_PYTHON_ARCHIVE} . ;\
@if ! test -f ${PYTHON_APPIMAGE}; then \
wget https://github.com/niess/python-appimage/releases/download/python3.10/python3.10.9-cp310-cp310-manylinux2014_x86_64.AppImage \
&& chmod u+x ${PYTHON_APPIMAGE} \
&& ./${PYTHON_APPIMAGE} --appimage-extract \
&& mv squashfs-root python3.10.AppDir;\
fi
mkdir -p python3.10.AppDir/opt/scancodeio
wget -c https://github.com/nexB/scancode.io/archive/refs/heads/scancode.io-appimage.tar.gz -O - | tar xz --directory=python3.10.AppDir/opt/scancodeio --strip-components=1
python3.10.AppDir/AppRun -m pip install python3.10.AppDir/opt/scancodeio
python3.10.AppDir/AppRun -m pip install --upgrade https://github.com/nexB/python-inspector/archive/refs/heads/update-cache-location.zip
python3.10.AppDir/AppRun -m pip install --upgrade packaging==21.3

build: python
@echo "-> Build ScanCode.io AppImage"
@if ! test -f ${PKG2APPIMAGE_FILE}; then wget https://github.com/AppImageCommunity/pkg2appimage/releases/download/continuous/pkg2appimage-1807-x86_64.AppImage -O ${PKG2APPIMAGE_FILE}; chmod u+x ${PKG2APPIMAGE_FILE}; fi
@./${PKG2APPIMAGE_FILE} scancodeio.yml
@ARCH=x86_64 ./${PKG2APPIMAGE_FILE} scancodeio.yml

.PHONY: envfile python build
10 changes: 8 additions & 2 deletions etc/scripts/appimage-build/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,23 @@ Requirements
Building
--------

Ensure that the present directory has the following files:
- Dockerfile
- docker-compose.yml
- scancodeio.yml
- scancodeio.desktop
- python.png

Run ``docker-compose run builder`` to build the scancode.io AppImage. The built appimage will be located in the ``out/`` directory.

You can also run ``make build`` to build the scancode.io AppImage without the use of Docker.

Usage
-----

Note: scancode.io will be run using the Django development server. The entry point of the scancode.io AppImage points to ``manage.py`` of scancode.io.

Ensure that the AppImage is executable:
- ``chmod +x scancodeio-.glibc2.29-x86_64.AppImage``
- ``chmod +x scancodeio-.glibc2.27-x86_64.AppImage``

To use the scancode.io AppImage, you will need to have some environmental variables set:
- ``SCANCODEIO_DB_NAME``
Expand Down
28 changes: 28 additions & 0 deletions etc/scripts/appimage-build/resources/python3.10
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#! /bin/bash

# If running from an extracted image, then export ARGV0 and APPDIR
if [ -z "${APPIMAGE}" ]; then
export ARGV0="$0"

self=$(readlink -f -- "$0") # Protect spaces (issue 55)
here="${self%/*}"
tmp="${here%/*}"
export APPDIR="${tmp%/*}"
fi

# Resolve the calling command (preserving symbolic links).
export APPIMAGE_COMMAND=$(command -v -- "$ARGV0")

# Export TCl/Tk
export TCL_LIBRARY="${APPDIR}/usr/share/tcltk/tcl8.6"
export TK_LIBRARY="${APPDIR}/usr/share/tcltk/tk8.6"
export TKPATH="${TK_LIBRARY}"

# Export SSL certificate
export SSL_CERT_FILE="${APPDIR}/opt/_internal/certs.pem"

export PYTHONHOME="${APPDIR}/opt/python3.10"
export PYTHONPATH="${APPDIR}/opt/python3.10/lib/python3.10/site-packages"

# Call Python
"$APPDIR/opt/python3.10/bin/python3.10" "$@"
3 changes: 2 additions & 1 deletion etc/scripts/appimage-build/resources/scancodeio.desktop
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
Type=Application
Icon=python
Name=scancodeio
Exec=./usr/bin/python3.10 ./share/scancodeio/manage.py %F
Path=bin
Exec=python3.10 ../opt/scancodeio/manage.py %F
Terminal=true
Categories=Application;
Keywords=Python;
33 changes: 24 additions & 9 deletions etc/scripts/appimage-build/scancodeio.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,33 @@ ingredients:
- libxml2-dev
- libxslt1-dev
- libpopt0
- build-essential
- libssl-dev
- libpq-dev
- libgpgme11
- libdevmapper1.02.1
- libguestfs-tools
script:
# - wget -c https://github.com/niess/python-appimage/releases/download/python3.10/python3.10.9-cp310-cp310-manylinux2014_x86_64.AppImage
# - chmod u+x python3.10.9-cp310-cp310-manylinux2014_x86_64.AppImage
# - ./python3.10.9-cp310-cp310-manylinux2014_x86_64.AppImage --appimage-extract
# - mv squashfs-root python3.10.AppDir
# - wget -c https://github.com/nexB/scancode.io/archive/refs/heads/scancode.io-appimage.tar.gz
# - tar xzvf scancode.io-appimage.tar.gz
# - mv scancode.io-scancode.io-appimage scancodeio
# - mv scancodeio python3.10.AppDir/opt/
# - python3.10.AppDir/AppRun -m pip install python3.10.AppDir/opt/scancodeio
# - python3.10.AppDir/AppRun -m pip install --upgrade https://github.com/nexB/python-inspector/archive/refs/heads/update-cache-location.zip
# - python3.10.AppDir/AppRun -m pip install --upgrade packaging==21.3
- cd .. && make envfile && mv .env scancodeio && cd scancodeio


script:
- env
- mkdir -p usr/share/scancodeio
- wget -c https://github.com/nexB/scancode.io/archive/refs/heads/scancode.io-appimage.tar.gz -O - | tar xz --directory=./usr/share/scancodeio --strip-components=1
- make -f ../../Makefile envfile
- mv .env ./usr/share/scancodeio/.env
- cp -r ../../python3.10.AppDir/usr/. usr
- cp -r ../../python3.10.AppDir/opt .
- cp ../.env opt/scancodeio/
- cp ../../resources/python.png .
- tar xz --directory=./usr -f ../../Python-3.10-linux-x86_64-support.custom.tar.gz
- ./usr/bin/python3.10 -m ensurepip
- ./usr/bin/python3.10 -m pip install ./usr/share/scancodeio
- ./usr/bin/python3.10 -m pip install --upgrade https://github.com/nexB/python-inspector/archive/refs/heads/update-cache-location.zip
- ./usr/bin/python3.10 -m pip install --upgrade packaging==21.3
- cp ../../resources/scancodeio.desktop .
- cp ../../resources/python3.10 usr/bin
- cp ../../resources/scancodeio.desktop usr/share/applications/scancodeio.desktop

0 comments on commit a21f57e

Please sign in to comment.