Merge pull request #1 from a5dur/no-user-add

Fix pip 26+ compatibility and add ARM build/deployment docs
This commit is contained in:
Abdur Rahman 2026-06-05 11:20:33 +00:00 committed by GitHub
commit fb0d5af7fe
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 101 additions and 3 deletions

57
CLAUDE.md Normal file
View file

@ -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 <username> email=<email> password=<password>
/usr/lib/ckan/default/bin/ckan -c /etc/ckan/default/ckan.ini sysadmin add <username>
```

View file

@ -19,6 +19,9 @@
> [!NOTE] > [!NOTE]
> The `/etc/ckan/default/ckan.ini` config file will have its comments removed for now. There are plans to fix this in a future release of `ckan-devstaller`. > The `/etc/ckan/default/ckan.ini` config file will have its comments removed for now. There are plans to fix this in a future release of `ckan-devstaller`.
> [!NOTE]
> Currently `ckan-devstaller` supports x86 architecture. ARM support is planned.
You have two common options to choose from for installation. Paste one of the following scripts into your new Ubuntu 22.04 instance's terminal. You have two common options to choose from for installation. Paste one of the following scripts into your new Ubuntu 22.04 instance's terminal.
### Install with non-interactive mode (default config) ### Install with non-interactive mode (default config)
@ -33,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 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 <username> email=<email> password=<password>
/usr/lib/ckan/default/bin/ckan -c /etc/ckan/default/ckan.ini sysadmin add <username>
```
CKAN will be available at `http://localhost:5000`.
## Demos ## Demos
### Interactive customizable installation ### Interactive customizable installation

View file

@ -21,7 +21,7 @@ sudo chmod +x ./ckan-devstaller
# Otherwise run ckan-devstaller in interactive mode # Otherwise run ckan-devstaller in interactive mode
flag=$1 flag=$1
if [ $flag == "default" ]; then if [ "$flag" == "default" ]; then
./ckan-devstaller --default ./ckan-devstaller --default
else else
./ckan-devstaller ./ckan-devstaller

View file

@ -229,7 +229,7 @@ fn main() -> Result<()> {
venv.pip_upgrade("pip")?; venv.pip_upgrade("pip")?;
venv.pip_install( venv.pip_install(
format!( 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 config.ckan_version
) )
.as_str(), .as_str(),
@ -337,7 +337,7 @@ fn main() -> Result<()> {
); );
cmd!( cmd!(
sh, 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()?; .run()?;
let mut conf = ini::Ini::load_from_file("/etc/ckan/default/ckan.ini")?; let mut conf = ini::Ini::load_from_file("/etc/ckan/default/ckan.ini")?;