Hitchhiker's Guide to Openbsd
Download 1.27 Mb. Pdf ko'rish
|
obsd-faq49
Applying patches.
Patches for the OpenBSD Operating System are distributed as "Unified diffs", which are text files that hold differences to the original source code. They are NOT distributed in binary form. This means that to apply a patch you must have the source code from the RELEASE version of your system available. In general, it is advisable to aquire the entire source tree before applying a patch. If you are running a release from an official CDROM, the source trees are available as files on disk 3, these can also be downloaded from the FTP servers . We will assume you have the entire tree checked out. For our example here, we will look at patch 001 for OpenBSD 3.6 dealing with the st(4) driver, which handles tape drives. Without this patch, recovering data from backups was quite difficult. People using a tape drive needed this patch, however those without a tape drive may have had no particular need to install it. Let's look at the patch: # more 001_st.patch Apply by doing: cd /usr/src patch -p0 < 001_st.patch http://www.openbsd.org/faq/faq10.html (19 of 32)9/4/2011 10:02:15 AM 10 - System Management Rebuild your kernel. Index: sys/scsi/st.c =================================================================== RCS file: /cvs/src/sys/scsi/st.c,v retrieving revision 1.41 retrieving revision 1.41.2.1 diff -u -p -r1.41 -r1.41.2.1 --- sys/scsi/st.c 1 Aug 2004 23:01:06 -0000 1.41 +++ sys/scsi/st.c 2 Nov 2004 01:05:50 -0000 1.41.2.1 @@ -1815,7 +1815,7 @@ st_interpret_sense(xs) u_int8_t skey = sense->flags & SSD_KEY; int32_t info; - if (((sense->flags & SDEV_OPEN) == 0) || + if (((sc_link->flags & SDEV_OPEN) == 0) || (serr != 0x70 && serr != 0x71)) return (EJUSTRETURN); /* let the generic code handle it */ As you will note, the top of the patch includes brief instructions on applying it. We will assume you have put this patch into the /usr/src directory, in which case, the following steps are used: # cd /usr/src # patch -p0 < 001_st.patch Hmm... Looks like a unified diff to me... The text leading up to this was: -------------------------- |Apply by doing: | cd /usr/src | patch -p0 < 001_st.patch | |Rebuild your kernel. | |Index: sys/scsi/st.c | =================================================================== |RCS file: /cvs/src/sys/scsi/st.c,v |retrieving revision 1.41 |retrieving revision 1.41.2.1 |diff -u -p -r1.41 -r1.41.2.1 |--- sys/scsi/st.c 1 Aug 2004 23:01:06 -0000 1.41 |+++ sys/scsi/st.c 2 Nov 2004 01:05:50 -0000 http://www.openbsd.org/faq/faq10.html (20 of 32)9/4/2011 10:02:15 AM 10 - System Management 1.41.2.1 -------------------------- Patching file sys/scsi/st.c using Plan A... Hunk #1 succeeded at 1815. <-- Look for this message! done Note the " Hunk #1 succeeded " message above. This indicates the patch was applied successfully. Many patches are more complex than this one, and will involve multiple hunks and multiple files, in which case, you should verify that all hunks succeeded on all files. If they did not, it normally means your source tree was different in some way from the release source tree the patch was created from, or you didn't follow instructions carefully, or your patch was mangled. Patches are very sensitive to "white space" -- copying and pasting from your browser will often change tab characters into spaces or otherwise alter the white space of a file, making it not apply. At this point, you can build and install the new kernel, then reboot the system as normal. Not all patches are for the kernel. In some cases, you will have to rebuild individual utilities. At other times, will require recompiling all utilities statically linked to a patched library. Follow the guidance in the header of the patch, and if uncertain, rebuild the entire system. Patches that are irrelevant to your particular system need not be applied -- usually. For example, if you did not have a tape drive on your system, you would not benefit from the above patch. However, patches are assumed to be applied "in order" -- it is possible that a later patch is dependent upon an earlier one. Be aware of this if you elect to "pick and choose" which patches you apply, and if in doubt, apply them all, in order. Download 1.27 Mb. Do'stlaringiz bilan baham: |
Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©fayllar.org 2025
ma'muriyatiga murojaat qiling
ma'muriyatiga murojaat qiling