Repository: beeware/briefcase

Issue:
Python package generation generates invalid rpm specfile when there are files in the filename
### Describe the bug

The `briefcase package` command fails with messages such as:

```
error: File must begin with "/": manifest.xml
error: File must begin with "/": (dev).tmpl

```

Lines matching the strings listed in the spec file contain a space character:

```
/usr/lib64/rpmtest/app_packages/setuptools/command/launcher manifest.xml
/usr/lib64/rpmtest/app_packages/setuptools/script (dev).tmpl

```


### Steps to reproduce

In a Linux environment (reproduced on Almalinux 9)
1. Create a new project with `briefcase new`
2. Add `redislite` to the [tool.briefcase.app.rpmtest] requires
3. Create the Application using `briefcase create`
4. Build the project using `briefcase build`
5. Attempt to create an rpm package using `briefcase package`

### Expected behavior

An rpm package gets created

### Screenshots

_No response_

### Environment

- Almalinux 9.1:
- Python version: 3.9.14
- Software versions:
  - Briefcase: 0.3.14


### Logs


```
[briefcase.2023_04_25-20_43_53.package.log](https://github.com/beeware/briefcase/files/11326841/briefcase.2023_04_25-20_43_53.package.log)

```

### Additional context

_No response_

Comments:

Patch:
diff --git a/changes/1232.misc.rst b/changes/1232.misc.rst
new file mode 100644
index 00000000..8d8bf701
--- /dev/null
+++ b/changes/1232.misc.rst
@@ -0,0 +1,1 @@
+If `git` fails to update a template in the cookiecutter cache, the `git` command and output are now captured in the Briefcase log file.
diff --git a/changes/1236.bugfix.rst b/changes/1236.bugfix.rst
new file mode 100644
index 00000000..0518430a
--- /dev/null
+++ b/changes/1236.bugfix.rst
@@ -0,0 +1,1 @@
+Filenames and directories in rpm package definitions are quoted in order to include files with filenames that include whitespace.
diff --git a/src/briefcase/commands/base.py b/src/briefcase/commands/base.py
index cedf5412..b434bc21 100644
--- a/src/briefcase/commands/base.py
+++ b/src/briefcase/commands/base.py
@@ -772,10 +772,12 @@ Did you run Briefcase in a project directory that contains {filename.name!r}?"""
                     # Attempt to update the repository
                     remote = repo.remote(name="origin")
                     remote.fetch()
-                except self.tools.git.exc.GitCommandError:
+                except self.tools.git.exc.GitCommandError as e:
                     # We are offline, or otherwise unable to contact
-                    # the origin git repo. It's OK to continue; but warn
-                    # the user that the template may be stale.
+                    # the origin git repo. It's OK to continue; but
+                    # capture the error in the log and warn the user
+                    # that the template may be stale.
+                    self.logger.debug(str(e))
                     self.logger.warning(
                         """
 *************************************************************************
@@ -789,6 +791,7 @@ Did you run Briefcase in a project directory that contains {filename.name!r}?"""
 *************************************************************************
 """
                     )
+
                 try:
                     # Check out the branch for the required version tag.
                     head = remote.refs[branch]
diff --git a/src/briefcase/platforms/linux/system.py b/src/briefcase/platforms/linux/system.py
index 0867eb3d..944d6c01 100644
--- a/src/briefcase/platforms/linux/system.py
+++ b/src/briefcase/platforms/linux/system.py
@@ -981,9 +981,9 @@ class LinuxSystemPackageCommand(LinuxSystemMixin, PackageCommand):
 
                     if filename.is_dir():
                         if app.app_name in path.parts:
-                            f.write(f"%dir /{path}\n")
+                            f.write(f'%dir "/{path}"\n')
                     else:
-                        f.write(f"/{path}\n")
+                        f.write(f'"/{path}"\n')
 
                 # Add the changelog content to the bottom of the spec file.
                 f.write("\n%changelog\n")


Test patch:
diff --git a/tests/platforms/linux/system/test_package__rpm.py b/tests/platforms/linux/system/test_package__rpm.py
index ad0d1f08..534b9a26 100644
--- a/tests/platforms/linux/system/test_package__rpm.py
+++ b/tests/platforms/linux/system/test_package__rpm.py
@@ -204,21 +204,21 @@ def test_rpm_package(package_command, first_app_rpm, tmp_path):
                 "cp -r usr %{buildroot}/usr",
                 "",
                 "%files",
