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

Fixes #12 - Install custom packages from additional repositories #18

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
11 changes: 7 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,16 @@ The `dibby` script has three command line arguments, corresponding in turn to th

1. The _workspace_ is a directory on your local system which will contain your dibby project. This directory needs to be created before you run `dibby` for the first time. The workspace directory is kept separate from dibby itself, so your workspace can be public or private, depending on your project requirements. A dibby workspace can be developed collaboratively using your own git repository, if you wish.

2. The _config_ file is where you set the options for the target systems which will boot your dibby project image. This includes the CPU architecture for your dibby project, as well as the initial hostname and root password of the target devices. This file also enables you to specify a Debian preseed file and post-installation script, a custom package selection and custom tasks, using the following format:
2. The _config_ file is where you set the options for the target systems which will boot your dibby project image. This includes the CPU architecture for your dibby project, as well as the initial hostname and root password of the target devices. This file also enables you to specify a Debian preseed file and post-installation script, a custom package selection, custom tasks and a custom package mirror, using the following format:
```
CONFIG_ARCH="armhf"
CONFIG_HOSTNAME="myhostname"
CONFIG_ROOT_PASSWORD="myrootpassword"
CONFIG_PRESEED="preseed.conf"
CONFIG_POSTINST="postinst.sh"
CONFIG_CUSTOM_PACKAGES="jackd2"
CONFIG_CUSTOM_TASKS="openssh-server"
CONFIG_CUSTOM_TASKS="raspberry-pi-3"
CONFIG_CUSTOM_MIRROR="https://apt.64studio.net/"
```

You can also pass options to `debootstrap` from the dibby project config file, including the mirror to obtain the Debian packages from, the base Debian suite for your project, and any Debian packages to exclude from the build:
Expand All @@ -69,7 +70,7 @@ nano ~/myproject/myconfig
sudo ./dibby ~/myproject myconfig mydebian.img
```

Please be aware that the step _Unpacking the base system..._ can take a long time, depending on the speed of your build host.
Please be aware that the step _Unpacking the base system..._ can take a long time, depending on the speed of your build host.

### Creating unique images

Expand All @@ -79,7 +80,9 @@ For example, you might wish to create a series of up-to-date Debian images which

### The tasks directory

The purpose of tasks in dibby is to set up modular components containing Debian packages and configurations for them that work well together, without having to specify each package and configuration option every time you create a new dibby project. Inside the _tasks_ directory (installed to `/usr/share/dibby/tasks/` when using the Debian package of dibby) you will find scripts which are run from the main `dibby` script. You can use these ready-made task scripts as they are, modify them, or create as many new tasks as you need.
The purpose of tasks in dibby is to set up modular components containing Debian packages and configurations for them that work well together, without having to specify each package and configuration option every time you create a new dibby project. These tasks can be generic, for any system, or they can target specific hardware such as the Raspberry Pi 3.

Inside the _tasks_ directory (installed to `/usr/share/dibby/tasks/` when using the Debian package of dibby) you will find scripts which are run from the main `dibby` script. You can use these ready-made task scripts as they are, modify them, or create as many new tasks as you need.

For example, during the development phase of your dibby project, you might wish to include an OpenSSH server in your build with remote root access by password to the target device. A script called `openssh-server.sh` is included in the _tasks_ directory for this purpose. (This approach is a more modular alternative to using `d-i preseed/late_command` in the preseed file, one which enables you to put your hacks for a particular package in the same task script which selects that package).

Expand Down
37 changes: 35 additions & 2 deletions bootstrap/0002_minimal.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# hostname
info "Setting hostname to $CONFIG_HOSTNAME"
echo "$CONFIG_HOSTNAME" > $ROOTFS/etc/hostname

# hosts file
Expand Down Expand Up @@ -29,21 +30,32 @@ iface eth0 inet dhcp" >> $ROOTFS/etc/network/interfaces
mkdir -p "$ROOTFS/mnt/workspace"
mount --bind "$WORKSPACE" "$ROOTFS/mnt/workspace"

# setup main apt repository
# setup main apt and dibby repositories
info "Setting up APT for $CONFIG_DEBOOTSTRAP_MIRROR"
cat << EOF > $ROOTFS/etc/apt/sources.list
deb $CONFIG_DEBOOTSTRAP_MIRROR $CONFIG_DEBOOTSTRAP_SUITE main contrib non-free
deb-src $CONFIG_DEBOOTSTRAP_MIRROR $CONFIG_DEBOOTSTRAP_SUITE main contrib non-free

deb https://apt.64studio.net/dibby $CONFIG_DEBOOTSTRAP_SUITE main
deb-src https://apt.64studio.net/dibby $CONFIG_DEBOOTSTRAP_SUITE main
EOF

cat << EOF > $ROOTFS/etc/apt/preferences

Package: *
Pin: origin "apt.64studio.net"
Pin-Priority: 1001
EOF

if [ $CONFIG_DEBOOTSTRAP_SUITE = "buster" ] ||
[ $CONFIG_DEBOOTSTRAP_SUITE = "stretch" ] ||
[ $CONFIG_DEBOOTSTRAP_SUITE = "testing" ] ||
[ $CONFIG_DEBOOTSTRAP_SUITE = "stable" ]
then
# setup additional apt repositories
# setup additional Debian apt repositories
info "Adding update and debian-security repositories"
cat << EOF >> $ROOTFS/etc/apt/sources.list

deb $CONFIG_DEBOOTSTRAP_MIRROR $CONFIG_DEBOOTSTRAP_SUITE-updates main contrib non-free
deb-src $CONFIG_DEBOOTSTRAP_MIRROR $CONFIG_DEBOOTSTRAP_SUITE-updates main contrib non-free

Expand All @@ -52,6 +64,27 @@ deb-src http://deb.debian.org/debian-security $CONFIG_DEBOOTSTRAP_SUITE/updates
EOF
fi

# setup custom apt repository and pin it to high priority
if [ -n "$CONFIG_CUSTOM_MIRROR" ]; then

info "Setting up APT for $CONFIG_CUSTOM_MIRROR"
cat << EOF >> $ROOTFS/etc/apt/sources.list

deb $CONFIG_CUSTOM_MIRROR $CONFIG_DEBOOTSTRAP_SUITE main
deb-src $CONFIG_CUSTOM_MIRROR $CONFIG_DEBOOTSTRAP_SUITE main
EOF

CONFIG_CUSTOM_ORIGIN=$(echo $CONFIG_CUSTOM_MIRROR | sed 's;https://;;' | sed 's;http://;;' | sed 's;ftp://;;')

cat << EOF >> $ROOTFS/etc/apt/preferences

Package: *
Pin: origin "$CONFIG_CUSTOM_ORIGIN"
Pin-Priority: 1002
EOF

fi

# do not install recommended packages
# TODO remove after?
echo "APT::Install-Recommends \"0\";
Expand Down
3 changes: 2 additions & 1 deletion default-config
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,5 @@ CONFIG_ROOT_PASSWORD=""
CONFIG_PRESEED=""
CONFIG_POSTINST=""
CONFIG_CUSTOM_PACKAGES=""
CONFIG_CUSTOM_TASKS=""
CONFIG_CUSTOM_TASKS="raspberry-pi-3"
CONFIG_CUSTOM_MIRROR=""
3 changes: 3 additions & 0 deletions tasks/raspberry-pi-3.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# install raspberry pi 3 support packages from apt.64studio.net/dibby
chroot_exec apt-get install libraspberrypi0 libraspberrypi-bin linux-image-4.19.25-v7-raspberrypi-default raspberrypi-bootloader-nokernel --yes