From ca4d5e0d26ed2e90105ea0de552238cf73a485b3 Mon Sep 17 00:00:00 2001 From: pancake Date: Thu, 30 Apr 2026 18:34:12 +0200 Subject: [PATCH] Add debian packaging --- .github/workflows/ci.yml | 36 ++++++++++++++++- .gitignore | 8 ++++ dist/debian/CONFIG | 22 +++++++++++ dist/debian/DESCR | 2 + dist/debian/Makefile | 40 +++++++++++++++++++ dist/debian/deb.mk | 85 ++++++++++++++++++++++++++++++++++++++++ 6 files changed, 192 insertions(+), 1 deletion(-) create mode 100644 dist/debian/CONFIG create mode 100644 dist/debian/DESCR create mode 100644 dist/debian/Makefile create mode 100644 dist/debian/deb.mk diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ff116f2..97cb453 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -5,6 +5,9 @@ on: branches: ['**'] pull_request: +env: + R2V: 6.1.4 + concurrency: group: ${{ github.workflow }}-${{ github.ref }} cancel-in-progress: true @@ -20,6 +23,37 @@ jobs: - uses: actions/checkout@v4 - uses: radareorg/github-actions@v1 with: - version: '6.1.4' + version: ${{ env.R2V }} - name: Build run: make + + debian: + name: Build Debian package + runs-on: ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Install build deps + run: sudo apt-get update -y && sudo apt-get install -y build-essential pkg-config wget + + - name: Download Radare2 Debian packages + run: | + wget -O r2.deb https://github.com/radareorg/radare2/releases/download/${{ env.R2V }}/radare2_${{ env.R2V }}_amd64.deb + wget -O r2-dev.deb https://github.com/radareorg/radare2/releases/download/${{ env.R2V }}/radare2-dev_${{ env.R2V }}_amd64.deb + + - name: Install Radare2 + run: sudo dpkg -i r2.deb r2-dev.deb + + - name: Build Debian package + run: make -C dist/debian SUDO= + + - name: Upload Debian package artifact + uses: actions/upload-artifact@v4 + with: + name: debian-package + path: dist/debian/*.deb + if-no-files-found: error diff --git a/.gitignore b/.gitignore index aef91e0..d31e37b 100644 --- a/.gitignore +++ b/.gitignore @@ -5,6 +5,14 @@ *.o /r2unity +# Debian packaging artifacts +/dist/debian/*.deb +/dist/debian/build/ +/dist/debian/control/ +/dist/debian/data/ +/dist/debian/debian-binary +/dist/debian/root/ + # Third-party reference checkouts (radare2, il2cpp dumper, etc.) /third_party/ diff --git a/dist/debian/CONFIG b/dist/debian/CONFIG new file mode 100644 index 0000000..aa59a08 --- /dev/null +++ b/dist/debian/CONFIG @@ -0,0 +1,22 @@ +PACKAGE=r2unity +VERSION_RAW=$(shell git -C ../.. describe --tags --always --dirty 2>/dev/null || echo 0.0.0) +VERSION_BASE=$(shell printf '%s' "$(VERSION_RAW)" | sed -e 's/^v//' -e 's/-/+/g') +VERSION=$(shell v='$(VERSION_BASE)'; expr "$$v" : '[0-9]' >/dev/null && printf '%s' "$$v" || printf '0.0.0+git%s' "$$v") +DEPENDS=radare2 +SECTION=user/shell +PRIORITY=optional +MAINTAINER=pancake + +UNAMEM=$(shell uname -m) +DPKG_ARCH=$(shell command -v dpkg >/dev/null 2>&1 && dpkg --print-architecture) +ifneq ($(DPKG_ARCH),) +ARCH=$(DPKG_ARCH) +else ifeq ($(UNAMEM),x86_64) +ARCH=amd64 +else ifeq ($(UNAMEM),aarch64) +ARCH=arm64 +else ifeq ($(UNAMEM),arm64) +ARCH=arm64 +else +ARCH=$(UNAMEM) +endif diff --git a/dist/debian/DESCR b/dist/debian/DESCR new file mode 100644 index 0000000..7db3608 --- /dev/null +++ b/dist/debian/DESCR @@ -0,0 +1,2 @@ +Unity IL2CPP metadata tool and radare2 plugin +r2unity inspects Unity IL2CPP binaries and global-metadata.dat files, exposing recovered metadata as CLI output or radare2 flags and comments through its core plugin. diff --git a/dist/debian/Makefile b/dist/debian/Makefile new file mode 100644 index 0000000..8abaeba --- /dev/null +++ b/dist/debian/Makefile @@ -0,0 +1,40 @@ +include ./CONFIG + +UNAME=$(shell uname) +SUDO?=sudo +PWD=$(shell pwd) +PACKAGE_DIR?=$(PWD) +R2_VERSION=$(shell r2 -qv 2>/dev/null || echo last) +R2PLUGDIR?=/usr/lib/radare2/$(R2_VERSION) +R2_PLUGINS=core_r2unity.so + +all: root + $(SUDO) rm -rf control data + $(MAKE) clean + mkdir -p data + cp -rf root/* data + $(MAKE) control + $(MAKE) deb + +root: +ifneq ($(UNAME),Linux) + @echo "Debian packages must be built on Linux so radare2 plugins are built as .so files." + @false +else + cd ../.. && $(MAKE) clean && $(MAKE) && $(MAKE) plugin + rm -rf root + mkdir -p root/usr/bin + cp -f ../../r2unity root/usr/bin/ + mkdir -p root/$(R2PLUGDIR) + for plugin in $(R2_PLUGINS); do cp -f ../../src/r2/$$plugin root/$(R2PLUGDIR)/; done + mkdir -p root/usr/share/doc/r2unity + cp -f ../../README.md root/usr/share/doc/r2unity/ +endif + +purge: clean + rm -rf root + +summary: + echo $(VERSION) + +include deb.mk diff --git a/dist/debian/deb.mk b/dist/debian/deb.mk new file mode 100644 index 0000000..29bd383 --- /dev/null +++ b/dist/debian/deb.mk @@ -0,0 +1,85 @@ +# Create .deb without using dpkg tools. +# +# Author: Tim Wegener +# +# Use 'include deb.mk' after defining the user variables in a local +# makefile. + +ifeq ($(shell uname),Darwin) +MD5SUM=md5 +else +MD5SUM=md5sum +endif + +GAWK=awk +PACKAGE_DIR=$(shell pwd) +CONTROL_EXTRAS ?= ${wildcard preinst postinst prerm postrm} + +${PACKAGE_DIR}/control: ${PACKAGE_DIR}/data ${CONTROL_EXTRAS} DESCR \ + ${ICON_SOURCE} + mkdir -p $@ +ifneq (${CONTROL_EXTRAS},) + cp ${CONTROL_EXTRAS} $@ +endif + echo "Package: ${PACKAGE}" > $@/control + echo "Version: ${VERSION}" >> $@/control + echo "Section: ${SECTION}" >> $@/control + echo "Priority: ${PRIORITY}" >> $@/control + echo "Architecture: ${ARCH}" >> $@/control +ifneq (${DEPENDS},) + echo "Depends: ${DEPENDS}" >> $@/control +endif + echo "Installed-Size: ${shell du -s ${PACKAGE_DIR}/data|cut -f1}" \ + >> $@/control + echo "Maintainer: ${MAINTAINER}" >> $@/control + printf "Description:" >> $@/control + cat DESCR | ${GAWK} '{print " "$$0;}' >> $@/control + cd ${PACKAGE_DIR}/data && find . -type f -exec ${MD5SUM} {} \; \ + | sed -e 's| \./||' \ + > $@/md5sums + +${PACKAGE_DIR}/debian-binary: + echo "2.0" > $@ + +${PACKAGE_DIR}/clean: + rm -rf ${PACKAGE_DIR}/data ${PACKAGE_DIR}/control ${PACKAGE_DIR}/build *.deb + +${PACKAGE_DIR}/build: ${PACKAGE_DIR}/debian-binary ${PACKAGE_DIR}/control \ + ${PACKAGE_DIR}/data + rm -rf $@ + mkdir $@ + cp ${PACKAGE_DIR}/debian-binary $@/ + cd ${PACKAGE_DIR}/control && tar czvf $@/control.tar.gz * + cd ${PACKAGE_DIR}/data && \ + COPY_EXTENDED_ATTRIBUTES_DISABLE=true \ + COPYFILE_DISABLE=true \ + tar cpzvf $@/data.tar.gz * + +${PACKAGE_DIR}/${PACKAGE}_${VERSION}_${ARCH}.deb: ${PACKAGE_DIR}/build + ar -rc $@ $