How can I save and then install from ftp all installed packages?

I found small script:
# for p in `\ls /var/db/pkg`; do pkg_create -b ${p}; done
is there a standard command for this operation ?
and then how to create an INDEX file ?
 
Andrey said:
I found small script:
# for p in `\ls /var/db/pkg`; do pkg_create -b ${p}; done
is there a standard command for this operation ?
If there was the script wouldn't be needed.
 
So how can I make INDEX file from /var/db/pkg ?
[CMD=""]# cache-init[/CMD] cache-init works only with the /usr/ports? from /var/db/pkg it can not do INDEX?
Even if I set
[CMD=""]# setenv PORTSDIR /var/db/pkg[/CMD]
 
Andrey said:
So how can I make INDEX file from /var/db/pkg ?
[CMD=""]# cache-init[/CMD] cache-init works only with the /usr/ports?

No idea what that command is or does.

from /var/db/pkg it can not do INDEX?
Even if I set
[CMD=""]# setenv PORTSDIR /var/db/pkg[/CMD]

Setting PORTSDIR elsewhere may not do what you want. And that is really the question: what are you trying to do? Are you trying to duplicate all the packages installed on one system onto another system?
 
Yes, I trying to duplicate the system, and simultaneously stored all packages on a CD, FLASH or local FTP... for faster installation than via the internet...
 
Andrey said:
I found small script:
# for p in `\ls /var/db/pkg`; do pkg_create -b ${p}; done
is there a standard command for this operation ?
and then how to create an INDEX file ?

First, what is it that you are trying to accomplish, exactly? Are you just wanting to build packages on one machine and then install them on other machines? Are you trying to create a local package mirror? Something else?

Knowing what your goal is, will make it easier for people to make suggestions.

For example, if all you want to do is build packages on MachineA and then install them on Machines B through Q, the process is along the lines of:
  1. Create /usr/ports/packages/ directory
  2. Set PACKAGES=/usr/ports/packages in your shell's environment
  3. Use make package-recursive to install your apps (or use portmaster(8) configured to save packages); packages will be saved under /usr/ports/packages/
  4. Export /usr/ports/packages/ via NFS
  5. Mount the packages export onto the client machines
  6. Then use pkg_add(1) from within the NFS packages directory to install the packages. Since all the dependencies are also in that directory, everything is installed via packages.
 
phoenix said:
  1. Create /usr/ports/packages/ directory
  2. Set PACKAGES=/usr/ports/packages in your shell's environment
$PORTSDIR/packages is the default ;)
 
make package-recursive - start downloading all packages from the Internet :(

dump, restore - good method, but I want to keep everything in packages.tbz as
ftp://ftp.freebsd.org/pub/FreeBSD/ports/i386/packages-8.1-release/Latest/

I decided to do so:
# for p in `\ls /var/db/pkg`; do echo pkg_add -i ${p}.tbz >> install; done; chmod +x install

will generate a file
Code:
pkg_add -i ImageMagick-6.6.1.10.tbz
pkg_add -i ORBit2-2.14.18_1.tbz
pkg_add -i Terminal-0.4.5.tbz
pkg_add -i Thunar-1.0.2.tbz
pkg_add -i a2ps-a4-4.13b_4.tbz
pkg_add -i aalib-1.4.r5_5.tbz
...
 
Andrey said:
# for p in `\ls /var/db/pkg`; do echo pkg_add -i ${p}.tbz >> install; done; chmod +x install

Backslash looks unnecessary. But then...

Code:
pkg_add -i ImageMagick-6.6.1.10.tbz
pkg_add -i ORBit2-2.14.18_1.tbz
pkg_add -i Terminal-0.4.5.tbz
pkg_add -i Thunar-1.0.2.tbz
pkg_add -i a2ps-a4-4.13b_4.tbz
pkg_add -i aalib-1.4.r5_5.tbz
...

Seems like you could just do
# pkg_add -i packagedir/*

or maybe

# file packagedir -exec pkg_add -i {} \+

(Untested, and not sure about the correctness of using -i and installing packages out of dependency order.)
 
wblock said:
Seems like you could just do
# pkg_add -i packagedir/*

or maybe

# file packagedir -exec pkg_add -i {} \+

(Untested, and not sure about the correctness of using -i and installing packages out of dependency order.)
no your commands do not work...

but like this all ok!
[CMD=""]# cd /packagedir[/CMD]
[CMD=""]# for p in `ls *.tbz`; do pkg_add -i ${p}; done;[/CMD]
 
With verify that do not install already installed packages
[CMD=""]# cd /packagedir[/CMD]
[CMD=""]# for p in `ls *.tbz`; do if [ ! -d /var/db/pkg/${p%.*} ]; then pkg_add -i ${p}; fi; done;[/CMD]
 
You can simplify the for loop a bit:
# for p in *.tbz; ...

The shell expansion of *.tbz will be the same as executing ls in a sub-shell, but it should be faster/more efficient.
 
Back
Top