Forums

Skip to content

Advanced search
  • Quick links
    • Unanswered topics
    • Active topics
    • Search
  • FAQ
  • Login
  • Register
  • Board index Assistance Unsupported Software
  • Search

How to emerge a package from a private repo [SOLVED]

This forum covers all Gentoo-related software not officially supported by Gentoo. Ebuilds/software posted here might harm the health and stability of your system(s), and are not supported by Gentoo developers. Bugs/errors caused by ebuilds from overlays.gentoo.org are covered by this forum, too.
Post Reply
Advanced search
19 posts • Page 1 of 1
Author
Message
halcon
l33t
l33t
User avatar
Posts: 734
Joined: Sun Dec 15, 2019 8:54 pm

How to emerge a package from a private repo [SOLVED]

  • Quote

Post by halcon » Thu Mar 19, 2026 5:44 pm

I asked Google about it and got this answer from its AI.

Will it really work or AI just invented it?

-------------------

To emerge a package from a private GitHub repository, you must authenticate the
git fetch process. The most secure methods are setting up SSH keys (recommended)
or using a Personal Access Token (PAT) with a git credential helper. The SRC_URI
should ideally use SSH, or HTTP with credential helpers, rather than embedding
passwords directly.

Recommended Approaches

1. Using SSH Keys (Most Secure)

Generate an SSH key: ssh-keygen -t ed25519 -C "your_email@example.com".
Add the public key to your GitHub account.
Ensure ssh-agent is running: eval "$(ssh-agent -s)" and ssh-add ~/.ssh/id_ed25519.
Update SRC_URI in your ebuild:
ebuild

SRC_URI="git://git@github.com/username/repo.git"

2. Using HTTPS with Personal Access Token (PAT)

Generate a PAT (classic) in GitHub: Settings > Developer Settings > Personal access tokens.
Configure git to store credentials: git config --global credential.helper store.
Run a manual git clone once to cache it: git clone https://github.com/username/repo.git.
When prompted, use your username and the PAT as the password.
Use standard HTTPS in SRC_URI.
Last edited by halcon on Sun Mar 22, 2026 6:35 pm, edited 1 time in total.
A wife asks her husband, a programmer:
- Could you please go shopping for me and buy one carton of milk, and if they have eggs, get 6?
He comes back with 6 cartons of milk.
- Why did you buy 6 cartons of milk?
- They had eggs.
Top
pingtoo
Advocate
Advocate
User avatar
Posts: 2180
Joined: Fri Sep 10, 2021 8:37 pm
Location: Richmond Hill, Canada

  • Quote

Post by pingtoo » Thu Mar 19, 2026 6:18 pm

Now knowing what exactly your "prompt" so I tried with your subject line with Gemini (Not the google search page) and I got
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?
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.
Top
halcon
l33t
l33t
User avatar
Posts: 734
Joined: Sun Dec 15, 2019 8:54 pm

  • Quote

Post by halcon » Thu Mar 19, 2026 6:28 pm

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 :)
A wife asks her husband, a programmer:
- Could you please go shopping for me and buy one carton of milk, and if they have eggs, get 6?
He comes back with 6 cartons of milk.
- Why did you buy 6 cartons of milk?
- They had eggs.
Top
pingtoo
Advocate
Advocate
User avatar
Posts: 2180
Joined: Fri Sep 10, 2021 8:37 pm
Location: Richmond Hill, Canada

  • Quote

Post by pingtoo » Thu Mar 19, 2026 6:33 pm

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 :)
Sorry that I misunderstand your intent.

I think the Gemini's answer to some degree address your question.

And it just happen I also doing some development which utilize Github and I learn today that there is Github CLI "gh" I think it may be something you could use for using a Github private repo. (As some kind of replacement for the curl/wget download command used in emerge or git command for checkout)
Top
halcon
l33t
l33t
User avatar
Posts: 734
Joined: Sun Dec 15, 2019 8:54 pm

  • Quote

Post by halcon » Thu Mar 19, 2026 6:44 pm

pingtoo wrote:Sorry that I misunderstand your intent.
No problem.

It is a pleasure just to talk :)
pingtoo wrote:I also doing some development
Yeah. Also. And I think what is less time requiring - moving between different repos, or installing with this approach.
pingtoo wrote:As some kind of replacement for the curl/wget download command used in emerge
Or maybe just to use ebuild command, and simulate the fetch step manually.

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...

