** Also affects: reprepro (Ubuntu Resolute)
   Importance: Undecided
       Status: New

** Also affects: reprepro (Ubuntu Stonking)
   Importance: Undecided
       Status: New

** Also affects: reprepro (Ubuntu Jammy)
   Importance: Undecided
       Status: New

** Also affects: reprepro (Ubuntu Noble)
   Importance: Undecided
       Status: New

** Description changed:

  [ Impact ]
  
-  * reprepro keeps all repository state in Berkeley DB files under db/
-    (checksums.db, packages.db, references.db, packagenames.db). It opens them
-    without a transactional environment, so they are only consistent if
-    reprepro closes them cleanly before it exits.
+ reprepro keeps all repository state in Berkeley DB files under db/
+ (checksums.db, packages.db, references.db, packagenames.db). It doesn't
+ use
+ a transactional environment, so these files are only consistent if
+ reprepro
+ closes them properly before it exits.
  
-  * reprepro handles SIGTERM, SIGINT, SIGQUIT and SIGABRT by stopping through
-    its graceful interruption path, which closes the databases and removes
-    db/lockfile. It does not handle SIGHUP. When the terminal reprepro runs on
-    goes away, the kernel sends it SIGHUP and it dies at once with its
-    databases open. That happens when an ssh session drops, when the process
-    that started reprepro on a pty exits, or a reboot.
+ reprepro catches SIGTERM, SIGINT, SIGQUIT and SIGABRT. On those it stops
+ cleanly, closes the databases and removes db/lockfile. It does not catch
+ SIGHUP. If the terminal it's running on goes away (an ssh session drops,
+ the process that started it on a pty exits, the machine reboots), reprepro
+ is killed immediately with its databases still open.
  
-  * If the hangup arrives while reprepro is writing (from "Installing (and
-    possibly deleting) packages..." until it closes its databases), the
-    databases are left corrupt and db/lockfile is left behind.
+ If that happens while reprepro is writing, that is between "Installing
+ (and
+ possibly deleting) packages..." and closing the databases, the databases
+ are corrupted and db/lockfile is left behind.
  
-  * Landscape Server mirrors Ubuntu archives with reprepro. Its
-    job-handler service runs "reprepro update" on a pty (Twisted
-    spawnProcess with usePTY=True) so it can read the line-buffered
-    "--show-percent" progress output. Stopping job-handler (e.g. a Landscape
-    restart or a reboot) closes the pty, and reprepro
-    receives SIGHUP. If a mirror sync is in its install phase at that moment,
-    the databases of that distribution are corrupted. Every series and pocket
-    of a distribution shares one db/, so the damage is not limited to the
-    pocket that was syncing. Landscape takes sync progress only from
-    reprepro's "Got N%" lines, so a later sync where reprepro loops on the
-    damaged btree shows 0% indefinitely, with no error.
+ Landscape Server runs into this in normal operation. It mirrors Ubuntu
+ archives with reprepro, and its job-handler service runs "reprepro update"
+ on a pty (Twisted spawnProcess with usePTY=True) so it can read the
+ line-buffered --show-percent progress output. Stopping job-handler, for
+ example when restarting Landscape or rebooting, closes that pty and
+ reprepro gets SIGHUP. If a mirror sync is installing packages at that
+ moment, the distribution's databases are corrupted. All series and pockets
+ of a distribution share one db/, so the damage isn't limited to the pocket
+ that was syncing. Landscape only gets sync progress from reprepro's
+ "Got N%" lines, so a later sync that loops on the damaged btree sits at 0%
+ forever without reporting an error.
  
  [ Test Plan ]
  
- Use a disposable machine or container for the Ubuntu release being tested.
- Run the commands in Bash, keeping the same shell open throughout. No existing
- repository or signing key is needed. Do not use production repository data.
+ The test imports a large number of small packages into a local repository
+ and sends reprepro a SIGHUP partway through. You need two terminals.
  
- 1. Install the release package and record its version and origin:
+ 1. Install reprepro and note the installed version:
  
-     sudo apt update
-     sudo apt install reprepro
-     dpkg-query -W reprepro
-     apt-cache policy reprepro
+      sudo apt update
+      sudo apt install reprepro
+      apt policy reprepro
  
- 2. Create 2,000 tiny test packages. This gives us enough time to interrupt an
-    import. Keep these files for both runs.
+ 2. Build 10,000 small test packages. This takes a few minutes. Importing
+    them takes around 20 seconds, which leaves plenty of time to interrupt
+    the import by hand.
  
- WORK="$(mktemp -d)"
- mkdir -p "$WORK/build/DEBIAN" "$WORK/pkgs"
- for i in $(seq -w 1 2000); do
-     cat > "$WORK/build/DEBIAN/control" <<EOF
- Package: sru-test-$i
- Version: 1.0
- Architecture: all
- Section: misc
- Priority: optional
- Maintainer: Test <[email protected]>
- Description: test package for LP 2169601
- EOF
-     dpkg-deb --build "$WORK/build" "$WORK/pkgs/$i.deb" >/dev/null
- done
+      mkdir -p ~/sru-test/build/DEBIAN ~/sru-test/pkgs
+      cd ~/sru-test
+      for i in $(seq -w 1 10000); do
+          cat > build/DEBIAN/control <<EOF
+      Package: sru-test-$i
+      Version: 1.0
+      Architecture: all
+      Section: misc
+      Priority: optional
+      Maintainer: Test <[email protected]>
+      Description: test package for LP 2169601
+      EOF
+          dpkg-deb --build build pkgs/$i.deb >/dev/null
+      done
  
- 3. Create an empty repository. Repeat this step whenever the plan asks for a
-    fresh repository; it leaves earlier results untouched.
+ 3. Create an empty repository in ~/sru-test/repo1:
  
- REPO="$(mktemp -d "$WORK/repo.XXXXXX")"
- mkdir -p "$REPO/conf"
- cat > "$REPO/conf/distributions" <<EOF
- Codename: test
- Components: main
- Architectures: $(dpkg --print-architecture)
- EOF
+      mkdir -p ~/sru-test/repo1/conf
  
- 4. Start an import and send one SIGHUP after the twentieth package reaches
-    the repository. This is the signal reprepro receives on a terminal hangup.
-    The loop waits about 20 seconds for that package, rather than relying on
-    a fixed sleep or just the lock file appearing.
+    Create ~/sru-test/repo1/conf/distributions with this content (use the
+    architecture that "dpkg --print-architecture" prints):
  
