This commit is contained in:
eabdullin 2026-03-23 15:48:59 +03:00
commit 4345f1ecaf
5 changed files with 297 additions and 0 deletions

1
.gitignore vendored Normal file
View File

@ -0,0 +1 @@
fus-0+git.116.beed772.tar.gz

View File

@ -0,0 +1,22 @@
From 49e65642f07e2a159db3a97385acecdbeb48c218 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Lubom=C3=ADr=20Sedl=C3=A1=C5=99?= <lsedlar@redhat.com>
Date: Wed, 5 Jun 2019 10:53:52 +0200
Subject: [PATCH] Use C99 by default
---
meson.build | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/meson.build b/meson.build
index 4ff7ecc..93243e3 100644
--- a/meson.build
+++ b/meson.build
@@ -1,4 +1,4 @@
-project('fus', 'c', license : 'GPL-3.0+')
+project('fus', 'c', license : 'GPL-3.0+', default_options: ['c_std=c99'])
dep_glib = dependency('glib-2.0')
dep_gio = dependency('gio-2.0')
--
2.17.2

142
72.patch Normal file
View File

@ -0,0 +1,142 @@
From 16bb360e955728bacc8b8ff44043953adc07b2cb Mon Sep 17 00:00:00 2001
From: Rafael Fonseca <r4f4rfs@gmail.com>
Date: Wed, 14 Aug 2019 15:04:45 +0200
Subject: [PATCH] cache: Don't use checksum as filename
In some cases (e.g in Pungi), the metadata is changing all the time, fus
is run multiple times a day and the cache just grows. So instead of
using checksum we use the reponame passed in the command line invocation
and the metadata type to create a filename so that only one copy exists
for that reponame. Therefore the cache layout now is:
$CACHEDIR/fus/$reponame/$chksum.solv
$CACHEDIR/fus/$reponame/$chksum.solvx
$CACHEDIR/fus/$reponame/repodata/repomd.xml
$CACHEDIR/fus/$reponame/repodata/primary.xml.gz
$CACHEDIR/fus/$reponame/repodata/modules.xml.gz
$CACHEDIR/fus/$reponame/repodata/group_gz.x86_64.xml.xz
$CACHEDIR/fus/$reponame/repodata/filelists.xml.gz
Fixes #71
Signed-off-by: Rafael Fonseca <r4f4rfs@gmail.com>
---
repo.c | 53 +++++++++++++++++++++++++++++++++++++++++------------
1 file changed, 41 insertions(+), 12 deletions(-)
diff --git a/repo.c b/repo.c
index b3f3ec4..c445b12 100644
--- a/repo.c
+++ b/repo.c
@@ -510,22 +510,25 @@ download_repo_metadata (SoupSession *session,
const char *cachedir)
{
Id chksumtype;
- const char *fpath, *fname;
const unsigned char *chksum;
- fname = repomd_find (repo, type, &chksum, &chksumtype);
- if (!fname)
+ const char *mdname = repomd_find (repo, type, &chksum, &chksumtype);
+ if (!mdname)
return NULL;
- fpath = pool_tmpjoin (repo->pool, cachedir, "/", fname);
+ /* mdname should be "repodata/$(chksum)-$(type).xml.gz" */
+ const char *ext = strchr (mdname, '.');
+ const char *fpath = pool_tmpjoin (repo->pool, cachedir, "/", type);
+ fpath = pool_tmpappend (repo->pool, fpath, ext, 0);
+
if (!g_file_test (fpath, G_FILE_TEST_IS_REGULAR) ||
!checksum_matches (fpath, chksum, chksumtype))
{
g_autoptr(GError) error = NULL;
- const char *furl = pool_tmpjoin (repo->pool, repo_url, "/", fname);
- if (!download_to_path (session, furl, fpath, &error))
+ const char *mdurl = pool_tmpjoin (repo->pool, repo_url, "/", mdname);
+ if (!download_to_path (session, mdurl, fpath, &error))
{
- g_warning ("Could not download %s: %s", furl, error->message);
+ g_warning ("Could not download %s: %s", mdurl, error->message);
return NULL;
}
}
@@ -643,6 +646,25 @@ get_repo_cachedir (const char *name)
return g_build_filename (g_get_user_cache_dir (), "fus", name, NULL);
}
+static void
+remove_files_by_ext (const char *dirpath,
+ const char *ext)
+{
+ g_autoptr(GDir) dir = g_dir_open (dirpath, 0, NULL);
+ if (!dir)
+ return;
+
+ const gchar *fname;
+ while ((fname = g_dir_read_name (dir)) != NULL)
+ {
+ if (g_str_has_suffix (fname, ext))
+ {
+ g_autofree gchar *path = g_build_filename (dirpath, fname, NULL);
+ g_unlink (path);
+ }
+ }
+}
+
int
filelist_loadcb (Pool *pool,
Repodata *data,
@@ -668,11 +690,15 @@ filelist_loadcb (Pool *pool,
return 1;
}
+ /* Cleanup old libsolv cache files (if any) */
+ remove_files_by_ext (cachedir, ".solvx");
+
path = repodata_lookup_str (data, SOLVID_META, REPOSITORY_REPOMD_LOCATION);
if (!path)
return 0;
- fname = download_repo_metadata (session, repo, type, path, cachedir);
+ const char *destdir = pool_tmpjoin (pool, cachedir, "/", "repodata");
+ fname = download_repo_metadata (session, repo, type, path, destdir);
fp = solv_xfopen (fname, 0);
if (!fp)
{
@@ -747,10 +773,13 @@ create_repo (Pool *pool,
return repo;
}
+ /* Cleanup old libsolv cache files (if any) */
+ remove_files_by_ext (cachedir, ".solv");
+
repo_add_repomdxml (repo, fp, 0);
fclose (fp);
- fname = download_repo_metadata (session, repo, "primary", path, cachedir);
+ fname = download_repo_metadata (session, repo, "primary", path, destdir);
fp = solv_xfopen (fname, "r");
if (fp != NULL)
{
@@ -758,9 +787,9 @@ create_repo (Pool *pool,
fclose (fp);
}
- fname = download_repo_metadata (session, repo, "group_gz", path, cachedir);
+ fname = download_repo_metadata (session, repo, "group_gz", path, destdir);
if (!fname)
- fname = download_repo_metadata (session, repo, "group", path, cachedir);
+ fname = download_repo_metadata (session, repo, "group", path, destdir);
fp = solv_xfopen (fname, "r");
if (fp != NULL)
{
@@ -786,7 +815,7 @@ create_repo (Pool *pool,
pool_createwhatprovides (pool);
- fname = download_repo_metadata (session, repo, "modules", path, cachedir);
+ fname = download_repo_metadata (session, repo, "modules", path, destdir);
fp = solv_xfopen (fname, "r");
if (fp != NULL)
{

131
fus.spec Normal file
View File

@ -0,0 +1,131 @@
%global revcount 116
%global commit beed7724d9f0899e4920a7d4b042cf6590d2bbfb
%global shortcommit %(c=%{commit}; echo ${c:0:7})
Name: fus
Version: 0+git.%{revcount}.%{shortcommit}
Release: 1%{?dist}
Summary: Funny Solver
License: GPLv3+
URL: https://github.com/fedora-modularity/fus
Source0: %{url}/archive/%{commit}/%{name}-%{version}.tar.gz
Patch0: 0001-Use-C99-by-default.patch
Patch1: https://patch-diff.githubusercontent.com/raw/fedora-modularity/fus/pull/72.patch
# No libmodulemd on these arches
ExcludeArch: i686 ppc ppc64 s390
BuildRequires: meson
BuildRequires: gcc
BuildRequires: pkgconfig(glib-2.0)
BuildRequires: pkgconfig(gio-2.0)
BuildRequires: pkgconfig(libsolv) >= 0.6.34
BuildRequires: pkgconfig(libsolvext) >= 0.6.34
BuildRequires: pkgconfig(modulemd-2.0) >= 2.0
BuildRequires: pkgconfig(libsoup-2.4) >= 2.4
# Without this the build in eng-rhel-7-rh-python36 is failing...
# These macros are used in meson macro
%{!?_vpath_srcdir: %global _vpath_srcdir .}
%{!?_vpath_builddir: %global _vpath_builddir %_target_platform}
%description
%{summary}.
%prep
%autosetup -n %{name}-%{commit} -p1
%build
%meson
%meson_build
%install
%meson_install
%files
%license COPYING
%doc README.md
%{_bindir}/fus
%changelog
* Tue Feb 02 2021 Lubomír Sedlář <lsedlar@redhat.com> - 0+git.116.beed772-1
- Rebase to latest master
* Thu Jul 16 2020 Lubomír Sedlář <lsedlar@redhat.com> - 0+git.112.14171c3-2
- Ignore weak dependencies
* Tue Jan 28 2020 Lubomír Sedlář <lsedlar@redhat.com> - 0+git.112.14171c3-1
- Rebase to latest master
* Mon Dec 02 2019 Lubomír Sedlář <lsedlar@redhat.com> - 0+git.107.9cb602f-5
- Rebuild for newer libsoup
* Wed Nov 27 2019 Lubomír Sedlář <lsedlar@redhat.com> - 0+git.107.9cb602f-4
- Allow wildcards in exclude patterns
* Thu Sep 26 2019 Lubomír Sedlář <lsedlar@redhat.com> - 0+git.107.9cb602f-3
- Rebuild against libmodulemd2
* Fri Sep 20 2019 Lubomír Sedlář <lsedlar@redhat.com> - 0+git.107.9cb602f-2
- Fix segfault
* Tue Sep 17 2019 Lubomír Sedlář <lsedlar@redhat.com> - 0+git.107.9cb602f-1
- Rebase to latest master
- Use libmodulemd 2
* Wed Aug 14 2019 Lubomír Sedlář <lsedlar@redhat.com> - 0+git.89.a330cc6-5
- cache: Don't use checksum as filename
* Tue Jul 09 2019 Lubomír Sedlář <lsedlar@redhat.com> - 0+git.89.a330cc6-4
- Fix loading local repositories
* Mon Jul 08 2019 Lubomír Sedlář <lsedlar@redhat.com> - 0+git.89.a330cc6-3
- Revert patch for downloading from HTTP
* Wed May 22 2019 Lubomír Sedlář <lsedlar@redhat.com> - 0+git.89.a330cc6-2
- Allow retrieving repodata over HTTP
* Fri Oct 26 2018 Lubomír Sedlář <lsedlar@redhat.com> - 0+git.89.a330cc6-1
- New git snapshot
- Drop patches as they were merged upstream
- Revert update to new libmodulemd (which caused segfaults)
* Fri Oct 26 2018 Lubomír Sedlář <lsedlar@redhat.com> - 0+git.59.b59ec94-1
- New git snapshot
- Drop patch as reworked and merged into PR#47
* Mon Oct 22 2018 Lubomír Sedlář <lsedlar@redhat.com> - 0+git.54.0afe286-3
- Make wildcards match bare packages only
* Mon Oct 15 2018 Lubomír Sedlář <lsedlar@redhat.com>
- Refresh patches to include more fixes
* Fri Oct 12 2018 Lubomír Sedlář <lsedlar@redhat.com> - 0+git.54.0afe286-2
- New git snapshot
- Add patch to correctly select input packages
* Fri Oct 5 2018 Lubomír Sedlář <lsedlar@redhat.com> - 0+git.46.8ce1358-1
- New git snapshot
- Update patches to mask bare RPMs
* Thu Sep 20 2018 Lubomír Sedlář <lsedlar@redhat.com> - 0+git.38.1cc1d4c-1
- New git snapshot
- Refresh patches to mask bare RPMs
* Thu Sep 13 2018 Lubomír Sedlář <lsedlar@redhat.com> - 0+git.36.fb25ab2-1
- New git snapshot
- Add patches to mask bare RPMs
- Load filelists lazily
* Mon Aug 13 2018 Lubomír Sedlář <lsedlar@redhat.com> - 0+git.35.d97ca64-1
- New git snapshot
* Mon Aug 13 2018 Lubomír Sedlář <lsedlar@redhat.com> - 0+git.33.39180b3-1
- New git snapshot
* Mon Aug 13 2018 Lubomír Sedlář <lsedlar@redhat.com> - 0+git.30.6ff739b-2
- Compile with optimizations
* Mon Jul 30 2018 Igor Gnatenko <ignatenko@redhat.com> - 0+git.30.6ff739b-1
- Initial package

1
sources Normal file
View File

@ -0,0 +1 @@
2d453dc3e6c862c7ae4f9b7eda5ead55106e3b19d415cffd108917146e281a47435b995ac9ff39f896eb336c617ca188bf15bc81c9f26c5c0b24fabb03432438 fus-0+git.116.beed772.tar.gz