Pino Toscano
2015-Aug-12 10:47 UTC
[Libguestfs] [PATCH 1/2] inspect: recognize the Alpine Linux distribution
Just basic identification, name and version. --- generator/actions.ml | 4 ++++ src/guestfs-internal.h | 1 + src/inspect-fs-unix.c | 10 ++++++++++ src/inspect-fs.c | 2 ++ src/inspect-icon.c | 1 + src/inspect.c | 1 + 6 files changed, 19 insertions(+) diff --git a/generator/actions.ml b/generator/actions.ml index 35af981..26cc0da 100644 --- a/generator/actions.ml +++ b/generator/actions.ml @@ -1055,6 +1055,10 @@ Currently defined distros are: =over 4 +=item \"alpinelinux\" + +Alpine Linux. + =item \"archlinux\" Arch Linux. diff --git a/src/guestfs-internal.h b/src/guestfs-internal.h index bbd7fb4..0cd7f74 100644 --- a/src/guestfs-internal.h +++ b/src/guestfs-internal.h @@ -552,6 +552,7 @@ enum inspect_os_distro { OS_DISTRO_FREEBSD, OS_DISTRO_NETBSD, OS_DISTRO_COREOS, + OS_DISTRO_ALPINE_LINUX, }; enum inspect_os_package_format { diff --git a/src/inspect-fs-unix.c b/src/inspect-fs-unix.c index c9bbad9..abfa527 100644 --- a/src/inspect-fs-unix.c +++ b/src/inspect-fs-unix.c @@ -601,6 +601,16 @@ guestfs_int_check_linux_root (guestfs_h *g, struct inspect_fs *fs) if (guestfs_int_parse_major_minor (g, fs) == -1) return -1; } + else if (guestfs_is_file_opts (g, "/etc/alpine-release", + GUESTFS_IS_FILE_OPTS_FOLLOWSYMLINKS, 1, -1) > 0) { + fs->distro = OS_DISTRO_ALPINE_LINUX; + + if (parse_release_file (g, fs, "/etc/alpine-release") == -1) + return -1; + + if (guestfs_int_parse_major_minor (g, fs) == -1) + return -1; + } skip_release_checks:; diff --git a/src/inspect-fs.c b/src/inspect-fs.c index 073ae57..94c5bb9 100644 --- a/src/inspect-fs.c +++ b/src/inspect-fs.c @@ -494,6 +494,7 @@ guestfs_int_check_package_format (guestfs_h *g, struct inspect_fs *fs) case OS_DISTRO_FREEBSD: case OS_DISTRO_NETBSD: case OS_DISTRO_OPENBSD: + case OS_DISTRO_ALPINE_LINUX: case OS_DISTRO_UNKNOWN: fs->package_format = OS_PACKAGE_FORMAT_UNKNOWN; break; @@ -565,6 +566,7 @@ guestfs_int_check_package_management (guestfs_h *g, struct inspect_fs *fs) case OS_DISTRO_FREEBSD: case OS_DISTRO_NETBSD: case OS_DISTRO_OPENBSD: + case OS_DISTRO_ALPINE_LINUX: case OS_DISTRO_UNKNOWN: fs->package_management = OS_PACKAGE_MANAGEMENT_UNKNOWN; break; diff --git a/src/inspect-icon.c b/src/inspect-icon.c index ab730b5..77256a3 100644 --- a/src/inspect-icon.c +++ b/src/inspect-icon.c @@ -182,6 +182,7 @@ guestfs_impl_inspect_get_icon (guestfs_h *g, const char *root, size_t *size_r, case OS_DISTRO_FREEBSD: case OS_DISTRO_NETBSD: case OS_DISTRO_OPENBSD: + case OS_DISTRO_ALPINE_LINUX: case OS_DISTRO_UNKNOWN: ; /* nothing */ } diff --git a/src/inspect.c b/src/inspect.c index abe9087..79f674c 100644 --- a/src/inspect.c +++ b/src/inspect.c @@ -255,6 +255,7 @@ guestfs_impl_inspect_get_distro (guestfs_h *g, const char *root) return NULL; switch (fs->distro) { + case OS_DISTRO_ALPINE_LINUX: ret = safe_strdup (g, "alpinelinux"); break; case OS_DISTRO_ARCHLINUX: ret = safe_strdup (g, "archlinux"); break; case OS_DISTRO_BUILDROOT: ret = safe_strdup (g, "buildroot"); break; case OS_DISTRO_CENTOS: ret = safe_strdup (g, "centos"); break; -- 2.1.0
Pino Toscano
2015-Aug-12 10:47 UTC
[Libguestfs] [PATCH 2/2] inspect: support the APK package manager and its format
Associate the Alpine Linux distribution with it. --- generator/actions.ml | 4 ++-- src/guestfs-internal.h | 2 ++ src/inspect-apps.c | 1 + src/inspect-fs.c | 10 ++++++++-- src/inspect.c | 2 ++ 5 files changed, 15 insertions(+), 4 deletions(-) diff --git a/generator/actions.ml b/generator/actions.ml index 26cc0da..d0d6a21 100644 --- a/generator/actions.ml +++ b/generator/actions.ml @@ -1782,7 +1782,7 @@ package format I<or> if the operating system does not have a real packaging system (eg. Windows). Possible strings include: -C<rpm>, C<deb>, C<ebuild>, C<pisi>, C<pacman>, C<pkgsrc>. +C<rpm>, C<deb>, C<ebuild>, C<pisi>, C<pacman>, C<pkgsrc>, C<apk>. Future versions of libguestfs may return other strings. Please read L<guestfs(3)/INSPECTION> for more details." }; @@ -1804,7 +1804,7 @@ a real packaging system (eg. Windows). Possible strings include: C<yum>, C<dnf>, C<up2date>, C<apt> (for all Debian derivatives), -C<portage>, C<pisi>, C<pacman>, C<urpmi>, C<zypper>. +C<portage>, C<pisi>, C<pacman>, C<urpmi>, C<zypper>, C<apk>. Future versions of libguestfs may return other strings. Please read L<guestfs(3)/INSPECTION> for more details." }; diff --git a/src/guestfs-internal.h b/src/guestfs-internal.h index 0cd7f74..0c8857c 100644 --- a/src/guestfs-internal.h +++ b/src/guestfs-internal.h @@ -563,6 +563,7 @@ enum inspect_os_package_format { OS_PACKAGE_FORMAT_EBUILD, OS_PACKAGE_FORMAT_PISI, OS_PACKAGE_FORMAT_PKGSRC, + OS_PACKAGE_FORMAT_APK, }; enum inspect_os_package_management { @@ -576,6 +577,7 @@ enum inspect_os_package_management { OS_PACKAGE_MANAGEMENT_URPMI, OS_PACKAGE_MANAGEMENT_ZYPPER, OS_PACKAGE_MANAGEMENT_DNF, + OS_PACKAGE_MANAGEMENT_APK, }; struct inspect_fs { diff --git a/src/inspect-apps.c b/src/inspect-apps.c index 72c91ff..26091ab 100644 --- a/src/inspect-apps.c +++ b/src/inspect-apps.c @@ -162,6 +162,7 @@ guestfs_impl_inspect_list_applications2 (guestfs_h *g, const char *root) return NULL; break; + case OS_PACKAGE_FORMAT_APK: case OS_PACKAGE_FORMAT_EBUILD: case OS_PACKAGE_FORMAT_PISI: case OS_PACKAGE_FORMAT_PKGSRC: diff --git a/src/inspect-fs.c b/src/inspect-fs.c index 94c5bb9..aa198ad 100644 --- a/src/inspect-fs.c +++ b/src/inspect-fs.c @@ -484,6 +484,10 @@ guestfs_int_check_package_format (guestfs_h *g, struct inspect_fs *fs) fs->package_format = OS_PACKAGE_FORMAT_PISI; break; + case OS_DISTRO_ALPINE_LINUX: + fs->package_format = OS_PACKAGE_FORMAT_APK; + break; + case OS_DISTRO_SLACKWARE: case OS_DISTRO_TTYLINUX: case OS_DISTRO_COREOS: @@ -494,7 +498,6 @@ guestfs_int_check_package_format (guestfs_h *g, struct inspect_fs *fs) case OS_DISTRO_FREEBSD: case OS_DISTRO_NETBSD: case OS_DISTRO_OPENBSD: - case OS_DISTRO_ALPINE_LINUX: case OS_DISTRO_UNKNOWN: fs->package_format = OS_PACKAGE_FORMAT_UNKNOWN; break; @@ -556,6 +559,10 @@ guestfs_int_check_package_management (guestfs_h *g, struct inspect_fs *fs) fs->package_management = OS_PACKAGE_MANAGEMENT_ZYPPER; break; + case OS_DISTRO_ALPINE_LINUX: + fs->package_management = OS_PACKAGE_MANAGEMENT_APK; + break; + case OS_DISTRO_SLACKWARE: case OS_DISTRO_TTYLINUX: case OS_DISTRO_COREOS: @@ -566,7 +573,6 @@ guestfs_int_check_package_management (guestfs_h *g, struct inspect_fs *fs) case OS_DISTRO_FREEBSD: case OS_DISTRO_NETBSD: case OS_DISTRO_OPENBSD: - case OS_DISTRO_ALPINE_LINUX: case OS_DISTRO_UNKNOWN: fs->package_management = OS_PACKAGE_MANAGEMENT_UNKNOWN; break; diff --git a/src/inspect.c b/src/inspect.c index 79f674c..9332fc4 100644 --- a/src/inspect.c +++ b/src/inspect.c @@ -530,6 +530,7 @@ guestfs_impl_inspect_get_package_format (guestfs_h *g, const char *root) case OS_PACKAGE_FORMAT_EBUILD: ret = safe_strdup (g, "ebuild"); break; case OS_PACKAGE_FORMAT_PISI: ret = safe_strdup (g, "pisi"); break; case OS_PACKAGE_FORMAT_PKGSRC: ret = safe_strdup (g, "pkgsrc"); break; + case OS_PACKAGE_FORMAT_APK: ret = safe_strdup (g, "apk"); break; case OS_PACKAGE_FORMAT_UNKNOWN: ret = safe_strdup (g, "unknown"); break; @@ -550,6 +551,7 @@ guestfs_impl_inspect_get_package_management (guestfs_h *g, const char *root) return NULL; switch (fs->package_management) { + case OS_PACKAGE_MANAGEMENT_APK: ret = safe_strdup (g, "apk"); break; case OS_PACKAGE_MANAGEMENT_APT: ret = safe_strdup (g, "apt"); break; case OS_PACKAGE_MANAGEMENT_DNF: ret = safe_strdup (g, "dnf"); break; case OS_PACKAGE_MANAGEMENT_PACMAN: ret = safe_strdup (g, "pacman"); break; -- 2.1.0
Richard W.M. Jones
2015-Aug-12 14:20 UTC
Re: [Libguestfs] [PATCH 2/2] inspect: support the APK package manager and its format
Never heard of it. ACK series! Rich. -- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones Read my programming and virtualization blog: http://rwmj.wordpress.com virt-df lists disk usage of guests without needing to install any software inside the virtual machine. Supports Linux and Windows. http://people.redhat.com/~rjones/virt-df/
Reasonably Related Threads
- [PATCH 2/2] inspect: support the APK package manager and its format
- [PATCH 1/3] inspect: recognize the Void Linux distribution
- [PATCH] inspect: recognize the Frugalware distribution
- [PATCH 4/4] Add freebsd and netbsd distros
- [PATCH 5/5] Add freebsd and netbsd distros