From edb53cdc4e16d3cdeaad1e38cfde9b81ed719545 Mon Sep 17 00:00:00 2001 From: Abu Date: Fri, 5 Jun 2026 11:17:43 +0000 Subject: [PATCH] Fix pip 26+ egg fragment syntax, add ARM build docs - Fix unquoted $flag in install.bash (unary operator error when no arg) - Fix pip install syntax: use PEP 440 direct URL format for CKAN and ckanext-scheming (pip 26+ rejects extras in #egg= fragment) - Add CLAUDE.md with architecture notes, known issues, and sysadmin setup - Add deployment-from-source section to README for ARM users Co-Authored-By: Claude Sonnet 4.6 --- CLAUDE.md | 57 ++++++++++++++++++++++++++++++++++++++++++++++++++++ README.md | 38 +++++++++++++++++++++++++++++++++++ install.bash | 2 +- src/main.rs | 4 ++-- 4 files changed, 98 insertions(+), 3 deletions(-) create mode 100644 CLAUDE.md diff --git a/CLAUDE.md b/CLAUDE.md new file mode 100644 index 0000000..b9059c4 --- /dev/null +++ b/CLAUDE.md @@ -0,0 +1,57 @@ +# ckan-devstaller + +Rust CLI that installs CKAN 2.11.3 from source on Ubuntu 22.04. Two modes: interactive (prompts) or `--default` (silent). + +## Build + +```bash +cargo build --release +./target/release/ckan-devstaller +``` + +Requires Rust. Install via `curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh`. + +## Source layout + +| File | Purpose | +|------|---------| +| `src/main.rs` | CLI entry, `Config` struct, full install orchestration (~499 lines) | +| `src/questions.rs` | `inquire`-based interactive prompts (SSH, CKAN version, sysadmin) | +| `src/steps.rs` | Step display helpers (intro, numbered steps) | +| `src/styles.rs` | Terminal color helpers via `owo-colors` | +| `install.bash` | Bootstrap script: apt update, curl binary from releases, run installer | + +## Key dependencies + +- `clap` — CLI arg parsing (`--default` flag) +- `inquire` — interactive terminal prompts (requires real TTY) +- `xshell` / `xshell-venv` — shell command execution and Python venv management +- `rust-ini` — read/write `/etc/ckan/default/ckan.ini` +- `human-panic` — friendly panic messages + +## Architecture + +`main.rs` builds a `Config` struct (either from prompts or defaults), then runs install steps sequentially: + +1. `apt update && apt upgrade` +2. Install curl + optional openssh-server +3. Install Ahoy CLI (arm64 or x86_64 binary from GitHub releases) +4. Clone and start ckan-compose (PostgreSQL, Solr, Redis via Docker) +5. Create Python venv at `/usr/lib/ckan/default`, install CKAN via pip +6. Set up `/etc/ckan/default/ckan.ini` +7. Set up DataStore (DB permissions, config) +8. Optionally install ckanext-scheming, DataPusher+ +9. Start CKAN dev server + +## Known issues / fixes applied + +- **pip 26+ incompatibility**: `#egg=pkg[extras]` fragment syntax rejected. Fixed to use PEP 440 direct URL syntax: `pkg[extras] @ git+https://...` +- **ARM support**: Release binaries are x86_64. On ARM (e.g. Apple Silicon Ubuntu VM), build from source with `cargo build --release`. +- **install.bash unquoted variable**: `$flag` must be quoted in the `if` check to avoid `unary operator expected` error when no arg is passed. + +## Adding a sysadmin after install + +```bash +/usr/lib/ckan/default/bin/ckan -c /etc/ckan/default/ckan.ini user add email= password= +/usr/lib/ckan/default/bin/ckan -c /etc/ckan/default/ckan.ini sysadmin add +``` diff --git a/README.md b/README.md index ecabf6e..b2ba3b3 100644 --- a/README.md +++ b/README.md @@ -36,6 +36,44 @@ wget -O - https://github.com/dathere/ckan-devstaller/releases/download/0.2.0/ins wget -O - https://github.com/dathere/ckan-devstaller/releases/download/0.2.0/install.bash | bash ``` +## Deployment (build from source) + +Use this path when the release binary does not match your architecture (e.g. ARM / Apple Silicon). + +### Prerequisites + +- Ubuntu 22.04 (fresh instance) +- Rust toolchain + +```bash +curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh +source ~/.cargo/env +``` + +### Build and run + +```bash +git clone https://github.com/dathere/ckan-devstaller.git +cd ckan-devstaller +cargo build --release +./target/release/ckan-devstaller +``` + +Pass `--default` for non-interactive mode: + +```bash +./target/release/ckan-devstaller --default +``` + +### Add a sysadmin after install + +```bash +/usr/lib/ckan/default/bin/ckan -c /etc/ckan/default/ckan.ini user add email= password= +/usr/lib/ckan/default/bin/ckan -c /etc/ckan/default/ckan.ini sysadmin add +``` + +CKAN will be available at `http://localhost:5000`. + ## Demos ### Interactive customizable installation diff --git a/install.bash b/install.bash index 22f5fe0..c25873d 100644 --- a/install.bash +++ b/install.bash @@ -21,7 +21,7 @@ sudo chmod +x ./ckan-devstaller # Otherwise run ckan-devstaller in interactive mode flag=$1 -if [ $flag == "default" ]; then +if [ "$flag" == "default" ]; then ./ckan-devstaller --default else ./ckan-devstaller diff --git a/src/main.rs b/src/main.rs index f6f8957..fe577e6 100644 --- a/src/main.rs +++ b/src/main.rs @@ -229,7 +229,7 @@ fn main() -> Result<()> { venv.pip_upgrade("pip")?; venv.pip_install( format!( - "git+https://github.com/ckan/ckan.git@ckan-{}#egg=ckan[requirements]", + "ckan[requirements] @ git+https://github.com/ckan/ckan.git@ckan-{}", config.ckan_version ) .as_str(), @@ -337,7 +337,7 @@ fn main() -> Result<()> { ); cmd!( sh, - "pip install -e git+https://github.com/ckan/ckanext-scheming.git#egg=ckanext-scheming" + "pip install -e ckanext-scheming @ git+https://github.com/ckan/ckanext-scheming.git" ) .run()?; let mut conf = ini::Ini::load_from_file("/etc/ckan/default/ckan.ini")?;