diff --git a/misc/librepo/Makefile b/misc/librepo/Makefile index a247554909b4..333c18cc44b9 100644 --- a/misc/librepo/Makefile +++ b/misc/librepo/Makefile @@ -1,41 +1,42 @@ PORTNAME= librepo DISTVERSION= 1.14.0 +PORTREVISION= 1 CATEGORIES= misc MAINTAINER= yuri@FreeBSD.org COMMENT= Library downloading repository metadata LICENSE= MIT LICENSE_FILE= ${WRKSRC}/COPYING LIB_DEPENDS= libassuan.so:security/libassuan \ libcurl.so:ftp/curl \ libgpg-error.so:security/libgpg-error \ libgpgme.so:security/gpgme USES= gettext-runtime gnome cmake localbase:ldflags pkgconfig USE_GNOME= glib20 libxml2 USE_LDCONFIG= yes USE_GITHUB= yes GH_ACCOUNT= rpm-software-management CMAKE_OFF= ENABLE_DOCS ENABLE_TESTS OPTIONS_DEFINE= PYTHON ZCHUNK OPTIONS_DEFAULT= ZCHUNK OPTIONS_SUB= yes PYTHON_USES= python PYTHON_CMAKE_BOOL= ENABLE_PYTHON PYTHON_CMAKE_ON= -DPYTHON_DESIRED=${PYTHON_MAJOR_VER} ZCHUNK_DESC= Build with zchunk support ZCHUNK_CMAKE_BOOL= WITH_ZCHUNK ZCHUNK_LIB_DEPENDS= libzck.so:archivers/zchunk post-patch: @${RLN} ${FILESDIR}/xattr.c ${WRKSRC}/librepo/xattr.c @${RLN} ${FILESDIR}/xattr.h ${WRKSRC}/librepo/xattr.h .include diff --git a/misc/librepo/files/xattr.c b/misc/librepo/files/xattr.c index b89e82cf3df0..34ae5fce5ef6 100644 --- a/misc/librepo/files/xattr.c +++ b/misc/librepo/files/xattr.c @@ -1,33 +1,54 @@ #include #include #include /// /// xattr is a Linux kernel API that has to be mapped to the FreeBSD API /// // code below is adopted and simplified from the 'xattr' python module https://github.com/xattr/xattr/blob/master/xattr/lib_build.c +static void convert_bsd_list(char *namebuf, size_t size) { + size_t offset = 0; + while(offset < size) { + int length = (int) (unsigned char)namebuf[offset]; + memmove(namebuf+offset, namebuf+offset+1, length); + namebuf[offset+length] = '\0'; + offset += length+1; + } +} + int fsetxattr(int fd, const char *name, const void *value, size_t size, int flags) { int rv = 0; assert(flags == 0); // we do not handle flags here and the project currently doesn't use flags!=0 rv = extattr_set_fd(fd, EXTATTR_NAMESPACE_USER, name, value, size); /* freebsd returns the written length on success, not zero. */ if (rv >= 0) return 0; else return rv; } +ssize_t flistxattr(int fd, char *namebuf, size_t size) { + ssize_t rv = 0; + + rv = extattr_list_fd(fd, EXTATTR_NAMESPACE_USER, namebuf, size); + + if (rv > 0 && namebuf) + convert_bsd_list(namebuf, rv); + + return rv; +} + ssize_t fgetxattr(int fd, const char *name, void *value, size_t size) { return extattr_get_fd(fd, EXTATTR_NAMESPACE_USER, name, value, size); } int fremovexattr(int fd, const char *name) { return extattr_delete_fd(fd, EXTATTR_NAMESPACE_USER, name); } diff --git a/misc/librepo/files/xattr.h b/misc/librepo/files/xattr.h index 633417b953b3..8304b9a9660e 100644 --- a/misc/librepo/files/xattr.h +++ b/misc/librepo/files/xattr.h @@ -1,4 +1,5 @@ int fsetxattr(int fd, const char *name, const void *value, size_t size, int flags); +ssize_t flistxattr(int fd, char *namebuf, size_t size); ssize_t fgetxattr(int fd, const char *name, void *value, size_t size); int fremovexattr(int fd, const char *name);