Skip to content

Commit

Permalink
Support of arm64 (#563) (#564)
Browse files Browse the repository at this point in the history
Thank you very much @sbernhard
  • Loading branch information
sbernhard authored Jan 27, 2025
1 parent 659a905 commit bd9684f
Show file tree
Hide file tree
Showing 4 changed files with 98 additions and 24 deletions.
51 changes: 43 additions & 8 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,24 +10,59 @@ on:

env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

jobs:
build:
runs-on: ubuntu-20.04
runs-on: ${{ matrix.config.runner }}
strategy:
matrix:
config:
- runner: ubuntu-20.04
image: ubuntu:20.04
- runner: ubuntu-22.04-arm
image: ubuntu:22.04
container:
image: ubuntu:20.04
image: ${{ matrix.config.image }}
options: --privileged
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Print configuration
run: echo "Running build on ${{ matrix.config }}"

- name: Install dependencies
run: |
export DEBIAN_FRONTEND="noninteractive"
apt-get update
apt-get install -y sudo libarchive-tools curl zsync squashfs-tools aria2 desktop-file-utils wget fuse binutils file
apt-get install -y sudo libarchive-tools curl zsync squashfs-tools aria2 desktop-file-utils wget fuse binutils file imagemagick gcc
- name: Build pkg2appimage
run: |
bash -ex dogfeeding.sh
- name: Test to create Hello AppImage
run: |
chmod +x ./out/pkg2appimage*.AppImage*
./out/pkg2appimage*.AppImage* recipes/hello.yml
- name: Verify AppImage Creation and Test
run: |
if ls out/hello-*.AppImage 1> /dev/null 2>&1; then
echo "hello AppImage successfully created."
./out/hello-*.AppImage | tee output.txt
if grep -q "Hello, world!" output.txt; then
echo "hello AppImage test passed."
else
echo "hello AppImage test failed." >&2
exit 1
fi
else
echo "Failed to create hello AppImage." >&2
exit 1
fi
- name: Build and Release
- name: Release
run: |
bash -ex dogfeeding.sh
wget -c https://github.com/probonopd/uploadtool/raw/master/upload.sh
bash upload.sh ./out/pkg2appimage*.AppImage*
wget -c https://github.com/probonopd/uploadtool/raw/master/upload.sh
bash upload.sh ./out/pkg2appimage*.AppImage*
5 changes: 1 addition & 4 deletions dogfeeding.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ cd build/
apt download -y dpkg # We are still using dpkg-deb to extract debs, so we need to bundle it

wget -c "https://github.com/AppImage/AppImageKit/releases/download/continuous/appimagetool-$SYSTEM_ARCH.AppImage" # FIXME: Make arch independent
wget -c "https://github.com/ImageMagick/ImageMagick/releases/download/7.0.8-17/ImageMagick-0b0ce48-gcc-$SYSTEM_ARCH.AppImage" # FIXME: Make arch independent
chmod +x ./*.AppImage

./appimagetool-*.AppImage --appimage-extract && mv ./squashfs-root ./pkg2appimage.AppDir
Expand All @@ -22,14 +21,12 @@ cd ./pkg2appimage.AppDir
find ../*.deb -exec dpkg-deb -x {} . \; || true

rm *.desktop || true
mv ./usr/share/applications/appimagetool.desktop ./usr/share/applications/pkg2appimage.desktop
mv ./usr/share/applications/appimagetool.desktop ./usr/share/applications/pkg2appimage.desktop
sed -i -e 's|Name=appimagetool|Name=pkg2appimage|g' ./usr/share/applications/pkg2appimage.desktop
sed -i -e 's|Exec=appimagetool|Exec=pkg2appimage|g' ./usr/share/applications/pkg2appimage.desktop
sed -i -e 's|Comment=.*|Comment=Create AppImages from Debian/Ubuntu repositories|g' ./usr/share/applications/pkg2appimage.desktop
cp ./usr/share/applications/pkg2appimage.desktop .

cp ../ImageMagick-*.AppImage usr/bin/convert

# We don't suffer from NIH
# mkdir -p usr/src/
# wget -q "https://raw.githubusercontent.com/mikix/deb2snap/master/src/preload.c" -O - | \
Expand Down
43 changes: 31 additions & 12 deletions functions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ grep docker /proc/1/cgroup >/dev/null && export DOCKER_BUILD=1 || true
# Detect system architecture to know which binaries of AppImage tools
# should be downloaded and used.
case "$(uname -i)" in
aarch64|arm64)
# echo "aarch64 system architecture"
SYSTEM_ARCH="aarch64";;
x86_64|amd64)
# echo "x86-64 system architecture"
SYSTEM_ARCH="x86_64";;
Expand All @@ -47,6 +50,9 @@ case "$(uname -i)" in
unknown|AuthenticAMD|GenuineIntel)
# uname -i not answer on debian, then:
case "$(uname -m)" in
aarch64|arm64)
# echo "aarch64 system architecture"
SYSTEM_ARCH="aarch64";;
x86_64|amd64)
# echo "x86-64 system architecture"
SYSTEM_ARCH="x86_64";;
Expand Down Expand Up @@ -249,7 +255,7 @@ generate_type2_appimage()
GLIBC_NEEDED=$(glibc_needed)
_APP_DIR="${PWD}/$APP.AppDir/"
export OWD="${PWD}"

if ( [ ! -z "$KEY" ] ) && ( ! -z "$TRAVIS" ) ; then
wget https://github.com/AppImage/AppImageKit/files/584665/data.zip -O data.tar.gz.gpg
( set +x ; echo $KEY | gpg2 --batch --passphrase-fd 0 --no-tty --skip-verify --output data.tar.gz --decrypt data.tar.gz.gpg )
Expand Down Expand Up @@ -375,16 +381,29 @@ patch_strings_in_file() {

function apt-get.update(){
echo -n > cache.txt

cat Packages.gz | gunzip -c | grep -E "^Package:|^Filename:|^Depends:|^Version:" >> cache.txt || true


local arch=$SYSTEM_ARCH
case "$SYSTEM_ARCH" in
x86_64)
arch="amd64";;
aarch64)
arch="arm64";;
i686)
arch="i386";;
*)
echo "Unsupported system architecture"
exit 1;;
esac

echo APT_GET_UPDATE
while read line; do
local line=$(echo "${line}" | sed 's|[[:space:]]| |g')
local repo_info=($(echo ${line} | tr " " "\n"))
local base_url=${repo_info[1]}
local dist_name=${repo_info[2]}

echo line=${line}
echo repo_info=${repo_info}
echo base_url=${base_url}
Expand All @@ -398,7 +417,7 @@ function apt-get.update(){
else
for i in $(seq 3 $((${#repo_info[@]} - 1))); do
echo "Caching ${base_url} ${dist_name} ${repo_info[${i}]}..."
local repo_url="${base_url}/dists/${dist_name}/${repo_info[${i}]}/binary-amd64/Packages.gz"
local repo_url="${base_url}/dists/${dist_name}/${repo_info[${i}]}/binary-${arch}/Packages.gz"
wget -q "${repo_url}" -O - | gunzip -c | grep -E "^Package:|^Filename:|^Depends:|^Version:" | sed "s|^Filename: |Filename: ${base_url}/|g" >> cache.txt
done
fi
Expand All @@ -409,18 +428,18 @@ function apt-get.do-download(){
[ -f "status" ] && {
grep -q ^"Package: ${1}"$ status && return
}

local package_name=$(echo ${1} | cut -d= -f1)
local package_version=`echo ${1} | cut -s -d= -f2-`

echo "${already_downloaded_package[@]}" | sed 's| |\n|g' | grep -q ^"${package_name}"$ && return

if ! test -z "${package_version}" ; then
local package_url=`cat cache.txt | grep -v ^"Depends: " \
| grep -A 3 ^"Package: ${package_name}"$ \
| grep -A 2 ^"Version: ${package_version}" \
| grep ^"Filename: " \
| cut -c 11-`
| cut -c 11-`
else
local package_url=`cat cache.txt | grep -v ^"Depends: " \
| grep -A 3 -m 1 ^"Package: ${package_name}"$ \
Expand All @@ -429,7 +448,7 @@ function apt-get.do-download(){
fi

already_downloaded_package+=(${package_name})

local dependencies=($(cat cache.txt | grep -A 2 -m 1 ^"Package: ${package_name}"$ \
| grep ^"Depends: " \
| cut -c 9- \
Expand All @@ -440,17 +459,17 @@ function apt-get.do-download(){
echo PACKAGE NAME: ${package_name}
echo PACKAGE_VERSION: ${package_version}
echo PACKAGE_URL: ${package_url}

[ ! -f "${package_url}" ] && {
[ ! "${package_url}" = "" ] && {
wget -c "${package_url}"
} || {
echo ${1} >> teste_123
}
}

unset package_url

for depend in "${dependencies[@]}"; do
apt-get.do-download ${depend}
done
Expand Down
23 changes: 23 additions & 0 deletions recipes/hello.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
app: hello
union: true

ingredients:
dist: focal
sources:
- deb http://us.archive.ubuntu.com/ubuntu/ focal main # works for amd64
- deb http://ports.ubuntu.com/ubuntu-ports/ focal main # works for arm64

script:
- ls
- cat > hello.desktop <<\EOF
- [Desktop Entry]
- Type=Application
- Name=hello
- Exec=hello
- Icon=hello
- Categories=Utility
- Comment=Example package based on GNU hello
- EOF
- wget -c https://github.com/iconoir-icons/iconoir/blob/main/icons/regular/spock-hand-gesture.svg -o hello.svg
- mkdir -p usr/share/icons/hicolor/scalable/apps/
- cp hello.svg usr/share/icons/hicolor/scalable/apps/hello.svg

0 comments on commit bd9684f

Please sign in to comment.