-                "/usr/bin/first-app",
-                "%dir /usr/lib/first-app",
-                "%dir /usr/lib/first-app/app",
-                "/usr/lib/first-app/app/support.so",
-                "%dir /usr/lib/first-app/app_packages",
-                "%dir /usr/lib/first-app/app_packages/firstlib",
-                "/usr/lib/first-app/app_packages/firstlib/first.so",
-                "/usr/lib/first-app/app_packages/firstlib/first.so.1.0",
-                "%dir /usr/lib/first-app/app_packages/secondlib",
-                "/usr/lib/first-app/app_packages/secondlib/second_a.so",
-                "/usr/lib/first-app/app_packages/secondlib/second_b.so",
-                "%dir /usr/share/doc/first-app",
-                "/usr/share/doc/first-app/UserManual",
-                "/usr/share/doc/first-app/license",
-                "/usr/share/man/man1/first-app.1.gz",
+                '"/usr/bin/first-app"',
+                '%dir "/usr/lib/first-app"',
+                '%dir "/usr/lib/first-app/app"',
+                '"/usr/lib/first-app/app/support.so"',
+                '%dir "/usr/lib/first-app/app_packages"',
+                '%dir "/usr/lib/first-app/app_packages/firstlib"',
+                '"/usr/lib/first-app/app_packages/firstlib/first.so"',
+                '"/usr/lib/first-app/app_packages/firstlib/first.so.1.0"',
+                '%dir "/usr/lib/first-app/app_packages/secondlib"',
+                '"/usr/lib/first-app/app_packages/secondlib/second_a.so"',
+                '"/usr/lib/first-app/app_packages/secondlib/second_b.so"',
+                '%dir "/usr/share/doc/first-app"',
+                '"/usr/share/doc/first-app/UserManual"',
+                '"/usr/share/doc/first-app/license"',
+                '"/usr/share/man/man1/first-app.1.gz"',
                 "",
                 "%changelog",
                 "First App Changelog",
@@ -352,21 +352,21 @@ def test_rpm_re_package(package_command, first_app_rpm, tmp_path):
                 "cp -r usr %{buildroot}/usr",
                 "",
                 "%files",
-                "/usr/bin/first-app",
-                "%dir /usr/lib/first-app",
-                "%dir /usr/lib/first-app/app",
-                "/usr/lib/first-app/app/support.so",
-                "%dir /usr/lib/first-app/app_packages",
-                "%dir /usr/lib/first-app/app_packages/firstlib",
-                "/usr/lib/first-app/app_packages/firstlib/first.so",
-                "/usr/lib/first-app/app_packages/firstlib/first.so.1.0",
-                "%dir /usr/lib/first-app/app_packages/secondlib",
-                "/usr/lib/first-app/app_packages/secondlib/second_a.so",
-                "/usr/lib/first-app/app_packages/secondlib/second_b.so",
-                "%dir /usr/share/doc/first-app",
-                "/usr/share/doc/first-app/UserManual",
-                "/usr/share/doc/first-app/license",
-                "/usr/share/man/man1/first-app.1.gz",
+                '"/usr/bin/first-app"',
+                '%dir "/usr/lib/first-app"',
+                '%dir "/usr/lib/first-app/app"',
+                '"/usr/lib/first-app/app/support.so"',
+                '%dir "/usr/lib/first-app/app_packages"',
+                '%dir "/usr/lib/first-app/app_packages/firstlib"',
+                '"/usr/lib/first-app/app_packages/firstlib/first.so"',
+                '"/usr/lib/first-app/app_packages/firstlib/first.so.1.0"',
+                '%dir "/usr/lib/first-app/app_packages/secondlib"',
+                '"/usr/lib/first-app/app_packages/secondlib/second_a.so"',
+                '"/usr/lib/first-app/app_packages/secondlib/second_b.so"',
+                '%dir "/usr/share/doc/first-app"',
+                '"/usr/share/doc/first-app/UserManual"',
+                '"/usr/share/doc/first-app/license"',
+                '"/usr/share/man/man1/first-app.1.gz"',
                 "",
                 "%changelog",
                 "First App Changelog",
@@ -521,21 +521,21 @@ def test_rpm_package_extra_requirements(package_command, first_app_rpm, tmp_path
                 "cp -r usr %{buildroot}/usr",
                 "",
                 "%files",
-                "/usr/bin/first-app",
-                "%dir /usr/lib/first-app",
-                "%dir /usr/lib/first-app/app",
-                "/usr/lib/first-app/app/support.so",
-                "%dir /usr/lib/first-app/app_packages",
-                "%dir /usr/lib/first-app/app_packages/firstlib",
-                "/usr/lib/first-app/app_packages/firstlib/first.so",
-                "/usr/lib/first-app/app_packages/firstlib/first.so.1.0",
-                "%dir /usr/lib/first-app/app_packages/secondlib",
-                "/usr/lib/first-app/app_packages/secondlib/second_a.so",
-                "/usr/lib/first-app/app_packages/secondlib/second_b.so",
-                "%dir /usr/share/doc/first-app",
-                "/usr/share/doc/first-app/UserManual",
-                "/usr/share/doc/first-app/license",
-                "/usr/share/man/man1/first-app.1.gz",
+                '"/usr/bin/first-app"',
+                '%dir "/usr/lib/first-app"',
+                '%dir "/usr/lib/first-app/app"',
+                '"/usr/lib/first-app/app/support.so"',
+                '%dir "/usr/lib/first-app/app_packages"',
+                '%dir "/usr/lib/first-app/app_packages/firstlib"',
+                '"/usr/lib/first-app/app_packages/firstlib/first.so"',
+                '"/usr/lib/first-app/app_packages/firstlib/first.so.1.0"',
+                '%dir "/usr/lib/first-app/app_packages/secondlib"',
+                '"/usr/lib/first-app/app_packages/secondlib/second_a.so"',
+                '"/usr/lib/first-app/app_packages/secondlib/second_b.so"',
+                '%dir "/usr/share/doc/first-app"',
+                '"/usr/share/doc/first-app/UserManual"',
+                '"/usr/share/doc/first-app/license"',
+                '"/usr/share/man/man1/first-app.1.gz"',
                 "",
                 "%changelog",
                 "First App Changelog",