# P4LF Session Log — 2026-06-26 (Session 5: Deployment & Install Script)

## Session Goal

Discuss and implement the deployment/installation workflow for p4lf in
customer SDP environments.

## Key Decisions

### Binary versioning in P4

Binaries will be submitted to P4 as part of the release process, but
**only in release and main streams** (not dev). The `bin/` directory stays
in `.p4ignore` for the dev stream. This allows:
- Customers to `curl` binaries directly from workshop.perforce.com
- A predictable, stable URL via `//p4lf/main`

### Download URL format

Correct URL base: `https://workshop.perforce.com/download/p4lf/<stream>/`
- `main` stream = stable "latest release" URL
- `r1.0` etc = pinned release stream URL
- `dev` stream = available for testing but not recommended for production

Example:
```
https://workshop.perforce.com/download/p4lf/main/bin/p4lf-linux-amd64
https://workshop.perforce.com/download/p4lf/main/install.sh
```

Note: Always use `curl -fsSL` (and `-L` for redirect following) when
downloading from workshop.perforce.com.

### install.sh must run as root

The install script requires root to:
- Write to `/p4/common/site/log_feeder/`
- Install/update `/etc/systemd/system/p4lf.service`
- Run `systemctl daemon-reload`

The script bails immediately with a clear message if not run as root.

### Perforce user service management: deferred, tracked as P4LF-2

The problem of allowing the `perforce` OS user to manage the p4lf service
without root (via SDP limited-sudoers or a wrapper script) is deferred to
a future release. Tracked as **job P4LF-2**.

### Release/promotion workflow

```
dev  (test here)
 └─ p4 copy → main  (only promote tested code; main = "safe to rely on")
               └─ p4 copy → rX.Y  (release stream; add binaries here)
```

The `//p4lf/main` stream serves as the stable "latest release" URL.
Only promote to main code that has passed testing in dev.

## What Was Built (CL 32834)

### install.sh (type text+x, carries $Id$/$Change$/$DateTime$ stamps)

Key features:
- Root check (bails early with clear message if not root)
- Platform detection: Linux amd64/arm64, macOS arm64/amd64
- Downloads binary, `p4lf.cfg.example`, `p4lf.service` via `curl -fsSL`
- Options: `-s <stream>` (default: main), `-d <dir>`, `-n` (dry run), `-h`
- Never overwrites an existing `p4lf.cfg`
- Installs/updates systemd unit only if content changed; runs `daemon-reload`
- Prints clear next-step instructions including P4LF-2 note

### Makefile updates

- `release` target includes `install.sh` in dist/ tarballs
- New `promote` comment block documents the full copy-up workflow with
  correct workshop.perforce.com URLs

### Job P4LF-2 created

Title: "Enable perforce OS user to manage p4lf service without requiring root."
Options to evaluate in a future release:
1. SDP gen_sudoers.sh entries for p4lf systemctl commands
2. Wrapper script with sudoers entries
3. Split install.sh into root-required and perforce-user phases

## One-liner customer install (once binaries are in main)

```bash
curl -fsSL https://workshop.perforce.com/download/p4lf/main/install.sh | sudo bash
# or for a specific stream:
sudo bash -c "$(curl -fsSL https://workshop.perforce.com/download/p4lf/main/install.sh)" -- -s r1.0
```

## Status at End of Session

- CL 32834 submitted to //p4lf/dev
- install.sh reachable at: https://workshop.perforce.com/download/p4lf/dev/install.sh
- Binaries not yet in any stream (will be added when promoting to main/rX.Y)
- Ready to proceed to Linux integration testing
