"Hacktree" is now known as "OSTree"

It just sounds better.
This commit is contained in:
Colin Walters 2011-10-18 14:44:48 -04:00
parent 6114bc3b06
commit b27df6fd72
37 changed files with 478 additions and 445 deletions

View File

@ -1,58 +0,0 @@
# Makefile for C source code
#
# Copyright (C) 2011 Colin Walters <walters@verbum.org>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
# Author: Colin Walters <walters@verbum.org>
noinst_LTLIBRARIES += libhtutil.la
libhtutil_la_SOURCES = \
src/libhtutil/ht-unix-utils.c \
src/libhtutil/ht-unix-utils.h \
src/libhtutil/ht-gio-utils.c \
src/libhtutil/ht-gio-utils.h \
src/libhtutil/htutil.h \
$(NULL)
libhtutil_la_CFLAGS = -I$(srcdir)/src/libhtutil -DLOCALEDIR=\"$(datadir)/locale\" $(GIO_UNIX_CFLAGS)
libhtutil_la_LIBADD = $(GIO_UNIX_LIBS)
noinst_LTLIBRARIES += libhacktree.la
libhacktree_la_SOURCES = src/libhacktree/hacktree.h \
src/libhacktree/hacktree-core.c \
src/libhacktree/hacktree-core.h \
src/libhacktree/hacktree-repo.c \
src/libhacktree/hacktree-repo.h \
src/libhacktree/hacktree-types.h \
$(NULL)
libhacktree_la_CFLAGS = -I$(srcdir)/src/libhacktree -I$(srcdir)/src/libhtutil -DLOCALEDIR=\"$(datadir)/locale\" $(GIO_UNIX_CFLAGS)
libhacktree_la_LIBADD = libhtutil.la $(GIO_UNIX_LIBS)
bin_PROGRAMS += hacktree
hacktree_SOURCES = src/main.c \
src/ht-builtins.h \
src/ht-builtin-checkout.c \
src/ht-builtin-commit.c \
src/ht-builtin-fsck.c \
src/ht-builtin-init.c \
src/ht-builtin-link-file.c \
src/ht-builtin-log.c \
src/ht-builtin-show.c \
$(NULL)
hacktree_CFLAGS = -I$(srcdir)/src -I$(srcdir)/src/libhacktree -I$(srcdir)/src/libhtutil -DLOCALEDIR=\"$(datadir)/locale\" $(GIO_UNIX_CFLAGS)
hacktree_LDADD = libhtutil.la libhacktree.la $(GIO_UNIX_LIBS)

58
Makefile-src.am Normal file
View File

@ -0,0 +1,58 @@
# Makefile for C source code
#
# Copyright (C) 2011 Colin Walters <walters@verbum.org>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
# Author: Colin Walters <walters@verbum.org>
noinst_LTLIBRARIES += libotutil.la
libotutil_la_SOURCES = \
src/libotutil/ot-unix-utils.c \
src/libotutil/ot-unix-utils.h \
src/libotutil/ot-gio-utils.c \
src/libotutil/ot-gio-utils.h \
src/libotutil/otutil.h \
$(NULL)
libotutil_la_CFLAGS = -I$(srcdir)/src/libotutil -DLOCALEDIR=\"$(datadir)/locale\" $(GIO_UNIX_CFLAGS)
libotutil_la_LIBADD = $(GIO_UNIX_LIBS)
noinst_LTLIBRARIES += libostree.la
libostree_la_SOURCES = src/libostree/ostree.h \
src/libostree/ostree-core.c \
src/libostree/ostree-core.h \
src/libostree/ostree-repo.c \
src/libostree/ostree-repo.h \
src/libostree/ostree-types.h \
$(NULL)
libostree_la_CFLAGS = -I$(srcdir)/src/libostree -I$(srcdir)/src/libotutil -DLOCALEDIR=\"$(datadir)/locale\" $(GIO_UNIX_CFLAGS)
libostree_la_LIBADD = libotutil.la $(GIO_UNIX_LIBS)
bin_PROGRAMS += ostree
ostree_SOURCES = src/main.c \
src/ot-builtins.h \
src/ot-builtin-checkout.c \
src/ot-builtin-commit.c \
src/ot-builtin-fsck.c \
src/ot-builtin-init.c \
src/ot-builtin-link-file.c \
src/ot-builtin-log.c \
src/ot-builtin-show.c \
$(NULL)
ostree_CFLAGS = -I$(srcdir)/src -I$(srcdir)/src/libostree -I$(srcdir)/src/libotutil -DLOCALEDIR=\"$(datadir)/locale\" $(GIO_UNIX_CFLAGS)
ostree_LDADD = libotutil.la libostree.la $(GIO_UNIX_LIBS)

View File

@ -10,5 +10,4 @@ libexec_PROGRAMS =
noinst_LTLIBRARIES = noinst_LTLIBRARIES =
noinst_PROGRAMS = noinst_PROGRAMS =
include Makefile-src.am
include Makefile-hacktree.am

View File

@ -1,4 +1,4 @@
Hacktree OSTree
======== ========
Problem statement Problem statement
@ -48,7 +48,7 @@ Comparison with existing tools
the old package. the old package.
This is most realistic option for people hacking on system This is most realistic option for people hacking on system
components currently, but hacktree will be better. components currently, but ostree will be better.
- LXC / containers - LXC / containers
@ -66,7 +66,7 @@ Comparison with existing tools
this means you can't build NetworkManager, and thus are permanently this means you can't build NetworkManager, and thus are permanently
stuck on whatever the distro provides. stuck on whatever the distro provides.
Who is hacktree for? Who is ostree for?
------------------------------ ------------------------------
First - operating system developers and testers. I specifically keep First - operating system developers and testers. I specifically keep
@ -103,22 +103,19 @@ Debian). It has a root filesystem like this:
Now, what we can do is have a system that installs chroots as a subdirectory Now, what we can do is have a system that installs chroots as a subdirectory
of the root, like: of the root, like:
/usr /ostree/gnomeos-3.0-opt-393a4555/{usr,etc,sbin,...}
/etc /ostree/gnomeos-3.2-opt-7e9788a2/{usr,etc,sbin,...}
/home
/gnomeos/root-3.0-opt/{usr,etc,var,...}
/gnomeos/root-3.2-opt/{usr,etc,var,...}
These live in the same root filesystem as your regular distribution These live in the same root filesystem as your regular distribution
(Note though, the root partition should be reasonably sized, or (Note though, the root partition should be reasonably sized, or
hopefully you've used just one big partition). hopefully you've used just one big partition).
You should be able to boot into one of these roots. Since hacktree You should be able to boot into one of these roots. Since ostree
lives inside a distro created partition, a tricky part here is that we lives inside a distro created partition, a tricky part here is that we
need to know how to interact with the installed distribution's grub. need to know how to interact with the installed distribution's grub.
This is an annoying but tractable problem. This is an annoying but tractable problem.
Hacktree will allow efficiently parallel installing and downloading OS OSTree will allow efficiently parallel installing and downloading OS
builds. builds.
An important note here is that we explicitly link /home in each root An important note here is that we explicitly link /home in each root
@ -126,6 +123,40 @@ to the real /home. This means you have your data. This also implies
we share uid/gid, so /etc/passwd will have to be in sync. Probably we share uid/gid, so /etc/passwd will have to be in sync. Probably
what we'll do is have a script to pull the data from the "host" OS. what we'll do is have a script to pull the data from the "host" OS.
Other shared directories are /var and /root. Note that /etc is
explicitly NOT shared!
On a pure OSTree system, the filesystem layout will look like this:
.
|-- boot
|-- home
|-- ostree
| |-- current -> gnomeos-3.2-opt-7e9788a2
| |-- gnomeos-3.0-opt-393a4555
| | |-- etc
| | |-- lib
| | |-- mnt
| | |-- proc
| | |-- run
| | |-- sbin
| | |-- srv
| | |-- sys
| | `-- usr
| `-- gnomeos-3.2-opt-7e9788a2
| |-- etc
| |-- lib
| |-- mnt
| |-- proc
| |-- run
| |-- sbin
| |-- srv
| |-- sys
| `-- usr
|-- root
`-- var
Making this efficient Making this efficient
--------------------- ---------------------
@ -142,14 +173,14 @@ that point to it. This mutability means that we have to either:
This is probably tractable over a long period of time, but if anything This is probably tractable over a long period of time, but if anything
has a bug, then it corrupts the file effectively. has a bug, then it corrupts the file effectively.
2. Make the core OS read-only, with a well-defined mechanism for mutating 2. Make the core OS read-only, with a well-defined mechanism for mutating
under the control of hacktree. under the control of ostree.
I chose 2. I chose 2.
A userspace content-addressed versioning filesystem A userspace content-addressed versioning filesystem
--------------------------------------------------- ---------------------------------------------------
At its very core, that's what hacktree is. Just like git. If you At its very core, that's what ostree is. Just like git. If you
understand git, you know it's not like other revision control systems. understand git, you know it's not like other revision control systems.
git is effectively a specialized, userspace filesystem, and that is a git is effectively a specialized, userspace filesystem, and that is a
very powerful idea. very powerful idea.
@ -162,16 +193,16 @@ source trees - it goes to effort to be sure it's compressing text for
example, under the assumption that you have a lot of text. Its example, under the assumption that you have a lot of text. Its
handling of binaries is very generic and unoptimized. handling of binaries is very generic and unoptimized.
In contrast, hacktree is explicitly designed for binaries, and in In contrast, ostree is explicitly designed for binaries, and in
particular one type of binary - ELF executables (or it will be once we particular one type of binary - ELF executables (or it will be once we
start using bsdiff). start using bsdiff).
Another big difference versus git is that hacktree uses hard links Another big difference versus git is that ostree uses hard links
between "checkouts" and the repository. This means each checkout uses between "checkouts" and the repository. This means each checkout uses
almost no additional space, and is *extremely* fast to check out. We almost no additional space, and is *extremely* fast to check out. We
can do this because again each checkout is designed to be read-only. can do this because again each checkout is designed to be read-only.
So we mentioned above the So we mentioned above there are:
/gnomeos/root-3.0-opt /gnomeos/root-3.0-opt
/gnomeos/root-3.2-opt /gnomeos/root-3.2-opt
@ -206,7 +237,7 @@ change =)
Atomic upgrades, rollback Atomic upgrades, rollback
------------------------- -------------------------
Hacktree is designed to atomically swap operating systems - such that OSTree is designed to atomically swap operating systems - such that
during an upgrade and reboot process, you either get the full new during an upgrade and reboot process, you either get the full new
system, or the old one. There is no "Please don't turn off your system, or the old one. There is no "Please don't turn off your
computer". We do this by simply using a symbolic link like: computer". We do this by simply using a symbolic link like:
@ -272,13 +303,13 @@ What about "packages"?
Basically I think they're a broken idea. There are several different Basically I think they're a broken idea. There are several different
classes of things that demand targeted solutions: classes of things that demand targeted solutions:
1. Managing and upgrading the core OS (hacktree) 1. Managing and upgrading the core OS (ostree)
2. Managing and upgrading desktop applications (gnome-shell, glick?) 2. Managing and upgrading desktop applications (gnome-shell, glick?)
3. System extensions - these are arbitrary RPMs like say the nVidia driver. 3. System extensions - these are arbitrary RPMs like say the nVidia driver.
We apply them after constructing each root. Media codecs also fall We apply them after constructing each root. Media codecs also fall
into this category. into this category.
How one might install say Apache on top of hacktree is an open How one might install say Apache on top of ostree is an open
question - I think it probably makes sense honestly to ship services question - I think it probably makes sense honestly to ship services
like this with no configuration - just the binaries. Then admins can like this with no configuration - just the binaries. Then admins can
do whatever they want. do whatever they want.
@ -286,7 +317,7 @@ do whatever they want.
Downloads Downloads
--------- ---------
I'm pretty sure hacktree should be significantly better than RPM with I'm pretty sure ostree should be significantly better than RPM with
deltarpms. Note we only download changed objects. If say just one deltarpms. Note we only download changed objects. If say just one
translation changes, we only download that new translation! One translation changes, we only download that new translation! One
problem we will have to hunt down is programs that inject problem we will have to hunt down is programs that inject
@ -350,7 +381,7 @@ approach is it doesn't solve the race conditions that happen when
unpacking packages into the live system. This problem is really unpacking packages into the live system. This problem is really
important to me. important to me.
Note though hacktree can definitely take advantage of BTRFS features! Note though ostree can definitely take advantage of BTRFS features!
In particular, we could use "reflink" In particular, we could use "reflink"
<http://lwn.net/Articles/331808/> instead of hard links, and avoid <http://lwn.net/Articles/331808/> instead of hard links, and avoid
having the object store corrupted if somehow the files are modified having the object store corrupted if somehow the files are modified
@ -383,7 +414,7 @@ didn't use them:
- Conary: <http://wiki.rpath.com/wiki/Conary:Updates_and_Rollbacks> - Conary: <http://wiki.rpath.com/wiki/Conary:Updates_and_Rollbacks>
If rpm/dpkg are like CVS, Conary is closer to Subversion. It's not If rpm/dpkg are like CVS, Conary is closer to Subversion. It's not
bad, but hacktree is better than it for the exact same reasons git bad, but ostree is better than it for the exact same reasons git
is better than Subversion. is better than Subversion.
- BTRFS: <http://en.wikipedia.org/wiki/Btrfs> - BTRFS: <http://en.wikipedia.org/wiki/Btrfs>
@ -393,4 +424,4 @@ didn't use them:
- Jhbuild: <https://live.gnome.org/Jhbuild> - Jhbuild: <https://live.gnome.org/Jhbuild>
What we've been using in GNOME, and has the essential property of allowing you What we've been using in GNOME, and has the essential property of allowing you
to "fall back" to a stable system. But hacktree will blow it out of the water. to "fall back" to a stable system. But ostree will blow it out of the water.

