Skip to content

port: add 'source' subcommand for managing sources.conf#395

Open
herbygillot wants to merge 1 commit into
macports:masterfrom
herbygillot:port-source-mgmt
Open

port: add 'source' subcommand for managing sources.conf#395
herbygillot wants to merge 1 commit into
macports:masterfrom
herbygillot:port-source-mgmt

Conversation

@herbygillot

@herbygillot herbygillot commented Mar 20, 2026

Copy link
Copy Markdown
Member

Add port source to list, add, remove, and manage default-flag state
of entries in sources.conf.

--add supports --first (insert before existing sources), --no-sync
(append [nosync] flag), and --default (mark as the explicit default,
clearing it from other sources).

--set-default and --unset-default toggle the [default] flag on
existing entries.

--remove warns if the removed source was the only explicit default.

Bare local paths starting with / or ~ are automatically normalized and
converted to file:// URLs; local paths with spaces are supported.

Write operations are atomic (write to temp file, then rename), check
for write permission, and emit a sudo hint on failure.

Business logic uses a structured read-parse-modify-write pipeline in
macports1.0/macports.tcl: source_read_conf / source_parse_line /
source_write_conf / source_render_record handle round-tripping the
file while preserving comments and blank lines. port.tcl contains the
thin UI wrapper (action_source).

Uses file tildeexpand before file normalize for Tcl 9 compatibility,
where file normalize no longer performs tilde expansion.

Includes 20 tcltest unit tests (sources.test), a new port-source(1)
man page (port-source.1.txt), and updates to port(1) and
sources.conf(5).

Fixes: https://trac.macports.org/ticket/73683

@herbygillot herbygillot requested a review from jmroot March 20, 2026 04:40
@herbygillot herbygillot force-pushed the port-source-mgmt branch 3 times, most recently from 0afed4c to f0e724e Compare March 22, 2026 07:49
Add `port source` to list, add, remove, and manage default-flag state
of entries in sources.conf.

--add supports --first (insert before existing sources), --no-sync
(append [nosync] flag), and --default (mark as the explicit default,
clearing it from other sources).

--set-default and --unset-default toggle the [default] flag on
existing entries.

--remove warns if the removed source was the only explicit default.

Bare local paths starting with / or ~ are automatically normalized and
converted to file:// URLs; local paths with spaces are supported.

Write operations are atomic (write to temp file, then rename), check
for write permission, and emit a sudo hint on failure.

Business logic uses a structured read-parse-modify-write pipeline in
macports1.0/macports.tcl: source_read_conf / source_parse_line /
source_write_conf / source_render_record handle round-tripping the
file while preserving comments and blank lines. port.tcl contains the
thin UI wrapper (action_source).

Uses file tildeexpand before file normalize for Tcl 9 compatibility,
where file normalize no longer performs tilde expansion.

Includes 20 tcltest unit tests (sources.test), a new port-source(1)
man page (port-source.1.txt), and updates to port(1) and
sources.conf(5).

Fixes: https://trac.macports.org/ticket/73683
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant