oasislinux / oasis

a small statically-linked linux system
Other
2.75k stars 84 forks source link

"git merge oasis" #3

Closed finnoleary closed 6 years ago

finnoleary commented 6 years ago

When installing oasis, everything runs smoothly until

$ cd $ROOT
$ git merge oasis
merge: oasis - not something we can merge
finnoleary commented 6 years ago

Wiped and repeated the steps, works now ¯_(ツ)_/¯

michaelforney commented 6 years ago

Thanks for trying it out. Don't hesitate to open new issues if you run into anything else (or even just have any suggestions for improving the install guide).

finnoleary commented 6 years ago

Overall, my main complaint is that there isn't a deeper walkthrough of the install system and (specifically) how to add a package. Trying to reverse engineer this was a nightmare with half a dozen hundred line ninja scripts, there didn't seem to be any obvious part that did the pulling, and building.

michaelforney commented 6 years ago

Okay, thanks for the feedback. I'll see if I can put together a document describing this.

But, here is a quick overview: gen.rc is an rc script which writes a ninja file to stdout. It usually makes use of the helper functions in ninja.rc to output rules and actions. The action to fetch the sources is emitted through the fetch function, which can fetch either with curl based on the url and sha256 files, or git with a submodule. The commands themselves are listed in rules.ninja.

setup.rc is what actually writes the local.ninja files (and calls gen.rc), and sets up srcdir and outdir for the package (as well as a rule to regenerate local.ninja when gen.rc changes).

So, to add a new package, you'd create a directory for it and write a gen.rc with something like

exe foo foo.c
fetch git

Then, you'd update pkg/gen.rc with subgen foo to tell the build system to recurse into the foo directory.

I think one potential tripping point is setup.rc uses the presence of the rev file in a directory to determine if there are downloadable sources, and if so sets srcdir = $dir/src (the src directory in the repository root does not fetch sources), so you need to create this as well. Whenever rev is bumped, the package sources are redownloaded (in case of a version update or patch change).

Perhaps https://github.com/michaelforney/oasis/commit/3282029cb9e6e7c5338f2c34ee831b6b4b7dcb16 is a good example.

hovind commented 6 years ago

@finnoleary Any idea what went wrong on your first try? I am experiencing the same issue.

michaelforney commented 6 years ago

Hi @hovind,

I recently updated the output repository configuration to be in config.lua with everything else rather than split between config.ninja. Looks like I forgot to update the install documentation to reflect this.

Anyway, ninja commit should be writing a new commit object to the repository specified by config.repo.path in the branch specified by config.repo.branch. Perhaps your config.lua is configured to write the commit to the master branch of $builddir/root.git (which is the default in config.def.lua). Either setup is possible, you can have oasis builds written to a bare $builddir/root.git and then pull from that into your repository in /, or you can have oasis builds written directly to a separate oasis branch in the / repository, and merge that branch into master. The latter is recommended in the install guide since you don't have to keep around multiple repositories (and updates are faster).

Hopefully that helps!

a-schaefers commented 4 years ago

A little late to the party, but just wanted to say that I too am running in to this, and I have to wonder how many others have, now too, and might have just given up. The docs are just not clear on this point still and I'm somewhat baffled. I will keep trying. If I can get it figured out maybe I will try to help with the wiki some. Thanks.

a-schaefers commented 4 years ago

Currently I have

        -- output git repository
        repo={
                path='../..',
                flags='',
                tag='tree',
                branch='',
        },

and get this output


[6005/6005] sh ./scripts/commit.sh ../..  tree out/root.commit
FAILED: out/root.commit 
sh ./scripts/commit.sh ../..  tree out/root.commit
fatal: Not a valid object name out/root.commit
ninja: build stopped: subcommand failed.

This is my second attempt, after being unable to "git merge oasis" on the first attempt, finding this, and changing the config.lua as such

michaelforney commented 4 years ago

Looks like you specified an empty repo.branch which specifies which branch to commit the new root tree. This is causing the commit.sh script to interpret out/root.commit as the tree, which is not a valid tree object in the git repository.

I pushed a commit to add checks to the scripts that they got the right number of parameters, which should prevent this type of configuration issue in the future.