Compare commits
8
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
819772d00d
|
||
|
|
d873619a6f
|
||
|
|
62e50748da
|
||
|
|
66279df701
|
||
|
|
a88d7d7723
|
||
|
|
5923b9f6a4
|
||
|
|
0aa20c7362
|
||
|
|
abdd2f5df8
|
@@ -51,14 +51,13 @@ jobs:
|
||||
env:
|
||||
GITEA_URL: ${{ gitea.server_url || github.server_url }}
|
||||
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 }}
|
||||
run: |
|
||||
echo "Veröffentliche Debian-Paket (Distribution: stable, Component: main)..."
|
||||
for deb in target/debian/*.deb; do
|
||||
[ -f "$deb" ] || continue
|
||||
curl -f -s -S -X PUT \
|
||||
--user "${ACTOR}:${TOKEN}" \
|
||||
-H "Authorization: token ${TOKEN}" \
|
||||
--upload-file "$deb" \
|
||||
"${GITEA_URL}/api/packages/${REPO_OWNER}/debian/pool/stable/main/upload"
|
||||
done
|
||||
@@ -67,7 +66,7 @@ jobs:
|
||||
for rpm in target/generate-rpm/*.rpm; do
|
||||
[ -f "$rpm" ] || continue
|
||||
curl -f -s -S -X PUT \
|
||||
--user "${ACTOR}:${TOKEN}" \
|
||||
-H "Authorization: token ${TOKEN}" \
|
||||
--upload-file "$rpm" \
|
||||
"${GITEA_URL}/api/packages/${REPO_OWNER}/rpm/stable/upload"
|
||||
done
|
||||
@@ -76,7 +75,7 @@ jobs:
|
||||
for pkg in target/arch/*.pkg.tar.zst; do
|
||||
[ -f "$pkg" ] || continue
|
||||
curl -f -s -S -X PUT \
|
||||
--user "${ACTOR}:${TOKEN}" \
|
||||
-H "Authorization: token ${TOKEN}" \
|
||||
--upload-file "$pkg" \
|
||||
"${GITEA_URL}/api/packages/${REPO_OWNER}/arch/stable/upload"
|
||||
done
|
||||
|
||||
@@ -51,14 +51,13 @@ jobs:
|
||||
env:
|
||||
GITEA_URL: ${{ gitea.server_url || github.server_url }}
|
||||
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 }}
|
||||
run: |
|
||||
echo "Veröffentliche Debian-Paket (Distribution: testing, Component: main)..."
|
||||
for deb in target/debian/*.deb; do
|
||||
[ -f "$deb" ] || continue
|
||||
curl -f -s -S -X PUT \
|
||||
--user "${ACTOR}:${TOKEN}" \
|
||||
-H "Authorization: token ${TOKEN}" \
|
||||
--upload-file "$deb" \
|
||||
"${GITEA_URL}/api/packages/${REPO_OWNER}/debian/pool/testing/main/upload"
|
||||
done
|
||||
@@ -67,7 +66,7 @@ jobs:
|
||||
for rpm in target/generate-rpm/*.rpm; do
|
||||
[ -f "$rpm" ] || continue
|
||||
curl -f -s -S -X PUT \
|
||||
--user "${ACTOR}:${TOKEN}" \
|
||||
-H "Authorization: token ${TOKEN}" \
|
||||
--upload-file "$rpm" \
|
||||
"${GITEA_URL}/api/packages/${REPO_OWNER}/rpm/testing/upload"
|
||||
done
|
||||
@@ -76,7 +75,7 @@ jobs:
|
||||
for pkg in target/arch/*.pkg.tar.zst; do
|
||||
[ -f "$pkg" ] || continue
|
||||
curl -f -s -S -X PUT \
|
||||
--user "${ACTOR}:${TOKEN}" \
|
||||
-H "Authorization: token ${TOKEN}" \
|
||||
--upload-file "$pkg" \
|
||||
"${GITEA_URL}/api/packages/${REPO_OWNER}/arch/testing/upload"
|
||||
done
|
||||
|
||||
+10
-2
@@ -1,6 +1,7 @@
|
||||
use crate::log::{LogLevel, log};
|
||||
use std::env;
|
||||
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.
|
||||
///
|
||||
@@ -11,10 +12,17 @@ use std::process::Command;
|
||||
pub fn is_run_as_root() -> bool {
|
||||
unsafe { libc::geteuid() == 0 }
|
||||
}
|
||||
|
||||
/// Startet das Programm mit Root-Rechten über `sudo` neu.
|
||||
///
|
||||
/// Diese Funktion versucht das Programm mit erhöhten Rechten neu zu starten.
|
||||
pub fn run_as_root() {
|
||||
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
@@ -93,7 +93,7 @@ fn run_docker_command(args: &[&str]) -> std::io::Result<Output> {
|
||||
}
|
||||
|
||||
/// 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> {
|
||||
let mut compose_args = vec!["compose"];
|
||||
compose_args.extend_from_slice(args);
|
||||
@@ -104,14 +104,32 @@ pub fn run_compose_command(dir: &Path, args: &[&str]) -> std::io::Result<Output>
|
||||
.output();
|
||||
|
||||
match output {
|
||||
Ok(out) if out.status.success() => Ok(out),
|
||||
_ => {
|
||||
// Fallback auf docker-compose (v1)
|
||||
Ok(out) => {
|
||||
let stderr = String::from_utf8_lossy(&out.stderr);
|
||||
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")
|
||||
.current_dir(dir)
|
||||
.args(args)
|
||||
.output()
|
||||
}
|
||||
Err(err) => Err(err),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user