View File

@ -1,5 +1,5 @@
AC_PREREQ([2.63]) AC_PREREQ([2.63])
AC_INIT([hacktree], [0], [walters@verbum.org]) AC_INIT([ostree], [0], [walters@verbum.org])
AC_CONFIG_HEADER([config.h]) AC_CONFIG_HEADER([config.h])
AC_CONFIG_MACRO_DIR([m4]) AC_CONFIG_MACRO_DIR([m4])
AC_CONFIG_AUX_DIR([build-aux]) AC_CONFIG_AUX_DIR([build-aux])

View File

@ -5,8 +5,8 @@
xmlns:gnome="http://api.gnome.org/doap-extensions#" xmlns:gnome="http://api.gnome.org/doap-extensions#"
xmlns="http://usefulinc.com/ns/doap#"> xmlns="http://usefulinc.com/ns/doap#">
<name>hacktree</name> <name>ostree</name>
<shortname>hacktree</shortname> <shortname>ostree</shortname>
<shortdesc xml:lang="en">GNOME OS build tool</shortdesc> <shortdesc xml:lang="en">GNOME OS build tool</shortdesc>

View File

@ -37,8 +37,11 @@ parts of the OS to a new directory "r0".
$ mkdir r0 $ mkdir r0
$ DIRS="bin dev etc lib lib32 lib64 media mnt opt proc root run sbin selinux srv sys tmp usr" $ DIRS="bin dev etc lib lib32 lib64 media mnt opt proc root run sbin selinux srv sys tmp usr"
$ mv $DIRS r0 $ mv $DIRS r0
$ mkdir r0/{boot,var,home}
$ touch r0/{boot,var,home}/EMPTY
Note that /boot, /home and /var are left shared. Now with it still Note that /boot, /home and /var are left shared; we create empty
destination directories that will be mounted over. Now with it still
mounted, we need to move on to the next part - modifying the initrd. mounted, we need to move on to the next part - modifying the initrd.
Then I started hacking on the initrd, making understand how to chroot Then I started hacking on the initrd, making understand how to chroot

View File

