Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

shellcheck test automation & new contributor's setup #143

Open
wants to merge 28 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
c8aa47a
mainly SC1901 and SC2086
chinyakao Jul 12, 2021
4c64b5a
test action
chinyakao Jul 15, 2021
daf0e68
correct shellcheck
chinyakao Jul 15, 2021
4a3a5f9
fix shellcheck
chinyakao Jul 15, 2021
06b9eeb
fix for loop in build package
chinyakao Jul 15, 2021
4e04842
main test yml typo
chinyakao Jul 15, 2021
ada6153
change the disable SC2044 section
chinyakao Jul 15, 2021
1375e8d
pre-commit setup
chinyakao Jul 19, 2021
2bb72bd
pre-commit setup shellcheck
chinyakao Jul 19, 2021
b53ffd2
fix pre-commit shellcheck
chinyakao Jul 19, 2021
eacbe1d
fix shellcheck pre-commit with new hooks
chinyakao Jul 19, 2021
e6dfbf8
pre-commit shellcheck exclude SC1091
chinyakao Jul 19, 2021
88d094c
test new commit
chinyakao Jul 21, 2021
4c06bc3
test new commit with offened
chinyakao Jul 21, 2021
bf60129
test new commit with offense
chinyakao Jul 21, 2021
b33cdaa
test with pre-commit & shellcheck
chinyakao Jul 21, 2021
77e00dc
contributor setup
chinyakao Jul 26, 2021
e523809
contributor setup
chinyakao Jul 26, 2021
ec97f3d
Markdown file syntax
chinyakao Jul 26, 2021
8634880
keep shellchcek delete other checking
chinyakao Jul 26, 2021
7cec710
test new file
chinyakao Jul 26, 2021
cb14917
fix pre commit
chinyakao Jul 26, 2021
15a2c92
fix github action's pre-commit
chinyakao Jul 26, 2021
1a3d6fc
local enviroment setting
chinyakao Jul 26, 2021
2d54ed6
fix venv
chinyakao Jul 27, 2021
8432ce9
fix venv
chinyakao Jul 27, 2021
3c50d2b
first review & move to main yml
chinyakao Aug 27, 2021
e1d0db6
Merge pull request #1 from chinyakao/test-automation
chinyakao Aug 27, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,19 @@ jobs:
run: DEBIAN_FRONTEND=noninteractive sudo apt-get install -yq --no-install-recommends build-essential debhelper dh-python dpkg-dev python3 python3-distutils-extra po-debconf pyflakes3 lsb-release gnu-efi
- name: Build package
run: dpkg-buildpackage --no-sign

pre-commit:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Refresh dependencies
run: sudo apt update
- name: Install dependencies
run: sudo apt install shellcheck -y
- name: Run pre-commit hooks
run: |
./contrib/setup
source venv/bin/activate
sed -i "/no-commit-to-branch/,+1d" .pre-commit-config.yaml
pre-commit run --all-files
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,4 @@ debian/files
debian/tmp/
secure_boot/MokSBStateSet.efi
.vscode
/venv
8 changes: 8 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
repos:
- repo: local
hooks:
- id: shellcheck
name: check shellscript style
language: system
entry: shellcheck -e SC1091
types: [shell]
13 changes: 13 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Contributor Guidelines

## Getting started

To set up your local environment, from the top level of the checkout run

`./contrib/setup`

This will create pre-commit hooks to fixup many code style issues
before your code is submitted.

On some Linux distributions this will install all build dependencies
needed to compile fwupd as well.
46 changes: 25 additions & 21 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Dell Recovery Media Creator
----
# Dell Recovery Media Creator

