1 | This document is a how-to for building new packaages for scripts.mit.edu. |
---|
2 | |
---|
3 | Prerequisites |
---|
4 | ============= |
---|
5 | |
---|
6 | * A trusted scripts.mit.edu server |
---|
7 | * A scripts-build account on that server (but that was created when it |
---|
8 | was installed, or something's wrong) |
---|
9 | * A set of personal credentials for the scripts svn repo |
---|
10 | |
---|
11 | Directions |
---|
12 | ========== |
---|
13 | |
---|
14 | * Log into the server as root |
---|
15 | |
---|
16 | * /bin/su scripts-build # It's a bad idea to build as root. This is |
---|
17 | # less urgent than it used to be, because you'll |
---|
18 | # be building using mock in a chroot, but it's |
---|
19 | # still good habit. Also, if you work in |
---|
20 | # /srv/repository as root, scripts-build won't |
---|
21 | # be able to change some of the resulting files |
---|
22 | |
---|
23 | * cd /srv/repository |
---|
24 | |
---|
25 | * svn up # Important both to build with current code, and because the |
---|
26 | # svn revision becomes part of the package release number, |
---|
27 | # and you can infer whether changes in the code were made |
---|
28 | # before or after a particular build by looking at the package |
---|
29 | # and svn release/revision. |
---|
30 | |
---|
31 | * cd server/fedora |
---|
32 | |
---|
33 | * # Look in the .dload directory. If you want to build with a newer |
---|
34 | # version of any upstream packages that are there, then |
---|
35 | * rm .dload/[OLD-PACKAGES].src.rpm # It's fine to delete all SRPMs here |
---|
36 | * rm download_stamp |
---|
37 | |
---|
38 | * make [PACKAGE-YOU-WANT] # e.g. 'make httpd' builds Apache with our patches |
---|
39 | # Note that openafs-devel is a build-dependency of accountadm, so if |
---|
40 | # this is a new Fedora release being bootstrapped, you'll have to |
---|
41 | # build openafs and install its -devel package before building accountadm |
---|
42 | |
---|
43 | * # If the build succeeds, the mock logs, build log, binary and SRPMs |
---|
44 | # will be in /var/lib/mock/fedora-[RELEASE]-{x86_64|i386}/result (note that |
---|
45 | # this will be cleared out each time you start a new build, so if |
---|
46 | # you're building several packages in succession, copy the results |
---|
47 | # somewhere safe after each build to preserve them) |
---|
48 | # Add the packages to the repository by using a trusted machine and |
---|
49 | krootscp root@[BUILD-SERVER]:/var/lib/mock/fedora-[RELEASE]-{x86_64|i386}/result /mit/scripts/rpm-fc[RELEASE] |
---|
50 | |
---|
51 | * # Rebuild the repo metadata to include the new packages. |
---|
52 | cd /mit/scripts/rpm-fc[RELEASE] |
---|
53 | # If you have a trusted machine: |
---|
54 | createrepo . |
---|
55 | # Otherwise, on a scripts server, as root: |
---|
56 | mkdir /root/repodata-YYYYMMDD # Or any suitable temp directory |
---|
57 | createrepo -o /root/repodata-YYYYMMDD . |
---|
58 | # Then from your trusted machine |
---|
59 | krootscp -r root@[BUILD-SERVER]:/root/repodata-YYYYMMDD /mit/scripts/rpm-fc[RELEASE] |
---|
60 | # Sanity check the files, and then replace the current repodata directory |
---|
61 | # with the one in repodata-YYYYMMDD. |
---|
62 | |
---|
63 | Patching packages |
---|
64 | ================= |
---|
65 | |
---|
66 | * To make changes to the packages that we are the upstream maintainers |
---|
67 | of (that is, the packages that the Scripts Team wrote): |
---|
68 | * The authoritative source lives in server/common/oursrc/[PACKAGE] |
---|
69 | * The RPM spec file is server/fedora/specs/[PACAKGE].spec |
---|
70 | * You directly make the relevant changes to those files, commit to |
---|
71 | svn, and then rebuild the package as above to include the new changes. |
---|
72 | |
---|
73 | * To make changes to the upstream packages that we "scriptsify": |
---|
74 | |
---|
75 | * If we haven't previously scriptsified this package, you'll need |
---|
76 | to add it to the upstream_yum line in SVN/server/fedora/Makefile, |
---|
77 | and remove the download_stamp file so that it gets fetched next |
---|
78 | time you run 'make [PACKAGE]'. |
---|
79 | |
---|
80 | * The authoritative upstream source comes from the SRPM in the upstream |
---|
81 | yum repo, or in odd cases like openafs, from some other URL. When |
---|
82 | you 'make [PACKAGE]' in SVN/server/fedora, if download_stamp has |
---|
83 | been removed, the SRPMs are all refetched into |
---|
84 | SVN/server/fedora/.dload, and then installed with 'rpm -i'. This |
---|
85 | results in the source patches, and tarballs landing in ~/rpmbuild/SOURCES |
---|
86 | and the spec files landing in ~/rpmbuild/SPECS. You can also |
---|
87 | manually get individual SRPMs for a package by doing this (these |
---|
88 | steps work fine as a mortal user, including the 'rpm -i'): |
---|
89 | * yumdownloader --source [PACKAGE] |
---|
90 | # That deposits [PACKAGE]-[VER]-[RELEASE].src.rpm in the current dir |
---|
91 | * rpm -i [PACAKGE]-[VER]-[RELEASE].src.rpm |
---|
92 | # That unpacks the SRPM, placing the source tarball and patches in |
---|
93 | # ~/rpmbuild/SOURCES and the spec file in ~/rpmbuild/SPECS; it |
---|
94 | # does *not* globally install anything, and doesn't require root |
---|
95 | If you prefer to not install the file, you can simply extract it |
---|
96 | into a directory by running: |
---|
97 | * /mit/ghudson/scripts/rpmx [PACKAGE]-[VER]-[RELEASE].src.rpm |
---|
98 | |
---|
99 | * If you develop a patch to the upstream source, you should save a |
---|
100 | diff with your changes and add it to the repo as |
---|
101 | SVN/server/common/patches/[PACKAGE]-[SHORT_DESCRIPTIVE_STRING].patch |
---|
102 | |
---|
103 | * To cause your patch to be applied when the package is built, you |
---|
104 | will need to save a copy of the original spec file for the upstream |
---|
105 | package, then modify it to add a line like: |
---|
106 | Patch[NUM]: [PACKAGE]-[SHORT_DESCRIPTOVE_STRING].patch |
---|
107 | # This should generally go after the last existing Patch line |
---|
108 | # in the file, and [NUM] should be significantly larger than |
---|
109 | # the upstream Fedora patches, to avoid conflicts later. This |
---|
110 | # line tells rpmbuild where the contents of the patch live. |
---|
111 | You also add a line like: |
---|
112 | %patch[NUM] -p1 -b .[SHORT_DESCRIPTIVE_STRING] |
---|
113 | # This should generally go after the last existing %patch line |
---|
114 | # in the file, [NUM] should be the same as in the Patch line, and |
---|
115 | # tells rpmbuild that this is the point at which to actually apply |
---|
116 | # the patch |
---|
117 | |
---|
118 | * The Release tag in the spec file should have ".scripts.%{scriptsversion} |
---|
119 | inserted into it just before %{?dist}, or at the end of the release |
---|
120 | if %{?dist} is unused. |
---|
121 | # e.g. Release: 1%{?dist} |
---|
122 | # changes to Release: 1.scripts.%{scriptsversion}%{?dist} |
---|
123 | This causes the package version to include the string "scripts" |
---|
124 | and our SVN revision number (which is set by the Makefile) for |
---|
125 | easy identification (this version will also be greater than the |
---|
126 | upstream version, so the system will prefer to update to it). |
---|
127 | |
---|
128 | * If the scriptsified version of the package needs to be installed |
---|
129 | on the servers, and a new upstream version would break scripts |
---|
130 | without our changes, add a line like this: |
---|
131 | Provides: scripts-[PACKAGE] |
---|
132 | and correspondingly, add "scripts-[PACKAGE]" to the Requires line |
---|
133 | in SVN/server/fedora/specs/scripts-base.spec (and remember to |
---|
134 | build, upload, and deploy a new scripts-base package) |
---|
135 | |
---|
136 | * Though we're not always good about it, do feel encouraged to add |
---|
137 | an entry at the top of the %changelog section near the bottom of |
---|
138 | the spec file explaining your modifications |
---|
139 | |
---|
140 | * When you're finished with the updates to the upstream spec file, |
---|
141 | create a diff from the upstream spec file to your new version, |
---|
142 | and add it to the SVN repo as |
---|
143 | SVN/server/fedora/specs/[PACKAGE].spec.patch |
---|
144 | Make sure to copy it there before you try to build the package, |
---|
145 | since if you don't mock will use the original specfile (and |
---|
146 | overwrite any changes you made in place). |
---|
147 | |
---|