EDIT
moving between different repos
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.
Github can't deploy for Gentoo, right?
A wife asks her husband, a programmer:
- Could you please go shopping for me and buy one carton of milk, and if they have eggs, get 6?
He comes back with 6 cartons of milk.
- Why did you buy 6 cartons of milk?
- They had eggs.
Top
pingtoo
Advocate
Advocate
User avatar
Posts: 2180
Joined: Fri Sep 10, 2021 8:37 pm
Location: Richmond Hill, Canada

  • Quote

Post by pingtoo » Thu Mar 19, 2026 7:05 pm

halcon wrote:
pingtoo wrote:Sorry that I misunderstand your intent.
No problem.

It is a pleasure just to talk :)
pingtoo wrote:I also doing some development
Yeah. Also. And I think what is less time requiring - moving between different repos, or installing with this approach.
pingtoo wrote:As some kind of replacement for the curl/wget download command used in emerge
Or maybe just to use ebuild command, and simulate the fetch step manually.

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...

EDIT
moving between different repos
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.
Github can't deploy for Gentoo, right?
I am not sure what do you mean by "Github can't deploy for Gentoo"

As for doing download in ebuild, please note that it is discouraged do so in configure/unpack/compile phase, some FEATURES default will prevent you from doing that. the download phase it usually not place inside a ebuild script but an automated step as part of emerge. so the SRC_URI become impotent to identify where to download.

I don't know much of detail on how to work with ebuild. 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.
Top
halcon
l33t
l33t
User avatar
Posts: 734
Joined: Sun Dec 15, 2019 8:54 pm

  • Quote

Post by halcon » Thu Mar 19, 2026 7:23 pm

Pingtoo wrote:I am not sure what do you mean by "Github can't deploy for Gentoo"
I mean GitHub actions like that:

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/erp
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...

It would be fantastic if GitHub actions include installing a certain commit from a certain branch in Gentoo via emerge, and e.g running integral tests.
Pingtoo wrote:As for doing download in ebuild, please note that it is discouraged
Yes, I know. I thought you were suggesting to do so when saying this:
Pingtoo wrote:As some kind of replacement for the curl/wget download command used in emerge
Pingtoo wrote:I don't know much of detail on how to work with ebuild.
It is not difficult. An ebuild command for each main phase.
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.
May be. I created it here as I believed that private repos can be something not supported. Let it be here for some time.
Last edited by halcon on Thu Mar 19, 2026 7:46 pm, edited 1 time in total.
A wife asks her husband, a programmer:
- Could you please go shopping for me and buy one carton of milk, and if they have eggs, get 6?
He comes back with 6 cartons of milk.
- Why did you buy 6 cartons of milk?
- They had eggs.
Top
pingtoo
Advocate
Advocate
User avatar
Posts: 2180
Joined: Fri Sep 10, 2021 8:37 pm
Location: Richmond Hill, Canada

  • Quote

Post by pingtoo » Thu Mar 19, 2026 7:40 pm

halcon wrote:...
Pingtoo wrote:As for doing download in ebuild, please note that it is discouraged
Yes, I know. I thought you were suggesting to do so when saying this:
Pingtoo wrote:As some kind of replacement for the curl/wget download command used in emerge
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/release
Top
halcon
l33t
l33t
User avatar
Posts: 734
Joined: Sun Dec 15, 2019 8:54 pm

  • Quote

Post by halcon » Thu Mar 19, 2026 7:43 pm

An ebuild command for each main phase.
You posted an example of it here:
Pingtoo wrote:3. Run `ebuild <path-to-ebuild> manifest` to generate the checksums.
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?
Last edited by halcon on Thu Mar 19, 2026 7:48 pm, edited 1 time in total.
A wife asks her husband, a programmer:
- Could you please go shopping for me and buy one carton of milk, and if they have eggs, get 6?
He comes back with 6 cartons of milk.
- Why did you buy 6 cartons of milk?
- They had eggs.
Top
halcon
l33t
l33t
User avatar
Posts: 734
Joined: Sun Dec 15, 2019 8:54 pm

  • Quote

Post by halcon » Thu Mar 19, 2026 7:44 pm

