summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKaren Arutyunov <karen@codesynthesis.com>2020-07-28 18:11:12 +0300
committerKaren Arutyunov <karen@codesynthesis.com>2020-07-31 13:44:00 +0300
commit8a4d53d45bf83605e2db8a996ece93fffe34bc6c (patch)
treed45a5ab5c964a137a6a9da2581edb03adb6d2593
parent2a98ae9d1b795b398d53996e35ae50b63aba3774 (diff)
Add implementation
-rw-r--r--.gitattributes19
-rw-r--r--.gitmodules4
l---------COPYING1
-rw-r--r--README-DEV82
-rw-r--r--buildfile7
-rw-r--r--libexpat/.gitignore20
l---------libexpat/COPYING1
-rw-r--r--libexpat/INSTALL7
-rw-r--r--libexpat/README21
-rw-r--r--libexpat/README-DEV18
-rw-r--r--libexpat/build/.gitignore3
-rw-r--r--libexpat/build/bootstrap.build28
-rw-r--r--libexpat/build/export.build9
-rw-r--r--libexpat/build/root.build13
-rw-r--r--libexpat/buildfile9
-rw-r--r--libexpat/libexpat/.gitignore1
l---------libexpat/libexpat/amigaconfig.h1
l---------libexpat/libexpat/ascii.h1
l---------libexpat/libexpat/asciitab.h1
-rw-r--r--libexpat/libexpat/buildfile79
l---------libexpat/libexpat/expat.h1
l---------libexpat/libexpat/expat_config.h1
l---------libexpat/libexpat/expat_external.h1
l---------libexpat/libexpat/iasciitab.h1
l---------libexpat/libexpat/internal.h1
l---------libexpat/libexpat/latin1tab.h1
l---------libexpat/libexpat/libexpat.def.orig1
l---------libexpat/libexpat/macconfig.h1
l---------libexpat/libexpat/nametab.h1
l---------libexpat/libexpat/utf8tab.h1
l---------libexpat/libexpat/xmlparse.c1
l---------libexpat/libexpat/xmlrole.c1
l---------libexpat/libexpat/xmlrole.h1
l---------libexpat/libexpat/xmltok.c1
l---------libexpat/libexpat/xmltok.h1
l---------libexpat/libexpat/xmltok_impl.c1
l---------libexpat/libexpat/xmltok_impl.h1
l---------libexpat/libexpat/xmltok_ns.c1
-rw-r--r--libexpat/manifest18
-rw-r--r--libexpat/tests/.gitignore8
-rw-r--r--libexpat/tests/basic/buildfile6
-rw-r--r--libexpat/tests/basic/driver.c21
-rw-r--r--libexpat/tests/basic/testscript6
-rw-r--r--libexpat/tests/build/.gitignore3
-rw-r--r--libexpat/tests/build/bootstrap.build8
-rw-r--r--libexpat/tests/build/root.build21
-rw-r--r--libexpat/tests/buildfile4
-rw-r--r--libexpat/tests/regression/buildfile25
l---------libexpat/tests/regression/chardata.c1
l---------libexpat/tests/regression/chardata.h1
l---------libexpat/tests/regression/minicheck.c1
l---------libexpat/tests/regression/minicheck.h1
l---------libexpat/tests/regression/runtests.c1
-rw-r--r--libexpat/tests/regression/testscript9
-rw-r--r--packages.manifest2
m---------upstream0
56 files changed, 479 insertions, 0 deletions
diff --git a/.gitattributes b/.gitattributes
new file mode 100644
index 0000000..1631641
--- /dev/null
+++ b/.gitattributes
@@ -0,0 +1,19 @@
+# This is a good default: files that are auto-detected by git to be text are
+# converted to the platform-native line ending (LF on Unix, CRLF on Windows)
+# in the working tree and to LF in the repository.
+#
+* text=auto
+
+# Use `eol=crlf` for files that should have the CRLF line ending both in the
+# working tree (even on Unix) and in the repository.
+#
+#*.bat text eol=crlf
+
+# Use `eol=lf` for files that should have the LF line ending both in the
+# working tree (even on Windows) and in the repository.
+#
+#*.sh text eol=lf
+
+# Use `binary` to make sure certain files are never auto-detected as text.
+#
+#*.png binary
diff --git a/.gitmodules b/.gitmodules
new file mode 100644
index 0000000..65129ff
--- /dev/null
+++ b/.gitmodules
@@ -0,0 +1,4 @@
+[submodule "upstream"]
+ path = upstream
+ url = https://github.com/boris-kolpackov/libexpat.git
+ ignore = untracked \ No newline at end of file
diff --git a/COPYING b/COPYING
new file mode 120000
index 0000000..948896a
--- /dev/null
+++ b/COPYING
@@ -0,0 +1 @@
+upstream/expat/COPYING \ No newline at end of file
diff --git a/README-DEV b/README-DEV
new file mode 100644
index 0000000..2a8d624
--- /dev/null
+++ b/README-DEV
@@ -0,0 +1,82 @@
+This document describes an approach applied to packaging Expat for build2. In
+particular, this understanding will be useful when upgrading to a new upstream
+version.
+
+The upstream package contains the libexpat C library, its usage examples and
+tests, and xmlwf utility. Currently, we only package the library (see
+libexpat/README-DEV for details).
+
+We add the upstream package as a git submodule and symlink the required files
+and subdirectories into the build2 package subdirectories. Then, when required,
+we "overlay" the upstream with our own headers, placing them into the library
+directory.
+
+Note that symlinking upstream submodule subdirectories into a build2 package
+subdirectory results in creating intermediate build files (.d, .o, etc) inside
+upstream directory while building the package in source tree. That's why we
+need to make sure that packages do not share upstream source files via
+subdirectory symlinks, not to also share the related intermediate files. If
+several packages need to compile the same upstream source file, then only one
+of them can symlink it via the parent directory while others must symlink it
+directly. We also add the `ignore = untracked` configuration option into
+.gitmodules to make sure that git ignores the intermediate build files under
+upstream/ subdirectory.
+
+The upstream package can be configured to contain a specific feature set. We
+reproduce the union of features configured for the upstream source package in
+Debian and Fedora distributions. The configuration options defining these sets
+are specified in the Debian's rules and Fedora's RPM .spec files. These files
+can be obtained as follows:
+
+$ wget http://security.debian.org/debian-security/pool/updates/main/e/expat/expat_2.1.0-6+deb8u6.debian.tar.xz
+$ tar xf expat_2.1.0-6+deb8u6.debian.tar.xz debian/rules
+
+$ wget https://kojipkgs.fedoraproject.org//packages/expat/2.2.8/1.fc32/src/expat-2.2.8-1.fc32.src.rpm
+$ rpm2cpio expat-2.2.8-1.fc32.src.rpm | cpio -civ '*.spec'
+
+As a side note, on Debian and Fedora the source, libraries, and headers are
+packaged as follows:
+
+ src libraries headers
+Debian/Ubuntu: expat libexpat1 libexpat1-dev
+Fedora/RHEL: expat expat expat-devel
+
+Search for the Debian and Fedora packages at https://packages.debian.org/search
+and https://apps.fedoraproject.org/packages/.
+
+Both distributions use the default feature set and specify no additional
+configuration options for the configure script.
+
+Normally, when packaging a project, we need to replace some auto-generated
+headers with our own implementations and deduce the source files and
+compilation/linking options. For Expat we can rely for that on configure.in,
+expat_config.h.in and CMakeLists.txt. In practice, however, that can be uneasy
+and error prone, so you may also need to see the actual compiler and linker
+command lines in the build log. If that's the case, you can configure/build
+the upstream package on the platform of interest running the following
+commands in the upstream project root directory.
+
+On POSIX and for MinGW GCC:
+
+$ cd expat
+$ ./buildconf.sh
+$ mkdir build
+$ cd build
+$ ../configure >build.log 2>&1
+$ make VERBOSE=1 >>build.log 2>&1
+
+For MSVC:
+
+> cd expat
+> mkdir build
+> cd build
+> cmake -DCMAKE_VERBOSE_MAKEFILE:BOOL=ON .. >build.log
+> cmake --build . >>build.log 2>&1
+
+See upstream/expat/{README,CMake.README,win32/README.txt} for details.
+
+When the packaging is complete, build all the project packages in source tree
+and make sure that no Expat headers are included from the system, running the
+following command from the project root:
+
+$ grep -a -e '/usr/include/expat.*' `find . -type f -name '*.d'`
diff --git a/buildfile b/buildfile
new file mode 100644
index 0000000..ed63daf
--- /dev/null
+++ b/buildfile
@@ -0,0 +1,7 @@
+# file : buildfile
+# license : MIT; see accompanying COPYING file
+
+# Glue buildfile that "pulls" all the packages.
+
+import pkgs = {*/ -upstream/}
+./: $pkgs
diff --git a/libexpat/.gitignore b/libexpat/.gitignore
new file mode 100644
index 0000000..4c4fec7
--- /dev/null
+++ b/libexpat/.gitignore
@@ -0,0 +1,20 @@
+# Compiler/linker output.
+#
+*.d
+*.t
+*.i
+*.ii
+*.o
+*.obj
+*.so
+*.so.*
+*.dll
+*.a
+*.lib
+*.exp
+*.pdb
+*.ilk
+*.exe
+*.exe.dlls/
+*.exe.manifest
+*.pc
diff --git a/libexpat/COPYING b/libexpat/COPYING
new file mode 120000
index 0000000..012065c
--- /dev/null
+++ b/libexpat/COPYING
@@ -0,0 +1 @@
+../COPYING \ No newline at end of file
diff --git a/libexpat/INSTALL b/libexpat/INSTALL
new file mode 100644
index 0000000..a835adc
--- /dev/null
+++ b/libexpat/INSTALL
@@ -0,0 +1,7 @@
+The aim of this package is to make reading the INSTALL file unnecessary. So
+next time try running:
+
+$ bpkg build libexpat
+
+But if you don't want to use the package manager, then you can also build this
+package manually using the standard build2 build system.
diff --git a/libexpat/README b/libexpat/README
new file mode 100644
index 0000000..b0b157d
--- /dev/null
+++ b/libexpat/README
@@ -0,0 +1,21 @@
+Expat is a stream-oriented XML parsing C library. This means that you register
+handlers with the parser before starting the parse. These handlers are called
+when the parser discovers the associated structures (start tag, etc) in the
+document being parsed. For more information see:
+
+https://libexpat.github.io/
+
+This package contains the original libexpat library source code overlaid with
+the build2-based build system and packaged for the build2 package manager
+(bpkg).
+
+See the INSTALL file for the prerequisites and installation instructions.
+
+Post questions, bug reports, or any other feedback about the library itself at
+https://github.com/libexpat/libexpat/issues. Send build system and
+packaging-related feedback to the packaging@build2.org mailing list (see
+https://lists.build2.org for posting guidelines, etc).
+
+The packaging of Expat for build2 is tracked in a Git repository at:
+
+https://git.build2.org/cgit/packaging/expat/
diff --git a/libexpat/README-DEV b/libexpat/README-DEV
new file mode 100644
index 0000000..0b1c57d
--- /dev/null
+++ b/libexpat/README-DEV
@@ -0,0 +1,18 @@
+This document describes how libexpat was packaged for build2. In particular,
+this understanding will be useful when upgrading to a new upstream version.
+See ../README-DEV for general notes on Expat packaging.
+
+Symlink the required upstream files:
+
+$ ln -s ../COPYING
+$ pushd libexpat
+$ ln -s ../../upstream/expat/lib/*.{c,h} ./
+$ rm watcomconfig.h winconfig.h
+$ ln -s ../../upstream/expat/lib/libexpat.def libexpat.def.orig
+$ popd
+
+Use some of the upstream's tests for testing:
+
+$ pushd tests/regression/
+$ ln -s ../../../upstream/expat/tests/*.{c,h} ./
+$ popd
diff --git a/libexpat/build/.gitignore b/libexpat/build/.gitignore
new file mode 100644
index 0000000..4a730a3
--- /dev/null
+++ b/libexpat/build/.gitignore
@@ -0,0 +1,3 @@
+config.build
+root/
+bootstrap/
diff --git a/libexpat/build/bootstrap.build b/libexpat/build/bootstrap.build
new file mode 100644
index 0000000..2474d15
--- /dev/null
+++ b/libexpat/build/bootstrap.build
@@ -0,0 +1,28 @@
+# file : build/bootstrap.build
+# license : MIT; see accompanying COPYING file
+
+project = libexpat
+
+using version
+using config
+using dist
+using test
+using install
+
+# The Expat version has the <major>.<minor>.<micro> form and follows the
+# semver semantics, according to the documentation in expat/lib/expat.h
+# present in the latest library version (2.2.9 at the time of this writing).
+#
+# The ABI version doesn't correlate with the release version and is assigned
+# via the libtool's -version-info <current>:<revision>:<age> option
+# (LIBCURRENT, LIBREVISION, and LIBAGE in expat/configure.in). As it follows
+# from the comment in expat/configure.in, the major version (current - age) is
+# incremented for backwards-incompatible ABI changes.
+#
+if ($version.major == 2 && $version.minor == 1 && $version.patch == 0)
+{
+ abi_version_major = 1
+ abi_version = "$abi_version_major.6.0" # <current - age>.<age>.<revision>
+}
+else
+ fail 'increment the ABI version?'
diff --git a/libexpat/build/export.build b/libexpat/build/export.build
new file mode 100644
index 0000000..f1302a1
--- /dev/null
+++ b/libexpat/build/export.build
@@ -0,0 +1,9 @@
+# file : build/export.build
+# license : MIT; see accompanying COPYING file
+
+$out_root/
+{
+ include libexpat/
+}
+
+export $out_root/libexpat/lib{expat}
diff --git a/libexpat/build/root.build b/libexpat/build/root.build
new file mode 100644
index 0000000..070d5ec
--- /dev/null
+++ b/libexpat/build/root.build
@@ -0,0 +1,13 @@
+# file : build/root.build
+# license : MIT; see accompanying COPYING file
+
+using c
+
+h{*}: extension = h
+c{*}: extension = c
+
+if ($c.target.system == 'win32-msvc')
+ c.poptions += -D_CRT_SECURE_NO_WARNINGS -D_SCL_SECURE_NO_WARNINGS
+
+if ($c.class == 'msvc')
+ c.coptions += /wd4251 /wd4275 /wd4800
diff --git a/libexpat/buildfile b/libexpat/buildfile
new file mode 100644
index 0000000..6d3efdd
--- /dev/null
+++ b/libexpat/buildfile
@@ -0,0 +1,9 @@
+# file : buildfile
+# license : MIT; see accompanying COPYING file
+
+./: {*/ -build/} doc{INSTALL README} legal{COPYING} manifest
+
+# Don't install tests or the INSTALL file.
+#
+tests/: install = false
+doc{INSTALL}@./: install = false
diff --git a/libexpat/libexpat/.gitignore b/libexpat/libexpat/.gitignore
new file mode 100644
index 0000000..e75e9a2
--- /dev/null
+++ b/libexpat/libexpat/.gitignore
@@ -0,0 +1 @@
+libexpat.def
diff --git a/libexpat/libexpat/amigaconfig.h b/libexpat/libexpat/amigaconfig.h
new file mode 120000
index 0000000..7f925a3
--- /dev/null
+++ b/libexpat/libexpat/amigaconfig.h
@@ -0,0 +1 @@
+../../upstream/expat/lib/amigaconfig.h \ No newline at end of file
diff --git a/libexpat/libexpat/ascii.h b/libexpat/libexpat/ascii.h
new file mode 120000
index 0000000..ad11588
--- /dev/null
+++ b/libexpat/libexpat/ascii.h
@@ -0,0 +1 @@
+../../upstream/expat/lib/ascii.h \ No newline at end of file
diff --git a/libexpat/libexpat/asciitab.h b/libexpat/libexpat/asciitab.h
new file mode 120000
index 0000000..1336131
--- /dev/null
+++ b/libexpat/libexpat/asciitab.h
@@ -0,0 +1 @@
+../../upstream/expat/lib/asciitab.h \ No newline at end of file
diff --git a/libexpat/libexpat/buildfile b/libexpat/libexpat/buildfile
new file mode 100644
index 0000000..65aacc4
--- /dev/null
+++ b/libexpat/libexpat/buildfile
@@ -0,0 +1,79 @@
+# file : libexpat/buildfile
+# license : MIT; see accompanying COPYING file
+
+# xmltok_{impl,nc}.c files are included into xmltok.c, so exclude them from
+# the compilation.
+#
+lib{expat}: h{*} c{* -xmltok_impl -xmltok_ns}
+lib{expat}: c{xmltok_impl xmltok_ns}: include = false
+
+tclass = $c.target.class
+
+windows = ($tclass == 'windows')
+
+# Symbol exporting on Windows is done via the .def file.
+#
+libs{expat}: def{libexpat}: include = $windows
+def{libexpat}: file{libexpat.def.orig}
+{{
+ # Remove the 'LIBRARY' line from the .def file to make it acceptable for the
+ # MinGW linker.
+ #
+ sed -e 's/^\s*LIBRARY\s*$//' $path($<) >$path($>)
+}}
+
+# Build options.
+#
+c.poptions += -DHAVE_EXPAT_CONFIG_H
+c.poptions =+ "-I$src_base"
+
+if ($c.class == 'gcc')
+{
+ # Note that it's unlikely that the code is strict aliasing-safe, given that
+ # the -fno-strict-aliasing option is added in the later library versions.
+ # Let's also add this option for good measure.
+ #
+ c.coptions += -fexceptions -fno-strict-aliasing
+
+ # Disable warnings that pop up with -Wall -Wextra.
+ #
+ # Note that -Wno-implicit-fallthrough is only supported starting from GCC 7
+ # and Clang 3.9. However, we don't check for the compiler version since the
+ # earlier compiler versions do not complain about unknown -Wno-* options,
+ # unless some other diagnostics is issued.
+ #
+ # Also note that these warnings can be build2-specific due to the
+ # intermediate translation unit pre-processing phase, which wipes the `fall
+ # through` comments from the macro definitions.
+ #
+ c.coptions += -Wno-implicit-fallthrough
+}
+
+switch $tclass
+{
+ case 'linux' | 'bsd'
+ {
+ # Make sure all symbols are resolvable.
+ #
+ c.loptions += -Wl,--no-undefined
+ }
+}
+
+# Export options.
+#
+lib{expat}: cc.export.poptions = "-I$src_base"
+liba{expat}: cc.export.poptions += -DXML_STATIC
+
+# See bootstrap.build for details.
+#
+if $version.pre_release
+ lib{expat}: bin.lib.version = @"-$version.project_id"
+else
+ lib{expat}: bin.lib.version = @"-$abi_version_major" linux@"$abi_version"
+
+# Install the bare minimum of headers (note: not recreating subdirectories).
+#
+h{*}: install = false
+
+for h: expat expat_external expat_config
+ h{$h}@./: install = include/
diff --git a/libexpat/libexpat/expat.h b/libexpat/libexpat/expat.h
new file mode 120000
index 0000000..d130deb
--- /dev/null
+++ b/libexpat/libexpat/expat.h
@@ -0,0 +1 @@
+../../upstream/expat/lib/expat.h \ No newline at end of file
diff --git a/libexpat/libexpat/expat_config.h b/libexpat/libexpat/expat_config.h
new file mode 120000
index 0000000..be8609d
--- /dev/null
+++ b/libexpat/libexpat/expat_config.h
@@ -0,0 +1 @@
+../../upstream/expat/lib/expat_config.h \ No newline at end of file
diff --git a/libexpat/libexpat/expat_external.h b/libexpat/libexpat/expat_external.h
new file mode 120000
index 0000000..04ec915
--- /dev/null
+++ b/libexpat/libexpat/expat_external.h
@@ -0,0 +1 @@
+../../upstream/expat/lib/expat_external.h \ No newline at end of file
diff --git a/libexpat/libexpat/iasciitab.h b/libexpat/libexpat/iasciitab.h
new file mode 120000
index 0000000..0c6ca4a
--- /dev/null
+++ b/libexpat/libexpat/iasciitab.h
@@ -0,0 +1 @@
+../../upstream/expat/lib/iasciitab.h \ No newline at end of file
diff --git a/libexpat/libexpat/internal.h b/libexpat/libexpat/internal.h
new file mode 120000
index 0000000..f24b340
--- /dev/null
+++ b/libexpat/libexpat/internal.h
@@ -0,0 +1 @@
+../../upstream/expat/lib/internal.h \ No newline at end of file
diff --git a/libexpat/libexpat/latin1tab.h b/libexpat/libexpat/latin1tab.h
new file mode 120000
index 0000000..380f82f
--- /dev/null
+++ b/libexpat/libexpat/latin1tab.h
@@ -0,0 +1 @@
+../../upstream/expat/lib/latin1tab.h \ No newline at end of file
diff --git a/libexpat/libexpat/libexpat.def.orig b/libexpat/libexpat/libexpat.def.orig
new file mode 120000
index 0000000..7f3cd3c
--- /dev/null
+++ b/libexpat/libexpat/libexpat.def.orig
@@ -0,0 +1 @@
+../../upstream/expat/lib/libexpat.def \ No newline at end of file
diff --git a/libexpat/libexpat/macconfig.h b/libexpat/libexpat/macconfig.h
new file mode 120000
index 0000000..52104f7
--- /dev/null
+++ b/libexpat/libexpat/macconfig.h
@@ -0,0 +1 @@
+../../upstream/expat/lib/macconfig.h \ No newline at end of file
diff --git a/libexpat/libexpat/nametab.h b/libexpat/libexpat/nametab.h
new file mode 120000
index 0000000..da05055
--- /dev/null
+++ b/libexpat/libexpat/nametab.h
@@ -0,0 +1 @@
+../../upstream/expat/lib/nametab.h \ No newline at end of file
diff --git a/libexpat/libexpat/utf8tab.h b/libexpat/libexpat/utf8tab.h
new file mode 120000
index 0000000..ea15fd9
--- /dev/null
+++ b/libexpat/libexpat/utf8tab.h
@@ -0,0 +1 @@
+../../upstream/expat/lib/utf8tab.h \ No newline at end of file
diff --git a/libexpat/libexpat/xmlparse.c b/libexpat/libexpat/xmlparse.c
new file mode 120000
index 0000000..2e8e67f
--- /dev/null
+++ b/libexpat/libexpat/xmlparse.c
@@ -0,0 +1 @@
+../../upstream/expat/lib/xmlparse.c \ No newline at end of file
diff --git a/libexpat/libexpat/xmlrole.c b/libexpat/libexpat/xmlrole.c
new file mode 120000
index 0000000..1842f74
--- /dev/null
+++ b/libexpat/libexpat/xmlrole.c
@@ -0,0 +1 @@
+../../upstream/expat/lib/xmlrole.c \ No newline at end of file
diff --git a/libexpat/libexpat/xmlrole.h b/libexpat/libexpat/xmlrole.h
new file mode 120000
index 0000000..d6840a4
--- /dev/null
+++ b/libexpat/libexpat/xmlrole.h
@@ -0,0 +1 @@
+../../upstream/expat/lib/xmlrole.h \ No newline at end of file
diff --git a/libexpat/libexpat/xmltok.c b/libexpat/libexpat/xmltok.c
new file mode 120000
index 0000000..71e09c6
--- /dev/null
+++ b/libexpat/libexpat/xmltok.c
@@ -0,0 +1 @@
+../../upstream/expat/lib/xmltok.c \ No newline at end of file
diff --git a/libexpat/libexpat/xmltok.h b/libexpat/libexpat/xmltok.h
new file mode 120000
index 0000000..7d364ab
--- /dev/null
+++ b/libexpat/libexpat/xmltok.h
@@ -0,0 +1 @@
+../../upstream/expat/lib/xmltok.h \ No newline at end of file
diff --git a/libexpat/libexpat/xmltok_impl.c b/libexpat/libexpat/xmltok_impl.c
new file mode 120000
index 0000000..d43e690
--- /dev/null
+++ b/libexpat/libexpat/xmltok_impl.c
@@ -0,0 +1 @@
+../../upstream/expat/lib/xmltok_impl.c \ No newline at end of file
diff --git a/libexpat/libexpat/xmltok_impl.h b/libexpat/libexpat/xmltok_impl.h
new file mode 120000
index 0000000..62df0da
--- /dev/null
+++ b/libexpat/libexpat/xmltok_impl.h
@@ -0,0 +1 @@
+../../upstream/expat/lib/xmltok_impl.h \ No newline at end of file
diff --git a/libexpat/libexpat/xmltok_ns.c b/libexpat/libexpat/xmltok_ns.c
new file mode 120000
index 0000000..607cbbc
--- /dev/null
+++ b/libexpat/libexpat/xmltok_ns.c
@@ -0,0 +1 @@
+../../upstream/expat/lib/xmltok_ns.c \ No newline at end of file
diff --git a/libexpat/manifest b/libexpat/manifest
new file mode 100644
index 0000000..3bb534e
--- /dev/null
+++ b/libexpat/manifest
@@ -0,0 +1,18 @@
+: 1
+name: libexpat
+version: 2.1.0-a.0.z
+project: expat
+summary: Stream-oriented XML parsing C library
+license: MIT
+topics: Expat, C, XML parser, streaming
+description-file: README
+url: https://libexpat.github.io/
+doc-url: https://libexpat.github.io/doc/
+src-url: https://git.build2.org/cgit/packaging/expat/expat/tree/libexpat/
+package-url: https://git.build2.org/cgit/packaging/expat/
+email: packaging@build2.org ; Report issues at https://github.com/libexpat/libexpat/issues.
+package-email: packaging@build2.org ; Mailing list.
+build-warning-email: builds@build2.org
+builds: all
+depends: * build2 >= 0.13.0
+depends: * bpkg >= 0.13.0
diff --git a/libexpat/tests/.gitignore b/libexpat/tests/.gitignore
new file mode 100644
index 0000000..662178d
--- /dev/null
+++ b/libexpat/tests/.gitignore
@@ -0,0 +1,8 @@
+# Test executables.
+#
+driver
+
+# Testscript output directories (can be symlinks).
+#
+test
+test-*
diff --git a/libexpat/tests/basic/buildfile b/libexpat/tests/basic/buildfile
new file mode 100644
index 0000000..b64f25a
--- /dev/null
+++ b/libexpat/tests/basic/buildfile
@@ -0,0 +1,6 @@
+# file : tests/basic/buildfile
+# license : MIT; see accompanying COPYING file
+
+import libs = libexpat%lib{expat}
+
+exe{driver}: {h c}{**} $libs testscript
diff --git a/libexpat/tests/basic/driver.c b/libexpat/tests/basic/driver.c
new file mode 100644
index 0000000..067b96b
--- /dev/null
+++ b/libexpat/tests/basic/driver.c
@@ -0,0 +1,21 @@
+/* file : tests/basic/driver.c
+ * license : MIT; see accompanying COPYING file
+ */
+
+#include <stdio.h>
+#include <assert.h>
+
+#include <expat.h>
+
+int
+main ()
+{
+ XML_Expat_Version v = XML_ExpatVersionInfo ();
+
+ assert (v.major == XML_MAJOR_VERSION &&
+ v.minor == XML_MINOR_VERSION &&
+ v.micro == XML_MICRO_VERSION);
+
+ printf ("version: %d.%d.%d\n", v.major, v.minor, v.micro);
+ return 0;
+}
diff --git a/libexpat/tests/basic/testscript b/libexpat/tests/basic/testscript
new file mode 100644
index 0000000..d9037da
--- /dev/null
+++ b/libexpat/tests/basic/testscript
@@ -0,0 +1,6 @@
+# file : tests/basic/testscript
+# license : MIT; see accompanying COPYING file
+
+: version
+:
+$* >~'%version: \d+.\d+.\d+%d'
diff --git a/libexpat/tests/build/.gitignore b/libexpat/tests/build/.gitignore
new file mode 100644
index 0000000..4a730a3
--- /dev/null
+++ b/libexpat/tests/build/.gitignore
@@ -0,0 +1,3 @@
+config.build
+root/
+bootstrap/
diff --git a/libexpat/tests/build/bootstrap.build b/libexpat/tests/build/bootstrap.build
new file mode 100644
index 0000000..d7f6bee
--- /dev/null
+++ b/libexpat/tests/build/bootstrap.build
@@ -0,0 +1,8 @@
+# file : tests/build/bootstrap.build
+# license : MIT; see accompanying COPYING file
+
+project = # Unnamed tests subproject.
+
+using config
+using test
+using dist
diff --git a/libexpat/tests/build/root.build b/libexpat/tests/build/root.build
new file mode 100644
index 0000000..2d95750
--- /dev/null
+++ b/libexpat/tests/build/root.build
@@ -0,0 +1,21 @@
+# file : tests/build/root.build
+# license : MIT; see accompanying COPYING file
+
+using c
+
+h{*}: extension = h
+c{*}: extension = c
+
+if ($c.target.system == 'win32-msvc')
+ c.poptions += -D_CRT_SECURE_NO_WARNINGS -D_SCL_SECURE_NO_WARNINGS
+
+if ($c.class == 'msvc')
+ c.coptions += /wd4251 /wd4275 /wd4800
+
+# Every exe{} in this subproject is by default a test.
+#
+exe{*}: test = true
+
+# The test target for cross-testing (running tests under Wine, etc).
+#
+test.target = $c.target
diff --git a/libexpat/tests/buildfile b/libexpat/tests/buildfile
new file mode 100644
index 0000000..52f7ade
--- /dev/null
+++ b/libexpat/tests/buildfile
@@ -0,0 +1,4 @@
+# file : tests/buildfile
+# license : MIT; see accompanying COPYING file
+
+./: {*/ -build/}
diff --git a/libexpat/tests/regression/buildfile b/libexpat/tests/regression/buildfile
new file mode 100644
index 0000000..f32dabe
--- /dev/null
+++ b/libexpat/tests/regression/buildfile
@@ -0,0 +1,25 @@
+# file : tests/regression/buildfile
+# license : MIT; see accompanying COPYING file
+
+import libs = libexpat%lib{expat}
+
+exe{driver}: {h c}{**} $libs testscript
+
+switch $c.class
+{
+ case 'gcc'
+ {
+ # Disable warnings that pop up with -Wall -Wextra. Upstream doesn't seem
+ # to care about these and it is not easy to disable specific warnings in a
+ # way that works across compilers/version (some -Wno-* options are only
+ # recognized in newer versions).
+ #
+ c.coptions += -Wno-all -Wno-extra
+ }
+ case 'msvc'
+ {
+ # Disable warnings that pop up with /W3.
+ #
+ c.coptions += /wd4267
+ }
+}
diff --git a/libexpat/tests/regression/chardata.c b/libexpat/tests/regression/chardata.c
new file mode 120000
index 0000000..321a5e8
--- /dev/null
+++ b/libexpat/tests/regression/chardata.c
@@ -0,0 +1 @@
+../../../upstream/expat/tests/chardata.c \ No newline at end of file
diff --git a/libexpat/tests/regression/chardata.h b/libexpat/tests/regression/chardata.h
new file mode 120000
index 0000000..fe51175
--- /dev/null
+++ b/libexpat/tests/regression/chardata.h
@@ -0,0 +1 @@
+../../../upstream/expat/tests/chardata.h \ No newline at end of file
diff --git a/libexpat/tests/regression/minicheck.c b/libexpat/tests/regression/minicheck.c
new file mode 120000
index 0000000..abcc94a
--- /dev/null
+++ b/libexpat/tests/regression/minicheck.c
@@ -0,0 +1 @@
+../../../upstream/expat/tests/minicheck.c \ No newline at end of file
diff --git a/libexpat/tests/regression/minicheck.h b/libexpat/tests/regression/minicheck.h
new file mode 120000
index 0000000..c499235
--- /dev/null
+++ b/libexpat/tests/regression/minicheck.h
@@ -0,0 +1 @@
+../../../upstream/expat/tests/minicheck.h \ No newline at end of file
diff --git a/libexpat/tests/regression/runtests.c b/libexpat/tests/regression/runtests.c
new file mode 120000
index 0000000..7753f85
--- /dev/null
+++ b/libexpat/tests/regression/runtests.c
@@ -0,0 +1 @@
+../../../upstream/expat/tests/runtests.c \ No newline at end of file
diff --git a/libexpat/tests/regression/testscript b/libexpat/tests/regression/testscript
new file mode 100644
index 0000000..d2af7af
--- /dev/null
+++ b/libexpat/tests/regression/testscript
@@ -0,0 +1,9 @@
+# file : tests/regression/testscript
+# license : MIT; see accompanying COPYING file
+
+: check
+:
+$* >>~/EOE/
+ /Expat version: expat_\d+.\d+.\d+/d
+ /100%: Checks: .+, Failed: 0/
+ EOE
diff --git a/packages.manifest b/packages.manifest
new file mode 100644
index 0000000..a3354e2
--- /dev/null
+++ b/packages.manifest
@@ -0,0 +1,2 @@
+: 1
+location: libexpat/
diff --git a/upstream b/upstream
new file mode 160000
+Subproject 9bc7d8ae2e5a0025a4f825f56d52481d706dab1