Commit Graph

68 Commits

Author SHA1 Message Date
Colin Walters
8a7943fef6 console: Fix bar progress length
The previous fix added the last character of text, but failed to
account for the space we're adding.
2016-02-08 14:09:13 +01:00
Colin Walters
769522753c console: Don't delete last character of output text
Not sure why we were doing this...I guess people were working around
it by adding their own spaces?
2016-01-26 11:16:56 -05:00
Colin Walters
34a96c03dd console: Fix g_auto() and unlock cleanup
This way, one can unlock the console while still using the cleanup
macro.  Otherwise we miss a lot of the ergonomics of cleanup macros.
2016-01-25 11:25:19 -05:00
Colin Walters
aac5a6cef7 console: g_auto() macro no-ops if console is not locked
Otherwise we miss a lot of the ergonomics of cleanup macros.
2016-01-25 10:23:34 -05:00
Colin Walters
2ca280f012 Introduce glnx-alloca.h with glnx_strjoina()
This is taken from systemd, and is really useful when one has a few
known-to-be-small strings one wants to concatenate without resorting
to malloc.
2016-01-24 12:10:26 -05:00
Alexander Larsson
194eb7a09c Add autoptr support for GZlib* 2016-01-22 15:27:11 +01:00
Colin Walters
3c470803d0 fdio: Export loop_write
I plan to use this in rpm-ostree.  Sad how many times this gets
reinvented.  Should probably stick a copy in `glib-unix.h` or so.
2016-01-10 21:46:45 -05:00
Colin Walters
91e060699f dirfd: Add a public API to ensure a filled dtype
It's quite common to iterate over a directory recursively, only caring
about the file type, but not other bits returned by `stat()`.

Good file systems fill in `dt_type`, but not all do.  This function
papers over that in userspace conveniently.
2016-01-02 19:42:53 -05:00
Alexander Larsson
e7f7081054 autocleanups: Fix g_autoptr(GString) with glib 2.44
The g_autoptr support for GString was added in 2.45.8, so we need
to define it on 2.44 for it to work.
2015-12-17 13:29:08 +01:00
Alexander Larsson
0313864129 Add glnx_mkdtempat
Create a temporary directory using mkdirat.

https://bugzilla.gnome.org/show_bug.cgi?id=757611
2015-12-11 16:22:07 +01:00
Alexander Larsson
4e9969998b Add glnx_steal_fd
This is very useful in combination with glnx_close_fd

https://bugzilla.gnome.org/show_bug.cgi?id=757611
2015-12-11 16:22:07 +01:00
Colin Walters
bf4d1504a4 README.md: Add note on contributing 2015-12-02 09:59:10 -05:00
Alexander Larsson
1d65bc0ff7 Add backport of g_set_object 2015-12-01 16:32:59 +01:00
Alexander Larsson
dade12b558 Add g_autoptr support for GSubprocess 2015-12-01 16:32:55 +01:00
Matthew Barnes
7e24c244ff Backport g_autoptr support for GFileOutputStream 2015-11-23 14:47:34 -05:00
Matthew Barnes
825d308b04 Comment typo 2015-11-06 10:31:37 -05:00
Matthew Barnes
c7da81208d Backport g_autoptr support for GCancellable 2015-11-06 09:57:30 -05:00
Alexander Larsson
7310bbdb58 Backport g_autoptr support for GString 2015-09-24 15:28:21 +02:00
Matthew Barnes
e684ef07f0 libcontainer: Set PATH when using execvp()
Set PATH to something sane for a chroot'ed environment rather than
relying on the user's PATH value.
2015-09-16 14:14:43 -04:00
Colin Walters
0cf50c6735 Add a generic glnx-backports.h
Where we can put general functions that come in newer glib.
2015-08-29 09:29:11 -04:00
Colin Walters
dc5702aba9 backport-autocleanups: Add GDBusConnection,GDBusMessage 2015-08-28 13:10:01 -04:00
Colin Walters
fbdb15cd95 libcontainer: Pare down to just "run in root" API
rpm-ostree is going through some awkwardness trying to
support being run both inside and outside of a container.

For now, let's drop all recursive container usage.  There is still
some value in readding this in the future - for example, downloading
packages requires networking, but `%post` scripts do not.  But we
should really solve that when we return to running unprivileged or the
like.
2015-08-24 14:29:45 -04:00
Colin Walters
58a9a5c50e libcontainer: Fall back to noop if / is not a mountpoint
Trying to change the mount namespace was breaking in mock, which just
uses plain chroot.
2015-07-28 16:40:29 -04:00
Colin Walters
91875459cd libcontainer: Search $PATH for exec() if argv[0] is not absolute
In Fedora rawhide, dracut switched from `/usr/sbin` to `/usr/bin`,
which broke rpm-ostree's hardcoding of the path.

There was no real reason to hardcode it (assume our `$PATH` is sane
and secure), so in order to help support that, this change in libglnx
will automatically search $PATH if the input is not absolute.