Pingtoo wrote:FETCHCOMMAND and RESUMECOMMAND
Ah, interesting, I was not aware of them. Thanks.
A wife asks her husband, a programmer:
- Could you please go shopping for me and buy one carton of milk, and if they have eggs, get 6?
He comes back with 6 cartons of milk.
- Why did you buy 6 cartons of milk?
- They had eggs.
Top
flexibeast
l33t
l33t
Posts: 679
Joined: Mon Apr 04, 2022 4:15 am
Location: Naarm/Melbourne, Australia
Contact:
Contact flexibeast
Website

  • Quote

Post by flexibeast » Thu Mar 19, 2026 10:01 pm

halcon wrote:This is why I am asking: did anyone here use emerge for installing from a private repo?
Append the name of the repo (e.g. 'private') to the package name, e.g.:

Code: Select all

# emerge dev-util/program::private
https://wiki.gentoo.org/wiki/User:Flexibeast
My most recent wiki contributions
Top
halcon
l33t
l33t
User avatar
Posts: 734
Joined: Sun Dec 15, 2019 8:54 pm

  • Quote

Post by halcon » Fri Mar 20, 2026 5:21 am

flexibeast wrote:

Code: Select all

# emerge dev-util/program::private
This is not repo. This is overlay.

These words can be used as synonyms, but in this topic repo = git repo with program sources, written in SRC_URI.

Well, I think I will test it out sooner than get an answer :)
A wife asks her husband, a programmer:
- Could you please go shopping for me and buy one carton of milk, and if they have eggs, get 6?
He comes back with 6 cartons of milk.
- Why did you buy 6 cartons of milk?
- They had eggs.
Top
halcon
l33t
l33t
User avatar
Posts: 734
Joined: Sun Dec 15, 2019 8:54 pm

  • Quote

Post by halcon » Fri Mar 20, 2026 5:51 am

Found the same question here.

And nobody says that he tried that and it worked, but "probably", "should"... :)

I am going to test it and be the first who will say if it really work or no :)
A wife asks her husband, a programmer:
- Could you please go shopping for me and buy one carton of milk, and if they have eggs, get 6?
He comes back with 6 cartons of milk.
- Why did you buy 6 cartons of milk?
- They had eggs.
Top
pingtoo
Advocate
Advocate
User avatar
Posts: 2180
Joined: Fri Sep 10, 2021 8:37 pm
Location: Richmond Hill, Canada

  • Quote

Post by pingtoo » Fri Mar 20, 2026 2:30 pm

halcon,

Because FETCHCOMMAND is a global setting affect every emerge build process. So I have a idea may be you can consider,

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 use a logic either call gh (Github CLI) or curl with github API endpoint (https://api.github.com/) with the private repo's Personal Access Token (PAT) that way you can continue to work in standard emerge procedure.

And BTW, the default FETCHCOMMAND value you can get it from command

Code: Select all

portageq envvar FETCHCOMMAND
Top
halcon
l33t
l33t
User avatar
Posts: 734
Joined: Sun Dec 15, 2019 8:54 pm

  • Quote

Post by halcon » Fri Mar 20, 2026 3:35 pm

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]
Thank you for that suggestion, it makes sense.

I already have a working emerge wrapper and I think may be I will add this functionality to it. Or may be I will follow your suggestion.

I am figuring out how it all should work, cons and pros.
A wife asks her husband, a programmer:
- Could you please go shopping for me and buy one carton of milk, and if they have eggs, get 6?
He comes back with 6 cartons of milk.
- Why did you buy 6 cartons of milk?
- They had eggs.
Top
halcon
l33t
l33t
User avatar
Posts: 734
Joined: Sun Dec 15, 2019 8:54 pm

  • Quote

Post by halcon » Fri Mar 20, 2026 6:14 pm

Meanwhile, about Github actions.
halcon 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...
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 it :)
A wife asks her husband, a programmer:
- Could you please go shopping for me and buy one carton of milk, and if they have eggs, get 6?
He comes back with 6 cartons of milk.
- Why did you buy 6 cartons of milk?
- They had eggs.
Top
halcon
l33t
l33t
User avatar
Posts: 734
Joined: Sun Dec 15, 2019 8:54 pm

  • Quote

Post by halcon » Sun Mar 22, 2026 6:34 pm

Well. I found the easiest way to achieve my goal.

A local overlay.
A local repo with sources (pulled from remote origin). The version A.B.C set in the tags.

