# Upgrading ports



## benpptung (Nov 8, 2010)

Everytime I installed a new FreeBSD system, should I tried the following commands after portsnap fetch extract?

`portupgrade -af`
or
`portmaster -a` 

Everytime, I issued the above commands, the system took a lot of time to fetch/checking/compile...I am sure some of the ports is not installed in my system, like freebsd-doc-ru...and since this is a new installed system, there I have not installed any package except /usr/ports/shells/bash .

portupgrade -af | portmaster -a took couple of hours to upgrade my system? It looks like it is rebuilding all the ports, even I didn't install the port.

I really confused what is the difference between portupgrade and port update ?

ps. I use portupgrade for securing system purpose.


----------



## ahavatar (Nov 8, 2010)

benpptung, I was confuesd same when I started to use FreeBSD. 

The best solution I found was

1. Install only the base system as minimal as possible, because packages in the RELEASE installation CD are already quite behind the packages in the current updated port tree. You are gonna update almost all of the packages installed from the CD --- why bother installing them in the first place? 

2. After installation, boot FreeBSD and do [cmd=]portsnap fetch extract[/cmd]

3. Install packages you want using [cmd=]pkg_add -r[/cmd] Now the packages to be installed are newer than the ones in the installation CD. So, your future updating does not try to reinstall/update everthing later.


----------



## benpptung (Nov 8, 2010)

ahavatar said:
			
		

> benpptung, I was confuesd same when I started to use FreeBSD.
> 
> The best solution I found was
> 
> ...



Yes... I did similiar to your way. I skip port tree while installing, and use `portsnap fetch extract` to build the port tree, so I am sure I didn't install port like freebsd-doc-ru... but when I issue `portupgrade -af` ( because I am study securing FreeBSD ), it tooks a very long time to upgrade....in the beginning, I think there are a lot of base lib required to upgrade...but when the dialog window of freebsd-doc-ru appear to ask me to make choice...I doubt... I am sure I skip this already...ru is not my language... so I come to here hope to confirm what exactly the portupgrade is. 

Thank you anyway for your advice...


----------



## benpptung (Nov 8, 2010)

But maybe I am wrong.
I use `portmaster -L` to check how many installed ports, and confirmed the freebsd-doc-ru is an installed port.
But I don't know why it is installed, because this is a fresh new installation, I've just installed bash(for my personal preference) and
portupgrade (because I am going to issue: portupgrade -af).

Don't know when and why freebsd-doc-ru is installed. Maybe I should check their dependency.


----------



## wblock@ (Nov 8, 2010)

benpptung said:
			
		

> But maybe I am wrong.
> I use `portmaster -L` to check how many installed ports, and confirmed the freebsd-doc-ru is an installed port.
> But I don't know why it is installed, because this is a fresh new installation



All the localized versions of the docs are installed when you install misc/freebsd-doc-all, probably as part of the original install.  Deinstall that meta-port with pkg_delete(1) and then deinstall the individual language versions you don't need.



> I've just installed bash(for my personal preference) and portupgrade (because I am going to issue: portupgrade -af).



portupgrade -af will take a lot of time and do a lot of work.  It forces an upgrade and reinstall of every installed port, whether they need it or not.  portupgrade -a is less brute-force and quicker, only upgrading ports that need to be upgraded.

I wrote an Upgrading FreeBSD Ports article to cover the way to keep your ports upgraded without getting in trouble.


----------



## phoenix (Nov 8, 2010)

ahavatar said:
			
		

> 2. After installation, boot FreeBSD and do [cmd=]portsnap fetch extract[/cmd]
> 
> 3. Install packages you want using [cmd=]pkg_add -r[/cmd] Now the packages to be installed are newer than the ones in the installation CD. So, your future updating does not try to reinstall/update everthing later.



If you are going to be using pkg_add() to install apps, you don't need the ports tree installed, so the portsnap command is unneeded.  Unless you are using pkg_add to do the initial install (to get up and running quickly), and then will be using the ports tree to keep things up-to-date.


----------



## sk8harddiefast (Nov 8, 2010)

https://sites.google.com/site/unixbasedsystems/FreeBSDnoob
Will help you understand exactly all the basic commands.


----------



## ahavatar (Nov 8, 2010)

phoenix said:
			
		

> If you are going to be using pkg_add() to install apps, you don't need the ports tree installed, so the portsnap command is unneeded.  Unless you are using pkg_add to do the initial install (to get up and running quickly), and then will be using the ports tree to keep things up-to-date.



Yes, my intention is to do the initial installation with pkg_add. By the way, I forgot to mention that it is necesary to change PACKAGESITE before installing packages like:

