Solved pkg(8) ignored "PACKAGESITE" environment variable

Hi All

I'm trying to use pkg(7) with local repository.
And need change repository dynamically working for jail(7)

I had saw in pkg(7) section CONFIGURATION
Code:
url           Refer to    PACKAGESITE in "ENVIRONMENT"

My work fine configure of repository: /usr/local/etc/pkg/repos/barfoo.conf
Code:
BARFOO_PKG: {                                                                                                                                                                                              
    url: "file://[WORK_FINE_REPOS]",
    enabled: yes
}

Disabled original FreeBSD repository /usr/local/etc/pkg/repos/FreeBSD.conf
Code:
FreeBSD: {
    enabled: no
}

FreeBSD-kmods: {
    enabled: no
}

And reference other thread about PACKAGESITE, my test procedure...
  1. Modified /usr/local/etc/pkg/repos/barfoo.conf
    Code:
    BARFOO_PKG: {                                                                                                                                                                                              
        url: "file://[NOT_EXIST_REPOS]",
        enabled: yes
    }
  2. Set PACKAGESITE environment variable with work fine repository
    setenv PACKAGESITE "file://[WORK_FINE_REPOS]"
  3. Execute pkg(7)
    # /usr/local/sbin/pkg --debug install --dry-run zip
  4. Result:
    Code:
    Updating BARFOO_PKG repository catalogue...DBG(1)[56927]> PkgRepo: verifying update for BARFOO_PKG
    pkg: Repository BARFOO_PKG has a wrong packagesite, need to re-create database
    DBG(1)[56927]> PkgRepo: need forced update of BARFOO_PKG
    DBG(1)[56927]> Pkgrepo, begin update of '/var/db/pkg/repos/BARFOO_PKG/db'
    DBG(1)[56927]> (fetch) Request to fetch file://[NOT_EXIST_REPOS]/meta.conf
    DBG(1)[56927]> (fetch) Request to fetch file://[NOT_EXIST_REPOS]/meta.txz
    pkg: file://[NOT_EXIST_REPOS]/meta.txz: No such file or directory
    repository BARFOO_PKG has no meta file, using default settings
    DBG(1)[56927]> (fetch) Request to fetch file://[NOT_EXIST_REPOS]/data.pkg
    pkg: file://[NOT_EXIST_REPOS]/data.pkg: No such file or directory
    DBG(1)[56927]> (fetch) Request to fetch file://[NOT_EXIST_REPOS]/data.tzst
    pkg: file://[NOT_EXIST_REPOS]/data.tzst: No such file or directory
    DBG(1)[56927]> (fetch) Request to fetch file://[NOT_EXIST_REPOS]/packagesite.pkg
    pkg: file://[NOT_EXIST_REPOS]/packagesite.pkg: No such file or directory
    DBG(1)[56927]> (fetch) Request to fetch file://[NOT_EXIST_REPOS]/packagesite.tzst
    pkg: file://[NOT_EXIST_REPOS]/packagesite.tzst: No such file or directory
    Unable to update repository BARFOO_PKG
    Error updating repositories!
pkg(7) always using url of /usr/local/etc/pkg/repos/barfoo.conf, ignored my wishing PACKAGESITE

Would all help me?
Thanks a lot.
 
In fact, you are using pkg(8), not pkg(7). The only use of this last is to bootstrap pkg(8).

And pkg(8) (as well as his brother pkg-static) is ignoring PACKAGESITE as stated here:
pkg.conf(5)
Note that pkg(7) uses PACKAGESITE for the URL to download pkg(8) from,
and subsequently passes it in the environment to pkg-static(8), which
ignores it (possibly with a deprecation warning that should be ig-
nored), and reads the configuration files instead.
 
In fact, you are using pkg(8), not pkg(7). The only use of this last is to bootstrap pkg(8).

And pkg(8) (as well as his brother pkg-static) is ignoring PACKAGESITE as stated here:
pkg.conf(5)
Hi Emrion

Thanks you,

I have workaround with REPOS_DIR environment variable as follows
  1. # setenv REPOS_DIR "/tmp"
  2. Create /tmp/barfoo.conf with follows content.
    Code:
    BARFOO_PKG: {
        url: "file://[WORK_FINE_REPOS]",
        enabled: yes
    }
  3. Execute # pkg --debug install --dry-run zip and result
    Code:
    Updating BARFOO_PKG repository catalogue...
    DBG(1)[68132]> PkgRepo: verifying update for BARFOO_PKG
    DBG(1)[68132]> Pkgrepo, begin update of '/var/db/pkg/repos/BARFOO_PKG/db'
    DBG(1)[68132]> (fetch) Request to fetch file://[WORK_FINE_REPOS]/meta.conf
    DBG(1)[68132]> (fetch) Request to fetch file://[WORK_FINE_REPOS]/data.pkg
    BARFOO_PKG repository is up to date.
    All repositories are up to date.
    DBG(1)[68132]> (solver) problem has no requests
    Checking integrity...DBG(1)[68132]> (jobs) check integrity for 0 items added
    done (0 conflicting)
    The most recent versions of packages are already installed
  4. Re-create /tmp/barfoo.conf with follows content.
    Code:
    BARFOO_PKG: {
        url: "file://[NOT_EXIST_REPOS]",
        enabled: yes
    }
  5. Execute # pkg --debug install --dry-run zip and result
    Code:
    Updating BARFOO_PKG repository catalogue...
    DBG(1)[34527]> PkgRepo: verifying update for BARFOO_PKG
    pkg: Repository BARFOO_PKG has a wrong packagesite, need to re-create database
    DBG(1)[34527]> PkgRepo: need forced update of BARFOO_PKG
    DBG(1)[34527]> Pkgrepo, begin update of '/var/db/pkg/repos/BARFOO_PKG/db'
    DBG(1)[34527]> (fetch) Request to fetch file://[NOT_EXIST_REPOS]/meta.conf
    DBG(1)[34527]> (fetch) Request to fetch file://[NOT_EXIST_REPOS]/meta.txz
    pkg: file://[NOT_EXIST_REPOS]/meta.txz: No such file or directory
    repository BARFOO_PKG has no meta file, using default settings
    DBG(1)[34527]> (fetch) Request to fetch file://[NOT_EXIST_REPOS]/data.pkg
    pkg: file://[NOT_EXIST_REPOS]/data.pkg: No such file or directory
    DBG(1)[34527]> (fetch) Request to fetch file://[NOT_EXIST_REPOS]/data.tzst
    pkg: file://[NOT_EXIST_REPOS]/data.tzst: No such file or directory
    DBG(1)[34527]> (fetch) Request to fetch file://[NOT_EXIST_REPOS]/packagesite.pkg
    pkg: file://[NOT_EXIST_REPOS]/packagesite.pkg: No such file or directory
    DBG(1)[34527]> (fetch) Request to fetch file://[NOT_EXIST_REPOS]/packagesite.tzst
    pkg: file://[NOT_EXIST_REPOS]/packagesite.tzst: No such file or directory
    Unable to update repository BARFOO_PKG
    Error updating repositories!
Workable look like, I suppose generate /tmp/barfoo.conf dynamicly for jail(7) need.

Have better solution?

Thanks you very much.
 
Back
Top