Repository: shssoichiro/oxipng (language: rust)

Issue:
Move the location for generated man pages inside target dir
The cargo release process expects that the `build.rs` file will not modify anything outside of the `target` directory. Currently, we are doing this for the man pages, which results in the following error when running `cargo publish`:

```
  Source directory was modified by build.rs during cargo publish. Build scripts should not modify anything outside of OUT_DIR.
  Added: /home/soichiro/repos/oxipng/target/package/oxipng-9.1.0/generated
        /home/soichiro/repos/oxipng/target/package/oxipng-9.1.0/generated/assets
        /home/soichiro/repos/oxipng/target/package/oxipng-9.1.0/generated/assets/oxipng.1
```

This change moves the `generated` directory to within `target` in order to resolve this.

Fixes #611 (will need to tag a 9.1.1 and `cargo publish` after)


Discussion / hints:
Issue was noted by @andrews05 [here](https://github.com/shssoichiro/oxipng/pull/607#issuecomment-2068215565).

Fix patch:
diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml
index c1dfd28d..e41443f0 100644
--- a/.github/workflows/deploy.yml
+++ b/.github/workflows/deploy.yml
@@ -90,11 +90,12 @@ jobs:
         run: |
           mkdir -p "target/${{ matrix.target }}/release"
           mv target/oxipng "target/${{ matrix.target }}/release"
+          mv target/debug/assets "target/${{ matrix.target }}/release"
           cargo install --locked cargo-deb
           cargo deb --target "${{ matrix.target }}" --no-build --no-strip
 
       - name: Create release notes
-        run: tail -n +2 CHANGELOG.md | sed -e '/^$/,$d' > RELEASE_NOTES.txt
+        run: tail -n +3 CHANGELOG.md | sed -e '/^$/,$d' > RELEASE_NOTES.txt
 
       - name: Create release
         uses: softprops/action-gh-release@v2
diff --git a/.gitignore b/.gitignore
index 868a47a4..c03f402b 100644
--- a/.gitignore
+++ b/.gitignore
@@ -4,4 +4,3 @@ target
 *.out.png
 /.idea
 /node_modules
-/generated
diff --git a/Cargo.toml b/Cargo.toml
index 7a218a72..d2a3cb09 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -104,7 +104,7 @@ panic = "abort"
 [package.metadata.deb]
 assets = [
     ["target/release/oxipng", "usr/bin/", "755"],
-    ["generated/assets/oxipng.1", "usr/share/man/man1/", "644"],
+    ["target/release/assets/oxipng.1", "usr/share/man/man1/", "644"],
     ["README.md", "usr/share/doc/oxipng/", "644"],
     ["CHANGELOG.md", "usr/share/doc/oxipng/", "644"],
 ]
diff --git a/build.rs b/build.rs
index 91cd1b6d..12b545b1 100644
--- a/build.rs
+++ b/build.rs
@@ -24,8 +24,14 @@ fn main() -> Result<(), Error> {
     println!("cargo:rerun-if-changed=src/cli.rs");
     println!("cargo:rerun-if-changed=src/display_chunks.rs");
 
-    // Create `generated/assets/` folder.
-    let path = env::current_dir()?.join("generated").join("assets");
+    // Create `target/<debug|release>/assets/` folder.
+    let outdir = match env::var_os("OUT_DIR") {
+        None => return Ok(()),
+        Some(outdir) => outdir,
+    };
+    let out_path = PathBuf::from(outdir);
+    let mut path = out_path.ancestors().nth(3).unwrap().to_owned();
+    path.push("assets");
     std::fs::create_dir_all(&path).unwrap();
 
     build_manpages(&path)?;


Test patch: