Compare commits

..
4 changed files with 38 additions and 14 deletions
+3 -4
View File
@@ -51,14 +51,13 @@ jobs:
env: env:
GITEA_URL: ${{ gitea.server_url || github.server_url }} GITEA_URL: ${{ gitea.server_url || github.server_url }}
REPO_OWNER: ${{ gitea.repository_owner || github.repository_owner }} REPO_OWNER: ${{ gitea.repository_owner || github.repository_owner }}
ACTOR: ${{ gitea.actor || github.actor }}
TOKEN: ${{ secrets.PACKAGE_TOKEN || secrets.RELEASE_TOKEN || secrets.PUBLISH_TOKEN || secrets.API_TOKEN || secrets.PAT_TOKEN || secrets.CUSTOM_TOKEN || secrets.GITEA_TOKEN || secrets.GITHUB_TOKEN || github.token }} TOKEN: ${{ secrets.PACKAGE_TOKEN || secrets.RELEASE_TOKEN || secrets.PUBLISH_TOKEN || secrets.API_TOKEN || secrets.PAT_TOKEN || secrets.CUSTOM_TOKEN || secrets.GITEA_TOKEN || secrets.GITHUB_TOKEN || github.token }}
run: | run: |
echo "Veröffentliche Debian-Paket (Distribution: stable, Component: main)..." echo "Veröffentliche Debian-Paket (Distribution: stable, Component: main)..."
for deb in target/debian/*.deb; do for deb in target/debian/*.deb; do
[ -f "$deb" ] || continue [ -f "$deb" ] || continue
curl -f -s -S -X PUT \ curl -f -s -S -X PUT \
--user "${ACTOR}:${TOKEN}" \ -H "Authorization: token ${TOKEN}" \
--upload-file "$deb" \ --upload-file "$deb" \
"${GITEA_URL}/api/packages/${REPO_OWNER}/debian/pool/stable/main/upload" "${GITEA_URL}/api/packages/${REPO_OWNER}/debian/pool/stable/main/upload"
done done
@@ -67,7 +66,7 @@ jobs:
for rpm in target/generate-rpm/*.rpm; do for rpm in target/generate-rpm/*.rpm; do
[ -f "$rpm" ] || continue [ -f "$rpm" ] || continue
curl -f -s -S -X PUT \ curl -f -s -S -X PUT \
--user "${ACTOR}:${TOKEN}" \ -H "Authorization: token ${TOKEN}" \
--upload-file "$rpm" \ --upload-file "$rpm" \
"${GITEA_URL}/api/packages/${REPO_OWNER}/rpm/stable/upload" "${GITEA_URL}/api/packages/${REPO_OWNER}/rpm/stable/upload"
done done
@@ -76,7 +75,7 @@ jobs:
for pkg in target/arch/*.pkg.tar.zst; do for pkg in target/arch/*.pkg.tar.zst; do
[ -f "$pkg" ] || continue [ -f "$pkg" ] || continue
curl -f -s -S -X PUT \ curl -f -s -S -X PUT \
--user "${ACTOR}:${TOKEN}" \ -H "Authorization: token ${TOKEN}" \
--upload-file "$pkg" \ --upload-file "$pkg" \
"${GITEA_URL}/api/packages/${REPO_OWNER}/arch/stable/upload" "${GITEA_URL}/api/packages/${REPO_OWNER}/arch/stable/upload"
done done
+3 -4
View File
@@ -51,14 +51,13 @@ jobs:
env: env:
GITEA_URL: ${{ gitea.server_url || github.server_url }} GITEA_URL: ${{ gitea.server_url || github.server_url }}
REPO_OWNER: ${{ gitea.repository_owner || github.repository_owner }} REPO_OWNER: ${{ gitea.repository_owner || github.repository_owner }}
ACTOR: ${{ gitea.actor || github.actor }}
TOKEN: ${{ secrets.PACKAGE_TOKEN || secrets.RELEASE_TOKEN || secrets.PUBLISH_TOKEN || secrets.API_TOKEN || secrets.PAT_TOKEN || secrets.CUSTOM_TOKEN || secrets.GITEA_TOKEN || secrets.GITHUB_TOKEN || github.token }} TOKEN: ${{ secrets.PACKAGE_TOKEN || secrets.RELEASE_TOKEN || secrets.PUBLISH_TOKEN || secrets.API_TOKEN || secrets.PAT_TOKEN || secrets.CUSTOM_TOKEN || secrets.GITEA_TOKEN || secrets.GITHUB_TOKEN || github.token }}
run: | run: |
echo "Veröffentliche Debian-Paket (Distribution: testing, Component: main)..." echo "Veröffentliche Debian-Paket (Distribution: testing, Component: main)..."
for deb in target/debian/*.deb; do for deb in target/debian/*.deb; do
[ -f "$deb" ] || continue [ -f "$deb" ] || continue
curl -f -s -S -X PUT \ curl -f -s -S -X PUT \
--user "${ACTOR}:${TOKEN}" \ -H "Authorization: token ${TOKEN}" \
--upload-file "$deb" \ --upload-file "$deb" \
"${GITEA_URL}/api/packages/${REPO_OWNER}/debian/pool/testing/main/upload" "${GITEA_URL}/api/packages/${REPO_OWNER}/debian/pool/testing/main/upload"
done done
@@ -67,7 +66,7 @@ jobs:
for rpm in target/generate-rpm/*.rpm; do for rpm in target/generate-rpm/*.rpm; do
[ -f "$rpm" ] || continue [ -f "$rpm" ] || continue
curl -f -s -S -X PUT \ curl -f -s -S -X PUT \
--user "${ACTOR}:${TOKEN}" \ -H "Authorization: token ${TOKEN}" \
--upload-file "$rpm" \ --upload-file "$rpm" \
"${GITEA_URL}/api/packages/${REPO_OWNER}/rpm/testing/upload" "${GITEA_URL}/api/packages/${REPO_OWNER}/rpm/testing/upload"
done done
@@ -76,7 +75,7 @@ jobs:
for pkg in target/arch/*.pkg.tar.zst; do for pkg in target/arch/*.pkg.tar.zst; do
[ -f "$pkg" ] || continue [ -f "$pkg" ] || continue
curl -f -s -S -X PUT \ curl -f -s -S -X PUT \
--user "${ACTOR}:${TOKEN}" \ -H "Authorization: token ${TOKEN}" \
--upload-file "$pkg" \ --upload-file "$pkg" \
"${GITEA_URL}/api/packages/${REPO_OWNER}/arch/testing/upload" "${GITEA_URL}/api/packages/${REPO_OWNER}/arch/testing/upload"
done done
+10 -2
View File
@@ -1,6 +1,7 @@
use crate::log::{LogLevel, log};
use std::env; use std::env;
use std::os::unix::process::CommandExt; use std::os::unix::process::CommandExt;
use std::process::Command; use std::process::{Command, exit};
/// Prüft, ob das Programm mit Root-/Administrator-Rechten ausgeführt wird. /// Prüft, ob das Programm mit Root-/Administrator-Rechten ausgeführt wird.
/// ///
@@ -11,10 +12,17 @@ use std::process::Command;
pub fn is_run_as_root() -> bool { pub fn is_run_as_root() -> bool {
unsafe { libc::geteuid() == 0 } unsafe { libc::geteuid() == 0 }
} }
/// Startet das Programm mit Root-Rechten über `sudo` neu. /// Startet das Programm mit Root-Rechten über `sudo` neu.
/// ///
/// Diese Funktion versucht das Programm mit erhöhten Rechten neu zu starten. /// Diese Funktion versucht das Programm mit erhöhten Rechten neu zu starten.
pub fn run_as_root() { pub fn run_as_root() {
let commandline_args: Vec<String> = env::args().collect(); let commandline_args: Vec<String> = env::args().collect();
let _output = Command::new("sudo").args(&commandline_args).exec(); // Bye bye never returns let err = Command::new("sudo").args(&commandline_args).exec();
log(
"auth",
&format!("Fehler beim Ausführen von 'sudo': {}", err),
LogLevel::Error,
);
exit(1);
} }
+22 -4
View File
@@ -93,7 +93,7 @@ fn run_docker_command(args: &[&str]) -> std::io::Result<Output> {
} }
/// Führt einen Docker-Compose-Befehl im angegebenen Verzeichnis aus. /// Führt einen Docker-Compose-Befehl im angegebenen Verzeichnis aus.
/// Versucht zuerst `docker compose` und fällt bei Bedarf auf `docker-compose` zurück. /// Versucht zuerst `docker compose` und fällt bei Nichtverfügbarkeit auf `docker-compose` zurück.
pub fn run_compose_command(dir: &Path, args: &[&str]) -> std::io::Result<Output> { pub fn run_compose_command(dir: &Path, args: &[&str]) -> std::io::Result<Output> {
let mut compose_args = vec!["compose"]; let mut compose_args = vec!["compose"];
compose_args.extend_from_slice(args); compose_args.extend_from_slice(args);
@@ -104,14 +104,32 @@ pub fn run_compose_command(dir: &Path, args: &[&str]) -> std::io::Result<Output>
.output(); .output();
match output { match output {
Ok(out) if out.status.success() => Ok(out), Ok(out) => {
_ => { let stderr = String::from_utf8_lossy(&out.stderr);
// Fallback auf docker-compose (v1) let is_unavailable = !out.status.success()
&& (stderr.contains("is not a docker command")
|| stderr.contains("unknown command \"compose\"")
|| stderr.contains("unknown command: compose"));
if is_unavailable {
if let Ok(fallback_out) = Command::new("docker-compose")
.current_dir(dir)
.args(args)
.output()
{
return Ok(fallback_out);
}
}
Ok(out)
}
Err(err) if err.kind() == std::io::ErrorKind::NotFound => {
// docker-Binary nicht gefunden, versuche docker-compose
Command::new("docker-compose") Command::new("docker-compose")
.current_dir(dir) .current_dir(dir)
.args(args) .args(args)
.output() .output()
} }
Err(err) => Err(err),
} }
} }