```
export PACKAGESITE="ftp://ftp.freebsd.org/pub/FreeBSD/ports/amd64/packages-8-stable/Latest/"
```
to install the lastes packages available.


----------



## benpptung (Nov 9, 2010)

[file said:
			
		

> portupgrade -af[/file] will take a lot of time and do a lot of work.  It forces an upgrade and reinstall of every installed port, whether they need it or not.  portupgrade -a is less brute-force and quicker, only upgrading ports that need to be upgraded.
> 
> I wrote an Upgrading FreeBSD Ports article to cover the way to keep your ports upgraded without getting in trouble.



THANK YOU...
I just issue the command [cmd=]portupgrade -af[/cmd] again to see what happen.
Oh my god, it seems running all over again...because it reinstall every installed port again?( Thank you for confirm this, it explain my doubt)

So, next time, should I do port upgrade in the following steps of a new install?

1. [cmd=]portsnap fetch extract[/cmd]
2. [cmd=]cd /usr/ports/ports-mgmt/portupgrade && make install clean[/cmd]
3. [cmd=]portupgrade -a[/cmd]

or use [cmd=]portmaster -a[/cmd] ?? Is it the same? from handbook, it seems portmaster is a better way.


----------



## benpptung (Nov 9, 2010)

sk8harddiefast said:
			
		

> https://sites.google.com/site/unixbasedsystems/FreeBSDnoob
> Will help you understand exactly all the basic commands.



Thank you for your suggestion...:e


----------



## wblock@ (Nov 9, 2010)

benpptung said:
			
		

> so, next time, should I do port upgrade in the following steps of a new install?
> 
> 1.portsnap fetch extract
> 2.cd /usr/ports/ports-mgmt/portupgrade && make install clean
> ...



You don't need to reinstall portupgrade each time.  And using -a can be a problem; that's covered more in the article.  portupgrade or portmaster is a judgement call.  I prefer portupgrade, as it feels quicker and doesn't want to reinstall ports it has already upgraded.


----------



## benpptung (Nov 9, 2010)

I just made another new install of FreeBSD, and I issued the following commands:


```
portsnap fetch extract ( to build the portree)
=> install apache22
=> install portmaster
portmaster -L ==> I see I have around 40 installed packages
```

and I issue `portmaster -a` 

I got around 126 installed packages, why?

Why does portmaster add so many packages for me? Can I avoid this? This is a server, I don't need install so many package.

Will `portupgrade -a` have the same effect? to add so many additional packages?

Following is the detail log...


```
===>>> The following actions were performed:
	Installation of devel/pkg-config (pkg-config-0.25_1)
	Installation of print/freetype2 (freetype2-2.4.2)
	Installation of x11/xproto (xproto-7.0.16)
	Installation of x11-fonts/libfontenc (libfontenc-1.0.5)
	Installation of x11-fonts/mkfontscale (mkfontscale-1.0.7)
	Installation of x11-fonts/mkfontdir (mkfontdir-1.0.5)
	Installation of chinese/ttfm (zh-ttfm-0.9.5_3)
	Installation of x11-fonts/fontconfig (fontconfig-2.8.0,1)
	Installation of chinese/arphicttf (zh-arphicttf-2.11_2)
	Installation of print/t1utils (t1utils-1.32)
	Installation of print/ttf2pt1 (ttf2pt1-3.4.4_2)
	Installation of chinese/ttf2pt1 (zh-ttf2pt1-3.4.0)
	Installation of graphics/png (png-1.4.3)
	Installation of print/libpaper (libpaper-1.1.24)
	Installation of x11/kbproto (kbproto-1.0.4)
	Installation of devel/xorg-macros (xorg-macros-1.6.0)
	Installation of x11/xtrans (xtrans-1.2.5)
	Installation of x11/libICE (libICE-1.0.6,1)
	Installation of x11/libSM (libSM-1.1.1_3,1)
	Installation of x11-fonts/xf86bigfontproto (xf86bigfontproto-1.2.0)
	Installation of x11/bigreqsproto (bigreqsproto-1.1.0)
	Installation of x11/inputproto (inputproto-2.0)
	Installation of x11/libXau (libXau-1.0.5)
	Installation of x11/libXdmcp (libXdmcp-1.0.3)
	Installation of devel/libcheck (libcheck-0.9.8)
	Installation of devel/libpthread-stubs (libpthread-stubs-0.3_3)
	Installation of security/libgpg-error (libgpg-error-1.8)
	Installation of security/libgcrypt (libgcrypt-1.4.6)
	Installation of textproc/libxml2 (libxml2-2.7.7)
	Installation of textproc/libxslt (libxslt-1.1.26_2)
	Installation of x11/xcb-proto (xcb-proto-1.6)
	Installation of x11/libxcb (libxcb-1.7)
	Installation of x11/xcmiscproto (xcmiscproto-1.2.0)
	Installation of x11/xextproto (xextproto-7.1.1)
	Installation of x11/libX11 (libX11-1.3.3_1,1)
	Installation of x11-toolkits/libXt (libXt-1.0.7)
	Installation of x11/libXext (libXext-1.1.1,1)
	Installation of x11-toolkits/libXmu (libXmu-1.0.5,1)
	Installation of x11/printproto (printproto-1.0.4)
	Installation of x11/libXp (libXp-1.0.0,1)
	Installation of x11/libXpm (libXpm-3.5.7)
	Installation of x11-toolkits/libXaw (libXaw-1.0.7,1)
	Installation of devel/t1lib (t1lib-5.1.2_1,1)
	Installation of graphics/jpeg (jpeg-8_3)
	Installation of graphics/gd (gd-2.0.35_7,1)
	Installation of x11-fonts/p5-type1inst (p5-type1inst-0.6.1_5)
	Installation of print/amspsfnt (amspsfnt-1.0_5)
	Installation of print/cmpsfont (cmpsfont-1.0_6)
	Installation of print/tex-texmflocal (tex-texmflocal-1.9)
	Installation of print/teTeX-texmf (teTeX-texmf-3.0_6)
	Installation of www/libwww (libwww-5.4.0_4)
	Installation of archivers/unzip (unzip-6.0)
	Installation of graphics/jasper (jasper-1.900.1_9)
	Installation of graphics/jbig2dec (jbig2dec-0.11)
	Installation of graphics/jbigkit (jbigkit-1.6)
	Installation of graphics/tiff (tiff-4.0.0)
	Installation of security/gnutls (gnutls-2.8.6_2)
	Installation of print/cups-client (cups-client-1.4.4)
	Installation of print/cups-image (cups-image-1.4.4)
	Installation of print/gsfonts (gsfonts-8.11_5)
	Installation of print/ghostscript8 (ghostscript8-8.71_6)
	Installation of textproc/texi2html (texi2html-1.82,1)
	Installation of print/teTeX-base (teTeX-base-3.0_20)
	Installation of print/adobe-cmaps (adobe-cmaps-20051217_1)
	Installation of print/dvipdfmx (dvipdfmx-20100328)
	Installation of print/freetype (freetype-1.3.1_4)
	Installation of print/freetype-tools (freetype-tools-1.3.1_8)
	Installation of print/cm-super (cm-super-0.3.4_3)
	Installation of print/dvipsk-tetex (dvipsk-tetex-5.95a_5)
	Installation of x11/xbitmaps (xbitmaps-1.1.0)
	Installation of x11-toolkits/open-motif (open-motif-2.2.3_6)
	Installation of print/xdvik (xdvik-tetex-22.84.16_2)
	Installation of print/teTeX (teTeX-3.0_4)
	Installation of print/latex-cjk (latex-cjk-4.8.2_4)
	Installation of chinese/docproj (zh-docproj-0.1.20060303_4)
	Installation of graphics/netpbm (netpbm-10.26.64_4)
	Installation of graphics/peps (peps-2.0_4)
	Installation of graphics/scr2png (scr2png-1.2_4)
	Installation of print/jadetex (jadetex-3.13_6)
	Installation of textproc/xmlcatmgr (xmlcatmgr-2.2)
	Installation of textproc/iso8879 (iso8879-1986_2)
	Installation of textproc/docbook-410 (docbook-4.1_4)
	Installation of textproc/docbook-xml (docbook-xml-4.2_1)
	Installation of textproc/docbook-420 (docbook-4.2)
	Installation of textproc/docbook-430 (docbook-4.3)
	Installation of textproc/docbook-440 (docbook-4.4_2)
	Installation of textproc/docbook-450 (docbook-4.5_2)
	Installation of textproc/xmlcharent (xmlcharent-0.3_2)
	Installation of textproc/docbook-500 (docbook-5.0_1)
	Installation of textproc/docbook-sk (docbook-sk-4.1.2_4)
	Installation of textproc/docbook-xml-430 (docbook-xml-4.3)
	Installation of textproc/docbook-xml-440 (docbook-xml-4.4_1)
	Installation of textproc/docbook-xml-450 (docbook-xml-4.5)
	Installation of textproc/docbook (docbook-1.4)
	Installation of textproc/docbook-xsl (docbook-xsl-1.75.2)
	Installation of textproc/dsssl-docbook-modular (dsssl-docbook-modular-1.79_1,1)
	Installation of textproc/fixrtf (fixrtf-0.1.20060303_1)
	Installation of textproc/html (html-4.01_2)
	Installation of textproc/html2text (html2text-1.3.2a)
	Installation of textproc/jade (jade-1.2.1_9)
	Installation of textproc/linuxdoc (linuxdoc-1.1_1)
	Installation of textproc/p5-XML-Parser (p5-XML-Parser-2.40)
	Installation of textproc/scr2txt (scr2txt-1.2)
	Installation of textproc/xhtml (xhtml-1.0.20020801_4)
	Installation of www/links1 (links-0.98,1)
	Installation of www/tidy (tidy-20000804_2)
	Installation of textproc/docproj-jadetex (docproj-jadetex-1.17_4)
	Upgrade of bn-freebsd-doc-20100625 to bn-freebsd-doc-20100926
	Upgrade of da-freebsd-doc-20100625 to da-freebsd-doc-20100926
	Upgrade of de-freebsd-doc-20100625 to de-freebsd-doc-20100926
	Upgrade of el-freebsd-doc-20100625 to el-freebsd-doc-20100926
	Upgrade of en-freebsd-doc-20100625 to en-freebsd-doc-20100926
	Upgrade of es-freebsd-doc-20100625 to es-freebsd-doc-20100926
	Upgrade of fr-freebsd-doc-20100625 to fr-freebsd-doc-20100926
	Upgrade of hu-freebsd-doc-20100625 to hu-freebsd-doc-20100926
	Upgrade of it-freebsd-doc-20100625 to it-freebsd-doc-20100926
	Upgrade of ja-freebsd-doc-20100625 to ja-freebsd-doc-20100926
	Upgrade of mn-freebsd-doc-20100625 to mn-freebsd-doc-20100926
	Upgrade of nl-freebsd-doc-20100625 to nl-freebsd-doc-20100926
	Upgrade of pl-freebsd-doc-20100625 to pl-freebsd-doc-20100926
	Upgrade of pt-freebsd-doc-20100625 to pt-freebsd-doc-20100926
	Upgrade of ru-freebsd-doc-20100625 to ru-freebsd-doc-20100926
	Upgrade of sr-freebsd-doc-20100625 to sr-freebsd-doc-20100926
	Upgrade of tr-freebsd-doc-20100625 to tr-freebsd-doc-20100926
	Upgrade of zh_cn-freebsd-doc-20100625 to zh_cn-freebsd-doc-20100926
	Upgrade of zh_tw-freebsd-doc-20100625 to zh_tw-freebsd-doc-2010092
```


----------



## kpa (Nov 9, 2010)

That does not make any sense since www/apache22 or ports-mgmt/portmaster do not have any X11 dependencies. Did you choose to install any packages during the initial setup in sysinstall?


----------



## benpptung (Nov 9, 2010)

Thank you for reply, you've gave me a direction... I'll try to figure out what's wrong during my installation.

I "THINK" I was keeping the installed packages as few as possible, but anyway something was wrong with my installation. YES, you point out my doubt, why X11, print...are there??

And I really don't get it, why the installed packages increased to 126 from around 40. It tooks me about 3 hours to do the upgrade. I'll try another installation later to figure what's wrong with my installation.

Thank you again.


----------



## wblock@ (Nov 9, 2010)

benpptung said:
			
		

> Thank you for reply, you've gave me a direction... I'll try to figure out what's wrong during my installation.
> 
> I "THINK" I was keeping the installed packages as few as possible, but anyway something was wrong with my installation. YES, you point out my doubt, why X11, print...are there??



Dependencies of the FreeBSD documentation, probably.  ghostscript needs X11 libraries, documentation needs TeX and ghostscript, and so on.



> And I really don't get it, why the installed packages increased to 126 from around 40. It tooks me about 3 hours to do the upgrade. I'll try another installation later to figure what's wrong with my installation.



Capture the session so you can look at it later, or show it here.


----------



## kpa (Nov 9, 2010)

You don't have to reinstall the whole OS from scratch, just do this:

`# pkg_delete -f \*`
`# cd /usr/ports/ports-mgmt/portmaster && make clean && make install clean`
`# portmaster www/apache22`

This will first remove all installed packages and then install just ports-mgmt/portmaster 
and www/apache22.

Or you can install ports-mgmt/pkg_cutleaves and let it remove everything else but ports-mgmt/portmaster 
and www/apache22. That would save you from recompiling apache.


----------

