mirror of
https://github.com/danog/ytop.git
synced 2024-11-26 20:15:03 +01:00
cleanup package-publisher
This commit is contained in:
parent
c0dc111055
commit
17a721aa26
@ -5,8 +5,7 @@ authors = ["Caleb Bassi <calebjbassi@gmail.com>"]
|
|||||||
edition = "2018"
|
edition = "2018"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
git2 = "0.11.0"
|
|
||||||
reqwest = { version = "0.10" }
|
|
||||||
sha2 = "0.8.1"
|
|
||||||
hex = "0.4.0"
|
hex = "0.4.0"
|
||||||
|
reqwest = "0.10"
|
||||||
|
sha2 = "0.8.1"
|
||||||
tokio = { version = "0.2", features = ["full"] }
|
tokio = { version = "0.2", features = ["full"] }
|
||||||
|
@ -1,9 +1,27 @@
|
|||||||
use sha2::{Digest, Sha256};
|
|
||||||
use std::fs;
|
use std::fs;
|
||||||
use std::process::Command;
|
use std::process::Command;
|
||||||
|
use std::env;
|
||||||
|
|
||||||
|
use sha2::{Digest, Sha256};
|
||||||
|
use hex;
|
||||||
|
use tokio;
|
||||||
|
use reqwest;
|
||||||
|
|
||||||
const VERSION: &str = "0.4.3";
|
const VERSION: &str = "0.4.3";
|
||||||
|
|
||||||
|
const AUR_DIR: &str = "/home/cjbassi/playground/packages/ytop";
|
||||||
|
const AUR_BIN_DIR: &str = "/home/cjbassi/playground/packages/ytop-bin";
|
||||||
|
const HOMEBREW_DIR: &str = "/home/cjbassi/playground/packages/homebrew-ytop";
|
||||||
|
|
||||||
|
const AUR_TEMPLATE: &str = include_str!("../templates/aur");
|
||||||
|
const AUR_BIN_TEMPLATE: &str = include_str!("../templates/aur-bin");
|
||||||
|
const HOMEBREW_TEMPLATE: &str = include_str!("../templates/homebrew");
|
||||||
|
|
||||||
|
const AUR_FILE: &str = "PKGBUILD";
|
||||||
|
const AUR_BIN_FILE: &str = "PKGBUILD";
|
||||||
|
const HOMEBREW_FILE: &str = "ytop.rb";
|
||||||
|
|
||||||
|
|
||||||
async fn fetch_archive(url: &str) -> Vec<u8> {
|
async fn fetch_archive(url: &str) -> Vec<u8> {
|
||||||
reqwest::get(url)
|
reqwest::get(url)
|
||||||
.await
|
.await
|
||||||
@ -20,16 +38,32 @@ fn hash_archive(archive: &[u8]) -> String {
|
|||||||
hex::encode(&hasher.result()[..])
|
hex::encode(&hasher.result()[..])
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn srcinfo() {
|
||||||
|
let output = Command::new("makepkg")
|
||||||
|
.args(&["--printsrcinfo"])
|
||||||
|
.output()
|
||||||
|
.unwrap()
|
||||||
|
.stdout;
|
||||||
|
fs::write(".SRCINFO", output).unwrap();
|
||||||
|
}
|
||||||
|
|
||||||
|
fn git_add_commit_push() {
|
||||||
|
Command::new("git")
|
||||||
|
.args(&["add", "."])
|
||||||
|
.status()
|
||||||
|
.unwrap();
|
||||||
|
Command::new("git")
|
||||||
|
.args(&["commit", "-m", VERSION])
|
||||||
|
.status()
|
||||||
|
.unwrap();
|
||||||
|
Command::new("git")
|
||||||
|
.args(&["push"])
|
||||||
|
.status()
|
||||||
|
.unwrap();
|
||||||
|
}
|
||||||
|
|
||||||
#[tokio::main]
|
#[tokio::main]
|
||||||
async fn main() {
|
async fn main() {
|
||||||
let aur_dir = "/home/cjbassi/playground/packages/ytop";
|
|
||||||
let aur_bin_dir = "/home/cjbassi/playground/packages/ytop-bin";
|
|
||||||
let homebrew_dir = "/home/cjbassi/playground/packages/homebrew-ytop";
|
|
||||||
|
|
||||||
let aur_template = include_str!("../templates/aur");
|
|
||||||
let aur_bin_template = include_str!("../templates/aur-bin");
|
|
||||||
let homebrew_template = include_str!("../templates/homebrew");
|
|
||||||
|
|
||||||
let macos_url = format!(
|
let macos_url = format!(
|
||||||
"https://github.com/cjbassi/ytop/releases/download/{}/ytop-{}-x86_64-apple-darwin.tar.gz",
|
"https://github.com/cjbassi/ytop/releases/download/{}/ytop-{}-x86_64-apple-darwin.tar.gz",
|
||||||
VERSION, VERSION
|
VERSION, VERSION
|
||||||
@ -45,79 +79,36 @@ async fn main() {
|
|||||||
let linux_hash = hash_archive(&linux_archive);
|
let linux_hash = hash_archive(&linux_archive);
|
||||||
let repo_hash = hash_archive(&repo_archive);
|
let repo_hash = hash_archive(&repo_archive);
|
||||||
|
|
||||||
std::env::set_current_dir(homebrew_dir).unwrap();
|
env::set_current_dir(HOMEBREW_DIR).unwrap();
|
||||||
fs::write(
|
fs::write(
|
||||||
"ytop.rb",
|
HOMEBREW_FILE,
|
||||||
homebrew_template
|
HOMEBREW_TEMPLATE
|
||||||
.replace("{{ VERSION }}", VERSION)
|
.replace("{{ VERSION }}", VERSION)
|
||||||
.replace("{{ MACOS_SHA256 }}", &macos_hash)
|
.replace("{{ MACOS_SHA256 }}", &macos_hash)
|
||||||
.replace("{{ LINUX_SHA256 }}", &linux_hash),
|
.replace("{{ LINUX_SHA256 }}", &linux_hash),
|
||||||
)
|
)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
Command::new("git")
|
git_add_commit_push();
|
||||||
.args(&["add", "."])
|
|
||||||
.status()
|
|
||||||
.expect("failed to execute process");
|
|
||||||
Command::new("git")
|
|
||||||
.args(&["commit", "-m", VERSION])
|
|
||||||
.status()
|
|
||||||
.expect("failed to execute process");
|
|
||||||
Command::new("git")
|
|
||||||
.args(&["push"])
|
|
||||||
.status()
|
|
||||||
.expect("failed to execute process");
|
|
||||||
|
|
||||||
std::env::set_current_dir(aur_dir).unwrap();
|
env::set_current_dir(AUR_DIR).unwrap();
|
||||||
fs::write(
|
fs::write(
|
||||||
"PKGBUILD",
|
AUR_FILE,
|
||||||
aur_template
|
AUR_TEMPLATE
|
||||||
.replace("{{ VERSION }}", VERSION)
|
.replace("{{ VERSION }}", VERSION)
|
||||||
.replace("{{ SHA256 }}", &repo_hash),
|
.replace("{{ REPO_SHA256 }}", &repo_hash),
|
||||||
)
|
)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
let output = Command::new("makepkg")
|
srcinfo();
|
||||||
.args(&["--printsrcinfo"])
|
git_add_commit_push();
|
||||||
.output()
|
|
||||||
.expect("failed to execute process")
|
|
||||||
.stdout;
|
|
||||||
fs::write(".SRCINFO", output).unwrap();
|
|
||||||
Command::new("git")
|
|
||||||
.args(&["add", "."])
|
|
||||||
.status()
|
|
||||||
.expect("failed to execute process");
|
|
||||||
Command::new("git")
|
|
||||||
.args(&["commit", "-m", VERSION])
|
|
||||||
.status()
|
|
||||||
.expect("failed to execute process");
|
|
||||||
Command::new("git")
|
|
||||||
.args(&["push"])
|
|
||||||
.status()
|
|
||||||
.expect("failed to execute process");
|
|
||||||
|
|
||||||
std::env::set_current_dir(aur_bin_dir).unwrap();
|
env::set_current_dir(AUR_BIN_DIR).unwrap();
|
||||||
fs::write(
|
fs::write(
|
||||||
"PKGBUILD",
|
AUR_BIN_FILE,
|
||||||
aur_bin_template
|
AUR_BIN_TEMPLATE
|
||||||
.replace("{{ VERSION }}", VERSION)
|
.replace("{{ VERSION }}", VERSION)
|
||||||
.replace("{{ SHA256 }}", &linux_hash),
|
.replace("{{ LINUX_SHA256 }}", &linux_hash),
|
||||||
)
|
)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
let output = Command::new("makepkg")
|
srcinfo();
|
||||||
.args(&["--printsrcinfo"])
|
git_add_commit_push();
|
||||||
.output()
|
|
||||||
.expect("failed to execute process")
|
|
||||||
.stdout;
|
|
||||||
fs::write(".SRCINFO", output).unwrap();
|
|
||||||
Command::new("git")
|
|
||||||
.args(&["add", "."])
|
|
||||||
.status()
|
|
||||||
.expect("failed to execute process");
|
|
||||||
Command::new("git")
|
|
||||||
.args(&["commit", "-m", VERSION])
|
|
||||||
.status()
|
|
||||||
.expect("failed to execute process");
|
|
||||||
Command::new("git")
|
|
||||||
.args(&["push"])
|
|
||||||
.status()
|
|
||||||
.expect("failed to execute process");
|
|
||||||
}
|
}
|
||||||
|
@ -13,7 +13,7 @@ makedepends=("cargo")
|
|||||||
provides=(${pkgname})
|
provides=(${pkgname})
|
||||||
conflicts=(${pkgname})
|
conflicts=(${pkgname})
|
||||||
source=("${pkgname}-${pkgver}.tar.gz::${url}/archive/${pkgver}.tar.gz")
|
source=("${pkgname}-${pkgver}.tar.gz::${url}/archive/${pkgver}.tar.gz")
|
||||||
sha256sums=("{{ SHA256 }}")
|
sha256sums=("{{ REPO_SHA256 }}")
|
||||||
|
|
||||||
build() {
|
build() {
|
||||||
cd "${pkgname}-${pkgver}"
|
cd "${pkgname}-${pkgver}"
|
||||||
|
@ -11,7 +11,7 @@ license=("MIT")
|
|||||||
provides=(${_pkgname})
|
provides=(${_pkgname})
|
||||||
conflicts=(${_pkgname})
|
conflicts=(${_pkgname})
|
||||||
source=("${_pkgname}-${pkgver}.tar.gz::${url}/releases/download/${pkgver}/${_pkgname}-${pkgver}-${arch}-unknown-linux-gnu.tar.gz")
|
source=("${_pkgname}-${pkgver}.tar.gz::${url}/releases/download/${pkgver}/${_pkgname}-${pkgver}-${arch}-unknown-linux-gnu.tar.gz")
|
||||||
sha256sums=("{{ SHA256 }}")
|
sha256sums=("{{ LINUX_SHA256 }}")
|
||||||
|
|
||||||
package() {
|
package() {
|
||||||
install -Dm755 "${_pkgname}" "${pkgdir}/usr/bin/${_pkgname}"
|
install -Dm755 "${_pkgname}" "${pkgdir}/usr/bin/${_pkgname}"
|
||||||
|
Loading…
Reference in New Issue
Block a user