- reprepro -b "$REPO" includedeb test "$WORK"/pkgs/*.deb >"$REPO/import.log" 
2>&1 &
- pid=$!
- ready="$REPO/pool/main/s/sru-test-0020/sru-test-0020_1.0_all.deb"
- for attempt in $(seq 1 400); do
-     test -f "$ready" && break
-     kill -0 "$pid" 2>/dev/null || break
-     sleep 0.05
- done
- if test -f "$ready" && kill -HUP "$pid"; then
-     status=0
-     wait "$pid" || status=$?
-     echo "exit=$status"
- else
-     echo "INCONCLUSIVE: missed the import; repeat steps 3-4."
- fi
- cat "$REPO/import.log"
- if test -e "$REPO/db/lockfile"; then echo "lock remains"; else echo "lock 
removed"; fi
+      Codename: test
+      Components: main
+      Architectures: amd64
  
-    Before the fix: expect exit=129 (terminated by SIGHUP) and "lock remains".
-    Bash may also print "Hangup". Database corruption is timing-dependent and
-    is not required to reproduce the bug; the abrupt exit and stale lock are
-    sufficient. Do not delete this lock or reuse this repository.
+ 4. In the first terminal, start importing the packages:
  
-    If the command has not exited within a minute after the signal, record a
-    failure and retain the log; do not send another SIGHUP to make it pass.
+      reprepro -b ~/sru-test/repo1 includedeb test ~/sru-test/pkgs/*.deb
  
- 5. Rebuild and install reprepro with cherry picked upstream commit
- e4dfe4f2857a3566fa944527156594024009595a
- 
(https://salsa.debian.org/debian/reprepro/-/commit/e4dfe4f2857a3566fa944527156594024009595a)
+    Wait a few seconds, then send reprepro a hangup from the second
+    terminal:
  
-    Repeat steps 3-4 with the fixed package, using a fresh repository.
+      pkill -HUP -x reprepro
  
-    After the fix: expect "Interruption in progress" in the log and
-    "lock removed". A nonzero exit is normal (247 in the tested package), but
-    it must not be the default SIGHUP termination seen before the fix.
-    A warning about unexported indices is also normal: interruption stops the
-    import early; it does not undo packages already imported.
+    When reprepro exits, check its exit status in the first terminal:
  
- 6. Check that the interrupted repository is usable, then finish the
- import:
+      echo $?
  
- timeout 30s reprepro -b "$REPO" check && echo "check passed"
- timeout 30s reprepro -b "$REPO" list test >"$REPO/list.txt" && echo "list 
passed"
- timeout 60s reprepro -b "$REPO" includedeb test "$WORK"/pkgs/*.deb 
>"$REPO/resume.log" 2>&1 && echo "import passed"
- timeout 30s reprepro -b "$REPO" export test && echo "export passed"
- timeout 30s reprepro -b "$REPO" check && echo "check passed"
- timeout 30s reprepro -b "$REPO" list test >"$REPO/list.txt" && wc -l 
<"$REPO/list.txt"
+    Then try to use the repository:
  
-    Expected: every "passed" message appears, no command times out, and the
-    final count is 2000. A timeout, error, or missing package is a failure.
+      reprepro -b ~/sru-test/repo1 check
  
- 7. Check the nohup regression: repeat step 3, then repeat step 4 with only its
-    first command changed to the following (keep the rest of step 4 unchanged):
+    Expected with the current package:
+    - reprepro stops at once, and bash prints "Hangup". You may also see a
+      "Broken pipe" error from zstd.
+    - The exit status is 129.
+    - ~/sru-test/repo1/db/lockfile is still there, and "reprepro check"
+      refuses to run with "The lock file '.../db/lockfile' already
+      exists...".
  
- nohup reprepro -b "$REPO" includedeb test "$WORK"/pkgs/*.deb
- >"$REPO/import.log" 2>&1 &
+    Whether the databases are actually corrupted depends on timing, so the
+    test doesn't depend on it. The abrupt exit and the leftover lock file
+    are enough to show the bug. Leave repo1 as it is.
  
-    Expected: despite receiving SIGHUP, the import completes with exit=0 and
-    "lock removed". Confirm all packages were imported and the repository is
-    consistent:
+ 5. Install reprepro with the fix (upstream commit e4dfe4f, see below).
+    Then repeat steps 3 and 4 with a new repository, ~/sru-test/repo2.
  
- timeout 30s reprepro -b "$REPO" list test >"$REPO/list.txt" && wc -l 
<"$REPO/list.txt"
- timeout 30s reprepro -b "$REPO" check && echo "check passed"
+    Expected with the fixed package:
+    - reprepro prints "Interruption in progress" and exits shortly
+      afterwards.
+    - The exit status is not 0, but it is not 129 either (it was 247 in
+      my test).
+    - ~/sru-test/repo2/db/lockfile has been removed, and "reprepro check"
+      runs.
+    - A warning about indices not being exported is expected. Interrupting
+      the import stops it, but it doesn't undo the packages already added.
  
-    Expected: 2000 and "check passed". This also works before the fix; it 
checks
-    that adding the SIGHUP handler has not broken inherited ignored SIGHUP.
+    If reprepro is still running a minute after the hangup, the test has
+    failed. Keep the output, and don't send a second signal.
+ 
+ 6. Check that repo2 still works and that the interrupted import can be
+    finished:
+ 
+      cd ~/sru-test/repo2
+      reprepro -b . check
+      reprepro -b . includedeb test ~/sru-test/pkgs/*.deb
+      reprepro -b . export test
+      reprepro -b . check
+      reprepro -b . list test | wc -l
+ 
+    Expected: each command finishes within a minute, and the last one
+    prints 10000. A command that hangs means the database is damaged, and
+    the test has failed.
  
  [ Where problems could occur ]
  
-  * The change is in signal setup at the start of main(). If it were wrong,
-    the visible effect would be in how reprepro reacts to a terminal hangup.
-    Repository contents, the database format and the command line are not
-    touched.
+ The patch only changes how signals are set up at the start of main(). It
+ doesn't touch repository contents, the database format or any command line
+ options.
  
-  * A regression would most likely show up as incorrect process behavior when
-    the controlling terminal hangs up:
-    - reprepro could ignore a SIGHUP that should interrupt it.
-    - reprepro could terminate immediately rather than running cleanup.
-    - nohup-style runs could stop being immune to SIGHUP.
-    - cleanup could fail to remove db/lockfile, blocking later repository work.
- 
+ If the change is wrong, it would show up in how reprepro behaves when its
+ terminal hangs up. It could ignore a SIGHUP it should act on, or it could
+ still be killed immediately without cleaning up.
  
  [ Other Info ]
  
-  * Debian merge request, merged into master:
-    https://salsa.debian.org/debian/reprepro/-/merge_requests/22
+ Upstream commit:
+ https://salsa.debian.org/debian/reprepro/-/commit/e4dfe4f2857a3566fa944527
+ 156594024009595a
  
-  * Noble test PPA:
-    https://launchpad.net/~quanchobi/+archive/ubuntu/reprepro-lp2169601
+ The fix is merged into Debian's master branch:
+ https://salsa.debian.org/debian/reprepro/-/merge_requests/22

** Description changed:

  [ Impact ]
  
  reprepro keeps all repository state in Berkeley DB files under db/
- (checksums.db, packages.db, references.db, packagenames.db). It doesn't
- use
- a transactional environment, so these files are only consistent if
- reprepro
+ (checksums.db, packages.db, references.db, packagenames.db). It doesn't use
+ a transactional environment, so these files are only consistent if reprepro
  closes them properly before it exits.
  
  reprepro catches SIGTERM, SIGINT, SIGQUIT and SIGABRT. On those it stops
  cleanly, closes the databases and removes db/lockfile. It does not catch
  SIGHUP. If the terminal it's running on goes away (an ssh session drops,
  the process that started it on a pty exits, the machine reboots), reprepro
  is killed immediately with its databases still open.
  
- If that happens while reprepro is writing, that is between "Installing
- (and
+ If that happens while reprepro is writing, that is between "Installing (and
  possibly deleting) packages..." and closing the databases, the databases
  are corrupted and db/lockfile is left behind.
  
  Landscape Server runs into this in normal operation. It mirrors Ubuntu
  archives with reprepro, and its job-handler service runs "reprepro update"
  on a pty (Twisted spawnProcess with usePTY=True) so it can read the
  line-buffered --show-percent progress output. Stopping job-handler, for
  example when restarting Landscape or rebooting, closes that pty and
  reprepro gets SIGHUP. If a mirror sync is installing packages at that
  moment, the distribution's databases are corrupted. All series and pockets
  of a distribution share one db/, so the damage isn't limited to the pocket
  that was syncing. Landscape only gets sync progress from reprepro's
  "Got N%" lines, so a later sync that loops on the damaged btree sits at 0%
  forever without reporting an error.
  
  [ Test Plan ]
  
  The test imports a large number of small packages into a local repository
  and sends reprepro a SIGHUP partway through. You need two terminals.
+ Commands are shown without indentation so they can be pasted as they are.
  
  1. Install reprepro and note the installed version:
  
-      sudo apt update
-      sudo apt install reprepro
-      apt policy reprepro
+ sudo apt update
+ sudo apt install reprepro
+ apt policy reprepro
  
- 2. Build 10,000 small test packages. This takes a few minutes. Importing
-    them takes around 20 seconds, which leaves plenty of time to interrupt
-    the import by hand.
+ 2. Build 10,000 small test packages. This takes a couple of minutes.
+    Importing them takes around 20 seconds, which leaves plenty of time to
+    interrupt the import by hand.
  
-      mkdir -p ~/sru-test/build/DEBIAN ~/sru-test/pkgs
-      cd ~/sru-test
-      for i in $(seq -w 1 10000); do
-          cat > build/DEBIAN/control <<EOF
-      Package: sru-test-$i
-      Version: 1.0
-      Architecture: all
-      Section: misc
-      Priority: optional
-      Maintainer: Test <[email protected]>
-      Description: test package for LP 2169601
-      EOF
-          dpkg-deb --build build pkgs/$i.deb >/dev/null
-      done
+ mkdir -p ~/sru-test/build/DEBIAN ~/sru-test/pkgs
+ cd ~/sru-test
+ for i in $(seq -w 1 10000); do
+     cat > build/DEBIAN/control <<EOF
+ Package: sru-test-$i
+ Version: 1.0
+ Architecture: all
+ Section: misc
+ Priority: optional
+ Maintainer: Test <[email protected]>
+ Description: test package for LP 2169601
+ EOF
+     dpkg-deb --build build pkgs/$i.deb >/dev/null
+ done
  
  3. Create an empty repository in ~/sru-test/repo1:
  
-      mkdir -p ~/sru-test/repo1/conf
+ mkdir -p ~/sru-test/repo1/conf
  
-    Create ~/sru-test/repo1/conf/distributions with this content (use the
-    architecture that "dpkg --print-architecture" prints):
+    Create ~/sru-test/repo1/conf/distributions with these three lines, with
+    no leading spaces (use the architecture that "dpkg --print-architecture"
+    prints):
  
-      Codename: test
-      Components: main
-      Architectures: amd64
+ Codename: test
+ Components: main
+ Architectures: amd64
  
  4. In the first terminal, start importing the packages:
  
-      reprepro -b ~/sru-test/repo1 includedeb test ~/sru-test/pkgs/*.deb
+ reprepro -b ~/sru-test/repo1 includedeb test ~/sru-test/pkgs/*.deb
  
-    Wait a few seconds, then send reprepro a hangup from the second
+    Wait about five seconds, then send reprepro a hangup from the second
     terminal:
  
-      pkill -HUP -x reprepro
+ pkill -HUP -x reprepro
  
     When reprepro exits, check its exit status in the first terminal:
  
-      echo $?
+ echo $?
  
     Then try to use the repository:
  
-      reprepro -b ~/sru-test/repo1 check
+ reprepro -b ~/sru-test/repo1 check
  
     Expected with the current package:
     - reprepro stops at once, and bash prints "Hangup". You may also see a
       "Broken pipe" error from zstd.
     - The exit status is 129.
     - ~/sru-test/repo1/db/lockfile is still there, and "reprepro check"
       refuses to run with "The lock file '.../db/lockfile' already
       exists...".
  
     Whether the databases are actually corrupted depends on timing, so the
     test doesn't depend on it. The abrupt exit and the leftover lock file
     are enough to show the bug. Leave repo1 as it is.
  
- 5. Install reprepro with the fix (upstream commit e4dfe4f, see below).
-    Then repeat steps 3 and 4 with a new repository, ~/sru-test/repo2.
+ 5. Install reprepro with the fix. Then repeat steps 3 and 4 with a new
+    repository, ~/sru-test/repo2.
  
     Expected with the fixed package:
-    - reprepro prints "Interruption in progress" and exits shortly
-      afterwards.
-    - The exit status is not 0, but it is not 129 either (it was 247 in
-      my test).
+    - reprepro prints "Interruption in progress, interrupt again to
+      force-stop it" and exits within a second or two.
+    - The exit status is 247, not 129.
     - ~/sru-test/repo2/db/lockfile has been removed, and "reprepro check"
-      runs.
-    - A warning about indices not being exported is expected. Interrupting
-      the import stops it, but it doesn't undo the packages already added.
+      runs without errors.
+    - A warning that the database "was modified but no index file was
+      exported" is expected. Interrupting the import stops it, but it
+      doesn't undo the packages already added.
  
     If reprepro is still running a minute after the hangup, the test has
     failed. Keep the output, and don't send a second signal.
  
  6. Check that repo2 still works and that the interrupted import can be
     finished:
  
-      cd ~/sru-test/repo2
-      reprepro -b . check
-      reprepro -b . includedeb test ~/sru-test/pkgs/*.deb
-      reprepro -b . export test
-      reprepro -b . check
-      reprepro -b . list test | wc -l
+ cd ~/sru-test/repo2
+ reprepro -b . check
+ reprepro -b . includedeb test ~/sru-test/pkgs/*.deb
+ reprepro -b . export test
+ reprepro -b . check
+ reprepro -b . list test | wc -l
  
-    Expected: each command finishes within a minute, and the last one
-    prints 10000. A command that hangs means the database is damaged, and
-    the test has failed.
+    Expected: the includedeb prints "Skipping inclusion of ..." for each
+    package imported before the hangup, then adds the rest. Each command
+    finishes within a minute, and the last one prints 10000. A command
+    that hangs means the database is damaged, and the test has failed.
  
  [ Where problems could occur ]
  
  The patch only changes how signals are set up at the start of main(). It
  doesn't touch repository contents, the database format or any command line
  options.
  
  If the change is wrong, it would show up in how reprepro behaves when its
  terminal hangs up. It could ignore a SIGHUP it should act on, or it could
  still be killed immediately without cleaning up.
  
  [ Other Info ]
  
  Upstream commit:
- https://salsa.debian.org/debian/reprepro/-/commit/e4dfe4f2857a3566fa944527
- 156594024009595a
+ 
https://salsa.debian.org/debian/reprepro/-/commit/e4dfe4f2857a3566fa944527156594024009595a
  
  The fix is merged into Debian's master branch:
  https://salsa.debian.org/debian/reprepro/-/merge_requests/22

** Description changed:

  [ Impact ]
  
  reprepro keeps all repository state in Berkeley DB files under db/
  (checksums.db, packages.db, references.db, packagenames.db). It doesn't use
  a transactional environment, so these files are only consistent if reprepro
  closes them properly before it exits.
  
  reprepro catches SIGTERM, SIGINT, SIGQUIT and SIGABRT. On those it stops
  cleanly, closes the databases and removes db/lockfile. It does not catch
  SIGHUP. If the terminal it's running on goes away (an ssh session drops,
  the process that started it on a pty exits, the machine reboots), reprepro
  is killed immediately with its databases still open.
  
  If that happens while reprepro is writing, that is between "Installing (and
  possibly deleting) packages..." and closing the databases, the databases
  are corrupted and db/lockfile is left behind.
  
  Landscape Server runs into this in normal operation. It mirrors Ubuntu
  archives with reprepro, and its job-handler service runs "reprepro update"
  on a pty (Twisted spawnProcess with usePTY=True) so it can read the
  line-buffered --show-percent progress output. Stopping job-handler, for
  example when restarting Landscape or rebooting, closes that pty and
  reprepro gets SIGHUP. If a mirror sync is installing packages at that
  moment, the distribution's databases are corrupted. All series and pockets
  of a distribution share one db/, so the damage isn't limited to the pocket
  that was syncing. Landscape only gets sync progress from reprepro's
  "Got N%" lines, so a later sync that loops on the damaged btree sits at 0%
  forever without reporting an error.
  
  [ Test Plan ]
  
  The test imports a large number of small packages into a local repository
  and sends reprepro a SIGHUP partway through. You need two terminals.
  Commands are shown without indentation so they can be pasted as they are.
  
  1. Install reprepro and note the installed version:
  
  sudo apt update
  sudo apt install reprepro
  apt policy reprepro
  
  2. Build 10,000 small test packages. This takes a couple of minutes.
-    Importing them takes around 20 seconds, which leaves plenty of time to
-    interrupt the import by hand.
+    Importing them takes around 20 seconds, which leaves plenty of time to
+    interrupt the import by hand.
  
  mkdir -p ~/sru-test/build/DEBIAN ~/sru-test/pkgs
  cd ~/sru-test
  for i in $(seq -w 1 10000); do
-     cat > build/DEBIAN/control <<EOF
+     cat > build/DEBIAN/control <<EOF
  Package: sru-test-$i
  Version: 1.0
  Architecture: all
  Section: misc
  Priority: optional
  Maintainer: Test <[email protected]>
  Description: test package for LP 2169601
  EOF
-     dpkg-deb --build build pkgs/$i.deb >/dev/null
+     dpkg-deb --build build pkgs/$i.deb >/dev/null
  done
  
  3. Create an empty repository in ~/sru-test/repo1:
  
  mkdir -p ~/sru-test/repo1/conf
  
-    Create ~/sru-test/repo1/conf/distributions with these three lines, with
-    no leading spaces (use the architecture that "dpkg --print-architecture"
-    prints):
+    Create ~/sru-test/repo1/conf/distributions with these three lines, with
+    no leading spaces (use the architecture that "dpkg --print-architecture"
+    prints):
  
  Codename: test
  Components: main
  Architectures: amd64
  
  4. In the first terminal, start importing the packages:
  
  reprepro -b ~/sru-test/repo1 includedeb test ~/sru-test/pkgs/*.deb
  
-    Wait about five seconds, then send reprepro a hangup from the second
-    terminal:
+    Wait about five seconds, then send reprepro a hangup from the second
+    terminal:
  
  pkill -HUP -x reprepro
  
-    When reprepro exits, check its exit status in the first terminal:
+    When reprepro exits, check its exit status in the first terminal:
  
  echo $?
  
-    Then try to use the repository:
+    Then try to use the repository:
  
  reprepro -b ~/sru-test/repo1 check
  
-    Expected with the current package:
-    - reprepro stops at once, and bash prints "Hangup". You may also see a
-      "Broken pipe" error from zstd.
-    - The exit status is 129.
-    - ~/sru-test/repo1/db/lockfile is still there, and "reprepro check"
-      refuses to run with "The lock file '.../db/lockfile' already
-      exists...".
+    Expected with the current package:
+    - reprepro stops at once, and bash prints "Hangup". You may also see a
+      "Broken pipe" error from zstd.
+    - The exit status is 129.
+    - ~/sru-test/repo1/db/lockfile is still there, and "reprepro check"
+      refuses to run with "The lock file '.../db/lockfile' already
+      exists...".
  
-    Whether the databases are actually corrupted depends on timing, so the
-    test doesn't depend on it. The abrupt exit and the leftover lock file
-    are enough to show the bug. Leave repo1 as it is.
+    Whether the databases are actually corrupted depends on timing, so the
+    test doesn't depend on it. The abrupt exit and the leftover lock file
+    are enough to show the bug. Leave repo1 as it is.
  
- 5. Install reprepro with the fix. Then repeat steps 3 and 4 with a new
-    repository, ~/sru-test/repo2.
+ 5. Install reprepro with the fix, either via the PPA or cherry-picking the
+    upstream commit below. Then repeat steps 3 and 4 with a new
+    repository, ~/sru-test/repo2.
  
-    Expected with the fixed package:
-    - reprepro prints "Interruption in progress, interrupt again to
-      force-stop it" and exits within a second or two.
-    - The exit status is 247, not 129.
-    - ~/sru-test/repo2/db/lockfile has been removed, and "reprepro check"
-      runs without errors.
-    - A warning that the database "was modified but no index file was
-      exported" is expected. Interrupting the import stops it, but it
-      doesn't undo the packages already added.
+    Expected with the fixed package:
+    - reprepro prints "Interruption in progress, interrupt again to
+      force-stop it" and exits within a second or two.
+    - The exit status is 247, not 129.
+    - ~/sru-test/repo2/db/lockfile has been removed, and "reprepro check"
+      runs without errors.
+    - A warning that the database "was modified but no index file was
+      exported" is expected. Interrupting the import stops it, but it
+      doesn't undo the packages already added.
  
-    If reprepro is still running a minute after the hangup, the test has
-    failed. Keep the output, and don't send a second signal.
+    If reprepro is still running a minute after the hangup, the test has
+    failed. Keep the output, and don't send a second signal.
  
  6. Check that repo2 still works and that the interrupted import can be
-    finished:
+    finished:
  
  cd ~/sru-test/repo2
  reprepro -b . check
  reprepro -b . includedeb test ~/sru-test/pkgs/*.deb
  reprepro -b . export test
  reprepro -b . check
  reprepro -b . list test | wc -l
  
-    Expected: the includedeb prints "Skipping inclusion of ..." for each
-    package imported before the hangup, then adds the rest. Each command
-    finishes within a minute, and the last one prints 10000. A command
-    that hangs means the database is damaged, and the test has failed.
+    Expected: the includedeb prints "Skipping inclusion of ..." for each
+    package imported before the hangup, then adds the rest. Each command
+    finishes within a minute, and the last one prints 10000. A command
+    that hangs means the database is damaged, and the test has failed.
  
  [ Where problems could occur ]
  
  The patch only changes how signals are set up at the start of main(). It
  doesn't touch repository contents, the database format or any command line
  options.
  
  If the change is wrong, it would show up in how reprepro behaves when its
  terminal hangs up. It could ignore a SIGHUP it should act on, or it could
  still be killed immediately without cleaning up.
  
  [ Other Info ]
  
  Upstream commit:
  
https://salsa.debian.org/debian/reprepro/-/commit/e4dfe4f2857a3566fa944527156594024009595a
  
  The fix is merged into Debian's master branch:
  https://salsa.debian.org/debian/reprepro/-/merge_requests/22

-- 
You received this bug notification because you are a member of Ubuntu
Bugs, which is subscribed to Ubuntu.
https://bugs.launchpad.net/bugs/2169601

Title:
  SIGHUP during db write corrupts the repository

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/reprepro/+bug/2169601/+subscriptions


-- 
ubuntu-bugs mailing list
[email protected]
https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs

Reply via email to