In the ebuild:

Code: Select all

inherit git-r3

EGIT_REPO_URI="file:///path/to/repo"
EGIT_COMMIT="vA.B.C"
File metadata/layout.conf in the overlay:

Code: Select all

masters = gentoo
thin-manifests = true
manifest-hashes = BLAKE2B SHA512
manifest-required-hashes = BLAKE2B
And I confirm, it works.
And I confirm, Gentoo rocks :)

No need in emerge wrappers, in make.conf tweaking, in storing credentails, in nothing more.

Easy.

Marking the topic as solved.
A wife asks her husband, a programmer:
- Could you please go shopping for me and buy one carton of milk, and if they have eggs, get 6?
He comes back with 6 cartons of milk.
- Why did you buy 6 cartons of milk?
- They had eggs.
Top
mid-kid
n00b
n00b
Posts: 26
Joined: Sun Aug 24, 2014 9:51 am

  • Quote

Post by mid-kid » Tue Mar 24, 2026 11:53 am

Bit late, but FETCHCOMMAND tweaking is a bad idea - it will affect all your ebuilds. If wget doesn't support what you're trying to do, you can either:
* set SRC_URI to a filename, instead of a URL, and use RESTRICT=fetch. Have the user (or a different program) fetch the files into /var/cache/distfiles. This is done for commercial games you need to buy, for example.
* set FEATURES=network, and write code to fetch the sources in src_unpack. This is what git-r3.eclass does.

Since your question is related to git, you're already using FEATURES=network with git-r3.eclass. Look at how that eclass does things or write your own git cloning routine. What you did works as well, I suppose. Keep in mind that the ebuild environment runs with an empty $HOME directory, so if you need ssh keys or configurations, you'll have to copy them in from portage:portage visible files and folders.
Top
halcon
l33t
l33t
User avatar
Posts: 734
Joined: Sun Dec 15, 2019 8:54 pm

  • Quote

Post by halcon » Tue Mar 24, 2026 1:46 pm

mid-kid wrote:Bit late, but ...
Better late than never! :)

Thank you, it is an useful addition to the topic.
A wife asks her husband, a programmer:
- Could you please go shopping for me and buy one carton of milk, and if they have eggs, get 6?
He comes back with 6 cartons of milk.
- Why did you buy 6 cartons of milk?
- They had eggs.
Top
Post Reply

19 posts • Page 1 of 1

Return to “Unsupported Software”

Jump to
  • Assistance
  • ↳   News & Announcements
  • ↳   Frequently Asked Questions
  • ↳   Installing Gentoo
  • ↳   Multimedia
  • ↳   Desktop Environments
  • ↳   Networking & Security
  • ↳   Kernel & Hardware
  • ↳   Portage & Programming
  • ↳   Gamers & Players
  • ↳   Other Things Gentoo
  • ↳   Unsupported Software
  • Discussion & Documentation
  • ↳   Documentation, Tips & Tricks
  • ↳   Gentoo Chat
  • ↳   Gentoo Forums Feedback
  • ↳   Duplicate Threads
  • International Gentoo Users
  • ↳   中文 (Chinese)
  • ↳   Dutch
  • ↳   Finnish
  • ↳   French
  • ↳   Deutsches Forum (German)
  • ↳   Diskussionsforum
  • ↳   Deutsche Dokumentation
  • ↳   Greek
  • ↳   Forum italiano (Italian)
  • ↳   Forum di discussione italiano
  • ↳   Risorse italiane (documentazione e tools)
  • ↳   Polskie forum (Polish)
  • ↳   Instalacja i sprzęt
  • ↳   Polish OTW
  • ↳   Portuguese
  • ↳   Documentação, Ferramentas e Dicas
  • ↳   Russian
  • ↳   Scandinavian
  • ↳   Spanish
  • ↳   Other Languages
  • Architectures & Platforms
  • ↳   Gentoo on ARM
  • ↳   Gentoo on PPC
  • ↳   Gentoo on Sparc
  • ↳   Gentoo on Alternative Architectures
  • ↳   Gentoo on AMD64
  • ↳   Gentoo for Mac OS X (Portage for Mac OS X)
  • Board index
  • All times are UTC
  • Delete cookies

© 2001–2026 Gentoo Foundation, Inc.

Powered by phpBB® Forum Software © phpBB Limited

Privacy Policy