@ -21,8 +21,8 @@
#include "config.h" #include "config.h"
#include "hacktree.h" #include "ostree.h"
#include "htutil.h" #include "otutil.h"
#include <sys/types.h> #include <sys/types.h>
#include <attr/xattr.h> #include <attr/xattr.h>
@ -80,7 +80,7 @@ read_xattr_name_array (const char *path,
bytes_read = lgetxattr (path, p, NULL, 0); bytes_read = lgetxattr (path, p, NULL, 0);
if (bytes_read < 0) if (bytes_read < 0)
{ {
ht_util_set_error_from_errno (error, errno); ot_util_set_error_from_errno (error, errno);
goto out; goto out;
} }
if (bytes_read == 0) if (bytes_read == 0)
@ -89,7 +89,7 @@ read_xattr_name_array (const char *path,
buf = g_malloc (bytes_read); buf = g_malloc (bytes_read);
if (lgetxattr (path, p, buf, bytes_read) < 0) if (lgetxattr (path, p, buf, bytes_read) < 0)
{ {
ht_util_set_error_from_errno (error, errno); ot_util_set_error_from_errno (error, errno);
g_free (buf); g_free (buf);
goto out; goto out;
} }
@ -108,7 +108,7 @@ read_xattr_name_array (const char *path,
} }
GVariant * GVariant *
hacktree_get_xattrs_for_path (const char *path, ostree_get_xattrs_for_path (const char *path,
GError **error) GError **error)
{ {
GVariant *ret = NULL; GVariant *ret = NULL;
@ -125,7 +125,7 @@ hacktree_get_xattrs_for_path (const char *path,
{ {
if (errno != ENOTSUP) if (errno != ENOTSUP)
{ {
ht_util_set_error_from_errno (error, errno); ot_util_set_error_from_errno (error, errno);
goto out; goto out;
} }
} }
@ -135,7 +135,7 @@ hacktree_get_xattrs_for_path (const char *path,
xattr_names = g_malloc (bytes_read); xattr_names = g_malloc (bytes_read);
if (llistxattr (path, xattr_names, bytes_read) < 0) if (llistxattr (path, xattr_names, bytes_read) < 0)
{ {
ht_util_set_error_from_errno (error, errno); ot_util_set_error_from_errno (error, errno);
goto out; goto out;
} }
xattr_names_canonical = canonicalize_xattrs (xattr_names, bytes_read); xattr_names_canonical = canonicalize_xattrs (xattr_names, bytes_read);
@ -154,7 +154,7 @@ hacktree_get_xattrs_for_path (const char *path,
} }
gboolean gboolean
hacktree_stat_and_checksum_file (int dir_fd, const char *path, ostree_stat_and_checksum_file (int dir_fd, const char *path,
GChecksum **out_checksum, GChecksum **out_checksum,
struct stat *out_stbuf, struct stat *out_stbuf,
GError **error) GError **error)
@ -180,7 +180,7 @@ hacktree_stat_and_checksum_file (int dir_fd, const char *path,
temp_dir = opendir (dirname); temp_dir = opendir (dirname);
if (temp_dir == NULL) if (temp_dir == NULL)
{ {
ht_util_set_error_from_errno (error, errno); ot_util_set_error_from_errno (error, errno);
g_free (dirname); g_free (dirname);
} }
g_free (dirname); g_free (dirname);
@ -189,22 +189,22 @@ hacktree_stat_and_checksum_file (int dir_fd, const char *path,
if (fstatat (dir_fd, basename, &stbuf, AT_SYMLINK_NOFOLLOW) < 0) if (fstatat (dir_fd, basename, &stbuf, AT_SYMLINK_NOFOLLOW) < 0)
{ {
ht_util_set_error_from_errno (error, errno); ot_util_set_error_from_errno (error, errno);
goto out; goto out;
} }
if (!S_ISLNK(stbuf.st_mode)) if (!S_ISLNK(stbuf.st_mode))
{ {
fd = ht_util_open_file_read_at (dir_fd, basename, error); fd = ot_util_open_file_read_at (dir_fd, basename, error);
if (fd < 0) if (fd < 0)
{ {
ht_util_set_error_from_errno (error, errno); ot_util_set_error_from_errno (error, errno);
goto out; goto out;
} }
} }
stat_string = stat_to_string (&stbuf); stat_string = stat_to_string (&stbuf);
xattrs = hacktree_get_xattrs_for_path (path, error); xattrs = ostree_get_xattrs_for_path (path, error);
if (!xattrs) if (!xattrs)
goto out; goto out;
@ -218,7 +218,7 @@ hacktree_stat_and_checksum_file (int dir_fd, const char *path,
g_checksum_update (content_sha256, buf, bytes_read); g_checksum_update (content_sha256, buf, bytes_read);
if (bytes_read < 0) if (bytes_read < 0)
{ {
ht_util_set_error_from_errno (error, errno); ot_util_set_error_from_errno (error, errno);
goto out; goto out;
} }
} }
@ -228,7 +228,7 @@ hacktree_stat_and_checksum_file (int dir_fd, const char *path,
if (readlinkat (dir_fd, basename, symlink_target, PATH_MAX) < 0) if (readlinkat (dir_fd, basename, symlink_target, PATH_MAX) < 0)
{ {
ht_util_set_error_from_errno (error, errno); ot_util_set_error_from_errno (error, errno);
goto out; goto out;
} }
g_checksum_update (content_sha256, (guint8*)symlink_target, strlen (symlink_target)); g_checksum_update (content_sha256, (guint8*)symlink_target, strlen (symlink_target));

View File

@ -19,36 +19,36 @@
* Author: Colin Walters <walters@verbum.org> * Author: Colin Walters <walters@verbum.org>
*/ */
#ifndef _HACKTREE_CORE #ifndef _OSTREE_CORE
#define _HACKTREE_CORE #define _OSTREE_CORE
#include <htutil.h> #include <otutil.h>
G_BEGIN_DECLS G_BEGIN_DECLS
#define HACKTREE_EMPTY_STRING_SHA256 "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855"; #define OSTREE_EMPTY_STRING_SHA256 "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855";
typedef enum { typedef enum {
HACKTREE_OBJECT_TYPE_FILE = 1, OSTREE_OBJECT_TYPE_FILE = 1,
HACKTREE_OBJECT_TYPE_META = 2, OSTREE_OBJECT_TYPE_META = 2,
} HacktreeObjectType; } OstreeObjectType;
typedef enum { typedef enum {
HACKTREE_SERIALIZED_TREE_VARIANT = 1, OSTREE_SERIALIZED_TREE_VARIANT = 1,
HACKTREE_SERIALIZED_COMMIT_VARIANT = 2, OSTREE_SERIALIZED_COMMIT_VARIANT = 2,
HACKTREE_SERIALIZED_DIRMETA_VARIANT = 3, OSTREE_SERIALIZED_DIRMETA_VARIANT = 3,
HACKTREE_SERIALIZED_XATTR_VARIANT = 4 OSTREE_SERIALIZED_XATTR_VARIANT = 4
} HacktreeSerializedVariantType; } OstreeSerializedVariantType;
#define HACKTREE_SERIALIZED_VARIANT_FORMAT "(uv)" #define OSTREE_SERIALIZED_VARIANT_FORMAT "(uv)"
/* /*
* xattr objects: * xattr objects:
* a(ayay) - array of (name, value) pairs, both binary data, though name is a bytestring * a(ayay) - array of (name, value) pairs, both binary data, though name is a bytestring
*/ */
#define HACKTREE_XATTR_GVARIANT_FORMAT "a(ayay)" #define OSTREE_XATTR_GVARIANT_FORMAT "a(ayay)"
#define HACKTREE_DIR_META_VERSION 0 #define OSTREE_DIR_META_VERSION 0
/* /*
* dirmeta objects: * dirmeta objects:
* u - Version * u - Version
@ -57,9 +57,9 @@ typedef enum {
* u - mode * u - mode
* a(ayay) - xattrs * a(ayay) - xattrs
*/ */
#define HACKTREE_DIRMETA_GVARIANT_FORMAT "(uuuua(ayay))" #define OSTREE_DIRMETA_GVARIANT_FORMAT "(uuuua(ayay))"
#define HACKTREE_TREE_VERSION 0 #define OSTREE_TREE_VERSION 0
/* /*
* Tree objects: * Tree objects:
* u - Version * u - Version
@ -67,9 +67,9 @@ typedef enum {
* a(ss) - array of (filename, checksum) for files * a(ss) - array of (filename, checksum) for files
* a(sss) - array of (dirname, tree_checksum, meta_checksum) for directories * a(sss) - array of (dirname, tree_checksum, meta_checksum) for directories
*/ */
#define HACKTREE_TREE_GVARIANT_FORMAT "(ua{sv}a(ss)a(sss)" #define OSTREE_TREE_GVARIANT_FORMAT "(ua{sv}a(ss)a(sss)"
#define HACKTREE_COMMIT_VERSION 0 #define OSTREE_COMMIT_VERSION 0
/* /*
* Commit objects: * Commit objects:
* u - Version * u - Version
@ -81,15 +81,15 @@ typedef enum {
* s - Root tree contents * s - Root tree contents
* s - Root tree metadata * s - Root tree metadata
*/ */
#define HACKTREE_COMMIT_GVARIANT_FORMAT "(ua{sv}ssstss)" #define OSTREE_COMMIT_GVARIANT_FORMAT "(ua{sv}ssstss)"
GVariant *hacktree_get_xattrs_for_path (const char *path, GVariant *ostree_get_xattrs_for_path (const char *path,
GError **error); GError **error);
gboolean hacktree_stat_and_checksum_file (int dirfd, const char *path, gboolean ostree_stat_and_checksum_file (int dirfd, const char *path,
GChecksum **out_checksum, GChecksum **out_checksum,
struct stat *out_stbuf, struct stat *out_stbuf,
GError **error); GError **error);
#endif /* _HACKTREE_REPO */ #endif /* _OSTREE_REPO */

View File

@ -21,22 +21,22 @@
#include "config.h" #include "config.h"
#include "hacktree.h" #include "ostree.h"
#include "htutil.h" #include "otutil.h"
#include <gio/gunixoutputstream.h> #include <gio/gunixoutputstream.h>
#include <gio/gunixinputstream.h> #include <gio/gunixinputstream.h>
static gboolean static gboolean
link_one_file (HacktreeRepo *self, const char *path, link_one_file (OstreeRepo *self, const char *path,
HacktreeObjectType type, OstreeObjectType type,
gboolean ignore_exists, gboolean force, gboolean ignore_exists, gboolean force,
GChecksum **out_checksum, GChecksum **out_checksum,
GError **error); GError **error);
static char * static char *
get_object_path (HacktreeRepo *self, get_object_path (OstreeRepo *self,
const char *checksum, const char *checksum,
HacktreeObjectType type); OstreeObjectType type);
enum { enum {
PROP_0, PROP_0,
@ -44,14 +44,14 @@ enum {
PROP_PATH PROP_PATH
}; };
G_DEFINE_TYPE (HacktreeRepo, hacktree_repo, G_TYPE_OBJECT) G_DEFINE_TYPE (OstreeRepo, ostree_repo, G_TYPE_OBJECT)
#define GET_PRIVATE(o) \ #define GET_PRIVATE(o) \
(G_TYPE_INSTANCE_GET_PRIVATE ((o), HACKTREE_TYPE_REPO, HacktreeRepoPrivate)) (G_TYPE_INSTANCE_GET_PRIVATE ((o), OSTREE_TYPE_REPO, OstreeRepoPrivate))
typedef struct _HacktreeRepoPrivate HacktreeRepoPrivate; typedef struct _OstreeRepoPrivate OstreeRepoPrivate;
struct _HacktreeRepoPrivate { struct _OstreeRepoPrivate {
char *path; char *path;
GFile *repo_file; GFile *repo_file;
char *head_ref_path; char *head_ref_path;
@ -62,10 +62,10 @@ struct _HacktreeRepoPrivate {
}; };
static void static void
hacktree_repo_finalize (GObject *object) ostree_repo_finalize (GObject *object)
{ {
HacktreeRepo *self = HACKTREE_REPO (object); OstreeRepo *self = OSTREE_REPO (object);
HacktreeRepoPrivate *priv = GET_PRIVATE (self); OstreeRepoPrivate *priv = GET_PRIVATE (self);
g_free (priv->path); g_free (priv->path);
g_clear_object (&priv->repo_file); g_clear_object (&priv->repo_file);
@ -73,17 +73,17 @@ hacktree_repo_finalize (GObject *object)
g_free (priv->objects_path); g_free (priv->objects_path);
g_free (priv->current_head); g_free (priv->current_head);
G_OBJECT_CLASS (hacktree_repo_parent_class)->finalize (object); G_OBJECT_CLASS (ostree_repo_parent_class)->finalize (object);
} }
static void static void
hacktree_repo_set_property(GObject *object, ostree_repo_set_property(GObject *object,
guint prop_id, guint prop_id,
const GValue *value, const GValue *value,
GParamSpec *pspec) GParamSpec *pspec)
{ {
HacktreeRepo *self = HACKTREE_REPO (object); OstreeRepo *self = OSTREE_REPO (object);
HacktreeRepoPrivate *priv = GET_PRIVATE (self); OstreeRepoPrivate *priv = GET_PRIVATE (self);
switch (prop_id) switch (prop_id)
{ {
@ -97,13 +97,13 @@ hacktree_repo_set_property(GObject *object,
} }
static void static void
hacktree_repo_get_property(GObject *object, ostree_repo_get_property(GObject *object,
guint prop_id, guint prop_id,
GValue *value, GValue *value,
GParamSpec *pspec) GParamSpec *pspec)
{ {
HacktreeRepo *self = HACKTREE_REPO (object); OstreeRepo *self = OSTREE_REPO (object);
HacktreeRepoPrivate *priv = GET_PRIVATE (self); OstreeRepoPrivate *priv = GET_PRIVATE (self);
switch (prop_id) switch (prop_id)
{ {
@ -117,39 +117,39 @@ hacktree_repo_get_property(GObject *object,
} }
static GObject * static GObject *
hacktree_repo_constructor (GType gtype, ostree_repo_constructor (GType gtype,
guint n_properties, guint n_properties,
GObjectConstructParam *properties) GObjectConstructParam *properties)
{ {
GObject *object; GObject *object;
GObjectClass *parent_class; GObjectClass *parent_class;
HacktreeRepoPrivate *priv; OstreeRepoPrivate *priv;
parent_class = G_OBJECT_CLASS (hacktree_repo_parent_class); parent_class = G_OBJECT_CLASS (ostree_repo_parent_class);
object = parent_class->constructor (gtype, n_properties, properties); object = parent_class->constructor (gtype, n_properties, properties);
priv = GET_PRIVATE (object); priv = GET_PRIVATE (object);
g_assert (priv->path != NULL); g_assert (priv->path != NULL);
priv->repo_file = ht_util_new_file_for_path (priv->path); priv->repo_file = ot_util_new_file_for_path (priv->path);
priv->head_ref_path = g_build_filename (priv->path, HACKTREE_REPO_DIR, "HEAD", NULL); priv->head_ref_path = g_build_filename (priv->path, OSTREE_REPO_DIR, "HEAD", NULL);
priv->objects_path = g_build_filename (priv->path, HACKTREE_REPO_DIR, "objects", NULL); priv->objects_path = g_build_filename (priv->path, OSTREE_REPO_DIR, "objects", NULL);
return object; return object;
} }
static void static void
hacktree_repo_class_init (HacktreeRepoClass *klass) ostree_repo_class_init (OstreeRepoClass *klass)
{ {
GObjectClass *object_class = G_OBJECT_CLASS (klass); GObjectClass *object_class = G_OBJECT_CLASS (klass);
g_type_class_add_private (klass, sizeof (HacktreeRepoPrivate)); g_type_class_add_private (klass, sizeof (OstreeRepoPrivate));
object_class->constructor = hacktree_repo_constructor; object_class->constructor = ostree_repo_constructor;
object_class->get_property = hacktree_repo_get_property; object_class->get_property = ostree_repo_get_property;
object_class->set_property = hacktree_repo_set_property; object_class->set_property = ostree_repo_set_property;
object_class->finalize = hacktree_repo_finalize; object_class->finalize = ostree_repo_finalize;
g_object_class_install_property (object_class, g_object_class_install_property (object_class,
PROP_PATH, PROP_PATH,
@ -161,18 +161,18 @@ hacktree_repo_class_init (HacktreeRepoClass *klass)
} }
static void static void
hacktree_repo_init (HacktreeRepo *self) ostree_repo_init (OstreeRepo *self)
{ {
} }
HacktreeRepo* OstreeRepo*
hacktree_repo_new (const char *path) ostree_repo_new (const char *path)
{ {
return g_object_new (HACKTREE_TYPE_REPO, "path", path, NULL); return g_object_new (OSTREE_TYPE_REPO, "path", path, NULL);
} }
static gboolean static gboolean
parse_checksum_file (HacktreeRepo *self, parse_checksum_file (OstreeRepo *self,
const char *path, const char *path,
char **sha256, char **sha256,
GError **error) GError **error)
@ -181,7 +181,7 @@ parse_checksum_file (HacktreeRepo *self,
gboolean ret = FALSE; gboolean ret = FALSE;
char *ret_sha256 = NULL; char *ret_sha256 = NULL;
ret_sha256 = ht_util_get_file_contents_utf8 (path, &temp_error); ret_sha256 = ot_util_get_file_contents_utf8 (path, &temp_error);
if (ret_sha256 == NULL) if (ret_sha256 == NULL)
{ {
if (g_error_matches (temp_error, G_FILE_ERROR, G_FILE_ERROR_NOENT)) if (g_error_matches (temp_error, G_FILE_ERROR, G_FILE_ERROR_NOENT))
@ -225,9 +225,9 @@ write_checksum_file (const char *path,
} }
gboolean gboolean
hacktree_repo_check (HacktreeRepo *self, GError **error) ostree_repo_check (OstreeRepo *self, GError **error)
{ {
HacktreeRepoPrivate *priv = GET_PRIVATE (self); OstreeRepoPrivate *priv = GET_PRIVATE (self);
g_return_val_if_fail (error == NULL || *error == NULL, FALSE); g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
@ -247,13 +247,13 @@ hacktree_repo_check (HacktreeRepo *self, GError **error)
} }
static gboolean static gboolean
import_gvariant_object (HacktreeRepo *self, import_gvariant_object (OstreeRepo *self,
HacktreeSerializedVariantType type, OstreeSerializedVariantType type,
GVariant *variant, GVariant *variant,
GChecksum **out_checksum, GChecksum **out_checksum,
GError **error) GError **error)
{ {
HacktreeRepoPrivate *priv = GET_PRIVATE (self); OstreeRepoPrivate *priv = GET_PRIVATE (self);
GVariant *serialized = NULL; GVariant *serialized = NULL;
gboolean ret = FALSE; gboolean ret = FALSE;
gsize bytes_written; gsize bytes_written;
@ -267,7 +267,7 @@ import_gvariant_object (HacktreeRepo *self,
fd = mkstemp (tmp_name); fd = mkstemp (tmp_name);
if (fd < 0) if (fd < 0)
{ {
ht_util_set_error_from_errno (error, errno); ot_util_set_error_from_errno (error, errno);
goto out; goto out;
} }
@ -283,7 +283,7 @@ import_gvariant_object (HacktreeRepo *self,
NULL, error)) NULL, error))
goto out; goto out;
if (!link_one_file (self, tmp_name, HACKTREE_OBJECT_TYPE_META, if (!link_one_file (self, tmp_name, OSTREE_OBJECT_TYPE_META,
TRUE, FALSE, out_checksum, error)) TRUE, FALSE, out_checksum, error))
goto out; goto out;
@ -301,9 +301,9 @@ import_gvariant_object (HacktreeRepo *self,
} }
static gboolean static gboolean
load_gvariant_object_unknown (HacktreeRepo *self, load_gvariant_object_unknown (OstreeRepo *self,
const char *sha256, const char *sha256,
HacktreeSerializedVariantType *out_type, OstreeSerializedVariantType *out_type,
GVariant **out_variant, GVariant **out_variant,
GError **error) GError **error)
{ {
@ -314,20 +314,20 @@ load_gvariant_object_unknown (HacktreeRepo *self,
char *path = NULL; char *path = NULL;
guint32 ret_type; guint32 ret_type;
path = get_object_path (self, sha256, HACKTREE_OBJECT_TYPE_META); path = get_object_path (self, sha256, OSTREE_OBJECT_TYPE_META);
mfile = g_mapped_file_new (path, FALSE, error); mfile = g_mapped_file_new (path, FALSE, error);
if (mfile == NULL) if (mfile == NULL)
goto out; goto out;
else else
{ {
container = g_variant_new_from_data (G_VARIANT_TYPE (HACKTREE_SERIALIZED_VARIANT_FORMAT), container = g_variant_new_from_data (G_VARIANT_TYPE (OSTREE_SERIALIZED_VARIANT_FORMAT),
g_mapped_file_get_contents (mfile), g_mapped_file_get_contents (mfile),
g_mapped_file_get_length (mfile), g_mapped_file_get_length (mfile),
FALSE, FALSE,
(GDestroyNotify) g_mapped_file_unref, (GDestroyNotify) g_mapped_file_unref,
mfile); mfile);
if (!g_variant_is_of_type (container, G_VARIANT_TYPE (HACKTREE_SERIALIZED_VARIANT_FORMAT))) if (!g_variant_is_of_type (container, G_VARIANT_TYPE (OSTREE_SERIALIZED_VARIANT_FORMAT)))
{ {
g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED, g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
"Corrupted metadata object '%s'", sha256); "Corrupted metadata object '%s'", sha256);
@ -359,14 +359,14 @@ load_gvariant_object_unknown (HacktreeRepo *self,
} }
static gboolean static gboolean
load_gvariant_object (HacktreeRepo *self, load_gvariant_object (OstreeRepo *self,
HacktreeSerializedVariantType expected_type, OstreeSerializedVariantType expected_type,
const char *sha256, const char *sha256,
GVariant **out_variant, GVariant **out_variant,
GError **error) GError **error)
{ {
gboolean ret = FALSE; gboolean ret = FALSE;
HacktreeSerializedVariantType type; OstreeSerializedVariantType type;
GVariant *ret_variant = NULL; GVariant *ret_variant = NULL;
if (!load_gvariant_object_unknown (self, sha256, &type, &ret_variant, error)) if (!load_gvariant_object_unknown (self, sha256, &type, &ret_variant, error))
@ -393,7 +393,7 @@ load_gvariant_object (HacktreeRepo *self,
} }
static gboolean static gboolean
import_directory_meta (HacktreeRepo *self, import_directory_meta (OstreeRepo *self,
const char *path, const char *path,
GVariant **out_variant, GVariant **out_variant,
GChecksum **out_checksum, GChecksum **out_checksum,
@ -408,7 +408,7 @@ import_directory_meta (HacktreeRepo *self,
if (lstat (path, &stbuf) < 0) if (lstat (path, &stbuf) < 0)
{ {
ht_util_set_error_from_errno (error, errno); ot_util_set_error_from_errno (error, errno);
goto out; goto out;
} }
@ -419,12 +419,12 @@ import_directory_meta (HacktreeRepo *self,
goto out; goto out;
} }
xattrs = hacktree_get_xattrs_for_path (path, error); xattrs = ostree_get_xattrs_for_path (path, error);
if (!xattrs) if (!xattrs)
goto out; goto out;
dirmeta = g_variant_new ("(uuuu@a(ayay))", dirmeta = g_variant_new ("(uuuu@a(ayay))",
HACKTREE_DIR_META_VERSION, OSTREE_DIR_META_VERSION,
(guint32)stbuf.st_uid, (guint32)stbuf.st_uid,
(guint32)stbuf.st_gid, (guint32)stbuf.st_gid,
(guint32)(stbuf.st_mode & (S_ISUID|S_ISGID|S_ISVTX|S_IRWXU|S_IRWXG|S_IRWXO)), (guint32)(stbuf.st_mode & (S_ISUID|S_ISGID|S_ISVTX|S_IRWXU|S_IRWXG|S_IRWXO)),
@ -432,7 +432,7 @@ import_directory_meta (HacktreeRepo *self,
xattrs = NULL; /* was floating */ xattrs = NULL; /* was floating */
g_variant_ref_sink (dirmeta); g_variant_ref_sink (dirmeta);
if (!import_gvariant_object (self, HACKTREE_SERIALIZED_DIRMETA_VARIANT, if (!import_gvariant_object (self, OSTREE_SERIALIZED_DIRMETA_VARIANT,
dirmeta, &ret_checksum, error)) dirmeta, &ret_checksum, error))
goto out; goto out;
@ -456,11 +456,11 @@ import_directory_meta (HacktreeRepo *self,
} }
static char * static char *
get_object_path (HacktreeRepo *self, get_object_path (OstreeRepo *self,
const char *checksum, const char *checksum,
HacktreeObjectType type) OstreeObjectType type)
{ {
HacktreeRepoPrivate *priv = GET_PRIVATE (self); OstreeRepoPrivate *priv = GET_PRIVATE (self);
char *checksum_prefix; char *checksum_prefix;
char *base_path; char *base_path;
char *ret; char *ret;
@ -470,10 +470,10 @@ get_object_path (HacktreeRepo *self,
base_path = g_build_filename (priv->objects_path, checksum_prefix, checksum + 2, NULL); base_path = g_build_filename (priv->objects_path, checksum_prefix, checksum + 2, NULL);
switch (type) switch (type)
{ {
case HACKTREE_OBJECT_TYPE_FILE: case OSTREE_OBJECT_TYPE_FILE:
type_string = ".file"; type_string = ".file";
break; break;
case HACKTREE_OBJECT_TYPE_META: case OSTREE_OBJECT_TYPE_META:
type_string = ".meta"; type_string = ".meta";
break; break;
default: default:
@ -487,9 +487,9 @@ get_object_path (HacktreeRepo *self,
} }
static char * static char *
prepare_dir_for_checksum_get_object_path (HacktreeRepo *self, prepare_dir_for_checksum_get_object_path (OstreeRepo *self,
GChecksum *checksum, GChecksum *checksum,
HacktreeObjectType type, OstreeObjectType type,
GError **error) GError **error)
{ {
char *checksum_dir = NULL; char *checksum_dir = NULL;
@ -498,7 +498,7 @@ prepare_dir_for_checksum_get_object_path (HacktreeRepo *self,
object_path = get_object_path (self, g_checksum_get_string (checksum), type); object_path = get_object_path (self, g_checksum_get_string (checksum), type);
checksum_dir = g_path_get_dirname (object_path); checksum_dir = g_path_get_dirname (object_path);
if (!ht_util_ensure_directory (checksum_dir, FALSE, error)) if (!ot_util_ensure_directory (checksum_dir, FALSE, error))
goto out; goto out;
out: out:
@ -507,7 +507,7 @@ prepare_dir_for_checksum_get_object_path (HacktreeRepo *self,
} }
static gboolean static gboolean
link_one_file (HacktreeRepo *self, const char *path, HacktreeObjectType type, link_one_file (OstreeRepo *self, const char *path, OstreeObjectType type,
gboolean ignore_exists, gboolean force, gboolean ignore_exists, gboolean force,
GChecksum **out_checksum, GChecksum **out_checksum,
GError **error) GError **error)
@ -530,11 +530,11 @@ link_one_file (HacktreeRepo *self, const char *path, HacktreeObjectType type,
src_dir = opendir (src_dirname); src_dir = opendir (src_dirname);
if (src_dir == NULL) if (src_dir == NULL)
{ {
ht_util_set_error_from_errno (error, errno); ot_util_set_error_from_errno (error, errno);
goto out; goto out;
} }
if (!hacktree_stat_and_checksum_file (dirfd (src_dir), path, &id, &stbuf, error)) if (!ostree_stat_and_checksum_file (dirfd (src_dir), path, &id, &stbuf, error))
goto out; goto out;
dest_path = prepare_dir_for_checksum_get_object_path (self, id, type, error); dest_path = prepare_dir_for_checksum_get_object_path (self, id, type, error);
if (!dest_path) if (!dest_path)
@ -545,7 +545,7 @@ link_one_file (HacktreeRepo *self, const char *path, HacktreeObjectType type,
dest_dir = opendir (dest_dirname); dest_dir = opendir (dest_dirname);
if (dest_dir == NULL) if (dest_dir == NULL)
{ {
ht_util_set_error_from_errno (error, errno); ot_util_set_error_from_errno (error, errno);
goto out; goto out;
} }
@ -561,7 +561,7 @@ link_one_file (HacktreeRepo *self, const char *path, HacktreeObjectType type,
{ {
if (errno != EEXIST || !ignore_exists) if (errno != EEXIST || !ignore_exists)
{ {
ht_util_set_error_from_errno (error, errno); ot_util_set_error_from_errno (error, errno);
goto out; goto out;
} }
} }
@ -571,7 +571,7 @@ link_one_file (HacktreeRepo *self, const char *path, HacktreeObjectType type,
if (renameat (dirfd (dest_dir), tmp_dest_basename, if (renameat (dirfd (dest_dir), tmp_dest_basename,
dirfd (dest_dir), dest_basename) < 0) dirfd (dest_dir), dest_basename) < 0)
{ {
ht_util_set_error_from_errno (error, errno); ot_util_set_error_from_errno (error, errno);
goto out; goto out;
} }
(void) unlinkat (dirfd (dest_dir), tmp_dest_basename, 0); (void) unlinkat (dirfd (dest_dir), tmp_dest_basename, 0);
@ -596,19 +596,19 @@ link_one_file (HacktreeRepo *self, const char *path, HacktreeObjectType type,
} }
gboolean gboolean
hacktree_repo_link_file (HacktreeRepo *self, ostree_repo_link_file (OstreeRepo *self,
const char *path, const char *path,
gboolean ignore_exists, gboolean ignore_exists,
gboolean force, gboolean force,
GError **error) GError **error)
{ {
HacktreeRepoPrivate *priv = GET_PRIVATE (self); OstreeRepoPrivate *priv = GET_PRIVATE (self);
GChecksum *checksum = NULL; GChecksum *checksum = NULL;
g_return_val_if_fail (error == NULL || *error == NULL, FALSE); g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
g_return_val_if_fail (priv->inited, FALSE); g_return_val_if_fail (priv->inited, FALSE);
if (!link_one_file (self, path, HACKTREE_OBJECT_TYPE_FILE, if (!link_one_file (self, path, OSTREE_OBJECT_TYPE_FILE,
ignore_exists, force, &checksum, error)) ignore_exists, force, &checksum, error))
return FALSE; return FALSE;
g_checksum_free (checksum); g_checksum_free (checksum);
@ -666,7 +666,7 @@ parsed_tree_data_free (ParsedTreeData *pdata)
} }
static gboolean static gboolean
parse_tree (HacktreeRepo *self, parse_tree (OstreeRepo *self,
const char *sha256, const char *sha256,
ParsedTreeData **out_pdata, ParsedTreeData **out_pdata,
GError **error) GError **error)
@ -680,7 +680,7 @@ parse_tree (HacktreeRepo *self,
GVariant *files_variant = NULL; GVariant *files_variant = NULL;
GVariant *dirs_variant = NULL; GVariant *dirs_variant = NULL;
if (!load_gvariant_object (self, HACKTREE_SERIALIZED_TREE_VARIANT, if (!load_gvariant_object (self, OSTREE_SERIALIZED_TREE_VARIANT,
sha256, &tree_variant, error)) sha256, &tree_variant, error))
goto out; goto out;
@ -715,7 +715,7 @@ parse_tree (HacktreeRepo *self,
if (!parse_tree (self, tree_checksum, &child_tree, error)) if (!parse_tree (self, tree_checksum, &child_tree, error))
goto out; goto out;
if (!load_gvariant_object (self, HACKTREE_SERIALIZED_DIRMETA_VARIANT, if (!load_gvariant_object (self, OSTREE_SERIALIZED_DIRMETA_VARIANT,
meta_checksum, &metadata, error)) meta_checksum, &metadata, error))
{ {
parsed_tree_data_free (child_tree); parsed_tree_data_free (child_tree);
@ -748,13 +748,13 @@ parse_tree (HacktreeRepo *self,
} }
static gboolean static gboolean
load_commit_and_trees (HacktreeRepo *self, load_commit_and_trees (OstreeRepo *self,
const char *commit_sha256, const char *commit_sha256,
GVariant **out_commit, GVariant **out_commit,
ParsedDirectoryData **out_root_data, ParsedDirectoryData **out_root_data,
GError **error) GError **error)
{ {
HacktreeRepoPrivate *priv = GET_PRIVATE (self); OstreeRepoPrivate *priv = GET_PRIVATE (self);
GVariant *ret_commit = NULL; GVariant *ret_commit = NULL;
ParsedDirectoryData *ret_root_data = NULL; ParsedDirectoryData *ret_root_data = NULL;
ParsedTreeData *tree_data = NULL; ParsedTreeData *tree_data = NULL;
@ -771,14 +771,14 @@ load_commit_and_trees (HacktreeRepo *self,
goto out; goto out;
} }
if (!load_gvariant_object (self, HACKTREE_SERIALIZED_COMMIT_VARIANT, if (!load_gvariant_object (self, OSTREE_SERIALIZED_COMMIT_VARIANT,
commit_sha256, &ret_commit, error)) commit_sha256, &ret_commit, error))
goto out; goto out;
g_variant_get_child (ret_commit, 6, "&s", &tree_contents_checksum); g_variant_get_child (ret_commit, 6, "&s", &tree_contents_checksum);
g_variant_get_child (ret_commit, 7, "&s", &tree_meta_checksum); g_variant_get_child (ret_commit, 7, "&s", &tree_meta_checksum);
if (!load_gvariant_object (self, HACKTREE_SERIALIZED_DIRMETA_VARIANT, if (!load_gvariant_object (self, OSTREE_SERIALIZED_DIRMETA_VARIANT,
tree_meta_checksum, &root_metadata, error)) tree_meta_checksum, &root_metadata, error))
goto out; goto out;
@ -815,7 +815,7 @@ create_empty_gvariant_dict (void)
} }
static gboolean static gboolean
import_parsed_tree (HacktreeRepo *self, import_parsed_tree (OstreeRepo *self,
ParsedTreeData *tree, ParsedTreeData *tree,
GChecksum **out_checksum, GChecksum **out_checksum,
GError **error) GError **error)
@ -862,7 +862,7 @@ import_parsed_tree (HacktreeRepo *self,
g_variant_builder_end (&dirs_builder)); g_variant_builder_end (&dirs_builder));
builders_initialized = FALSE; builders_initialized = FALSE;
g_variant_ref_sink (serialized_tree); g_variant_ref_sink (serialized_tree);
if (!import_gvariant_object (self, HACKTREE_SERIALIZED_TREE_VARIANT, serialized_tree, out_checksum, error)) if (!import_gvariant_object (self, OSTREE_SERIALIZED_TREE_VARIANT, serialized_tree, out_checksum, error))
goto out; goto out;
ret = TRUE; ret = TRUE;
@ -897,7 +897,7 @@ check_path (const char *filename,
goto out; goto out;
} }
if (ht_util_filename_has_dotdot (filename)) if (ot_util_filename_has_dotdot (filename))
{ {
g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED, g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
"Path uplink '..' in filename '%s' not allowed (yet)", filename); "Path uplink '..' in filename '%s' not allowed (yet)", filename);
@ -917,7 +917,7 @@ check_path (const char *filename,
} }
static gboolean static gboolean
walk_parsed_tree (HacktreeRepo *self, walk_parsed_tree (OstreeRepo *self,
const char *filename, const char *filename,
ParsedTreeData *tree, ParsedTreeData *tree,
int *out_filename_index, /* out*/ int *out_filename_index, /* out*/
@ -934,7 +934,7 @@ walk_parsed_tree (HacktreeRepo *self,
int i; int i;
int ret_filename_index = 0; int ret_filename_index = 0;
components = ht_util_path_split (filename); components = ot_util_path_split (filename);
g_assert (components != NULL); g_assert (components != NULL);
current_tree = tree; current_tree = tree;
@ -978,7 +978,7 @@ walk_parsed_tree (HacktreeRepo *self,
} }
static gboolean static gboolean
remove_files_from_tree (HacktreeRepo *self, remove_files_from_tree (OstreeRepo *self,
const char *base, const char *base,
GPtrArray *removed_files, GPtrArray *removed_files,
ParsedTreeData *tree, ParsedTreeData *tree,
@ -1028,7 +1028,7 @@ remove_files_from_tree (HacktreeRepo *self,
} }
static gboolean static gboolean
add_one_directory_to_tree_and_import (HacktreeRepo *self, add_one_directory_to_tree_and_import (OstreeRepo *self,
const char *basename, const char *basename,
const char *abspath, const char *abspath,
ParsedTreeData *tree, ParsedTreeData *tree,
@ -1068,7 +1068,7 @@ add_one_directory_to_tree_and_import (HacktreeRepo *self,
} }
static gboolean static gboolean
add_one_file_to_tree_and_import (HacktreeRepo *self, add_one_file_to_tree_and_import (OstreeRepo *self,
const char *basename, const char *basename,
const char *abspath, const char *abspath,
ParsedTreeData *tree, ParsedTreeData *tree,
@ -1080,7 +1080,7 @@ add_one_file_to_tree_and_import (HacktreeRepo *self,
g_return_val_if_fail (error == NULL || *error == NULL, FALSE); g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
g_assert (tree != NULL); g_assert (tree != NULL);
if (!link_one_file (self, abspath, HACKTREE_OBJECT_TYPE_FILE, if (!link_one_file (self, abspath, OSTREE_OBJECT_TYPE_FILE,
TRUE, FALSE, &checksum, error)) TRUE, FALSE, &checksum, error))
goto out; goto out;
@ -1095,7 +1095,7 @@ add_one_file_to_tree_and_import (HacktreeRepo *self,
} }
static gboolean static gboolean
add_one_path_to_tree_and_import (HacktreeRepo *self, add_one_path_to_tree_and_import (OstreeRepo *self,
const char *base, const char *base,
const char *filename, const char *filename,
ParsedTreeData *tree, ParsedTreeData *tree,
@ -1120,14 +1120,14 @@ add_one_path_to_tree_and_import (HacktreeRepo *self,
if (lstat (abspath, &stbuf) < 0) if (lstat (abspath, &stbuf) < 0)
{ {
ht_util_set_error_from_errno (error, errno); ot_util_set_error_from_errno (error, errno);
goto out; goto out;
} }
is_directory = S_ISDIR(stbuf.st_mode); is_directory = S_ISDIR(stbuf.st_mode);
if (components) if (components)
g_ptr_array_free (components, TRUE); g_ptr_array_free (components, TRUE);
components = ht_util_path_split (filename); components = ot_util_path_split (filename);
g_assert (components->len > 0); g_assert (components->len > 0);
current_tree = tree; current_tree = tree;
@ -1135,7 +1135,7 @@ add_one_path_to_tree_and_import (HacktreeRepo *self,
{ {
component = components->pdata[i]; component = components->pdata[i];
g_free (component_abspath); g_free (component_abspath);
component_abspath = ht_util_path_join_n (base, components, i); component_abspath = ot_util_path_join_n (base, components, i);
file_sha1 = g_hash_table_lookup (current_tree->files, component); file_sha1 = g_hash_table_lookup (current_tree->files, component);
dir = g_hash_table_lookup (current_tree->directories, component); dir = g_hash_table_lookup (current_tree->directories, component);
@ -1197,7 +1197,7 @@ add_one_path_to_tree_and_import (HacktreeRepo *self,
} }
static gboolean static gboolean
add_files_to_tree_and_import (HacktreeRepo *self, add_files_to_tree_and_import (OstreeRepo *self,
const char *base, const char *base,
GPtrArray *added_files, GPtrArray *added_files,
ParsedTreeData *tree, ParsedTreeData *tree,
@ -1220,7 +1220,7 @@ add_files_to_tree_and_import (HacktreeRepo *self,
} }
static gboolean static gboolean
commit_parsed_tree (HacktreeRepo *self, commit_parsed_tree (OstreeRepo *self,
const char *subject, const char *subject,
const char *body, const char *body,
GVariant *metadata, GVariant *metadata,
@ -1228,7 +1228,7 @@ commit_parsed_tree (HacktreeRepo *self,
GChecksum **out_commit, GChecksum **out_commit,
GError **error) GError **error)
{ {
HacktreeRepoPrivate *priv = GET_PRIVATE (self); OstreeRepoPrivate *priv = GET_PRIVATE (self);
gboolean ret = FALSE; gboolean ret = FALSE;
GChecksum *root_checksum = NULL; GChecksum *root_checksum = NULL;
GChecksum *ret_commit = NULL; GChecksum *ret_commit = NULL;
@ -1240,14 +1240,14 @@ commit_parsed_tree (HacktreeRepo *self,
now = g_date_time_new_now_utc (); now = g_date_time_new_now_utc ();
commit = g_variant_new ("(u@a{sv}ssstss)", commit = g_variant_new ("(u@a{sv}ssstss)",
HACKTREE_COMMIT_VERSION, OSTREE_COMMIT_VERSION,
create_empty_gvariant_dict (), create_empty_gvariant_dict (),
priv->current_head ? priv->current_head : "", priv->current_head ? priv->current_head : "",
subject, body ? body : "", subject, body ? body : "",
g_date_time_to_unix (now) / G_TIME_SPAN_SECOND, g_date_time_to_unix (now) / G_TIME_SPAN_SECOND,
g_checksum_get_string (root_checksum), g_checksum_get_string (root_checksum),
root->metadata_sha256); root->metadata_sha256);
if (!import_gvariant_object (self, HACKTREE_SERIALIZED_COMMIT_VARIANT, if (!import_gvariant_object (self, OSTREE_SERIALIZED_COMMIT_VARIANT,
commit, &ret_commit, error)) commit, &ret_commit, error))
goto out; goto out;
@ -1270,7 +1270,7 @@ commit_parsed_tree (HacktreeRepo *self,
} }
static gboolean static gboolean
import_root (HacktreeRepo *self, import_root (OstreeRepo *self,
const char *base, const char *base,
ParsedDirectoryData **out_root, ParsedDirectoryData **out_root,
GError **error) GError **error)
@ -1302,7 +1302,7 @@ import_root (HacktreeRepo *self,
} }
gboolean gboolean
hacktree_repo_commit (HacktreeRepo *self, ostree_repo_commit (OstreeRepo *self,
const char *subject, const char *subject,
const char *body, const char *body,
GVariant *metadata, GVariant *metadata,
@ -1312,7 +1312,7 @@ hacktree_repo_commit (HacktreeRepo *self,
GChecksum **out_commit, GChecksum **out_commit,
GError **error) GError **error)
{ {
HacktreeRepoPrivate *priv = GET_PRIVATE (self); OstreeRepoPrivate *priv = GET_PRIVATE (self);
gboolean ret = FALSE; gboolean ret = FALSE;
ParsedDirectoryData *root = NULL; ParsedDirectoryData *root = NULL;
GVariant *previous_commit = NULL; GVariant *previous_commit = NULL;
@ -1374,7 +1374,7 @@ hacktree_repo_commit (HacktreeRepo *self,
} }
gboolean gboolean
hacktree_repo_commit_from_filelist_fd (HacktreeRepo *self, ostree_repo_commit_from_filelist_fd (OstreeRepo *self,
const char *subject, const char *subject,
const char *body, const char *body,
GVariant *metadata, GVariant *metadata,
@ -1384,7 +1384,7 @@ hacktree_repo_commit_from_filelist_fd (HacktreeRepo *self,
GChecksum **out_commit, GChecksum **out_commit,
GError **error) GError **error)
{ {
HacktreeRepoPrivate *priv = GET_PRIVATE (self); OstreeRepoPrivate *priv = GET_PRIVATE (self);
gboolean ret = FALSE; gboolean ret = FALSE;
ParsedDirectoryData *root = NULL; ParsedDirectoryData *root = NULL;
GVariant *previous_commit = NULL; GVariant *previous_commit = NULL;
@ -1456,9 +1456,9 @@ hacktree_repo_commit_from_filelist_fd (HacktreeRepo *self,
} }
static gboolean static gboolean
iter_object_dir (HacktreeRepo *self, iter_object_dir (OstreeRepo *self,
GFile *dir, GFile *dir,
HacktreeRepoObjectIter callback, OstreeRepoObjectIter callback,
gpointer user_data, gpointer user_data,
GError **error) GError **error)
{ {
@ -1519,12 +1519,12 @@ iter_object_dir (HacktreeRepo *self,
} }
gboolean gboolean
hacktree_repo_iter_objects (HacktreeRepo *self, ostree_repo_iter_objects (OstreeRepo *self,
HacktreeRepoObjectIter callback, OstreeRepoObjectIter callback,
gpointer user_data, gpointer user_data,
GError **error) GError **error)
{ {
HacktreeRepoPrivate *priv = GET_PRIVATE (self); OstreeRepoPrivate *priv = GET_PRIVATE (self);
GFile *objectdir = NULL; GFile *objectdir = NULL;
GFileEnumerator *enumerator = NULL; GFileEnumerator *enumerator = NULL;
gboolean ret = FALSE; gboolean ret = FALSE;
@ -1534,7 +1534,7 @@ hacktree_repo_iter_objects (HacktreeRepo *self,
g_return_val_if_fail (error == NULL || *error == NULL, FALSE); g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
g_return_val_if_fail (priv->inited, FALSE); g_return_val_if_fail (priv->inited, FALSE);
objectdir = ht_util_new_file_for_path (priv->objects_path); objectdir = ot_util_new_file_for_path (priv->objects_path);
enumerator = g_file_enumerate_children (objectdir, "standard::name,standard::type,unix::*", enumerator = g_file_enumerate_children (objectdir, "standard::name,standard::type,unix::*",
G_FILE_QUERY_INFO_NOFOLLOW_SYMLINKS, G_FILE_QUERY_INFO_NOFOLLOW_SYMLINKS,
NULL, NULL,
@ -1579,14 +1579,14 @@ hacktree_repo_iter_objects (HacktreeRepo *self,
} }
gboolean gboolean
hacktree_repo_load_variant (HacktreeRepo *repo, ostree_repo_load_variant (OstreeRepo *repo,
const char *sha256, const char *sha256,
HacktreeSerializedVariantType *out_type, OstreeSerializedVariantType *out_type,
GVariant **out_variant, GVariant **out_variant,
GError **error) GError **error)
{ {
gboolean ret = FALSE; gboolean ret = FALSE;
HacktreeSerializedVariantType ret_type; OstreeSerializedVariantType ret_type;
GVariant *ret_variant = NULL; GVariant *ret_variant = NULL;
g_return_val_if_fail (error == NULL || *error == NULL, FALSE); g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
@ -1608,9 +1608,9 @@ hacktree_repo_load_variant (HacktreeRepo *repo,
} }
const char * const char *
hacktree_repo_get_head (HacktreeRepo *self) ostree_repo_get_head (OstreeRepo *self)
{ {
HacktreeRepoPrivate *priv = GET_PRIVATE (self); OstreeRepoPrivate *priv = GET_PRIVATE (self);
g_return_val_if_fail (priv->inited, NULL); g_return_val_if_fail (priv->inited, NULL);
@ -1618,14 +1618,14 @@ hacktree_repo_get_head (HacktreeRepo *self)
} }
static gboolean static gboolean
resolve_ref (HacktreeRepo *self, resolve_ref (OstreeRepo *self,
const char *ref, const char *ref,
char **resolved, char **resolved,
GError **error) GError **error)
{ {
if (strcmp (ref, "HEAD") == 0) if (strcmp (ref, "HEAD") == 0)
{ {
*resolved = g_strdup (hacktree_repo_get_head (self)); *resolved = g_strdup (ostree_repo_get_head (self));
return TRUE; return TRUE;
} }
else if (strlen (ref) == 64) else if (strlen (ref) == 64)
@ -1639,13 +1639,13 @@ resolve_ref (HacktreeRepo *self,
} }
static gboolean static gboolean
checkout_tree (HacktreeRepo *self, checkout_tree (OstreeRepo *self,
ParsedTreeData *tree, ParsedTreeData *tree,
const char *destination, const char *destination,
GError **error); GError **error);
static gboolean static gboolean
checkout_one_directory (HacktreeRepo *self, checkout_one_directory (OstreeRepo *self,
const char *destination, const char *destination,
const char *dirname, const char *dirname,
ParsedDirectoryData *dir, ParsedDirectoryData *dir,
@ -1666,7 +1666,7 @@ checkout_one_directory (HacktreeRepo *self,
if (mkdir (dest_path, (mode_t)mode) < 0) if (mkdir (dest_path, (mode_t)mode) < 0)
{ {
ht_util_set_error_from_errno (error, errno); ot_util_set_error_from_errno (error, errno);
g_prefix_error (error, "Failed to create directory '%s': ", dest_path); g_prefix_error (error, "Failed to create directory '%s': ", dest_path);
goto out; goto out;
} }
@ -1684,7 +1684,7 @@ checkout_one_directory (HacktreeRepo *self,
} }
static gboolean static gboolean
checkout_tree (HacktreeRepo *self, checkout_tree (OstreeRepo *self,
ParsedTreeData *tree, ParsedTreeData *tree,
const char *destination, const char *destination,
GError **error) GError **error)
@ -1701,11 +1701,11 @@ checkout_tree (HacktreeRepo *self,
char *object_path; char *object_path;
char *dest_path; char *dest_path;
object_path = get_object_path (self, checksum, HACKTREE_OBJECT_TYPE_FILE); object_path = get_object_path (self, checksum, OSTREE_OBJECT_TYPE_FILE);
dest_path = g_build_filename (destination, filename, NULL); dest_path = g_build_filename (destination, filename, NULL);
if (link (object_path, dest_path) < 0) if (link (object_path, dest_path) < 0)
{ {
ht_util_set_error_from_errno (error, errno); ot_util_set_error_from_errno (error, errno);
g_free (object_path); g_free (object_path);
g_free (dest_path); g_free (dest_path);
goto out; goto out;
@ -1730,7 +1730,7 @@ checkout_tree (HacktreeRepo *self,
} }
gboolean gboolean
hacktree_repo_checkout (HacktreeRepo *self, ostree_repo_checkout (OstreeRepo *self,
const char *ref, const char *ref,
const char *destination, const char *destination,
GError **error) GError **error)

View File

@ -18,56 +18,56 @@
* *
* Author: Colin Walters <walters@verbum.org> * Author: Colin Walters <walters@verbum.org>
*/ */
/* hacktree-repo.h */ /* ostree-repo.h */
#ifndef _HACKTREE_REPO #ifndef _OSTREE_REPO
#define _HACKTREE_REPO #define _OSTREE_REPO
#include <glib-object.h> #include <glib-object.h>
G_BEGIN_DECLS G_BEGIN_DECLS
#define HACKTREE_TYPE_REPO hacktree_repo_get_type() #define OSTREE_TYPE_REPO ostree_repo_get_type()
#define HACKTREE_REPO(obj) \ #define OSTREE_REPO(obj) \
(G_TYPE_CHECK_INSTANCE_CAST ((obj), HACKTREE_TYPE_REPO, HacktreeRepo)) (G_TYPE_CHECK_INSTANCE_CAST ((obj), OSTREE_TYPE_REPO, OstreeRepo))
#define HACKTREE_REPO_CLASS(klass) \ #define OSTREE_REPO_CLASS(klass) \
(G_TYPE_CHECK_CLASS_CAST ((klass), HACKTREE_TYPE_REPO, HacktreeRepoClass)) (G_TYPE_CHECK_CLASS_CAST ((klass), OSTREE_TYPE_REPO, OstreeRepoClass))
#define HACKTREE_IS_REPO(obj) \ #define OSTREE_IS_REPO(obj) \
(G_TYPE_CHECK_INSTANCE_TYPE ((obj), HACKTREE_TYPE_REPO)) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), OSTREE_TYPE_REPO))
#define HACKTREE_IS_REPO_CLASS(klass) \ #define OSTREE_IS_REPO_CLASS(klass) \
(G_TYPE_CHECK_CLASS_TYPE ((klass), HACKTREE_TYPE_REPO)) (G_TYPE_CHECK_CLASS_TYPE ((klass), OSTREE_TYPE_REPO))
#define HACKTREE_REPO_GET_CLASS(obj) \ #define OSTREE_REPO_GET_CLASS(obj) \
(G_TYPE_INSTANCE_GET_CLASS ((obj), HACKTREE_TYPE_REPO, HacktreeRepoClass)) (G_TYPE_INSTANCE_GET_CLASS ((obj), OSTREE_TYPE_REPO, OstreeRepoClass))
typedef struct { typedef struct {
GObject parent; GObject parent;
} HacktreeRepo; } OstreeRepo;
typedef struct { typedef struct {
GObjectClass parent_class; GObjectClass parent_class;
} HacktreeRepoClass; } OstreeRepoClass;
GType hacktree_repo_get_type (void); GType ostree_repo_get_type (void);
HacktreeRepo* hacktree_repo_new (const char *path); OstreeRepo* ostree_repo_new (const char *path);
gboolean hacktree_repo_check (HacktreeRepo *self, GError **error); gboolean ostree_repo_check (OstreeRepo *self, GError **error);
gboolean hacktree_repo_link_file (HacktreeRepo *self, gboolean ostree_repo_link_file (OstreeRepo *self,
const char *path, const char *path,
gboolean ignore_exists, gboolean ignore_exists,
gboolean force, gboolean force,
GError **error); GError **error);
const char * hacktree_repo_get_head (HacktreeRepo *self); const char * ostree_repo_get_head (OstreeRepo *self);
gboolean hacktree_repo_load_variant (HacktreeRepo *self, gboolean ostree_repo_load_variant (OstreeRepo *self,
const char *sha256, const char *sha256,
HacktreeSerializedVariantType *out_type, OstreeSerializedVariantType *out_type,
GVariant **out_variant, GVariant **out_variant,
GError **error); GError **error);
gboolean hacktree_repo_commit (HacktreeRepo *self, gboolean ostree_repo_commit (OstreeRepo *self,
const char *subject, const char *subject,
const char *body, const char *body,
GVariant *metadata, GVariant *metadata,
@ -77,7 +77,7 @@ gboolean hacktree_repo_commit (HacktreeRepo *self,
GChecksum **out_commit, GChecksum **out_commit,
GError **error); GError **error);
gboolean hacktree_repo_commit_from_filelist_fd (HacktreeRepo *self, gboolean ostree_repo_commit_from_filelist_fd (OstreeRepo *self,
const char *subject, const char *subject,
const char *body, const char *body,
GVariant *metadata, GVariant *metadata,
@ -87,19 +87,19 @@ gboolean hacktree_repo_commit_from_filelist_fd (HacktreeRepo *self,
GChecksum **out_commit, GChecksum **out_commit,
GError **error); GError **error);
gboolean hacktree_repo_checkout (HacktreeRepo *self, gboolean ostree_repo_checkout (OstreeRepo *self,
const char *ref, const char *ref,
const char *destination, const char *destination,
GError **error); GError **error);
typedef void (*HacktreeRepoObjectIter) (HacktreeRepo *self, const char *path, typedef void (*OstreeRepoObjectIter) (OstreeRepo *self, const char *path,
GFileInfo *fileinfo, gpointer user_data); GFileInfo *fileinfo, gpointer user_data);
gboolean hacktree_repo_iter_objects (HacktreeRepo *self, gboolean ostree_repo_iter_objects (OstreeRepo *self,
HacktreeRepoObjectIter callback, OstreeRepoObjectIter callback,
gpointer user_data, gpointer user_data,
GError **error); GError **error);
G_END_DECLS G_END_DECLS
#endif /* _HACKTREE_REPO */ #endif /* _OSTREE_REPO */

View File

@ -19,14 +19,14 @@
* Author: Colin Walters <walters@verbum.org> * Author: Colin Walters <walters@verbum.org>
*/ */
#ifndef __HACKTREE_TYPES_H__ #ifndef __OSTREE_TYPES_H__
#define __HACKTREE_TYPES_H__ #define __OSTREE_TYPES_H__
#include <gio/gio.h> #include <gio/gio.h>
G_BEGIN_DECLS G_BEGIN_DECLS
#define HACKTREE_REPO_DIR ".ht" #define OSTREE_REPO_DIR ".ot"
G_END_DECLS G_END_DECLS

View File

@ -19,10 +19,10 @@
* Author: Colin Walters <walters@verbum.org> * Author: Colin Walters <walters@verbum.org>
*/ */
#ifndef __HACKTREE_H__ #ifndef __OSTREE_H__
#include <hacktree-core.h> #include <ostree-core.h>
#include <hacktree-repo.h> #include <ostree-repo.h>
#include <hacktree-types.h> #include <ostree-types.h>
#endif #endif

View File

@ -27,10 +27,10 @@
#include <string.h> #include <string.h>
#include "htutil.h" #include "otutil.h"
gboolean gboolean
ht_util_ensure_directory (const char *path, gboolean with_parents, GError **error) ot_util_ensure_directory (const char *path, gboolean with_parents, GError **error)
{ {
GFile *dir; GFile *dir;
GError *temp_error = NULL; GError *temp_error = NULL;
@ -60,7 +60,7 @@ ht_util_ensure_directory (const char *path, gboolean with_parents, GError **erro
char * char *
ht_util_get_file_contents_utf8 (const char *path, ot_util_get_file_contents_utf8 (const char *path,
GError **error) GError **error)
{ {
char *contents; char *contents;
@ -81,7 +81,7 @@ ht_util_get_file_contents_utf8 (const char *path,
} }
GInputStream * GInputStream *
ht_util_read_file_noatime (GFile *file, GCancellable *cancellable, GError **error) ot_util_read_file_noatime (GFile *file, GCancellable *cancellable, GError **error)
{ {
GInputStream *ret = NULL; GInputStream *ret = NULL;
int fd; int fd;
@ -95,7 +95,7 @@ ht_util_read_file_noatime (GFile *file, GCancellable *cancellable, GError **erro
fd = open (path, flags); fd = open (path, flags);
if (fd < 0) if (fd < 0)
{ {
ht_util_set_error_from_errno (error, errno); ot_util_set_error_from_errno (error, errno);
goto out; goto out;
} }
@ -108,7 +108,7 @@ ht_util_read_file_noatime (GFile *file, GCancellable *cancellable, GError **erro
/* Like g_file_new_for_path, but only do local stuff, not GVFS */ /* Like g_file_new_for_path, but only do local stuff, not GVFS */
GFile * GFile *
ht_util_new_file_for_path (const char *path) ot_util_new_file_for_path (const char *path)
{ {
return g_vfs_get_file_for_path (g_vfs_get_local (), path); return g_vfs_get_file_for_path (g_vfs_get_local (), path);
} }

View File

@ -19,20 +19,20 @@
* Author: Colin Walters <walters@verbum.org> * Author: Colin Walters <walters@verbum.org>
*/ */
#ifndef __HACKTREE_GIO_UTILS_H__ #ifndef __OSTREE_GIO_UTILS_H__
#define __HACKTREE_GIO_UTILS_H__ #define __OSTREE_GIO_UTILS_H__
#include <gio/gio.h> #include <gio/gio.h>
G_BEGIN_DECLS G_BEGIN_DECLS
GFile *ht_util_new_file_for_path (const char *path); GFile *ot_util_new_file_for_path (const char *path);
gboolean ht_util_ensure_directory (const char *path, gboolean with_parents, GError **error); gboolean ot_util_ensure_directory (const char *path, gboolean with_parents, GError **error);
char * ht_util_get_file_contents_utf8 (const char *path, GError **error); char * ot_util_get_file_contents_utf8 (const char *path, GError **error);
GInputStream *ht_util_read_file_noatime (GFile *file, GCancellable *cancellable, GError **error); GInputStream *ot_util_read_file_noatime (GFile *file, GCancellable *cancellable, GError **error);
G_END_DECLS G_END_DECLS

View File

@ -21,7 +21,7 @@
#include "config.h" #include "config.h"
#include "ht-unix-utils.h" #include "ot-unix-utils.h"
#include <glib-unix.h> #include <glib-unix.h>
#include <gio/gio.h> #include <gio/gio.h>
@ -32,7 +32,7 @@
#include <dirent.h> #include <dirent.h>
gboolean gboolean
ht_util_spawn_pager (GOutputStream **out_stream, ot_util_spawn_pager (GOutputStream **out_stream,
GError **error) GError **error)
{ {
const char *pager; const char *pager;
@ -97,7 +97,7 @@ compare_filenames_by_component_length (const char *a,
} }
GPtrArray * GPtrArray *
ht_util_sort_filenames_by_component_length (GPtrArray *files) ot_util_sort_filenames_by_component_length (GPtrArray *files)
{ {
GPtrArray *array = g_ptr_array_sized_new (files->len); GPtrArray *array = g_ptr_array_sized_new (files->len);
memcpy (array->pdata, files->pdata, sizeof (gpointer) * files->len); memcpy (array->pdata, files->pdata, sizeof (gpointer) * files->len);
@ -106,7 +106,7 @@ ht_util_sort_filenames_by_component_length (GPtrArray *files)
} }
int int
ht_util_count_filename_components (const char *path) ot_util_count_filename_components (const char *path)
{ {
int i = 0; int i = 0;
@ -121,7 +121,7 @@ ht_util_count_filename_components (const char *path)
} }
gboolean gboolean
ht_util_filename_has_dotdot (const char *path) ot_util_filename_has_dotdot (const char *path)
{ {
char *p; char *p;
char last; char last;
@ -138,7 +138,7 @@ ht_util_filename_has_dotdot (const char *path)
} }
GPtrArray * GPtrArray *
ht_util_path_split (const char *path) ot_util_path_split (const char *path)
{ {
GPtrArray *ret = NULL; GPtrArray *ret = NULL;
const char *p; const char *p;
@ -176,7 +176,7 @@ ht_util_path_split (const char *path)
} }
char * char *
ht_util_path_join_n (const char *base, GPtrArray *components, int n) ot_util_path_join_n (const char *base, GPtrArray *components, int n)
{ {
int max = MIN(n+1, components->len); int max = MIN(n+1, components->len);
GPtrArray *subcomponents; GPtrArray *subcomponents;
@ -201,7 +201,7 @@ ht_util_path_join_n (const char *base, GPtrArray *components, int n)
} }
void void
ht_util_set_error_from_errno (GError **error, ot_util_set_error_from_errno (GError **error,
gint saved_errno) gint saved_errno)
{ {
g_set_error_literal (error, g_set_error_literal (error,
@ -212,7 +212,7 @@ ht_util_set_error_from_errno (GError **error,
} }
int int
ht_util_open_file_read (const char *path, GError **error) ot_util_open_file_read (const char *path, GError **error)
{ {
char *dirname = NULL; char *dirname = NULL;
char *basename = NULL; char *basename = NULL;
@ -224,11 +224,11 @@ ht_util_open_file_read (const char *path, GError **error)
dir = opendir (dirname); dir = opendir (dirname);
if (dir == NULL) if (dir == NULL)
{ {
ht_util_set_error_from_errno (error, errno); ot_util_set_error_from_errno (error, errno);
goto out; goto out;
} }
fd = ht_util_open_file_read_at (dirfd (dir), basename, error); fd = ot_util_open_file_read_at (dirfd (dir), basename, error);
out: out:
g_free (basename); g_free (basename);
@ -239,7 +239,7 @@ ht_util_open_file_read (const char *path, GError **error)
} }
int int
ht_util_open_file_read_at (int dirfd, const char *name, GError **error) ot_util_open_file_read_at (int dirfd, const char *name, GError **error)
{ {
int fd; int fd;
int flags = O_RDONLY; int flags = O_RDONLY;
@ -252,6 +252,6 @@ ht_util_open_file_read_at (int dirfd, const char *name, GError **error)
#endif #endif
fd = openat (dirfd, name, flags); fd = openat (dirfd, name, flags);
if (fd < 0) if (fd < 0)
ht_util_set_error_from_errno (error, errno); ot_util_set_error_from_errno (error, errno);
return fd; return fd;
} }

View File

@ -19,8 +19,8 @@
* Author: Colin Walters <walters@verbum.org> * Author: Colin Walters <walters@verbum.org>
*/ */
#ifndef __HACKTREE_UNIX_UTILS_H__ #ifndef __OSTREE_UNIX_UTILS_H__
#define __HACKTREE_UNIX_UTILS_H__ #define __OSTREE_UNIX_UTILS_H__
#include <gio/gio.h> #include <gio/gio.h>
#include <glib-unix.h> #include <glib-unix.h>
@ -36,23 +36,23 @@
G_BEGIN_DECLS G_BEGIN_DECLS
gboolean ht_util_spawn_pager (GOutputStream **out_stream, GError **error); gboolean ot_util_spawn_pager (GOutputStream **out_stream, GError **error);
gboolean ht_util_filename_has_dotdot (const char *path); gboolean ot_util_filename_has_dotdot (const char *path);
GPtrArray *ht_util_sort_filenames_by_component_length (GPtrArray *files); GPtrArray *ot_util_sort_filenames_by_component_length (GPtrArray *files);
GPtrArray* ht_util_path_split (const char *path); GPtrArray* ot_util_path_split (const char *path);
char *ht_util_path_join_n (const char *base, GPtrArray *components, int n); char *ot_util_path_join_n (const char *base, GPtrArray *components, int n);
int ht_util_count_filename_components (const char *path); int ot_util_count_filename_components (const char *path);
int ht_util_open_file_read (const char *path, GError **error); int ot_util_open_file_read (const char *path, GError **error);
int ht_util_open_file_read_at (int dirfd, const char *name, GError **error); int ot_util_open_file_read_at (int dirfd, const char *name, GError **error);
void ht_util_set_error_from_errno (GError **error, gint saved_errno); void ot_util_set_error_from_errno (GError **error, gint saved_errno);
G_END_DECLS G_END_DECLS

View File

@ -19,9 +19,9 @@
* Author: Colin Walters <walters@verbum.org> * Author: Colin Walters <walters@verbum.org>
*/ */
#ifndef __HACKTREE_UTIL_H__ #ifndef __OSTREE_UTIL_H__
#include <ht-unix-utils.h> #include <ot-unix-utils.h>
#include <ht-gio-utils.h> #include <ot-gio-utils.h>
#endif #endif

View File

@ -26,23 +26,23 @@
#include <string.h> #include <string.h>
#include "ht-builtins.h" #include "ot-builtins.h"
static HacktreeBuiltin builtins[] = { static OstreeBuiltin builtins[] = {
{ "checkout", hacktree_builtin_checkout, 0 }, { "checkout", ostree_builtin_checkout, 0 },
{ "init", hacktree_builtin_init, 0 }, { "init", ostree_builtin_init, 0 },
{ "commit", hacktree_builtin_commit, 0 }, { "commit", ostree_builtin_commit, 0 },
{ "link-file", hacktree_builtin_link_file, 0 }, { "link-file", ostree_builtin_link_file, 0 },
{ "log", hacktree_builtin_log, 0 }, { "log", ostree_builtin_log, 0 },
{ "fsck", hacktree_builtin_fsck, 0 }, { "fsck", ostree_builtin_fsck, 0 },
{ "show", hacktree_builtin_show, 0 }, { "show", ostree_builtin_show, 0 },
{ NULL } { NULL }
}; };
static int static int
usage (char **argv, gboolean is_error) usage (char **argv, gboolean is_error)
{ {
HacktreeBuiltin *builtin = builtins; OstreeBuiltin *builtin = builtins;
void (*print_func) (const gchar *format, ...); void (*print_func) (const gchar *format, ...);
if (is_error) if (is_error)
@ -67,7 +67,7 @@ int
main (int argc, main (int argc,
char **argv) char **argv)
{ {
HacktreeBuiltin *builtin; OstreeBuiltin *builtin;
const char *cmd; const char *cmd;
g_type_init (); g_type_init ();

View File

@ -21,8 +21,8 @@
#include "config.h" #include "config.h"
#include "ht-builtins.h" #include "ot-builtins.h"
#include "hacktree.h" #include "ostree.h"
#include <glib/gi18n.h> #include <glib/gi18n.h>
@ -34,11 +34,11 @@ static GOptionEntry options[] = {
}; };
gboolean gboolean
hacktree_builtin_checkout (int argc, char **argv, const char *prefix, GError **error) ostree_builtin_checkout (int argc, char **argv, const char *prefix, GError **error)
{ {
GOptionContext *context; GOptionContext *context;
gboolean ret = FALSE; gboolean ret = FALSE;
HacktreeRepo *repo = NULL; OstreeRepo *repo = NULL;
int i; int i;
const char *commit; const char *commit;
const char *destination; const char *destination;
@ -52,8 +52,8 @@ hacktree_builtin_checkout (int argc, char **argv, const char *prefix, GError **e
if (repo_path == NULL) if (repo_path == NULL)
repo_path = "."; repo_path = ".";
repo = hacktree_repo_new (repo_path); repo = ostree_repo_new (repo_path);
if (!hacktree_repo_check (repo, error)) if (!ostree_repo_check (repo, error))
goto out; goto out;
if (argc < 3) if (argc < 3)
@ -69,7 +69,7 @@ hacktree_builtin_checkout (int argc, char **argv, const char *prefix, GError **e
commit = argv[1]; commit = argv[1];
destination = argv[2]; destination = argv[2];
if (!hacktree_repo_checkout (repo, commit, destination, error)) if (!ostree_repo_checkout (repo, commit, destination, error))
goto out; goto out;
ret = TRUE; ret = TRUE;

View File

@ -21,8 +21,8 @@
#include "config.h" #include "config.h"
#include "ht-builtins.h" #include "ot-builtins.h"
#include "hacktree.h" #include "ostree.h"
#include <glib/gi18n.h> #include <glib/gi18n.h>
@ -50,11 +50,11 @@ static GOptionEntry options[] = {
}; };
gboolean gboolean
hacktree_builtin_commit (int argc, char **argv, const char *prefix, GError **error) ostree_builtin_commit (int argc, char **argv, const char *prefix, GError **error)
{ {
GOptionContext *context; GOptionContext *context;
gboolean ret = FALSE; gboolean ret = FALSE;
HacktreeRepo *repo = NULL; OstreeRepo *repo = NULL;
gboolean using_filename_cmdline; gboolean using_filename_cmdline;
gboolean using_filedescriptors; gboolean using_filedescriptors;
GPtrArray *additions_array = NULL; GPtrArray *additions_array = NULL;
@ -73,8 +73,8 @@ hacktree_builtin_commit (int argc, char **argv, const char *prefix, GError **err
if (prefix == NULL) if (prefix == NULL)
prefix = "."; prefix = ".";
repo = hacktree_repo_new (repo_path); repo = ostree_repo_new (repo_path);
if (!hacktree_repo_check (repo, error)) if (!ostree_repo_check (repo, error))
goto out; goto out;
using_filename_cmdline = (removals || additions); using_filename_cmdline = (removals || additions);
@ -113,7 +113,7 @@ hacktree_builtin_commit (int argc, char **argv, const char *prefix, GError **err
for (iter = removals; *iter; iter++) for (iter = removals; *iter; iter++)
g_ptr_array_add (removals_array, *iter); g_ptr_array_add (removals_array, *iter);
if (!hacktree_repo_commit (repo, subject, body, NULL, if (!ostree_repo_commit (repo, subject, body, NULL,
prefix, additions_array, prefix, additions_array,
removals_array, removals_array,
&commit_checksum, &commit_checksum,
@ -129,7 +129,7 @@ hacktree_builtin_commit (int argc, char **argv, const char *prefix, GError **err
from_fd = 0; from_fd = 0;
else if (from_file) else if (from_file)
{ {
temp_fd = ht_util_open_file_read (from_file, error); temp_fd = ot_util_open_file_read (from_file, error);
if (temp_fd < 0) if (temp_fd < 0)
{ {
g_prefix_error (error, "Failed to open '%s': ", from_file); g_prefix_error (error, "Failed to open '%s': ", from_file);
@ -137,7 +137,7 @@ hacktree_builtin_commit (int argc, char **argv, const char *prefix, GError **err
} }
from_fd = temp_fd; from_fd = temp_fd;
} }
if (!hacktree_repo_commit_from_filelist_fd (repo, subject, body, NULL, if (!ostree_repo_commit_from_filelist_fd (repo, subject, body, NULL,
prefix, from_fd, separator, prefix, from_fd, separator,
&commit_checksum, error)) &commit_checksum, error))
{ {

View File

@ -21,8 +21,8 @@
#include "config.h" #include "config.h"
#include "ht-builtins.h" #include "ot-builtins.h"
#include "hacktree.h" #include "ostree.h"
#include <glib/gi18n.h> #include <glib/gi18n.h>
@ -40,7 +40,7 @@ typedef struct {
} HtFsckData; } HtFsckData;
static void static void
object_iter_callback (HacktreeRepo *repo, object_iter_callback (OstreeRepo *repo,
const char *path, const char *path,
GFileInfo *file_info, GFileInfo *file_info,
gpointer user_data) gpointer user_data)
@ -62,7 +62,7 @@ object_iter_callback (HacktreeRepo *repo,
if (nlinks < 2 && !quiet) if (nlinks < 2 && !quiet)
g_printerr ("note: floating object: %s\n", path); */ g_printerr ("note: floating object: %s\n", path); */
if (!hacktree_stat_and_checksum_file (-1, path, &checksum, &stbuf, &error)) if (!ostree_stat_and_checksum_file (-1, path, &checksum, &stbuf, &error))
goto out; goto out;
filename_checksum = g_strdup (g_file_info_get_name (file_info)); filename_checksum = g_strdup (g_file_info_get_name (file_info));
@ -95,12 +95,12 @@ object_iter_callback (HacktreeRepo *repo,
} }
gboolean gboolean
hacktree_builtin_fsck (int argc, char **argv, const char *prefix, GError **error) ostree_builtin_fsck (int argc, char **argv, const char *prefix, GError **error)
{ {
GOptionContext *context; GOptionContext *context;
HtFsckData data; HtFsckData data;
gboolean ret = FALSE; gboolean ret = FALSE;
HacktreeRepo *repo = NULL; OstreeRepo *repo = NULL;
const char *head; const char *head;
context = g_option_context_new ("- Check the repository for consistency"); context = g_option_context_new ("- Check the repository for consistency");
@ -114,14 +114,14 @@ hacktree_builtin_fsck (int argc, char **argv, const char *prefix, GError **error
data.n_objects = 0; data.n_objects = 0;
repo = hacktree_repo_new (repo_path); repo = ostree_repo_new (repo_path);
if (!hacktree_repo_check (repo, error)) if (!ostree_repo_check (repo, error))
goto out; goto out;
if (!hacktree_repo_iter_objects (repo, object_iter_callback, &data, error)) if (!ostree_repo_iter_objects (repo, object_iter_callback, &data, error))
goto out; goto out;
head = hacktree_repo_get_head (repo); head = ostree_repo_get_head (repo);
if (!head) if (!head)
{ {
if (!quiet) if (!quiet)

View File

@ -21,8 +21,8 @@
#include "config.h" #include "config.h"
#include "ht-builtins.h" #include "ot-builtins.h"
#include "hacktree.h" #include "ostree.h"
#include <glib/gi18n.h> #include <glib/gi18n.h>
@ -33,7 +33,7 @@ static GOptionEntry options[] = {
}; };
gboolean gboolean
hacktree_builtin_init (int argc, char **argv, const char *prefix, GError **error) ostree_builtin_init (int argc, char **argv, const char *prefix, GError **error)
{ {
GOptionContext *context = NULL; GOptionContext *context = NULL;
gboolean ret = FALSE; gboolean ret = FALSE;
@ -51,8 +51,8 @@ hacktree_builtin_init (int argc, char **argv, const char *prefix, GError **error
if (repo_path == NULL) if (repo_path == NULL)
repo_path = "."; repo_path = ".";
htdir_path = g_build_filename (repo_path, HACKTREE_REPO_DIR, NULL); htdir_path = g_build_filename (repo_path, OSTREE_REPO_DIR, NULL);
htdir = ht_util_new_file_for_path (htdir_path); htdir = ot_util_new_file_for_path (htdir_path);
if (!g_file_make_directory (htdir, NULL, error)) if (!g_file_make_directory (htdir, NULL, error))
goto out; goto out;

View File

@ -21,8 +21,8 @@
#include "config.h" #include "config.h"
#include "ht-builtins.h" #include "ot-builtins.h"
#include "hacktree.h" #include "ostree.h"
#include <glib/gi18n.h> #include <glib/gi18n.h>
@ -38,11 +38,11 @@ static GOptionEntry options[] = {
}; };
gboolean gboolean
hacktree_builtin_link_file (int argc, char **argv, const char *prefix, GError **error) ostree_builtin_link_file (int argc, char **argv, const char *prefix, GError **error)
{ {
GOptionContext *context; GOptionContext *context;
gboolean ret = FALSE; gboolean ret = FALSE;
HacktreeRepo *repo = NULL; OstreeRepo *repo = NULL;
int i; int i;
context = g_option_context_new ("- Create a new hard link in the repository"); context = g_option_context_new ("- Create a new hard link in the repository");
@ -54,13 +54,13 @@ hacktree_builtin_link_file (int argc, char **argv, const char *prefix, GError **
if (repo_path == NULL) if (repo_path == NULL)
repo_path = "."; repo_path = ".";
repo = hacktree_repo_new (repo_path); repo = ostree_repo_new (repo_path);
if (!hacktree_repo_check (repo, error)) if (!ostree_repo_check (repo, error))
goto out; goto out;
for (i = 0; i < argc-1; i++) for (i = 0; i < argc-1; i++)
{ {
if (!hacktree_repo_link_file (repo, argv[i+1], ignore_exists, force, error)) if (!ostree_repo_link_file (repo, argv[i+1], ignore_exists, force, error))
goto out; goto out;
} }

View File

@ -21,8 +21,8 @@
#include "config.h" #include "config.h"
#include "ht-builtins.h" #include "ot-builtins.h"
#include "hacktree.h" #include "ostree.h"
#include <glib/gi18n.h> #include <glib/gi18n.h>
@ -34,11 +34,11 @@ static GOptionEntry options[] = {
}; };
gboolean gboolean
hacktree_builtin_log (int argc, char **argv, const char *prefix, GError **error) ostree_builtin_log (int argc, char **argv, const char *prefix, GError **error)
{ {
GOptionContext *context; GOptionContext *context;
gboolean ret = FALSE; gboolean ret = FALSE;
HacktreeRepo *repo = NULL; OstreeRepo *repo = NULL;
GOutputStream *pager = NULL; GOutputStream *pager = NULL;
GVariant *commit = NULL; GVariant *commit = NULL;
char *head; char *head;
@ -54,23 +54,23 @@ hacktree_builtin_log (int argc, char **argv, const char *prefix, GError **error)
if (prefix == NULL) if (prefix == NULL)
prefix = "."; prefix = ".";
repo = hacktree_repo_new (repo_path); repo = ostree_repo_new (repo_path);
if (!hacktree_repo_check (repo, error)) if (!ostree_repo_check (repo, error))
goto out; goto out;
head = g_strdup (hacktree_repo_get_head (repo)); head = g_strdup (ostree_repo_get_head (repo));
if (!head) if (!head)
{ {
g_set_error_literal (error, G_IO_ERROR, G_IO_ERROR_FAILED, "No HEAD exists"); g_set_error_literal (error, G_IO_ERROR, G_IO_ERROR_FAILED, "No HEAD exists");
goto out; goto out;
} }
if (!ht_util_spawn_pager (&pager, error)) if (!ot_util_spawn_pager (&pager, error))
goto out; goto out;
while (TRUE) while (TRUE)
{ {
HacktreeSerializedVariantType type; OstreeSerializedVariantType type;
char *formatted = NULL; char *formatted = NULL;
guint32 version; guint32 version;
const char *parent; const char *parent;
@ -88,7 +88,7 @@ hacktree_builtin_log (int argc, char **argv, const char *prefix, GError **error)
if (commit) if (commit)
g_variant_unref (commit); g_variant_unref (commit);
if (!hacktree_repo_load_variant (repo, head, &type, &commit, error)) if (!ostree_repo_load_variant (repo, head, &type, &commit, error))
goto out; goto out;
/* Ignore commit metadata for now */ /* Ignore commit metadata for now */

View File

@ -21,8 +21,8 @@
#include "config.h" #include "config.h"
#include "ht-builtins.h" #include "ot-builtins.h"
#include "hacktree.h" #include "ostree.h"
#include <glib/gi18n.h> #include <glib/gi18n.h>
@ -34,14 +34,14 @@ static GOptionEntry options[] = {
}; };
gboolean gboolean
hacktree_builtin_show (int argc, char **argv, const char *prefix, GError **error) ostree_builtin_show (int argc, char **argv, const char *prefix, GError **error)
{ {
GOptionContext *context; GOptionContext *context;
gboolean ret = FALSE; gboolean ret = FALSE;
HacktreeRepo *repo = NULL; OstreeRepo *repo = NULL;
int i; int i;
const char *target; const char *target;
HacktreeSerializedVariantType type; OstreeSerializedVariantType type;
GVariant *variant = NULL; GVariant *variant = NULL;
char *formatted_variant = NULL; char *formatted_variant = NULL;
@ -54,13 +54,13 @@ hacktree_builtin_show (int argc, char **argv, const char *prefix, GError **error
if (repo_path == NULL) if (repo_path == NULL)
repo_path = "."; repo_path = ".";
repo = hacktree_repo_new (repo_path); repo = ostree_repo_new (repo_path);
if (!hacktree_repo_check (repo, error)) if (!ostree_repo_check (repo, error))
goto out; goto out;
if (argc < 2) if (argc < 2)
{ {
target = hacktree_repo_get_head (repo); target = ostree_repo_get_head (repo);
if (!target) if (!target)
{ {
g_set_error_literal (error, G_IO_ERROR, G_IO_ERROR_FAILED, g_set_error_literal (error, G_IO_ERROR, G_IO_ERROR_FAILED,
@ -71,7 +71,7 @@ hacktree_builtin_show (int argc, char **argv, const char *prefix, GError **error
else else
target = argv[1]; target = argv[1];
if (!hacktree_repo_load_variant (repo, target, &type, &variant, error)) if (!ostree_repo_load_variant (repo, target, &type, &variant, error))
goto out; goto out;
g_print ("Object: %s\nType: %d\n", target, type); g_print ("Object: %s\nType: %d\n", target, type);

View File

@ -19,30 +19,30 @@
* Author: Colin Walters <walters@verbum.org> * Author: Colin Walters <walters@verbum.org>
*/ */
#ifndef __HACKTREE_BUILTINS__ #ifndef __OSTREE_BUILTINS__
#define __HACKTREE_BUILTINS__ #define __OSTREE_BUILTINS__
#include <glib-object.h> #include <glib-object.h>
G_BEGIN_DECLS G_BEGIN_DECLS
typedef enum { typedef enum {
HACKTREE_BUILTIN_FLAG_NONE = 0, OSTREE_BUILTIN_FLAG_NONE = 0,
} HacktreeBuiltinFlags; } OstreeBuiltinFlags;
typedef struct { typedef struct {
const char *name; const char *name;
gboolean (*fn) (int argc, char **argv, const char *prefix, GError **error); gboolean (*fn) (int argc, char **argv, const char *prefix, GError **error);
int flags; /* HacktreeBuiltinFlags */ int flags; /* OstreeBuiltinFlags */
} HacktreeBuiltin; } OstreeBuiltin;
gboolean hacktree_builtin_checkout (int argc, char **argv, const char *prefix, GError **error); gboolean ostree_builtin_checkout (int argc, char **argv, const char *prefix, GError **error);
gboolean hacktree_builtin_commit (int argc, char **argv, const char *prefix, GError **error); gboolean ostree_builtin_commit (int argc, char **argv, const char *prefix, GError **error);
gboolean hacktree_builtin_init (int argc, char **argv, const char *prefix, GError **error); gboolean ostree_builtin_init (int argc, char **argv, const char *prefix, GError **error);
gboolean hacktree_builtin_log (int argc, char **argv, const char *prefix, GError **error); gboolean ostree_builtin_log (int argc, char **argv, const char *prefix, GError **error);
gboolean hacktree_builtin_link_file (int argc, char **argv, const char *prefix, GError **error); gboolean ostree_builtin_link_file (int argc, char **argv, const char *prefix, GError **error);
gboolean hacktree_builtin_fsck (int argc, char **argv, const char *prefix, GError **error); gboolean ostree_builtin_fsck (int argc, char **argv, const char *prefix, GError **error);
gboolean hacktree_builtin_show (int argc, char **argv, const char *prefix, GError **error); gboolean ostree_builtin_show (int argc, char **argv, const char *prefix, GError **error);
G_END_DECLS G_END_DECLS

View File

@ -20,7 +20,7 @@
TMPDIR=${TMPDIR:-/tmp} TMPDIR=${TMPDIR:-/tmp}
export TMPDIR export TMPDIR
test_tmpdir=`mktemp -d "$TMPDIR/hacktree-tests.XXXXXXXXXX"` test_tmpdir=`mktemp -d "$TMPDIR/ostree-tests.XXXXXXXXXX"`
cd "$test_tmpdir" cd "$test_tmpdir"
touch "$test_tmpdir/.test$$" touch "$test_tmpdir/.test$$"
@ -57,12 +57,12 @@ setup_test_repository1 () {
echo second > secondfile echo second > secondfile
mkdir ../repo mkdir ../repo
ht_repo="--repo=../repo" ot_repo="--repo=../repo"
export ht_repo export ot_repo
hacktree init $ht_repo ostree init $ot_repo
hacktree commit $ht_repo -s "Test Commit 1" -b "Commit body first" --add=firstfile ostree commit $ot_repo -s "Test Commit 1" -b "Commit body first" --add=firstfile
hacktree commit $ht_repo -s "Test Commit 2" -b "Commit body second" --add=secondfile ostree commit $ot_repo -s "Test Commit 2" -b "Commit body second" --add=secondfile
hacktree fsck -q $ht_repo ostree fsck -q $ot_repo
} }
setup_test_repository2 () { setup_test_repository2 () {
@ -82,13 +82,13 @@ setup_test_repository2 () {
cd .. cd ..
mkdir repo mkdir repo
cd repo cd repo
ht_repo="--repo=`pwd`" ot_repo="--repo=`pwd`"
cd ../files cd ../files
export ht_repo export ot_repo
hacktree init $ht_repo ostree init $ot_repo
hacktree commit $ht_repo -s "Test Commit 1" -b "Commit body first" --add=firstfile ostree commit $ot_repo -s "Test Commit 1" -b "Commit body first" --add=firstfile
hacktree commit $ht_repo -s "Test Commit 2" -b "Commit body second" --add=baz/cow --add=baz/saucer --add=baz/deeper/ohyeah --add=baz/another/y ostree commit $ot_repo -s "Test Commit 2" -b "Commit body second" --add=baz/cow --add=baz/saucer --add=baz/deeper/ohyeah --add=baz/another/y
hacktree fsck -q $ht_repo ostree fsck -q $ot_repo
} }
trap 'die' EXIT trap 'die' EXIT

View File

@ -31,15 +31,15 @@ echo moo > files/cow
mkdir repo mkdir repo
cd repo cd repo
hacktree init ostree init
echo 'ok init' echo 'ok init'
hacktree fsck -q ostree fsck -q
echo 'ok fsck' echo 'ok fsck'
hacktree link-file $files/foo ostree link-file $files/foo
echo 'ok link' echo 'ok link'
hacktree fsck -q ostree fsck -q
echo 'ok link-fsk' echo 'ok link-fsk'
hacktree link-file $files/cow ostree link-file $files/cow
hacktree fsck -q ostree fsck -q
echo 'ok link-fsk2' echo 'ok link-fsk2'

View File

@ -29,9 +29,9 @@ cd files
echo hello > yy echo hello > yy
mkdir ../repo mkdir ../repo
hacktree init --repo=../repo ostree init --repo=../repo
echo 'ok init' echo 'ok init'
hacktree fsck --repo=../repo -q ostree fsck --repo=../repo -q
echo 'ok fsck' echo 'ok fsck'
hacktree link-file --repo=../repo yy ostree link-file --repo=../repo yy
echo 'ok link' echo 'ok link'

View File

@ -30,9 +30,9 @@ echo hello > yy
mkdir ../repo mkdir ../repo
repo="--repo=../repo" repo="--repo=../repo"
hacktree init $repo ostree init $repo
echo 'ok init' echo 'ok init'
hacktree commit $repo -s "Test Commit" -b "Commit body" --add=yy ostree commit $repo -s "Test Commit" -b "Commit body" --add=yy
echo 'ok commit' echo 'ok commit'
hacktree fsck -q $repo ostree fsck -q $repo
echo 'ok fsck' echo 'ok fsck'

View File

@ -31,11 +31,11 @@ echo second > secondfile
mkdir ../repo mkdir ../repo
repo="--repo=../repo" repo="--repo=../repo"
hacktree init $repo ostree init $repo
echo 'ok init' echo 'ok init'
hacktree commit $repo -s "Test Commit 1" -b "Commit body first" --add=firstfile ostree commit $repo -s "Test Commit 1" -b "Commit body first" --add=firstfile
echo 'ok commit 1' echo 'ok commit 1'
hacktree commit $repo -s "Test Commit 2" -b "Commit body first" --add=secondfile ostree commit $repo -s "Test Commit 2" -b "Commit body first" --add=secondfile
echo 'ok commit 2' echo 'ok commit 2'
hacktree fsck -q $repo ostree fsck -q $repo
echo 'ok fsck' echo 'ok fsck'

View File

@ -26,7 +26,7 @@ echo '1..3'
setup_test_repository1 setup_test_repository1
echo 'ok setup' echo 'ok setup'
hacktree checkout $ht_repo HEAD $test_tmpdir/checkout1-head ostree checkout $ot_repo HEAD $test_tmpdir/checkout1-head
echo 'ok checkout cmd' echo 'ok checkout cmd'
cd $test_tmpdir/checkout1-head cd $test_tmpdir/checkout1-head
assert_has_file firstfile assert_has_file firstfile

View File

@ -26,7 +26,7 @@ echo '1..5'
setup_test_repository2 setup_test_repository2
echo 'ok setup' echo 'ok setup'
hacktree checkout $ht_repo HEAD $test_tmpdir/checkout2-head ostree checkout $ot_repo HEAD $test_tmpdir/checkout2-head
echo 'ok checkout cmd' echo 'ok checkout cmd'
cd $test_tmpdir/checkout2-head cd $test_tmpdir/checkout2-head
assert_has_file firstfile assert_has_file firstfile

View File

@ -25,14 +25,14 @@ set -e
echo '1..4' echo '1..4'
setup_test_repository2 setup_test_repository2
hacktree checkout $ht_repo HEAD $test_tmpdir/checkout2-head ostree checkout $ot_repo HEAD $test_tmpdir/checkout2-head
echo 'ok setup' echo 'ok setup'
cd $test_tmpdir/checkout2-head cd $test_tmpdir/checkout2-head
hacktree commit -s delete $ht_repo -r firstfile ostree commit -s delete $ot_repo -r firstfile
echo 'ok rm firstfile' echo 'ok rm firstfile'
assert_has_file firstfile # It should still exist in this checkout assert_has_file firstfile # It should still exist in this checkout
cd $test_tmpdir cd $test_tmpdir
hacktree checkout $ht_repo HEAD $test_tmpdir/checkout3-head ostree checkout $ot_repo HEAD $test_tmpdir/checkout3-head
echo 'ok checkout 3' echo 'ok checkout 3'
cd $test_tmpdir/checkout3-head cd $test_tmpdir/checkout3-head
assert_not_has_file firstfile assert_not_has_file firstfile

View File

@ -25,7 +25,7 @@ set -e
echo "1..2" echo "1..2"
setup_test_repository2 setup_test_repository2
hacktree checkout $ht_repo HEAD $test_tmpdir/checkout2-head ostree checkout $ot_repo HEAD $test_tmpdir/checkout2-head
cd $test_tmpdir/checkout2-head cd $test_tmpdir/checkout2-head
mkdir -p a/nested/tree mkdir -p a/nested/tree
echo one > a/nested/tree/1 echo one > a/nested/tree/1
@ -39,9 +39,9 @@ mkdir -p another/nested/tree
echo anotherone > another/nested/tree/1 echo anotherone > another/nested/tree/1
echo whee2 > another/whee echo whee2 > another/whee
# FIXME - remove grep for . # FIXME - remove grep for .
find | grep -v '^\.$' | hacktree commit $ht_repo --from-stdin -s "From find" find | grep -v '^\.$' | ostree commit $ot_repo --from-stdin -s "From find"
echo "ok commit stdin" echo "ok commit stdin"
hacktree checkout $ht_repo HEAD $test_tmpdir/checkout3-head ostree checkout $ot_repo HEAD $test_tmpdir/checkout3-head
cd $test_tmpdir/checkout3-head cd $test_tmpdir/checkout3-head
assert_has_file a/nested/2 assert_has_file a/nested/2
assert_file_has_content a/nested/2 'two2' assert_file_has_content a/nested/2 'two2'

View File

@ -22,10 +22,10 @@ set -e
. libtest.sh . libtest.sh
echo "1..2" echo "1..1"
setup_test_repository2 setup_test_repository2
hacktree log $ht_repo > $test_tmpdir/log.txt ostree log $ot_repo > $test_tmpdir/log.txt
assert_file_has_content $test_tmpdir/log.txt "Test Commit 1" assert_file_has_content $test_tmpdir/log.txt "Test Commit 1"
assert_file_has_content $test_tmpdir/log.txt "Test Commit 2" assert_file_has_content $test_tmpdir/log.txt "Test Commit 2"
echo "ok log" echo "ok log"