(This is a sane default for a process spawning library IMO)
2015-06-15 13:38:43 -04:00
Colin Walters
900b25f701 backport-autocleanups: GTask
For OSTree.
2015-05-08 22:02:44 -04:00
Giuseppe Scrivano
cf8ae27bab glnx-fdio: always initialize buf
It can be used without initialization if condition causing a "goto
error" fails before buf is initialized.

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2015-05-05 16:39:12 +02:00
Matthew Barnes
013aa4fead Backport all the GIO object types used by OSTree 2015-05-05 10:26:33 -04:00
Colin Walters
be6bc2d75d lockfile: New code to lock files, massaged from systemd
Will be used by OSTree to lock the sysroot against concurrent
manipulation.  Taken from current systemd git master, tweaked to
GLibify.
2015-05-05 08:49:00 -04:00
Colin Walters
fda8f26625 README.md: Some more rationale 2015-05-04 16:10:28 -04:00
Matthew Barnes
dfe77be2d5 Backport more autocleanup types from GLib
GStrv, GFile, GOutputStream
2015-05-04 11:58:09 -04:00
Colin Walters
90390949f2 fdio: glnx_file_copy_at: If no stbuf passed, do stat internally
There are some cases where we want to copy with just a filename,
so let's be convenient in that case and do stat for the caller.

This will be used by an ostree commit.
2015-04-20 22:10:07 -04:00
Colin Walters
381ca54ee3 dirfd: Add API to get an absolute path from a dfd/relpath
There are a lot of APIs that still only take absolute paths, such as
librpm (and everything above it).  I plan to use this in rpm-ostree to
convert temporary directories that I'm accessing fd-relative back into
absolutes until such time as fd-relative APIs are plumbed through the
stack more.
2015-04-17 09:33:58 -04:00
Colin Walters
c231a3b845 console: Do basic output if we're not on a tty
Doing nothing isn't super useful; if you're using e.g. rpm-ostree in
Jenkins you want to see *something* from the "live tail".

This is a basic line-per-change implementation.

Closes: https://github.com/GNOME/libglnx/pull/6
2015-04-17 08:23:37 -04:00
Colin Walters
371172bcfd fdio: Fix errno handling from posix_fallocate() and loop_write()
For extra fun, both of these functions have different error handling
schemes.  `posix_fallocate` does *not* set `errno` because...  I'm not
sure.  Maybe POSIX was trying a new function design?

`loop_write` uses the systemd error handling style which returns
`-errno`, so we need to set errno back so that the macro can propagate
it into the `GError`.
2015-04-14 10:08:41 -04:00
Colin Walters
c36ea3ea80 fdio: Honor umask by default for glnx_file_replace_contents_at()
By default (with `-1) use the Unix traditional default of
`0666 - umask`.  But do support forcing a mode.
2015-04-14 10:08:41 -04:00
Matthew Barnes
02af92ffef fdio: Fix default mode in glnx_file_replace_contents_with_perms_at()
mkostemp() defaults to 0600.  Use 0644 instead unless a mode is
explicitly provided.

https://bugzilla.gnome.org/747813
2015-04-14 08:45:51 -04:00
Colin Walters
20fc302df5 fdio: Canonicalize dfd for replace contents API
Just noticed while inspecting the code.
2015-04-13 13:35:32 -04:00
Colin Walters
376219a9c2 fdio: Also add a replace variant that takes mode/uid/gid
This will be used for OSTree too.
2015-04-08 21:31:43 -04:00
Colin Walters
dc47528f51 fdio: Add glnx_file_replace_contents_at()
Sort of similar to `g_file_replace_contents()` but `*at()`.  Will be
used for further conversion of OSTree to `*at()`.
2015-04-08 21:13:05 -04:00
Colin Walters
55220bdbf2 shutil: Drop unnecessary new block scope 2015-04-08 05:59:16 -04:00
Colin Walters
16f02afb2b build: Drop leftover -lattr
See previous commits to drop libattr dependency.
2015-04-08 05:58:31 -04:00
Colin Walters
e72bbdebb0 fdio: Include <string.h> for basename
Most callers already included `string.h` which is why I didn't see
this earlier.
2015-04-07 12:34:30 -04:00
Colin Walters
19885b8a20 shutil: Add mkdir -p API
I looked at the systemd code but it didn't have a variant of
mkdir_parents that used `*at()`.  This is a fresh implementation, with
the risk that entails.

However I am changing libgsystem to call it now for testing, and
libgsystem APIs are covered by ostree usage at least.
2015-04-07 12:29:07 -04:00
Colin Walters
d59a63e3e6 Switch to using glibc xattrs
See https://github.com/GNOME/ostree/pull/78
2015-04-01 05:42:26 -04:00
Colin Walters
d8a3d3b821 README.md: Add some porting bits 2015-03-20 11:53:57 -04:00
Colin Walters
08d1339f9a console: Make glnx_console_lines and columns public
They'll be used by rpm-ostree at least.
2015-03-19 20:49:11 -04:00
Colin Walters
cf2a89f506 Add glnx_dirfd_canonicalize()
We want to honor `-1 == AT_FDCWD`.
2015-03-17 13:41:57 -04:00
Colin Walters
c92adab47a fdio: Add missing mode argument
Spotted by fortify-source.
2015-03-09 21:22:38 -04:00
Colin Walters
175502e5be Add glnx_basename()
We have to wrap the glibc version to ensure we get the right version,
otherwise depending on the variance of includes we may end up crashing
if we get the POSIX version.
2015-03-05 09:02:48 -05:00
Colin Walters
a11b2eb20a Import libcontainer code from rpm-ostree
Now that this module is Linux specific, we can more cleanly depend on
it here.
2015-03-04 18:29:14 -05:00