summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLars Wirzenius <liw@liw.fi>2021-03-30 09:11:48 +0000
committerLars Wirzenius <liw@liw.fi>2021-03-30 09:11:48 +0000
commit2a10fbddbc7da6a4e38818896e2961a7c5d8991d (patch)
tree53e4d3dee34886241edef578d5a254f041a19e71
parente139b4f8f89ebc718947542949f891415c423ef7 (diff)
parentd4c0918adbf8d1b88393df3763845cec1767e67b (diff)
downloadbumper-rs-2a10fbddbc7da6a4e38818896e2961a7c5d8991d.tar.gz
Merge branch 'debian' into 'main'
Add Debian packaging See merge request larswirzenius/bumper!1
-rw-r--r--debian/cargo-checksum.json0
-rw-r--r--debian/changelog6
-rw-r--r--debian/compat2
-rw-r--r--debian/control24
-rw-r--r--debian/copyright23
-rwxr-xr-xdebian/rules14
-rw-r--r--debian/source/format1
-rw-r--r--src/errors.rs6
-rw-r--r--src/git.rs1
-rw-r--r--src/rust.rs54
-rw-r--r--subplot/bumper.py21
11 files changed, 135 insertions, 17 deletions
diff --git a/debian/cargo-checksum.json b/debian/cargo-checksum.json
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/debian/cargo-checksum.json
diff --git a/debian/changelog b/debian/changelog
new file mode 100644
index 0000000..bdf4890
--- /dev/null
+++ b/debian/changelog
@@ -0,0 +1,6 @@
+bumper (0.1.0-1) unstable; urgency=low
+
+ * Initial packaging. This is not intended to be uploaded to Debian, so
+ no closing of an ITP bug.
+
+ -- Lars Wirzenius <liw@liw.fi> Tue, 30 Mar 2021 08:33:35 +0300
diff --git a/debian/compat b/debian/compat
new file mode 100644
index 0000000..021ea30
--- /dev/null
+++ b/debian/compat
@@ -0,0 +1,2 @@
+10
+
diff --git a/debian/control b/debian/control
new file mode 100644
index 0000000..1f8adc1
--- /dev/null
+++ b/debian/control
@@ -0,0 +1,24 @@
+Source: bumper
+Maintainer: Lars Wirzenius <liw@liw.fi>
+Section: devel
+Priority: optional
+Standards-Version: 4.2.0
+Build-Depends:
+ debhelper (>= 10~),
+ build-essential,
+ dh-cargo,
+ git,
+ python3,
+ subplot,
+ texlive-fonts-recommended,
+ texlive-latex-base,
+ texlive-latex-recommended
+Homepage: https://obnam.org
+
+Package: bumper
+Architecture: any
+Depends: ${misc:Depends}, ${shlibs:Depends}
+Built-Using: ${cargo:Built-Using}
+Description: set version number for release
+ Bumper sets the version number of a software project when it's being
+ released.
diff --git a/debian/copyright b/debian/copyright
new file mode 100644
index 0000000..7f68874
--- /dev/null
+++ b/debian/copyright
@@ -0,0 +1,23 @@
+Format: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
+Upstream-Name: bumper
+Upstream-Contact: Lars Wirzenius <liw@liw.fi>
+Source: http://git.liw.fi/bumper-rs
+
+Files: *
+Copyright: 2021, Lars Wirzenius
+License: GPL-3+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+ .
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+ .
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+ .
+ On a Debian system, you can find a copy of GPL version 3 at
+ /usr/share/common-licenses/GPL-3 .
diff --git a/debian/rules b/debian/rules
new file mode 100755
index 0000000..9c0d08b
--- /dev/null
+++ b/debian/rules
@@ -0,0 +1,14 @@
+#!/usr/bin/make -f
+
+%:
+ dh $@ --buildsystem cargo
+
+override_dh_auto_build:
+ true
+
+override_dh_auto_install:
+ cargo install --path=. --root=debian/obnam
+ find debian/obnam -name '.crates*' -delete
+
+override_dh_auto_test:
+ ./check
diff --git a/debian/source/format b/debian/source/format
new file mode 100644
index 0000000..163aaf8
--- /dev/null
+++ b/debian/source/format
@@ -0,0 +1 @@
+3.0 (quilt)
diff --git a/src/errors.rs b/src/errors.rs
index 282b5c5..c7febe3 100644
--- a/src/errors.rs
+++ b/src/errors.rs
@@ -26,6 +26,12 @@ pub enum BumperError {
#[error("'project' in Cargo.toml is not a table")]
ProjectNotTable,
+ #[error("Cargo.toml doesn't specify a package name")]
+ UnnamedProject,
+
+ #[error("Couldn't turn {0} into an absolute path: {1}")]
+ AbsPath(PathBuf, #[source] std::io::Error),
+
#[error("Failed to run git: {0}")]
GitInvoke(#[source] std::io::Error),
diff --git a/src/git.rs b/src/git.rs
index 76f6da1..38e99d9 100644
--- a/src/git.rs
+++ b/src/git.rs
@@ -3,6 +3,7 @@ use log::{debug, info};
use std::process::Command;
pub fn tag(version: &str) -> Result<(), BumperError> {
+ debug!("git tag in {}", std::env::current_dir().unwrap().display());
let tag_name = format!("v{}", version);
info!("Create git tag {}", tag_name);
let output = Command::new("git")
diff --git a/src/rust.rs b/src/rust.rs
index 192c387..56778b1 100644
--- a/src/rust.rs
+++ b/src/rust.rs
@@ -27,10 +27,15 @@ impl Rust {
self.cargo_toml.set_version(version)?;
self.cargo_toml.write()?;
+ let dirname = self
+ .dirname
+ .canonicalize()
+ .map_err(|err| BumperError::AbsPath(self.dirname.to_path_buf(), err))?;
+
info!(
"Rust project {}, in {}, version set to {}",
- self.dirname.display(),
- "xxx",
+ self.cargo_toml.name()?,
+ dirname.display(),
version
);
Ok(())
@@ -53,6 +58,36 @@ impl CargoToml {
})
}
+ fn get_package_table(&mut self) -> Result<&mut toml_edit::Table, BumperError> {
+ let package = self
+ .manifest
+ .get_table(&["package".to_string()])
+ .map_err(BumperError::NoPackage)?;
+ if let Some(table) = package.as_table_mut() {
+ Ok(table)
+ } else {
+ Err(BumperError::ProjectNotTable)
+ }
+ }
+
+ fn name(&mut self) -> Result<String, BumperError> {
+ let package = self.get_package_table()?;
+ let v = package.entry("name");
+ if let Some(name) = v.as_str() {
+ Ok(name.to_string())
+ } else {
+ Err(BumperError::UnnamedProject)
+ }
+ }
+
+ fn set_version(&mut self, version: &str) -> Result<(), BumperError> {
+ let package = self.get_package_table()?;
+ debug!("setting Cargo.toml set version to {} in memory", version);
+ let v = package.entry("version");
+ *v = Item::Value(Value::from(version));
+ Ok(())
+ }
+
fn write(&self) -> Result<(), BumperError> {
debug!("saving Cargo.toml to {}", self.dirname.display());
let mut file = Manifest::find_file(&Some(self.dirname.to_path_buf()))
@@ -62,19 +97,4 @@ impl CargoToml {
.map_err(|err| BumperError::WriteToml(self.dirname.to_path_buf(), err))?;
Ok(())
}
-
- fn set_version(&mut self, version: &str) -> Result<(), BumperError> {
- let package = self
- .manifest
- .get_table(&["package".to_string()])
- .map_err(BumperError::NoPackage)?;
- if let Some(package) = package.as_table_mut() {
- debug!("setting Cargo.toml set version to {} in memory", version);
- let v = package.entry("version");
- *v = Item::Value(Value::from(version));
- } else {
- return Err(BumperError::ProjectNotTable);
- }
- Ok(())
- }
}
diff --git a/subplot/bumper.py b/subplot/bumper.py
index 3198e13..329173c 100644
--- a/subplot/bumper.py
+++ b/subplot/bumper.py
@@ -13,15 +13,36 @@ def install_bumper(ctx):
def git_init_and_commit_everything(ctx, dirname=None):
runcmd_run = globals()["runcmd_run"]
+ runcmd_exit_code_is_zero = globals()["runcmd_exit_code_is_zero"]
+
+ runcmd_run(
+ ctx, ["git", "config", "--global", "user.email", "me@example.com", dirname]
+ )
+ runcmd_exit_code_is_zero(ctx)
+
+ runcmd_run(
+ ctx, ["git", "config", "--global", "user.name", "J. Random Hacker", dirname]
+ )
+ runcmd_exit_code_is_zero(ctx)
+
runcmd_run(ctx, ["git", "init", dirname])
+ runcmd_exit_code_is_zero(ctx)
+
runcmd_run(ctx, ["git", "add", "."], cwd=dirname)
+ runcmd_exit_code_is_zero(ctx)
+
runcmd_run(ctx, ["git", "commit", "-minitial"], cwd=dirname)
+ runcmd_exit_code_is_zero(ctx)
def remember_HEAD(ctx, dirname=None, varname=None):
runcmd_run = globals()["runcmd_run"]
runcmd_get_stdout = globals()["runcmd_get_stdout"]
+
runcmd_run(ctx, ["git", "rev-parse", "HEAD"], cwd=dirname)
+ runcmd_exit_code_is_zero = globals()["runcmd_exit_code_is_zero"]
+ runcmd_exit_code_is_zero(ctx)
+
ctx[varname] = runcmd_get_stdout(ctx).strip()