# Updating ports inside a Freebsd jail



## ngalante (Apr 11, 2014)

Greetings,

I administer a server with three service jails installed according the instructions reported in the documentation

https://www.freebsd.org/doc/handbook/jails-application.html

As a consequence of the heartbleed bug, I had to update the jails.  I updated the read-only portion of the system without problems.  I downloaded a brand-new snapshot of the ports tree with the command
`portsnap -p /home/j/mroot/usr/ports fetch extract`
mounted the read-only and writable filesystems and restarted the jail.  I log into the jail with jexec and I try to update the installed ports with `portmaster -a`  Indeed updated versions of the installed ports are found.  The compilation goes well, as 

```
# less /etc/make.conf
WRKDIRPREFIX?= /s/portbuild
```
is correctly set.  But the ports update fails with the following error

```
===> scripts (all)                                                                                                                                                                                                                           
--- all ---                                                                                                                                                                                                                                  
===> scripts/periodic (all)                                                                                                                                                                                                                  
--- objwarn ---                                                                                                                                                                                                                              
--- 411.pkg-backup ---                                                                                                                                                                                                                       
--- 490.status-pkg-changes ---                                                                                                                                                                                                               
--- 400.status-pkg ---                                                                                                                                                                                                                       
--- 410.pkg-audit ---                                                                                                                                                                                                                        
--- 460.pkg-checksum ---                                                                                                                                                                                                                     
--- objwarn ---                                                                                                                                                                                                                              
Warning: Object directory not changed from original /s/portbuild/usr/ports/ports-mgmt/pkg/work/pkg-1.2.7/scripts/periodic                                                                                                                    
--- 411.pkg-backup ---                                                                                                                                                                                                                       
sed -e 's,__PREFIX__,/usr/local,g'  411.pkg-backup.in > 411.pkg-backup                                                                                                                                                                       
--- 490.status-pkg-changes ---                                                                                                                                                                                                               
sed -e 's,__PREFIX__,/usr/local,g'  490.status-pkg-changes.in > 490.status-pkg-changes                                                                                                                                                       
--- 400.status-pkg ---                                                                                                                                                                                                                       
sed -e 's,__PREFIX__,/usr/local,g'  400.status-pkg.in > 400.status-pkg                                                                                                                                                                       
--- 410.pkg-audit ---                                                                                                                                                                                                                        
sed -e 's,__PREFIX__,/usr/local,g'  410.pkg-audit.in > 410.pkg-audit                                                                                                                                                                         
--- 460.pkg-checksum ---                                                                                                                                                                                                                     
sed -e 's,__PREFIX__,/usr/local,g'  460.pkg-checksum.in > 460.pkg-checksum                                                                                                                                                                   
===> scripts/completion (all)                                                                                                                                                                                                                
--- objwarn ---                                                                                                                                                                                                                              
--- _pkg.bash ---                                                                                                                                                                                                                            
--- _pkg.zsh ---                                                                                                                                                                                                                             
--- objwarn ---                                                                                                                                                                                                                              
Warning: Object directory not changed from original /s/portbuild/usr/ports/ports-mgmt/pkg/work/pkg-1.2.7/scripts/completion                                                                                                                  
--- _pkg.bash ---                                                                                                                                                                                                                            
sed -e 's,__PREFIX__,/usr/local,g'  _pkg.bash.in > _pkg.bash                                                                                                                                                                                 
--- _pkg.zsh ---                                                                                                                                                                                                                             
sed -e 's,__PREFIX__,/usr/local,g'  _pkg.zsh.in > _pkg.zsh                                                                                                                                                                                   
===> scripts/sbin (all)                                                                                                                                                                                                                      
--- objwarn ---                                                                                                                                                                                                                              
--- pkg2ng ---                                                                                                                                                                                                                               
--- objwarn ---                                                                                                                                                                                                                              
Warning: Object directory not changed from original /s/portbuild/usr/ports/ports-mgmt/pkg/work/pkg-1.2.7/scripts/sbin                                                                                                                        
--- pkg2ng ---                                                                                                                                                                                                                               
sed -e 's,__PREFIX__,/usr/local,g'  pkg2ng.in > pkg2ng                                                                                                                                                                                       
mkdir: /usr/ports/packages: Read-only file system                                                                                                                                                                                            

===>>> Creating a backup package for old version pkg-1.2.6

===>>> Cannot cd into /usr/ports/packages/portmaster-backup to create a package
===>>> Aborting update                                                         

===>>> Update for ports-mgmt/pkg failed
===>>> Aborting update                 

===>>> Killing background jobs
Terminated                    

===>>> You can restart from the point of failure with this command line:
       portmaster <flags> ports-mgmt/pkg ports-mgmt/portmaster net/rsync lang/perl5.16 net-mgmt/nrpe security/sudo 

===>>> Exiting
```
It seems that portmaster() tries to write in some read-only portion of the file system.  How can I avoid this and finalize the ports update?


----------



## junovitch@ (Apr 12, 2014)

There are multiple locations that must be writable to save dist files and packages.  Here is how sysutils/ezjail does it.  As you can see, packages are saved in /var/ports/packages rather than the default /usr/ports/packages where you see a failure in your example.

```
WRKDIRPREFIX= /var/ports
DISTDIR= /var/ports/distfiles
PACKAGES= /var/ports/packages
INDEXDIR= /var/ports
```


----------