[![Build Status](https://travis-ci.org/dell/dell-recovery.png)](https://travis-ci.org/dell/dell-recovery)

The Dell Recovery media creation tool supports two different usage modes,
Expand All @@ -8,39 +8,43 @@ create an image from an existing recovery partition with no customizations.
In builder mode, the tool allows modifying the source of the base image,
the source of the framework, as well as injection of additional content.

# Tool Modes
## Tool Modes

### End User Mode

End User Mode
---
When a customer receives a Dell machine that has been factory shipped
with Linux, there will be an icon available in GNOME shell to launch this
tool. They will be prompted for what type of media they would like to create.

Out of box experience mode
---
### Out of box experience mode

If a DVD burner or USB port is found on the machine, customers will be offered
to create media at the end of the out of box experience.

Media builder mode
---
In builder mode, the user will be offered a variety of options that allow them to create ISOs based upon
### Media builder mode

In builder mode, the user will be offered a variety of options that allow them
to create ISOs based upon
different snapshots of release upon standard Ubuntu media.

The latest information on how to use builder mode will be documented within the integrated help dialog.
The latest information on how to use builder mode will be documented within the
integrated help dialog.

# Flow
## Flow

Due to the nature of including a recovery partition, the installation flow varies from the standard Ubuntu
Due to the nature of including a recovery partition, the installation flow
varies from the standard Ubuntu
installation.
It is further documented [here](installation_flow.md).

Ubiquity
---
Dell recovery is built with an integrated Ubiquity plugin. It is branched with each Ubuntu LTS release and
has code that will tightly integrate with Ubiquity for factory installation. Documentation for all of the
features in Ubiquity mode and how to create packages to support it are stored outside of the dell-recovery
tree.
### Ubiquity

Dell recovery is built with an integrated Ubiquity plugin. It is branched with
each Ubuntu LTS release and has code that will tightly integrate with Ubiquity
for factory installation. Documentation for all of the features in Ubiquity
mode and how to create packages to support it are stored outside of the
dell-recovery tree.

### Modifying a factory image

Modifying a factory image
---
Information about how to modify a factory image are available [here](modifying_factory_image.md).
10 changes: 5 additions & 5 deletions casper/hooks/dell-bootstrap
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,15 @@ esac

. /usr/share/initramfs-tools/hook-functions

cp /usr/share/dell/scripts/pool.sh $DESTDIR/scripts
if [ ! -f $DESTDIR/scripts/casper-bottom/99dell_bootstrap ]; then
cp /usr/share/dell/casper/scripts/99dell_bootstrap $DESTDIR/scripts/casper-bottom
cp /usr/share/dell/scripts/pool.sh "$DESTDIR"/scripts
if [ ! -f "$DESTDIR"/scripts/casper-bottom/99dell_bootstrap ]; then
cp /usr/share/dell/casper/scripts/99dell_bootstrap "$DESTDIR"/scripts/casper-bottom
fi

#invoked from dell-recovery
if [ -n "$INJECT" ]; then
if ! grep 99dell_bootstrap $DESTDIR/scripts/casper-bottom/ORDER >/dev/null; then
cat >> $DESTDIR/scripts/casper-bottom/ORDER << EOF
if ! grep 99dell_bootstrap "$DESTDIR"/scripts/casper-bottom/ORDER >/dev/null; then
cat >> "$DESTDIR"/scripts/casper-bottom/ORDER << EOF
/scripts/casper-bottom/99dell_bootstrap "\$@"
[ -e /conf/param.conf ] && . /conf/param.conf
EOF
Expand Down
14 changes: 8 additions & 6 deletions casper/scripts/99dell_bootstrap
Original file line number Diff line number Diff line change
Expand Up @@ -61,19 +61,19 @@ elif [ -e /root/isodevice/scripts/emergency.sh ]; then
fi

if [ -d /root/isodevice ]; then
if [ -f /root/isodevice/.disk/info.recovery -a ! -f /root/isodevice/.disk/info ]; then
if [ -f /root/isodevice/.disk/info.recovery ] && [ ! -f /root/isodevice/.disk/info ]; then
mount -o remount,rw /root/isodevice
cp /root/isodevice/.disk/info.recovery /root/isodevice/.disk/info
mount -o remount,ro /root/isodevice
fi
elif [ -f /root/cdrom/.disk/info.recovery -a ! -f /root/cdrom/.disk/info ]; then
elif [ -f /root/cdrom/.disk/info.recovery ] && [ ! -f /root/cdrom/.disk/info ]; then
mount -o remount,rw /root/cdrom
cp /root/cdrom/.disk/info.recovery /root/cdrom/.disk/info
mount -o remount,ro /root/cdrom
fi

#Force ubiquity to run in automatic regardless if there are ubiquity options in /proc/cmdline (except single user mode)
if ! grep -q "single" /proc/cmdline 2>&1 >/dev/null; then
if ! grep -q "single" /proc/cmdline >/dev/null 2>&1; then
sed -i "s/ubiquity=\$/ubiquity=1/; s/\$automatic\ \$choose/--automatic/" /root/etc/init/ubiquity.conf
fi
#if they use a ubiquity icon it needs to run in automatic
Expand Down Expand Up @@ -134,7 +134,7 @@ ln -s /dev/null /root/etc/systemd/system/snapd.service
KERNELS=$(find /root/cdrom/kernel -maxdepth 1 -type d 2>/dev/null | sed "s,/root,,; /\/cdrom\/kernel\/$/d")
if [ -n "$KERNELS" ]; then
for KERNEL in $KERNELS; do
ln -s $KERNEL /root/lib/modules
ln -s "$KERNEL" /root/lib/modules
done
fi

Expand All @@ -143,12 +143,14 @@ rm -f /root/var/cache/debconf/*.dat-old

# Later emergency installer fixes
if [ -d /root/cdrom/scripts/emergency-scripts ]; then
# shellcheck source=/dev/null
for script in /root/cdrom/scripts/emergency-scripts/[0-9]*; do
. $script
. "$script"
done
elif [ -d /root/isodevice/scripts/emergency-scripts ]; then
# shellcheck source=/dev/null
for script in /root/isodevice/scripts/emergency-scripts/[0-9]*; do
. $script
. "$script"
done
fi

Expand Down
19 changes: 19 additions & 0 deletions contrib/setup
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/bin/bash -e
# Setup the repository.

cd "$(dirname "$0")/.."

DEPS=shellcheck
OS=$(python3 -c "import distro; print(distro.linux_distribution()[0].split()[0].lower())")
if [ "$OS" = "ubuntu" ]; then
if ! python3 -c "import venv"; then
DEPS="python3-venv"
fi
sudo apt install $DEPS
fi

python3 -m venv venv
source venv/bin/activate

python3 -m pip install pre-commit
pre-commit install
2 changes: 1 addition & 1 deletion debian/dell-recovery-bootloader.postrm
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ if [ "$1" = "purge" ]; then
TARGET=/var/lib/dell-recovery
FILES="boot.img core.img grub.cfg grubenv grubx64.efi grub-setup.exe"
for file in $FILES; do
rm -f $TARGET/$file
rm -f $TARGET/"$file"
done
rm -rf $TARGET/iso
fi
Expand Down
2 changes: 1 addition & 1 deletion grub/99_dell_recovery
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

source /usr/lib/grub/grub-mkconfig_lib

cat << EOF
cat << 'EOF'
menuentry "#RECOVERY_TEXT#" {
search --no-floppy --hint '(hd0,#PARTITION#)' --set --fs-uuid #UUID#
set uuid_options="uuid=#UUID#"
Expand Down
106 changes: 70 additions & 36 deletions installation_flow.md
Original file line number Diff line number Diff line change
@@ -1,60 +1,94 @@
Although the installer for Dell recovery media is the same as standard Ubuntu (*ubiquity*), the installation flow varies.
# Installation Flow

# Standard Ubuntu installation
A standard Ubuntu installation from a USB key only has one installation *phase*. The user is prompted for installation options such as disk, timezone, keyboard and username and installation runs in the background.
Although the installer for Dell recovery media is the same as standard Ubuntu
(*ubiquity*), the installation flow varies.

When the install is complete, upon rebooting the machine they are brought to a Ubuntu login screen and can use the computer.
## Standard Ubuntu installation

# *Standard* OEM installation
A standard OEM Ubuntu installation will be preseeded to operate in an automated fashion. Any questions that are not answered in the preseeding process will be prompted by the GUI. After installation is finished, the system will either be shut down or rebooted into **OEM-Config mode**.
A standard Ubuntu installation from a USB key only has one installation *phase*.
The user is prompted for installation options such as disk, timezone, keyboard
and username and installation runs in the background.

In **OEM-Config mode** the user will be prompted for questions that might not be the same as those preseeded. For example, Keyboard layout, Timezone or Language.
When the install is complete, upon rebooting the machine they are brought to a
Ubuntu login screen and can use the computer.

## *Standard* OEM installation

A standard OEM Ubuntu installation will be preseeded to operate in an automated
fashion. Any questions that are not answered in the preseeding process will be
prompted by the GUI. After installation is finished, the system will either be
shut down or rebooted into **OEM-Config mode**.

In **OEM-Config mode** the user will be prompted for questions that might not be
the same as those preseeded. For example, Keyboard layout, Timezone or
Language.

After completing OEM-Config, the user is brought to an Ubuntu login screen.

# Dell OEM installation
## Dell OEM installation

The Dell OEM installation is split across ***three** distinct phases*.
It is split this way to be able to support an archicture with a factory recovery partition on the hard disk.
This factory recovery partition is used both for Dell manufacturing as well as for customer based recovery.
It is split this way to be able to support an archicture with a factory recovery
partition on the hard disk.
This factory recovery partition is used both for Dell manufacturing as well as
for customer based recovery.

### Phase 1: Prepare partitions and content

The first phase prepares the disk and loads the recovery partition content onto
it. This can be approached from 3 different methods.

## Phase 1: Prepare partitions and content
The first phase prepares the disk and loads the recovery partition content onto it. This can be approached from 3 different methods.
#### Dell factory

### Dell factory
1. In the Dell factory we integrate with existing manufacturing tools, and these
tools create initial partition layout (ESP and Recovery partition) and load the
content onto the disk.

1. In the Dell factory we integrate with existing manufacturing tools, and these tools create initial partition layout (ESP and Recovery partition) and load the content onto the disk.
2. Other manufacturing tools also configure next boot (`BootOrder`/`BootNext`
variables)
3. Other manufacturing tools control reboot cycle.
4. On the next boot we’ll boot directly into phase 2.

2. Other manufacturing tools also configure next boot (`BootOrder`/`BootNext` variables)
3. Other manufacturing tools control reboot cycle.
4. On the next boot we’ll boot directly into phase 2.
#### Customer USB recovery

### Customer USB recovery
1. If customer boots up USB recovery disk, it will come to a prompt selecting
which disk to use to install to.
2. Customer presses next, and disk is wiped, content copied to ESP and recovery
partition
3. Boot variables set for next boot
4. System automatically reboots into phase 2.

1. If customer boots up USB recovery disk, it will come to a prompt selecting which disk to use to install to.
2. Customer presses next, and disk is wiped, content copied to ESP and recovery partition
3. Boot variables set for next boot
4. System automatically reboots into phase 2.
#### Customer HDD recovery

### Customer HDD recovery
1. GUI tool is offered in OS that will change grub next boot option to a recove
ry option we left to boot recovery partition.
2. Customer can also interrupt GRUB silent menu to select this option.
3. Customer agrees to wipe content.
4. System continues to phase 2.

1. GUI tool is offered in OS that will change grub next boot option to a recovery option we left to boot recovery partition.
2. Customer can also interrupt GRUB silent menu to select this option.
3. Customer agrees to wipe content.
4. System continues to phase 2.
### Phase 2: Install Ubuntu

This part of the installation is fully automated. The OS is booted from the rec
overy partition and the Ubiquity installer will launch.

## Phase 2: Install Ubuntu
This part of the installation is fully automated. The OS is booted from the recovery partition and the Ubiquity installer will launch.
Ubiquity will create additional partitions to install into, and all files will
be copied in. Any applicable drivers and updated packages distributed in
`/debs` of the recovery partition will be installed by Ubiquity and
dell-recovery plugins.

Ubiquity will create additional partitions to install into, and all files will be copied in. Any applicable drivers and updated packages distributed in `/debs` of the recovery partition will be installed by Ubiquity and dell-recovery plugins.
After Ubiquity finishes, a set of post-install scripts provided by Dell in the
`/scripts` directory of the recovery partition will run to complete the install.

After Ubiquity finishes, a set of post-install scripts provided by Dell in the `/scripts` directory of the recovery partition will run to complete the install.
When this phase is run during manufacturing, the system will return to Dell
manufacturing process.

When this phase is run during manufacturing, the system will return to Dell manufacturing process.
### Phase 3: Out of box experience

## Phase 3: Out of box experience
In a Dell manufactured machine, this is the first phase that a customer will actually see.
In a Dell manufactured machine, this is the first phase that a customer will
actually see.

As with standard OEM installation, the customer will select the Language, Timezone, Keyboard Layout, a username and a password.
As with standard OEM installation, the customer will select the Language,
Timezone, Keyboard Layout, a username and a password.

However specific to the Dell OEM install an additional page will prompt to create USB recovery media to use in the event of a failure.
However specific to the Dell OEM install an additional page will prompt to
create USB recovery media to use in the event of a failure.
1 change: 1 addition & 0 deletions late/chroot_scripts/02-grub.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
# MA 02110-1301, USA.

# shellcheck disable=SC2240
. /usr/share/dell/scripts/fifuncs ""

IFHALT "Rerun GRUB update"
Expand Down
5 changes: 3 additions & 2 deletions late/chroot_scripts/03-ubuntu-drivers.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@ export DEBIAN_FRONTEND=noninteractive

IFHALT "Run ubuntu-drivers autoinstall"
echo 'APT::Get::AllowUnauthenticated "true";' > /etc/apt/apt.conf.d/99disable_authentication
for blacklist in $(find /cdrom/scripts/chroot-scripts/blacklist /isodevice/scripts/chroot-scripts/blacklist -type f 2>/dev/null); do
UBUNTU_DRIVERS_BLACKLIST="$UBUNTU_DRIVERS_BLACKLIST $(cat $blacklist)"
LIST=$(find /cdrom/scripts/chroot-scripts/blacklist /isodevice/scripts/chroot-scripts/blacklist -type f 2>/dev/null)
for blacklist in $LIST; do
UBUNTU_DRIVERS_BLACKLIST="$UBUNTU_DRIVERS_BLACKLIST $(cat "$blacklist")"
done
if [ -n "$UBUNTU_DRIVERS_BLACKLIST" ]; then
echo "UBUNTU_DRIVERS_BLACKLIST: $UBUNTU_DRIVERS_BLACKLIST"
Expand Down
2 changes: 1 addition & 1 deletion late/chroot_scripts/04-disable-hibernate.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# Disable hibernate (S4) if RAM >= 4GB. (LP: #1284474)

for i in $(dmidecode -t 17 | grep Size | cut -d ':' -f 2 | cut -d ' ' -f 2); do
memsize=$((${memsize:-0} + $i))
memsize=$((${memsize:-0} + i))
done

if [ ${memsize:-0} -ge 4096 ]; then
Expand Down
1 change: 1 addition & 0 deletions late/chroot_scripts/05-enable-oem-config.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
# MA 02110-1301, USA.

# shellcheck disable=SC2240
. /usr/share/dell/scripts/fifuncs ""

IFHALT "Enable oem-config"
Expand Down
Loading