Skip to content

Add script for converting Zephyr repository #394

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

fstachura
Copy link
Collaborator

This is a work-in-progress version of Zephyr repository converter discussed in #279. It's not integrated with Elixir in any way yet, I'm not sure what would the best way to approach this. For now, probably the utils/index script could "inherit" functions from projects directory scripts, like script.sh does. Zephyr-specific repository conversion part could be then placed in projects/zephyr.sh.
The script does not try to properly order commits in the target repository, I don't think it matters for Elixir.

In this version, all the extra projects are placed in west_projects directory. West by default places project directories in directory above Zephyr, but that is not going to work for Elixir, because it would break URLs.
All west groups disabled in the manifest are enabled.
I have no experience with Zephyr, so I don't know if this makes sense.

Copy link
Member

@tleb tleb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

.

copy_git_worktree() {
echo $1 $2
rsync -q -av $1 --exclude .git $2
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the reasoning behind two Git directories? Could you use a single one instead and generate tags on it which have a prefix/suffix?

So maybe upstream pushes v1.0 and we add a new local tag called elixir-v1.0 (or whatever). Then the upper layers only pick those tags up?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seemed trickier to do it with a single repository, and I don't think modifying the original source in any way is a good idea.

But then I realized, that the repo directory has to be the conversion target, not source. And utils/index already fetches new tags into hardcoded repo directory. So if I want to have conversion target and source separate, I would have to modify utils/index (and possibly more) to fetch tags into a different directory. I don't really see a good way of changing that.
And then there is west wanting to have zephyr repository in the base directory/"top dir"...

The next (current) iteration uses worktrees, and adds tags prefixed with elixir- to the main repo.

west_manifest=$TOP_DIR/$PROJECT_NAME/west.yml
if [[ -f $west_manifest ]]; then
# Find disabled groups
extra_groups=`cat west-topdir/zephyr/west.yml | yq -r '(.manifest."group-filter" // [])[]' | grep '^-' | sed 's/^-/+/' | paste -s -d,`
Copy link
Member

@tleb tleb Feb 25, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use Python for YAML manipulation? This pipeline is hardly readable. eg

x='
import yaml
import sys
x = yaml.safe_load(sys.stdin)
# ...'
extra_groups="$(python -c "$x" < west-topdir/zephyr/west.yml)"

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mixing in multiline Python snippets won't make things more readable. I would rather rewrite the whole script in Python. For now I have split the pipeline into two and added a comment.

@tleb tleb mentioned this pull request Feb 25, 2025
@fstachura fstachura force-pushed the zephyr-converter branch 4 times, most recently from 3c1af40 to 42ed877 Compare February 28, 2025 22:30
@fstachura fstachura marked this pull request as ready for review March 4, 2025 13:05
@fstachura fstachura changed the title WIP: Add script for converting Zephyr repository Add script for converting Zephyr repository Mar 5, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants