PDA

View Full Version : *BSDs command reference for updating sources, recompiling, installing packages etc.


s0xxx
07-03-2008, 09:08 PM
Ok, these are some of commands (or sequence of commands) that one forgets easily, especially if using several operating systems (or is it just me :D). As commands can differ in older and newer versions of OS we will asume the commands are valid for FreeBSD 7, NetBSD 4 and OpenBSD 4. I sure have made mistakes somewhere so I would kindly ask you to report it so I could make corrections. Or give suggestions to improve it. ;) List will be updated.

Updating source code

FreeBSD

Using csup:
*default tag=RELENG_7
*default host=cvsup2.FreeBSD.org
*default prefix=/usr
*default base=/var/db
*default release=cvs delete use-rel-suffix compress
src-all

csup -g -L 2 <supfile>

NetBSD

Using CVS:
cd /usr
export CVS_RSH=ssh
cvs -d anoncvs@anoncvs.NetBSD.org:/cvsroot co -r netbsd-4 -P src
cd /usr/src
cvs update -dP

Using csup:
*default host=cvsup.de.NetBSD.org
*default base=/usr
*default prefix=/local/NetBSD-cvs
*default release=cvs
*default delete use-rel-suffix
*default compress

netbsd All available NetBSD collections
netbsd-basesrc The base distribution
netbsd-cryptosrc-us Crypto sources
netbsd-doc Documentation
netbsd-htdocs WWW pages
netbsd-othersrc Other Sources
netbsd-gnusrc GNU Sources
netbsd-pkgsrc Packages
netbsd-sharesrc The /usr/share distribution
netbsd-syssrc The kernel distribution
netbsd-xsrc The X11 distribution

csup -g -L 2 <supfile>

OpenBSD

Using CVS:
cd /usr
export CVSROOT=anoncvs@anoncvs.example.org:/cvs
cvs -d$CVSROOT checkout -rOPENBSD_4_3 -P src
cd /usr/src
export CVSROOT=anoncvs@anoncvs.example.org:/cvs
cvs -d$CVSROOT up -rOPENBSD_4_3 -Pd

Using csup:
# Defaults that apply to all the collections
*default release=cvs
*default delete use-rel-suffix
*default umask=002
*default host=cvsup.uk.openbsd.org
*default base=/cvs
*default prefix=/cvs

# If your network link is a T1 or faster, comment out the following line.
*default compress

OpenBSD-all
#OpenBSD-src
#OpenBSD-www
#OpenBSD-ports
#OpenBSD-x11
#OpenBSD-xf4
#OpenBSD-xenocara

csup -g -L 2 <supfile>

Build and Install Kernel & Userland

FreeBSD

cd /usr/src
make buildworld
make buildkernel KERNCONF=GENERIC
make installkernel KERNCONF=GENERIC
shutdown -r now (boot -s)
cd /usr/src
mergemaster -p
make installworld
mergemaster

NetBSD

mkdir /usr/obj /usr/tools
cd /usr/src
./build.sh -O /usr/obj -T /usr/tools -U -u tools
./build.sh -O ../obj -T ../tools kernel=<KERNEL>
./build.sh -O ../obj -T ../tools -U distribution
su
mv /netbsd /netbsd.old
mv /usr/src/sys/arch/i386/compile/GENERIC/netbsd /netbsd
shutdown -r now
cd /usr/src
su
./build.sh -O ../obj -T ../tools -U install=/
etcupdate

OpenBSD

cd /usr/src/sys/arch/i386/conf
config GENERIC
cd ../compile/GENERIC
make clean && make depend && make
make install
reboot
rm -rf /usr/obj/*
cd /usr/src
make obj
cd /usr/src/etc && env DESTDIR=/ make distrib-dirs
cd /usr/src
make build

Updating software collection (ports tree, pkgsrc)

FreeBSD
Using portsnap:

portsnap fetch
portsnap extract # Only needed the first time you get the ports tree
portsnap update
Using csup:
csup -L 2 ports-supfile # See: /usr/share/examples/cvsup/ports-supfile
make fetchindex or make index # portsdb -F or portsdb -Uu respectively if using portupgrade

NetBSD

Use csup supfile with netbsd-pkgsrc
csup -g -L 2 <supfile>
OpenBSD

Use csup supfile with OpenBSD-ports
csup -g -L 2 <supfile>
Installing binary packages

FreeBSD

export PACKAGESITE=ftp://ftp.freebsd.org/pub/FreeBSD/ports/i386/packages-7-stable/Latest/.
pkg_add –rv bash2

OpenBSD

export PKG_PATH=ftp://ftp.openbsd.org/pub/OpenBSD/4.3/packages/i386/
pkg_add -v gimp

NetBSD

export PKG_PATH="ftp://ftp.NetBSD.org/pub/pkgsrc/packages/NetBSD/i386/4.0/All"
pkg_add –v kde-3.5.7

Installing source packages

All *BSDs

cd /usr/ports/security/sudo
make install clean

FreeBSD

portinstall port # sysutils/portupgrade

Listing installed packages

pkg_info # -v switch for verbosity

Deleting installed packages

pkg_delete
make uninstall
make deinstall

Listing outdated software

FreeBSD

pkg_version –v
portversion -l '<' # sysutils/portupgrade
portmaster -L # sysutils/portmaster

NetBSD

lintpkgsrc –i # pkgtools/lintpkgsrc
pkg_chk –uq # pkgtools/ pkg_chk

OpenBSD

cd /usr/ports/infrastructure/build/
./out-of-date

Updating using binary packages

FreeBSD

portupgrade -PP gnome2

OpenBSD

pkg_add -ui pkgname

NetBSD

pkg_add –uu # -uu attempt to update prerequisite packages also
pkg_chk -b -P ftp://ftp.netbsd.org/pub/pkgsrc/packages/NetBSD-4.0/i386/All -u

pkg_chk –g # Generate a list of all installed packages. Default: ${PKGSRCDIR}/pkgchk.conf
pkg_chk –r # Remove outdated packages
pkg_chk –abk # Update all using packages
pkgmanager

Updating using source packages

FreeBSD

portupgrade -R firefox # ports-mgmt/portupgrade
portmanager x11/gnome2 # ports-mgmt/portmanager
portmaster –a # ports-mgmt/portmaster

OpenBSD

make update

NetBSD

make update
make replace
pkg_rolling-replace
pkg_chk –ask

Various cleaning in ports/pkgsrc directory

FreeBSD

make clear # Remove the expanded source code
make distclean # Remove the port's distfiles and perform the clean target
portsclean -C # Clean all work directories in ports tree
portsclean -D # Clean old distfiles
portsclean -DD # Clean all distfiles not referenced by any port currently installed

OpenBSD

make clean # Clean work directory
make clean=depends # Clean the working directories of all dependencies of the port
make clean=dist # Remove the source distribution set(s) of the port

NetBSD

make clean
make clean-depends # The same as: make clean CLEANDEPENDS=1

Listing softvare with security vulnarabilities


FreeBSD

portaudit –Fda

NetBSD

audit-packages # Retired in favour of pkg_install>=20070714 (2008-01-13)



Originally posted at: http://www.bsd-srbija.org/dokumentacija/doku.php/bsd_lista_referentnih_komandi

jb_daefo
07-04-2008, 01:46 AM
if you know just one port needs updating and do not have the Makefile/distinfo etc
for it, upto date yet, for the most recent csup-able version:
cd /usr/ports
csup -g -L 2 -i ports/[category]/[portname] /path/supfile-ports
(repeat for any new dependencies or dependencies that need updating also)

anomie
07-04-2008, 02:01 AM
Nice reference, s0xxx. (Should this move to Guides?)

phoenix
07-04-2008, 07:15 AM
Nice list. You probably should separate these into FreeBSD-specific, OpenBSD-specific, and NetBSD-specific threads, though. That way, people can comment on them without jumbling everything together.

Comments on the FreeBSD sections below.


Using csup:
*default tag=RELENG_7
*default host=cvsup2.FreeBSD.org
*default prefix=/usr
*default base=/var/db
*default release=cvs delete use-rel-suffix compress
src-all

csup -g -L 2 <supfile>

Fill in the SUP* variables in /etc/make.conf (see /usr/share/examples/etc/make.conf) this becomes:

# cd /usr/src
# make update

Build and Install Kernel & Userland

FreeBSD

cd /usr/src
make buildworld
make buildkernel KERNCONF=GENERIC
make installkernel KERNCONF=GENERIC
reboot (boot -s)
cd /usr/src
mergemaster -p
make installworld
cd /usr/src
mergemaster

The last cd is not needed. And one should get out of the habit of using reboot (or halt) directly, and use shutdown instead. With that, you only need one command to halt (-h), power-off (-p), or reboot (-r). And if you don't give an option, it drops to single-user mode.

Updating software collection (ports tree, pkgsrc)

FreeBSD

cd /usr/ports
portsnap fetch
portsnap update
make fetchindex
portsdb -u


portsnap rebuilds the INDEX file, so the fetchindex command is redundant. And portsdb is part of the portupgrade suite of tools, so the command is irrelevant to those who do not use portupgrade.

Listing outdated software

FreeBSD

pkg_version –v
portversion -l '<'
portmaster -L

Mentioning that the first command comes with FreeBSD, and that the other two require installing ports (portupgrade and portmaster respectively) would be helpful here.

TerryP
07-04-2008, 06:23 PM
quite interesting, especially for me since I've barely used NetBSD hehe :-)

s0xxx
07-04-2008, 06:28 PM
Nice reference, s0xxx. (Should this move to Guides?)
Thanx, I was about to post it to Guides section, but then I thought it doesn't really look like a guide, more like a reference. I forgot to make a note to moderators to move it where it is more appropriate.

@jb_daefo

I was going to put only things found in official docs, there are other "tricks" also, but I don't know if I should mention those too. Thoughts from others?

Nice list. You probably should separate these into FreeBSD-specific, OpenBSD-specific, and NetBSD-specific threads, though. That way, people can comment on them without jumbling everything together.
My initial plan was something like:

Kernel compiling:
FreeBSD way - - - OpenBSD way - - - NetBSD way

Userland Build:
FreeBSD way - - - OpenBSD way - - - NetBSD way

Sort of a cross-refrence. But the "section way" is fine too.
Comments on the FreeBSD sections below.

Fill in the SUP* variables in /etc/make.conf (see /usr/share/examples/etc/make.conf) this becomes:

# cd /usr/src
# make update
I will add it, thanx.
The last cd is not needed. And one should get out of the habit of using reboot (or halt) directly, and use shutdown instead. With that, you only need one command to halt (-h), power-off (-p), or reboot (-r). And if you don't give an option, it drops to single-user mode.
This was a copy-paste from FreeBSD Handbook, I will correct it and change the reboot in favor of shutdown.
portsnap rebuilds the INDEX file, so the fetchindex command is redundant. And portsdb is part of the portupgrade suite of tools, so the command is irrelevant to those who do not use portupgrade.
Noted, will sort it right.
Mentioning that the first command comes with FreeBSD, and that the other two require installing ports (portupgrade and portmaster respectively) would be helpful here.
I was planning to add a small info whenever its appropriate, this was just a primary list that I was intending to "extend" with information and descriptions.

Thanx all. :)

smooth187
11-11-2008, 05:42 PM
any body tell me what does the option g stands for in this command

csup -g -L 2 <supfile>

iv checked the man page the csup file & nothing there

DutchDaemon
11-11-2008, 05:47 PM
As far as I know it's there for historical reasons, enabling former cvsup users to keep the same command line.

http://slash.dotat.org/cgi-bin/man?name=cvsup

-g Disables the use of the graphical user interface. This op-
tion is implied if the DISPLAY environment variable is not
set.
From the csup source code:

case 'g':
/* For compatibility. */
break;

In other words: it doesn't do anything.

vermaden
11-11-2008, 06:59 PM
About FreeBSD's rebuild update this one is safer and faster (-iU)
# cd /usr/src
# make buildworld
# make kernel KERNCONF=GENERIC KODIR=/boot/testing
# nextboot -k testing
# reboot
(without -s just stop all services besides sshd --> good for remote upgrade)

-- If kernel booted and works ok then:
# cd /boot
# mv kernel OLD
# mv testing kernel
-- go back to standart things:
# cd /usr/src
# mergemaster -p
# make installworld
# mergemaster -iU # faster check man mergemaster

Oliver_H
11-11-2008, 09:30 PM
>make kernel KERNCONF=GENERIC KODIR=/boot/testing

Is this line correct? Usually I do a make buildkernel installkernel KERNCONF=blabla

phoenix
11-11-2008, 09:36 PM
Yes it's right. The KODIR option tells the install process to put the new kernel into /boot/testing instead of /boot/kernel, such that if things fail, you can still boot with the old kernel.

What's missing is the nextboot command, that is used to set which kernel to use on the next boot. You need to use this to tell the boot loader to use /boot/testing/kernel instead of /boot/kernel/kernel.

vermaden
11-11-2008, 09:54 PM
What's missing is the nextboot command, that is used to set which kernel to use on the next boot. You need to use this to tell the boot loader to use /boot/testing/kernel instead of /boot/kernel/kernel.

Damn, I knew I forgot something, thanks mate ... corrected.

Oliver_H
11-11-2008, 09:58 PM
Learned something new today, thx =)

killasmurf86
11-11-2008, 10:43 PM
Yes it's right. The KODIR option tells the install process to put the new kernel into /boot/testing instead of /boot/kernel, such that if things fail, you can still boot with the old kernel.

What's missing is the nextboot command, that is used to set which kernel to use on the next boot. You need to use this to tell the boot loader to use /boot/testing/kernel instead of /boot/kernel/kernel.

can this be used on regular basis (everyday)?
are there any side effects, which could make me consider using /boot/kernel for daily use?

phoenix
11-12-2008, 03:47 AM
You can use nextboot as often as you want. It only lasts for a single boot, though, so you'd have to use it everytime you shutdown. It's meant for testing kernels. If something fails in the boot process, you just reboot, and the system reverts back to using /boot/kernel/