├── Makefile ├── .github ├── dependabot.yml ├── scripts │ └── update-versions.sh └── workflows │ └── update.yaml ├── .gitignore ├── README.md └── snap └── snapcraft.yaml /Makefile: -------------------------------------------------------------------------------- 1 | .PHONY: snap clean 2 | 3 | snap: 4 | snapcraft -v 5 | 6 | clean: 7 | snapcraft clean -v 8 | rm -vf *.snap 9 | -------------------------------------------------------------------------------- /.github/dependabot.yml: -------------------------------------------------------------------------------- 1 | version: 2 2 | updates: 3 | - package-ecosystem: "github-actions" 4 | directory: "/" 5 | schedule: 6 | interval: "monthly" 7 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # gitginore template for creating Snap packages 2 | # website: https://snapcraft.io/ 3 | 4 | parts/ 5 | prime/ 6 | stage/ 7 | *.snap 8 | 9 | # Snapcraft global state tracking data(automatically generated) 10 | # https://forum.snapcraft.io/t/location-to-save-global-state/768 11 | /snap/.snapcraft/ 12 | 13 | # Source archive packed by `snapcraft cleanbuild` before pushing to the LXD container 14 | /*_source.tar.bz2 -------------------------------------------------------------------------------- /.github/scripts/update-versions.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -ae 4 | 5 | cd "$(dirname "$0")/../.." 6 | 7 | getLatestReleaseTag() { 8 | echo "Checking latest release version for $1..." > /dev/stderr 9 | gh release view --repo "$1" --json tagName --template '{{.tagName}}' 10 | } 11 | 12 | R2AI_VERSION=$(getLatestReleaseTag radareorg/r2ai) 13 | 14 | echo "Updating versions in snap/snapcraft.yaml..." > /dev/stderr 15 | yq eval -i '.version=strenv(R2AI_VERSION) | .parts.r2ai.source-tag=strenv(R2AI_VERSION)' snap/snapcraft.yaml 16 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # R2ai snap repository 2 | 3 | [![snap: r2ai](https://snapcraft.io/r2ai/badge.svg "snap latest stable version")](https://snapcraft.io/r2ai) 4 | 5 | This repository contains the recipie to build the snap version of [r2ai](https://github.com/radareorg/r2ai) for the original implementation of the AI support for radare2 written in Python. 6 | 7 | Although it is considered deprecated, it's still useful and aims to be maintained, but we recommend using decai or the C rewrite as alternatives (both included in the [radare2 snap](https://snapcraft.io/radare2)). 8 | 9 | [![Get it from the Snap Store](https://snapcraft.io/static/images/badges/en/snap-store-black.svg)](https://snapcraft.io/r2ai) 10 | 11 | To install: 12 | ```sh 13 | sudo snap install r2ai 14 | ``` 15 | -------------------------------------------------------------------------------- /snap/snapcraft.yaml: -------------------------------------------------------------------------------- 1 | name: r2ai 2 | version: '1.2.6' 3 | summary: local language model for radare2 4 | description: | 5 | Run a language model in local, without internet, to entertain you or help answering questions about radare2 or reverse engineering in general. 6 | Note that models used by r2ai are pulled from external sources which may behave different or respond unrealible information. 7 | That's why there's an ongoing effort into improving the post-finetuning using memgpt-like techniques which can't get better without your help! 8 | website: https://www.radare.org/ 9 | issues: https://github.com/radareorg/r2ai/issues 10 | contact: https://github.com/radareorg/radare2#community 11 | source-code: https://github.com/radareorg/r2ai-snap 12 | license: LGPL-3.0-only 13 | base: core24 14 | grade: stable 15 | confinement: strict 16 | environment: 17 | HOME: $SNAP_USER_COMMON 18 | XDG_CONFIG_HOME: $SNAP_USER_COMMON/config 19 | XDG_CACHE_HOME: $SNAP_USER_COMMON/cache 20 | XDG_DATA_HOME: $SNAP_USER_COMMON/data 21 | XDG_STATE_HOME: $SNAP_USER_COMMON/state 22 | TRANSFORMERS_NO_ADVISORY_WARNINGS: "1" 23 | apps: 24 | r2ai: 25 | command: bin/r2ai 26 | plugs: 27 | - network 28 | - network-bind 29 | - opengl 30 | platforms: 31 | amd64: 32 | build-on: [amd64] 33 | build-for: amd64 34 | arm64: 35 | build-on: [arm64] 36 | build-for: arm64 37 | # armhf: 38 | # build-on: [armhf] 39 | # build-for: armhf 40 | # ppc64el: 41 | # build-on: [ppc64el] 42 | # build-for: ppc64el 43 | # riscv64: 44 | # build-on: [riscv64] 45 | # build-for: riscv64 46 | # s390x: 47 | # build-on: [s390x] 48 | # build-for: s390x 49 | parts: 50 | r2ai: 51 | plugin: python 52 | source: https://github.com/radareorg/r2ai.git 53 | source-type: git 54 | source-depth: 1 55 | source-tag: 1.2.6 56 | source-subdir: py 57 | build-packages: 58 | # only used when prebuild pip packages are missing 59 | - cmake 60 | - libffi-dev 61 | - libprotobuf-dev 62 | - libsentencepiece-dev 63 | - pkg-config 64 | stage-packages: 65 | - libffi8 66 | - libgomp1 67 | - libprotobuf-lite32t64 68 | - libsentencepiece0 69 | - on amd64: 70 | - libgomp-plugin-amdgcn1 71 | - libgomp-plugin-hsa1 72 | - libgomp-plugin-nvptx1 73 | - on arm64: 74 | - libgomp-plugin-nvptx1 75 | -------------------------------------------------------------------------------- /.github/workflows/update.yaml: -------------------------------------------------------------------------------- 1 | name: Check for updates 2 | on: 3 | schedule: # for scheduling to work this file must be in the default branch 4 | - cron: "30 */6 * * *" # run every 6 hours 5 | workflow_dispatch: # can be manually dispatched under GitHub's "Actions" tab 6 | 7 | jobs: 8 | update-versions: 9 | runs-on: ubuntu-latest 10 | 11 | permissions: 12 | # Give the default GITHUB_TOKEN write permission to commit and push the 13 | # added or changed files to the repository. 14 | contents: write 15 | 16 | steps: 17 | # Install version checker dependencies 18 | - name: Install required dependencies 19 | run: | 20 | curl -Ls https://github.com/mikefarah/yq/releases/latest/download/yq_linux_amd64.tar.gz | tar -xzC /tmp 21 | sudo cp -v /tmp/yq_linux_* /usr/local/bin/yq 22 | 23 | # Perform the checkout of the main branch 24 | - name: Checkout 25 | uses: actions/checkout@v4 26 | with: 27 | ref: main 28 | 29 | # Perform the actual version check 30 | - name: Check for new versions for all parts 31 | run: .github/scripts/update-versions.sh 32 | env: 33 | GH_TOKEN: ${{ github.token }} 34 | 35 | # Commit changed file back to the repository 36 | - name: Commit changes 37 | id: commit 38 | uses: stefanzweifel/git-auto-commit-action@778341af668090896ca464160c2def5d1d1a3eb0 # v6.0.1 39 | with: 40 | commit_message: Automatic update versions 41 | #commit_user_name: 'github-actions[bot]' 42 | #commit_user_email: '41898282+github-actions[bot]@users.noreply.github.com' 43 | commit_author: 'github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>' 44 | 45 | # Try to autopromote old builds 46 | - name: Install snapcraft 47 | if: steps.commit.outputs.changes_detected == 'false' 48 | run: sudo snap install snapcraft --channel=8.x/stable --classic 49 | 50 | # Check latest snap revision at edge channel for the slowest building channel (arm64) 51 | - name: Check latest snapcraft build revision 52 | if: steps.commit.outputs.changes_detected == 'false' 53 | id: snap 54 | env: 55 | SNAPCRAFT_STORE_CREDENTIALS: ${{ secrets.SNAPCRAFT_STORE_CREDENTIALS }} 56 | run: snapcraft list-revisions r2ai --arch arm64 | awk 'NR==2{print "channels="$5}' >> $GITHUB_OUTPUT 57 | 58 | # Automatically promote to stable only if not already and no new build has been started 59 | - name: Promote Snap to stable if not yet promoted 60 | if: steps.commit.outputs.changes_detected == 'false' && steps.snap.outputs.channels == 'latest/edge*' 61 | env: 62 | SNAPCRAFT_STORE_CREDENTIALS: ${{ secrets.SNAPCRAFT_STORE_CREDENTIALS }} 63 | # Workaround for https://github.com/snapcore/snapcraft/issues/4439 64 | SNAPCRAFT_HAS_TTY: "true" 65 | run: yes | snapcraft promote r2ai --from-channel edge --to-channel stable 66 | --------------------------------------------------------------------------------