Skip to content

Commit

Permalink
Add example configurations for fedora
Browse files Browse the repository at this point in the history
rebuildctl pkgs sync fedora Everything https://ftp.halifax.rwth-aachen.de/fedora/linux/releases/38/ --architecture x86_64 --print-json
  • Loading branch information
kpcyrd committed Nov 1, 2023
1 parent 67bd823 commit a4e612b
Show file tree
Hide file tree
Showing 5 changed files with 76 additions and 31 deletions.
6 changes: 6 additions & 0 deletions contrib/confs/rebuilderd-sync.conf
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,12 @@ source = "https://ftp.halifax.rwth-aachen.de/archlinux/$repo/os/$arch"
#pkgs = ["some-pkg", "python-*"]
#excludes = ["tensorflow*"]

[profile."fedora"]
distro = "fedora"
suite = "Everything"
architectures = ["x86_64"]
source = "https://ftp.halifax.rwth-aachen.de/fedora/linux/releases/38/"

[profile."debian-main"]
distro = "debian"
suite = "main"
Expand Down
12 changes: 12 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,18 @@ services:
- REBUILDERD_COOKIE_PATH=/secret/auth
volumes:
- ./secret:/secret
worker-fedora:
build:
context: .
dockerfile: worker/Dockerfile.fedora
# number of concurrent workers
scale: 1
init: true
command: ['connect', 'http://daemon:8484']
environment:
- REBUILDERD_COOKIE_PATH=/secret/auth
volumes:
- ./secret:/secret
worker-tails:
build:
context: .
Expand Down
69 changes: 38 additions & 31 deletions tools/src/schedule/fedora.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,42 +14,49 @@ pub async fn sync(sync: &PkgsSync) -> Result<Vec<PkgGroup>> {
if !url.ends_with('/') {
url.push('/');
}
url.push_str(&sync.suite);
url.push('/');

let bytes = fetch_url_or_path(&client, &format!("{url}repodata/repomd.xml")).await?;
let location = get_primary_location_from_xml(&bytes)?;
let mut bases: HashMap<_, PkgGroup> = HashMap::new();
for arch in &sync.architectures {
let mut url = url.clone();
url.push_str(&arch);

Check failure on line 23 in tools/src/schedule/fedora.rs

View workflow job for this annotation

GitHub Actions / clippy

this expression creates a reference which is immediately dereferenced by the compiler
url.push_str("/os/");

let bytes = fetch_url_or_path(&client, &format!("{url}{location}")).await?;
info!("Parsing index ({} bytes)...", bytes.len());
let packages = parse_package_index(GzDecoder::new(&bytes[..]))?;
let bytes = fetch_url_or_path(&client, &format!("{url}repodata/repomd.xml")).await?;
let location = get_primary_location_from_xml(&bytes)?;

let mut bases: HashMap<_, PkgGroup> = HashMap::new();
for pkg in packages {
if !pkg.matches(sync) {
continue;
}
let bytes = fetch_url_or_path(&client, &format!("{url}{location}")).await?;
info!("Parsing index ({} bytes)...", bytes.len());
let packages = parse_package_index(GzDecoder::new(&bytes[..]))?;

for pkg in packages {
if !pkg.matches(sync) {
continue;
}

// let url = mirror_to_url(source, &sync.suite, arch, &pkg.filename)?;
let url = format!("{url}{}", pkg.location.href);
let version= format!("{}-{}", pkg.version.ver, pkg.version.rel);
let artifact = PkgArtifact {
name: pkg.name,
version,
url,
};
let url = format!("{url}{}", pkg.location.href);
let version= format!("{}-{}", pkg.version.ver, pkg.version.rel);
let artifact = PkgArtifact {
name: pkg.name,
version,
url,
};

if let Some(group) = bases.get_mut(&pkg.format.sourcerpm) {
group.add_artifact(artifact);
} else {
let mut group = PkgGroup::new(
pkg.format.sourcerpm.clone(),
format!("{}-{}", pkg.version.ver, pkg.version.rel),
sync.distro.to_string(),
sync.suite.to_string(),
pkg.arch,
None,
);
group.add_artifact(artifact);
bases.insert(pkg.format.sourcerpm, group);
if let Some(group) = bases.get_mut(&pkg.format.sourcerpm) {
group.add_artifact(artifact);
} else {
let mut group = PkgGroup::new(
pkg.format.sourcerpm.clone(),
format!("{}-{}", pkg.version.ver, pkg.version.rel),
sync.distro.to_string(),
sync.suite.to_string(),
pkg.arch,
None,
);
group.add_artifact(artifact);
bases.insert(pkg.format.sourcerpm, group);
}
}
}

Expand Down
18 changes: 18 additions & 0 deletions worker/Dockerfile.fedora
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
FROM fedora
WORKDIR /usr/src/rebuilderd
RUN dnf -y install cargo openssl-devel rust
COPY . .
RUN --mount=type=cache,target=/var/cache/buildkit \
CARGO_HOME=/var/cache/buildkit/cargo \
CARGO_TARGET_DIR=/var/cache/buildkit/fedora/target \
cargo build --release --locked -p rebuilderd-worker && \
cp -v /var/cache/buildkit/fedora/target/release/rebuilderd-worker /

FROM fedora
RUN dnf -y install openssl-libs
COPY --from=0 \
/usr/src/rebuilderd/worker/rebuilder-fedora.sh \
/usr/local/libexec/rebuilderd/
COPY --from=0 /rebuilderd-worker /usr/local/bin/
ENV REBUILDERD_WORKER_BACKEND=fedora=/usr/local/libexec/rebuilderd/rebuilder-fedora.sh
ENTRYPOINT ["rebuilderd-worker"]
2 changes: 2 additions & 0 deletions worker/rebuilder-fedora.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/bin/sh
echo hello

0 comments on commit a4e612b

Please sign in to comment.