litbuild 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- checksums.yaml.gz.sig +1 -0
- data/LICENSE +14 -0
- data/README +135 -0
- data/bin/lb +69 -0
- data/gpl-3.0.txt +674 -0
- data/lib/litbuild/ascii_doc_visitor.rb +557 -0
- data/lib/litbuild/bash_script_visitor.rb +547 -0
- data/lib/litbuild/blueprint.rb +232 -0
- data/lib/litbuild/blueprint_library.rb +122 -0
- data/lib/litbuild/blueprint_parser.rb +210 -0
- data/lib/litbuild/commands.rb +37 -0
- data/lib/litbuild/driver.rb +66 -0
- data/lib/litbuild/errors.rb +39 -0
- data/lib/litbuild/logfile_namer.rb +23 -0
- data/lib/litbuild/multi_part_visitor.rb +35 -0
- data/lib/litbuild/narrative.rb +16 -0
- data/lib/litbuild/package.rb +143 -0
- data/lib/litbuild/section.rb +73 -0
- data/lib/litbuild/service_dir.rb +59 -0
- data/lib/litbuild/source_code_manager.rb +143 -0
- data/lib/litbuild/source_files_visitor.rb +26 -0
- data/lib/litbuild/url_visitor.rb +29 -0
- data/lib/litbuild/version.rb +5 -0
- data/lib/litbuild/visitor.rb +42 -0
- data/lib/litbuild.rb +16 -0
- data.tar.gz.sig +0 -0
- metadata +94 -0
- metadata.gz.sig +0 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 5e5f97c8713b5ce5f416800f73b0b77dd26321356514b436720ffc44b883297b
|
4
|
+
data.tar.gz: cc17ddf34f292be8da19eda5370abed391904c6dffe86318786b5629d140ecb3
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 2ee385855edbe3468a30d9a9cc2f75db9d0711634e5d7d3cf0916cd04d6ab6ec8d8673c04b035c715ceeb5ba5ac6d5afcacb958c96f925557710cb041cf46ab8
|
7
|
+
data.tar.gz: 614310bea2b03889d74c98fdcdd5789d388fe9830842ada60bf8d8efcb901a538b2fd61c2ae86aa873e6dfeaddda19e9bad3510c506da491c7e7285d55cc3036
|
checksums.yaml.gz.sig
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
9�(Bę�O9N���lz����ݹH�8�`�����.�}IKuש�1����ky7Z$&`���S�se��}�����fF�P(D���*�kP�Z,�\s�M
|
data/LICENSE
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
Litbuild is copyright 2008-2019 by Brett Neumeier and Eric Herman.
|
2
|
+
|
3
|
+
litbuild is free software: you can redistribute it and/or modify it
|
4
|
+
under the terms of the GNU General Public License, version 3, as
|
5
|
+
published by the Free Software Foundation.
|
6
|
+
|
7
|
+
This program is distributed in the hope that it will be useful, but
|
8
|
+
without any warranty; without even the implied warranty of
|
9
|
+
merchantability or fitness for a particular purpose. See the GNU
|
10
|
+
General Public License for more details.
|
11
|
+
|
12
|
+
You should have received a copy of the GNU General Public License along
|
13
|
+
with this program, in the file gpl-3.0.txt. If not, see
|
14
|
+
<http://www.gnu.org/licenses/>.
|
data/README
ADDED
@@ -0,0 +1,135 @@
|
|
1
|
+
litbuild -- a literate build system
|
2
|
+
===================================
|
3
|
+
|
4
|
+
The idea of literate programming was invented by Donald Knuth. The basic
|
5
|
+
notion -- at least, the way I think of it -- is that the _primary_ users
|
6
|
+
of the source code of a program are the people who are reading the
|
7
|
+
source code to acquire an understanding of how it works (often, because
|
8
|
+
they want to modify it), and that the transformation of the source code
|
9
|
+
into an executable program that can be run, or the actual use of that
|
10
|
+
program, is a _secondary_ purpose of the code.
|
11
|
+
|
12
|
+
Because of this prioritization, most of the attention and energy
|
13
|
+
invested in writing the program is in a narrative discussion of how the
|
14
|
+
program works and what the purpose of each component (function
|
15
|
+
declaration, subroutine or coroutine, or whatever) is within that
|
16
|
+
narrative.
|
17
|
+
|
18
|
+
Automated build tools -- such as make, maven, and jam -- are great,
|
19
|
+
because they allow developers on a project to focus their attention on
|
20
|
+
the project codebase _per se_, and let the build system worry about how
|
21
|
+
to compile and test it. There are lots of build tools, reflecting a wide
|
22
|
+
variety of design goals and value systems. Regardless of which tool is
|
23
|
+
used, though, I have noticed that once a software project reaches a
|
24
|
+
certain level of complexity, the automated build becomes similarly
|
25
|
+
complex -- to the point that it is a major undertaking to figure out how
|
26
|
+
it actually works.
|
27
|
+
|
28
|
+
That makes it difficult to diagnose and correct problems with the build
|
29
|
+
system when they arise, for the same reason that any other
|
30
|
+
incomprehensible software code is hard to work with effectively... and
|
31
|
+
since nobody pays any attention to the build machinery until it stops
|
32
|
+
working for some reason, I've also noticed that it's common for everyone
|
33
|
+
on a team or project to forget how it works in between those times. At
|
34
|
+
best, there's one person who knows how it all works, and he or she gets
|
35
|
+
saddled with the job of fixing it or tweaking it when that's necessary.
|
36
|
+
|
37
|
+
Litbuild is an attempt to bring together the ideas of literate
|
38
|
+
programming and automated build tools. My goal is to make it easy to
|
39
|
+
write build scripts in such a way that they _tell a story_ about how to
|
40
|
+
build a project (regardless of how big or complex that project is),
|
41
|
+
focusing primarily on describing that build process with enough clarity
|
42
|
+
that other people can understand it -- while still providing enough
|
43
|
+
structure to that story that the litbuild system can produce scripts
|
44
|
+
that will perform an automated build of the project.
|
45
|
+
|
46
|
+
The original literate programming systems, WEB and CWEB, have two modes
|
47
|
+
of operation: you can run the literate source code through a `tangle`
|
48
|
+
program to produce source code in a traditional programming language
|
49
|
+
like Pascal or C (which you can then feed to a compiler to produce a
|
50
|
+
program), or you can run it through a `weave` program that produces
|
51
|
+
document source (which you can send through a typesetting system like
|
52
|
+
TeX or Docbook).
|
53
|
+
|
54
|
+
Litbuild takes, as input, human-readable files -- referred to as
|
55
|
+
"blueprints" -- that consist of narrative text interspersed with command
|
56
|
+
blocks and other directives, just like the literate source in WEB and
|
57
|
+
CWEB. It has a simpler interface, though: when litbuild is run, it
|
58
|
+
always generates both a set of bash scripts that automate the actual
|
59
|
+
build process and _also_ AsciiDoc-formatted documentation files that can
|
60
|
+
be run through a document production toolchain to produce HTML or
|
61
|
+
Docbook or some other documentation format.
|
62
|
+
|
63
|
+
The vision of litbuild is that, from a set of blueprints, you should be
|
64
|
+
able to say:
|
65
|
+
|
66
|
+
"Right now, on this system, supposing that I want to have thus-and-so
|
67
|
+
package installed...
|
68
|
+
|
69
|
+
* "Tell me a story about how I can set that up and have it working
|
70
|
+
properly", or
|
71
|
+
* "Produce a set of scripts that I can run to have that package set up
|
72
|
+
and working properly,"
|
73
|
+
|
74
|
+
Or both!
|
75
|
+
|
76
|
+
Using Litbuild
|
77
|
+
==============
|
78
|
+
|
79
|
+
The litbuild gem provides a simple driver script, `lb`, that loads all
|
80
|
+
the blueprint files it finds in a directory tree and then generates
|
81
|
+
output files for the blueprint target specified on the command line. You
|
82
|
+
can only specify one blueprint as a target; if you want more than one
|
83
|
+
thing to be built, create a Section blueprint that talks about all the
|
84
|
+
blueprints you want to build and how they fit together. If the target
|
85
|
+
you want to build is a phase within a blueprint, specify it as
|
86
|
+
`blueprint::phase_name`; if the phase has a space in it, you can of
|
87
|
+
course quote the command line argument like `"blueprint::phase name"`.
|
88
|
+
|
89
|
+
Blueprints can refer to parameterized values. It is expected that
|
90
|
+
default values for all these parameters will be provided (by convention,
|
91
|
+
I generally put all the default values into a "configuration" narrative
|
92
|
+
blueprint). To override any parameter value from the default, set an
|
93
|
+
environment variable before running the `lb` driver program.
|
94
|
+
|
95
|
+
To use the lb driver to build a complete cross-toolchain as part of the
|
96
|
+
Cross-Building Linux process, for example, you might use something like:
|
97
|
+
|
98
|
+
lb gnu-cross-toolchain
|
99
|
+
|
100
|
+
It's not strictly _necessary_ to use Section blueprints to perform a
|
101
|
+
complete build for a complex target, because blueprints can specify what
|
102
|
+
other bleuprints they depend on and litbuild will pull in whatever other
|
103
|
+
blueprints are needed to resolve those dependencies. If all dependencies
|
104
|
+
are correctly specified in all blueprints, all you really need to do is
|
105
|
+
request the final target! But it's still a good idea to write a Section
|
106
|
+
for any situation where the various components of a build story need to
|
107
|
+
have an overall framing narrative or discussion to make them
|
108
|
+
comprehensible, or when all the parts of a build need to share a common
|
109
|
+
configuration or environment -- which is the case for most complicated
|
110
|
+
processes!
|
111
|
+
|
112
|
+
Debugging Blueprints
|
113
|
+
====================
|
114
|
+
|
115
|
+
If litbuild is rejecting your blueprints with an error message and you
|
116
|
+
can't figure out why, you can produce a great deal of debugging
|
117
|
+
information by setting the environment variable RUBYOPT to `--debug`.
|
118
|
+
|
119
|
+
Cross-Building Linux
|
120
|
+
====================
|
121
|
+
|
122
|
+
The litbuild program is developed in conjunction with a set of
|
123
|
+
blueprints called "Cross-Building Linux," or CBL for short; this defines
|
124
|
+
the build process used for Little Blue Linux. A lot of the features in
|
125
|
+
litbuild are present for the convenience of CBL -- like the s6-rc
|
126
|
+
service directory and pipeline logic, the ability to produce
|
127
|
+
package-user scripts, and the invocation of configuration file
|
128
|
+
repository scripts. If you're using litbuild for some other purpose, and
|
129
|
+
don't want to make use of those features, you might want to eliminate
|
130
|
+
them.
|
131
|
+
|
132
|
+
We're thinking of eventually rewriting litbuild as a C program to
|
133
|
+
eliminate its dependency on ruby; if we do that, we'll probably provide
|
134
|
+
a compile-time configuration option that allows features like these to
|
135
|
+
be compiled out of the program.
|
data/bin/lb
ADDED
@@ -0,0 +1,69 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
gem 'litbuild'
|
5
|
+
require 'litbuild'
|
6
|
+
require 'optparse'
|
7
|
+
require 'ostruct'
|
8
|
+
require 'fileutils'
|
9
|
+
|
10
|
+
options = OpenStruct.new
|
11
|
+
|
12
|
+
# defaults:
|
13
|
+
options.query = nil
|
14
|
+
options.version = false
|
15
|
+
|
16
|
+
OptionParser.new do |opts|
|
17
|
+
opts.banner = 'Usage: lb [options] target'
|
18
|
+
opts.on('-q', '--query-packages TYPE',
|
19
|
+
'Output source "files" needed to build target, ' \
|
20
|
+
'or download "urls"') do |q|
|
21
|
+
options.query = q
|
22
|
+
end
|
23
|
+
opts.on('-v', '--version',
|
24
|
+
'Print version number of the litbuild program.') do
|
25
|
+
options.version = true
|
26
|
+
end
|
27
|
+
opts.on('-h', '--help', 'Prints this help message') do
|
28
|
+
puts opts
|
29
|
+
exit
|
30
|
+
end
|
31
|
+
end.parse!
|
32
|
+
|
33
|
+
if options.version
|
34
|
+
puts Litbuild::VERSION
|
35
|
+
exit 0
|
36
|
+
end
|
37
|
+
|
38
|
+
unless ARGV.size == 1
|
39
|
+
warn('A target blueprint must be specified')
|
40
|
+
exit 1
|
41
|
+
end
|
42
|
+
|
43
|
+
target = ARGV[0]
|
44
|
+
|
45
|
+
begin
|
46
|
+
driver = Litbuild::Driver.new
|
47
|
+
|
48
|
+
%w[DOCUMENT_DIR LOGFILE_DIR SCRIPT_DIR WORK_SITE].each do |dir_cfg|
|
49
|
+
dir = driver.params[dir_cfg]
|
50
|
+
FileUtils.mkdir_p(dir) unless File.directory?(dir)
|
51
|
+
end
|
52
|
+
|
53
|
+
if options.query
|
54
|
+
case options.query
|
55
|
+
when 'files'
|
56
|
+
driver.source_files_for(target: target).each { |f| puts f }
|
57
|
+
when 'urls'
|
58
|
+
driver.download_urls_for(target: target).each { |f| puts f }
|
59
|
+
else
|
60
|
+
raise "Unknown query type #{options.query}"
|
61
|
+
end
|
62
|
+
exit 0
|
63
|
+
end
|
64
|
+
|
65
|
+
driver.write_scripts_for(target: target)
|
66
|
+
driver.write_document_for(target: target)
|
67
|
+
rescue Litbuild::Error => e
|
68
|
+
warn("#{e.class}: #{e.message}")
|
69
|
+
end
|