>  3. Adds the cpuburn-udeb package (the interesting bit)

I have attached an updated part 3 that does not use 00h00m00s as a
progress meter due to translation issues.


Regards,

-- 
Chris Lamb, UK                                       [EMAIL PROTECTED]
                                                            GPG: 0x634F9A20
diff --git a/debian/control b/debian/control
index 65f46e4..57f3661 100644
--- a/debian/control
+++ b/debian/control
@@ -18,3 +18,12 @@ Description: a collection of programs to put heavy load on 
CPU
  putting stress on the CPU itself, cooling system, motherboard. This
  may cause data loss (filesystem corruption) and possibly permanent 
  damage to electronic components. Use at your own risk.
+
+Package: cpuburn-udeb
+XC-Package-Type: udeb
+XB-Installer-Menu-Item: 2600
+Priority: optional
+Section: debian-installer
+Architecture: amd64 i386 hurd-i386 kfreebsd-i386 kfreebsd-amd64
+Depends: ${shlibs:Depends}, ${misc:Depends}
+Description: perform CPU stress test (burn in) - expert use only
diff --git a/debian/cpuburn-udeb.dirs b/debian/cpuburn-udeb.dirs
new file mode 100644
index 0000000..e772481
--- /dev/null
+++ b/debian/cpuburn-udeb.dirs
@@ -0,0 +1 @@
+usr/bin
diff --git a/debian/cpuburn-udeb.postinst b/debian/cpuburn-udeb.postinst
new file mode 100644
index 0000000..66ea217
--- /dev/null
+++ b/debian/cpuburn-udeb.postinst
@@ -0,0 +1,172 @@
+#!/bin/sh
+
+#DEBHELPER#
+
+. /usr/share/debconf/confmodule
+
+db_capb backup progresscancel
+
+set -eu
+
+TEMPLATE_ROOT=cpuburn-udeb
+
+log() {
+       logger -t "$(basename $0)" "$@"
+}
+
+error() {
+       log "error: $*"
+}
+
+info() {
+       log "info: $*"
+}
+
+detect_burn_type() {
+       VENDOR=$(grep '^vendor_id' /proc/cpuinfo | head -n1 | cut -d: -f2)
+       FAMILY=$(grep '^cpu family' /proc/cpuinfo | head -n1 | cut -d: -f2)
+       MODEL=$(grep '^model[[:space:]]*:' /proc/cpuinfo | head -n1 | cut -d: 
-f2)
+
+       # Try and detect using vendor/model, etc.
+       case "$VENDOR" in
+           " AuthenticAMD"*)
+               case "$FAMILY" in
+                   " 6"|" 15") BURN_TYPE=K7 ;;
+                   " 5")       BURN_TYPE=K6 ;;
+               esac
+               ;;
+           " GenuineIntel")
+               case "$FAMILY" in
+                   " 6"|" 15") BURN_TYPE=P6 ;;
+               esac
+               ;;
+           " CentaurHauls")
+               case "$FAMILY" in
+                   " 6")
+                       case "$MODEL" in
+                           " 9"|" 10") BURN_TYPE=P6 ;;
+                       esac
+                       ;;
+               esac
+               ;;
+       esac
+
+       # If we haven't succeeded so far, try a capability-based approach. Fall
+       # back to 'P5', however.
+       if [ -z "$BURN_TYPE" ]; then
+               BURN_TYPE=P5
+
+               if grep '^flags.* mmx' /proc/cpuinfo > /dev/null; then
+                       BURN_TYPE=MMX
+               fi
+       fi
+
+       echo $BURN_TYPE
+}
+
+STATE=1
+
+while true; do
+       case "$STATE" in
+           1)
+               db_input critical $TEMPLATE_ROOT/confirm || true
+               ;;
+           2)
+               # Check confirmation before continuing
+               db_get $TEMPLATE_ROOT/confirm
+               test "$RET" = "true" || exit 0
+
+               db_input critical $TEMPLATE_ROOT/duration || true
+               ;;
+           3)
+               db_get $TEMPLATE_ROOT/duration
+               BURN_DURATION="$RET"
+
+               QUANTITY=$(echo $BURN_DURATION | sed -e 's/^\([0-9]*\).*/\1/')
+               case "$QUANTITY" in
+                   [0-9]*) ;;
+                   *)
+                       error "Could not parse duration '$BURN_DURATION'"
+                       exit 1
+                       ;;
+               esac
+
+               UNIT=$(echo $BURN_DURATION | sed -e 's/.*\([sSmMhHdD]\)$/\1/g' 
| tr A-Z a-z)
+               case "$UNIT" in
+                   s) SECONDS=$QUANTITY ;;
+                   m) SECONDS=$(($QUANTITY * 60)) ;;
+                   h) SECONDS=$(($QUANTITY * 60 * 60)) ;;
+                   d) SECONDS=$(($QUANTITY * 60 * 60 * 24)) ;;
+                   *)
+                       error "Could not parse duration '$BURN_DURATION'"
+                       exit 1
+                       ;;
+               esac
+
+               db_progress START 0 $SECONDS $TEMPLATE_ROOT/progress/title
+
+               NUM_CPUS=$(grep -c "^processor" /proc/cpuinfo)
+               info "Detected $NUM_CPUS CPU(s)"
+
+               BURN_TYPE=$(detect_burn_type)
+               info "Using '$BURN_TYPE' burn type"
+
+               # Start a burn process for each core/processor, keeping
+               # track of their pids.
+               PID_LIST=""
+               while [ $NUM_CPUS -gt 0 ]; do
+                       burn$BURN_TYPE &
+                       PID=$!
+                       info "Spawned burn$BURN_TYPE as pid $PID"
+
+                       PID_LIST="$PID_LIST $PID"
+                       NUM_CPUS=$(($NUM_CPUS - 1))
+               done
+
+               # We need to augment the progress bar with something that will
+               # stop moving when our system locks. Using the progress bar 
would 
+               # not be effective for this during long burns.
+               #
+               # An alternative solution would be to display the amount of time
+               # left for the burn-in, which the user can see decrementing as 
one
+               # clue that their machine is still alive. This may be difficult 
to
+               # translate, however.
+               STEP=1
+               while [ $SECONDS -gt 0 ]; do
+                       case $STEP in
+                           1)  PROGRESS="/" ;;
+                           2)  PROGRESS="-" ;;
+                           3)  PROGRESS="\\" ;;
+                           4)  PROGRESS="|"
+                               STEP=0
+                               ;;
+                       esac
+                       STEP=$(($STEP + 1))
+
+                       db_subst $TEMPLATE_ROOT/progress/step PROGRESS 
"$PROGRESS"
+                       db_progress INFO $TEMPLATE_ROOT/progress/step || break
+                       db_progress STEP 1 || break
+
+                       SECONDS=$(($SECONDS - 1))
+                       sleep 1
+               done
+
+               for PID in $PID_LIST; do
+                       info "Killing burn$BURN_TYPE process (pid $PID)"
+                       kill $PID || true
+               done
+
+               db_progress STOP
+               ;;
+
+           *)
+               break
+               ;;
+       esac
+
+       if db_go; then
+               STATE=$(($STATE + 1))
+       else
+               STATE=$(($STATE - 1))
+       fi
+done
diff --git a/debian/cpuburn-udeb.templates b/debian/cpuburn-udeb.templates
new file mode 100644
index 0000000..7a7d8e2
--- /dev/null
+++ b/debian/cpuburn-udeb.templates
@@ -0,0 +1,29 @@
+Template: debian-installer/cpuburn-udeb/title
+Type: text
+_Description: Perform CPU stress test (burn in)
+
+Template: cpuburn-udeb/confirm
+Type: boolean
+Default: false
+_Description: Are you sure you want to perform a burn test?
+ This may be dangerous for your system.
+ .
+ This process is designed to heavily load CPU chips. Undercooled,
+ overclocked or otherwise weak systems may fail causing possibly
+ permanent damage to electronic components.
+ .
+ Users should read the cpuburn documentation carefully before use.
+
+Template: cpuburn-udeb/duration
+Type: select
+Default: 30m
+Choices: 10m, 30m, 1h, 6h, 24h
+_Description: Burn-in duration
+
+Template: cpuburn-udeb/progress/title
+Type: text
+_Description: Performing hardware burn-in
+
+Template: cpuburn-udeb/progress/step
+Type: text
+_Description: Performing hardware burn-in. This may take some time... 
${PROGRESS}
diff --git a/debian/rules b/debian/rules
index 06f202e..4ffe368 100755
--- a/debian/rules
+++ b/debian/rules
@@ -32,6 +32,10 @@ install: build
                cp $(CURDIR)/$$i $(CURDIR)/debian/cpuburn/usr/bin ; \
        done
 
+       for i in burnP5 burnP6 burnK6 burnK7 burnMMX ; do \
+               cp $(CURDIR)/$$i $(CURDIR)/debian/cpuburn-udeb/usr/bin ; \
+       done
+
 # Build architecture-independent files here.
 binary-indep: build install
 # We have nothing to do by default.

Attachment: signature.asc
Description: PGP signature

Reply via email to