Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(202)

Side by Side Diff: installer/linux/build.scons

Issue 149132: Initial support for Linux installers. Currently just an amd64 .deb, but more ... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/o3d/
Patch Set: '' Created 11 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | installer/linux/debian_amd64/changelog » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 # Copyright 2009, Google Inc.
2 # All rights reserved.
3 #
4 # Redistribution and use in source and binary forms, with or without
5 # modification, are permitted provided that the following conditions are
6 # met:
7 #
8 # * Redistributions of source code must retain the above copyright
9 # notice, this list of conditions and the following disclaimer.
10 # * Redistributions in binary form must reproduce the above
11 # copyright notice, this list of conditions and the following disclaimer
12 # in the documentation and/or other materials provided with the
13 # distribution.
14 # * Neither the name of Google Inc. nor the names of its
15 # contributors may be used to endorse or promote products derived from
16 # this software without specific prior written permission.
17 #
18 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21 # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22 # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24 # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29
30 import os
31 import subprocess
32 Import('env')
33
34 # Check if Debian packaging tools are installed. If so, make a .deb package.
35 if subprocess.Popen(["which", "dpkg-buildpackage"],
36 stdout=open(os.devnull, "w")).wait() == 0:
37
38 print('Found dpkg-buildpackage in PATH; will create Debian packages.');
39
40 current_source_dir = os.path.join(env['SCONSTRUCT_DIR'], 'installer/linux')
41
42 def OutputFromShellCommand(command):
43 process = subprocess.Popen(command, shell=True, stdout=subprocess.PIPE)
44 return process.communicate()[0].strip()
45
46 def BuildDebianPackage(debian_files, package_files, output_dir=None):
47 """Creates build rules to build a Debian package from the specified sources.
48
49 Args:
50 debian_files: Array of the Debian control file sources that should be
51 copied into the package source tree, e.g., changelog, control, rules,
52 etc. Must be relative to current source dir.
53 package_files: An array of 2-tuples listing the files that should be
54 copied into the package source tree.
55 The first element is the path where the file should be placed for the
56 .install control file to find it, relative to the generated debian
57 package source directory.
58 The second element is the file source.
59 output_dir: An optional directory to place the files in. If omitted, the
60 current output directory is used.
61
62 Return:
63 A list of the (two) targets.
64 """
65 # Read the control file and changelog file to determine the package name,
66 # version, and arch that the Debian build tools will use to name the
67 # generated files.
68 control_file = None
69 changelog_file = None
70 for file in debian_files:
71 if os.path.basename(file) == "control":
72 control_file = os.path.join(current_source_dir, file)
73 elif os.path.basename(file) == "changelog":
74 changelog_file = os.path.join(current_source_dir, file)
75 if control_file == None:
76 raise Exception("Need to have a control file")
77 if changelog_file == None:
78 raise Exception("Need to have a changelog file")
79 package = OutputFromShellCommand("awk '/^Package:/ { print $2; }' "
80 + control_file)
81 version = OutputFromShellCommand("sed -nr '1 { s/.*\\((.*)\\).*/\\1/; p }' "
82 + changelog_file)
83 arch = OutputFromShellCommand("awk '/^Architecture:/ { print $2; }' "
84 + control_file)
85 package_file_name = package + "_" + version + "_" + arch
86 # Path to the outputs, minus extension.
87 if output_dir != None:
88 dest_files = os.path.join(output_dir, package_file_name)
89 else:
90 dest_files = package_file_name
91 # Path to where we will construct the debian build tree.
92 deb_build_tree = os.path.join(package_file_name, "deb_build_tree")
93 # The targets
94 targets = [dest_files + ".deb", dest_files + ".changes"]
95 # First copy the files.
96 for file in package_files:
97 env.Command(os.path.join(deb_build_tree, file[0]), file[1],
98 Copy('$TARGET', '$SOURCE'))
99 env.Depends(targets, os.path.join(deb_build_tree, file[0]))
100 # Now copy the Debian metadata sources. We have to do this all at once so
101 # that we can remove the target directory before copying, because there
102 # can't be any other stale files there or else dpkg-buildpackage may use
103 # them and give incorrect build output.
104 copied_debian_files_paths = []
105 for file in debian_files:
106 copied_debian_files_paths.append(os.path.join(deb_build_tree, "debian",
107 os.path.basename(file)))
108 env.Command(copied_debian_files_paths, debian_files,
109 """dir=$$(dirname $TARGET) && \
110 rm -Rf $$dir && \
111 mkdir -p $$dir && \
112 cp $SOURCES $$dir""")
113 env.Depends(targets, copied_debian_files_paths)
114 # TODO(tschmelcher): Change this to sign the package for Google builds once
115 # we start putting out Linux releases.
116 env.Command(targets, None,
117 """dir=$OBJ_ROOT/installer/linux/""" + deb_build_tree + """ && \
118 cd $$dir && \
119 dpkg-buildpackage -b -uc -aamd64 && \
120 cd $$OLDPWD && \
121 mv $$dir/../""" + package_file_name + """.deb \
122 $$(dirname $TARGET) && \
123 mv $$dir/../""" + package_file_name + """.changes \
124 $$(dirname $TARGET)""")
125 return targets
126
127
128 BuildDebianPackage(["debian_amd64/changelog",
129 "debian_amd64/control",
130 "debian_amd64/dirs",
131 "debian_amd64/google-o3d.install",
132 "debian_amd64/links",
133 "debian_amd64/postinst",
134 "debian_amd64/prerm",
135 "debian_amd64/rules"
136 ],
137 [("libnpo3dautoplugin.so",
138 '$ARTIFACTS_DIR/libnpo3dautoplugin.so'),
139 ("libGLEW.so.1.5", '$ARTIFACTS_DIR/libGLEW.so.1.5'),
140 ("libCg.so", '$ARTIFACTS_DIR/libCg.so'),
141 ("libCgGL.so", '$ARTIFACTS_DIR/libCgGL.so')
142 ],
143 output_dir='$ARTIFACTS_DIR')
144
145 # TODO(tschmelcher): Also build an i386 deb.
146
147 else:
148 print('dpkg-buildpackage not found in PATH; Debian packages will not be '
149 'built.');
150
151 # TODO(tschmelcher): Also build an RPM and a tgz.
OLDNEW
« no previous file with comments | « no previous file | installer/linux/debian_amd64/changelog » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698