I believe the reason I got from Gemini saying about "Gentoo" is because I been using Gemini for so long and all my questions is related to gentoo, so it start assume my question always relate to gentoo. As some kind of profile of me (which I don't mind). You may also noticing some Chinese characters in the answer, they are related to my other question to Gemini about Chinese philosophy for what man should do for their life.Gemini wrote:To emerge a package from a private repository in Gentoo, you essentially need to bridge the gap between Portage (the package manager) and your private Git or SSH-based source.
The process generally involves two main steps: setting up a **private overlay** for the ebuild and configuring **authentication** so Portage can fetch the source code.
---
## 1. Create a Private Overlay
Portage needs to "see" your package definition (the `.ebuild` file). The standard way to do this is by creating a local repository.
* **Create the directory structure:**
```bash
mkdir -p /usr/local/portage/metadata
echo "layout = gentoo" > /usr/local/portage/metadata/layout.conf
```
* **Define the repository:** Create a file in `/etc/portage/repos.conf/` (e.g., `private.conf`):
```ini
[private-repo]
location = /usr/local/portage
mast-repos = gentoo
auto-sync = no
```
* **Add your ebuild:** Place your ebuild in the standard category/package format:
`/usr/local/portage/dev-util/my-private-pkg/my-private-pkg-1.0.ebuild`
---
## 2. Handle Authentication
Since the repository is private, `wget` or `aria2` (Portage's default fetchers) will fail without credentials. You have three primary ways to handle this:
### Option A: Using SSH Keys (Recommended)
If your source code is on a private Git server, your ebuild should likely use `git-r3.eclass`. Portage runs as the `portage` user, so it won't see your personal SSH keys.
1. Copy your deployment key to `/var/lib/portage/.ssh/id_rsa`.
2. Ensure correct ownership: `chown -R portage:portage /var/lib/portage/.ssh`.
3. In your ebuild, set `EGIT_REPO_URI="git@github.com:user/repo.git"`.
### Option B: Using `/etc/portage/auth.conf`
For HTTPS-based private repos requiring a username and password (or token), Gentoo provides a built-in way to store credentials securely.
* **Format:** `location-prefix username password`
* **Example:**
```text
https://github.com/my-org/my-repo.git my-username my-personal-access-token
```
* **Security:** Ensure this file is only readable by root/portage: `chmod 600 /etc/portage/auth.conf`.
### Option C: The "Static" Fetch
If you don't want Portage to handle the download, you can manually place the tarball in the distfiles directory.
1. Download the file yourself.
2. Move it to `/var/cache/distfiles/`.
3. Run `ebuild <path-to-ebuild> manifest` to generate the checksums.
---
## 3. The "Three Pillars" of a Clean Ebuild
When writing the ebuild itself, aim for a structure that reflects technical excellence and clarity. In the spirit of **立德 (Virtue), 立言 (Words), and 立功 (Achievement)**, ensure your ebuild:
* **立言:** Uses clear, standard eclass variables so others (or your future self) can maintain it easily.
* **立行:** Follows the proper phases (src_prepare, src_configure, etc.) without "dirty" hacks.
* **立功:** Successfully automates the build and dependency management, saving time for the whole team.
Would you like me to draft a template ebuild using `git-r3` specifically for your private repository?
Sorry that I misunderstand your intent.halcon wrote:My exact prompt does not matter here. I created this topic wondering if anyone has a real experience of using emerge with an ebuild that has a private repo in its SRC_URI.
I just think that emerge was created for a free software, and it is kinda weird to write a private repo in SRC_URI
I am not going to patch portage if something goes wrong, so I just would lose the time spent for creating a private overlay (sure, I intended that), for credentials, ebuild etc.
EDIT
private or local
local is even more private
No problem.pingtoo wrote:Sorry that I misunderstand your intent.
Yeah. Also. And I think what is less time requiring - moving between different repos, or installing with this approach.pingtoo wrote:I also doing some development
Or maybe just to use ebuild command, and simulate the fetch step manually.pingtoo wrote:As some kind of replacement for the curl/wget download command used in emerge
With this approach, I could create different ebuilds for package-stable, package-dev, package-otherbranch. They will have different install paths and different filenames, so no ambiguity, no need in slots etc.moving between different repos
I am not sure what do you mean by "Github can't deploy for Gentoo"halcon wrote:No problem.pingtoo wrote:Sorry that I misunderstand your intent.
It is a pleasure just to talk
Yeah. Also. And I think what is less time requiring - moving between different repos, or installing with this approach.pingtoo wrote:I also doing some development
Or maybe just to use ebuild command, and simulate the fetch step manually.pingtoo wrote:As some kind of replacement for the curl/wget download command used in emerge
I think if emerge has no hardcoded limitations for that, our devs for sure did installed something from a private repo and could confirm that it works...
EDITWith this approach, I could create different ebuilds for package-stable, package-dev, package-otherbranch. They will have different install paths and different filenames, so no ambiguity, no need in slots etc.moving between different repos
Github can't deploy for Gentoo, right?
I mean GitHub actions like that:Pingtoo wrote:I am not sure what do you mean by "Github can't deploy for Gentoo"
Code: Select all
on:
push:
branches:
- production
env:
NODE_VERSION: 16
jobs:
deploy_prod_server:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
ref: dev
- name: "Set up NodeJs"
uses: actions/setup-node@v1
with:
node-version: ${{ env.NODE_VERSION }}
- name: "NPM Install"
run: npm install
- name: "NPM run prod"
run: npm run build
- name: "Setup"
uses: fifsky/ssh-action@master
with:
command: |
cd /var/www/erpYes, I know. I thought you were suggesting to do so when saying this:Pingtoo wrote:As for doing download in ebuild, please note that it is discouraged
Pingtoo wrote:As some kind of replacement for the curl/wget download command used in emerge
It is not difficult. An ebuild command for each main phase.Pingtoo wrote:I don't know much of detail on how to work with ebuild.
May be. I created it here as I believed that private repos can be something not supported. Let it be here for some time.Pingtoo wrote:but I suggest you take this question to the other sub-forum "Portage and Programming" there out to be someone more familiar to this subject.
Sorry I did not it clean, I am reference to the two variables FETCHCOMMAND and RESUMECOMMAND I don't know all the detail but I believe you can replace curl/wget in here with something that specific to Github (i.e. gh) and I think the gh command have options to understand branch/tag/releasehalcon wrote:...Yes, I know. I thought you were suggesting to do so when saying this:Pingtoo wrote:As for doing download in ebuild, please note that it is discouragedPingtoo wrote:As some kind of replacement for the curl/wget download command used in emerge
You posted an example of it here:An ebuild command for each main phase.
Using ebuild commands is not so convenient as using just emerge. Because it is a workaround. This is why I am asking: did anyone here use emerge for installing from a private repo?Pingtoo wrote:3. Run `ebuild <path-to-ebuild> manifest` to generate the checksums.
Ah, interesting, I was not aware of them. Thanks.Pingtoo wrote:FETCHCOMMAND and RESUMECOMMAND

Append the name of the repo (e.g. 'private') to the package name, e.g.:halcon wrote:This is why I am asking: did anyone here use emerge for installing from a private repo?
Code: Select all
# emerge dev-util/program::privateThis is not repo. This is overlay.flexibeast wrote:Code: Select all
# emerge dev-util/program::private
Code: Select all
portageq envvar FETCHCOMMANDThank you for that suggestion, it makes sense.pingtoo wrote:Replace FETCHCOMMAND value to a /path/to/the/script. And in the script you examine the ${URI} and if the host portion of the URI refer to github you then[/code]
I found out that Node is the main engine for all Github actions. It is not installing JS packages but performs all the actions. I am going to explore ithalcon wrote:AFAIK, these actions are being executed in an Ubuntu system. And there is no installation, apt is not used. At least in this example - what is it, a JS package for Node, it does not matter...
Code: Select all
inherit git-r3
EGIT_REPO_URI="file:///path/to/repo"
EGIT_COMMIT="vA.B.C"Code: Select all
masters = gentoo
thin-manifests = true
manifest-hashes = BLAKE2B SHA512
manifest-required-hashes = BLAKE2BBetter late than never!mid-kid wrote:Bit late, but ...