Skip to content

Commit

Permalink
add psplash support
Browse files Browse the repository at this point in the history
  • Loading branch information
ogra1 committed Nov 29, 2017
1 parent 772783e commit b8ea0f9
Show file tree
Hide file tree
Showing 9 changed files with 192 additions and 3 deletions.
2 changes: 2 additions & 0 deletions gadget.yaml
Expand Up @@ -26,3 +26,5 @@ volumes:
target: EFI/boot/bootx64.efi
- source: grub.cfg
target: EFI/ubuntu/grub.cfg
- source: psplash.img
target: EFI/ubuntu/psplash.img
4 changes: 2 additions & 2 deletions grub.cfg
Expand Up @@ -27,11 +27,11 @@ elif [ "$snap_mode" = "trying" ]; then
fi

set label="writable"
set cmdline="root=LABEL=$label snap_core=$snap_core snap_kernel=$snap_kernel ro net.ifnames=0 init=/lib/systemd/systemd console=ttyS0 console=tty1 panic=-1"
set cmdline="root=LABEL=$label snap_core=$snap_core snap_kernel=$snap_kernel ro net.ifnames=0 init=/lib/systemd/systemd console=ttyS0 console=tty1 vt.handoff=1 quiet splash"

menuentry "Ubuntu Core 16" {
search --label $label --set=writable
loopback loop ($writable)/system-data/var/lib/snapd/snaps/$snap_kernel
linux (loop)/kernel.img $cmdline
initrd (loop)/initrd.img
initrd (loop)/initrd.img $prefix/psplash.img
}
2 changes: 2 additions & 0 deletions psplash/config
@@ -0,0 +1,2 @@
SPLASH="logo.png"
FONT="/usr/share/fonts/truetype/ubuntu-font-family/Ubuntu-R.ttf"
14 changes: 14 additions & 0 deletions psplash/font-gen.sh
@@ -0,0 +1,14 @@
#! /bin/sh

# TTF to font.h generator

if [ "$#" -ne 1 ]; then
echo "Usage: $0 SOME_FONT.ttf"
exit 1
fi

otf2bdf -p 22 -r 75 -v $1 -o font.bdf
bdftobogl font.bdf > font.h
rm font.bdf
sed -i 's/#include "bogl\.h"/#include "psplash\.h"/g' font.h
sed -i 's/struct bogl_font font_font/PSplashFont font/g' font.h
8 changes: 8 additions & 0 deletions psplash/initrd/scripts/init-top/ORDER
@@ -0,0 +1,8 @@
/scripts/init-top/all_generic_ide "$@"
[ -e /conf/param.conf ] && . /conf/param.conf
/scripts/init-top/blacklist "$@"
[ -e /conf/param.conf ] && . /conf/param.conf
/scripts/init-top/udev "$@"
[ -e /conf/param.conf ] && . /conf/param.conf
/scripts/init-top/psplash "$@"
[ -e /conf/param.conf ] && . /conf/param.conf
23 changes: 23 additions & 0 deletions psplash/initrd/scripts/init-top/psplash
@@ -0,0 +1,23 @@
#!/bin/sh -e

PREREQS=""

prereqs() { echo "$PREREQS"; }

case "$1" in
prereqs)
prereqs
exit 0
;;
esac

for x in $(cat /proc/cmdline); do
case ${x} in
splash)
/bin/psplash &
;;
*)
;;
esac
done

Binary file added psplash/logo.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
105 changes: 105 additions & 0 deletions psplash/psplash.patch
@@ -0,0 +1,105 @@
diff --git a/Makefile.am b/Makefile.am
index a14152a..3c168c3 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -5,7 +5,7 @@ AM_CFLAGS = $(GCC_FLAGS) -D_GNU_SOURCE
psplash_SOURCES = psplash.c psplash.h psplash-fb.c psplash-fb.h \
psplash-console.c psplash-console.h \
psplash-colors.h psplash-config.h \
- psplash-poky-img.h psplash-bar-img.h radeon-font.h
+ psplash-core-img.h psplash-bar-img.h font.h

psplash_write_SOURCES = psplash-write.c psplash.h

diff --git a/make-image-header.sh b/make-image-header.sh
index d7cf67c..01750dd 100755
--- a/make-image-header.sh
+++ b/make-image-header.sh
@@ -3,8 +3,9 @@
set -e

imageh=`basename $1 .png`-img.h
+if [ -n "$3" ]; then
+ imageh="${3}-img.h"
+fi
name="${2}_IMG"
gdk-pixbuf-csource --macros $1 > $imageh.tmp
sed -e "s/MY_PIXBUF/${name}/g" -e "s/guint8/uint8/g" $imageh.tmp > $imageh && rm $imageh.tmp
-
-
diff --git a/psplash-bar-img.h b/psplash-bar-img.h
index c1c7626..c672894 100644
--- a/psplash-bar-img.h
+++ b/psplash-bar-img.h
@@ -1,8 +1,8 @@
/* GdkPixbuf RGBA C-Source image dump 1-byte-run-length-encoded */

#define BAR_IMG_ROWSTRIDE (920)
-#define BAR_IMG_WIDTH (230)
-#define BAR_IMG_HEIGHT (28)
+#define BAR_IMG_WIDTH (0)
+#define BAR_IMG_HEIGHT (0)
#define BAR_IMG_BYTES_PER_PIXEL (4) /* 3:RGB, 4:RGBA */
#define BAR_IMG_RLE_PIXEL_DATA ((uint8*) \
"\203\354\354\341\377\4\326\326\315\377\236\236\233\377\200\200\201\377" \
diff --git a/psplash.c b/psplash.c
index 992e199..f518278 100644
--- a/psplash.c
+++ b/psplash.c
@@ -21,9 +21,9 @@
#include "psplash.h"
#include "psplash-config.h"
#include "psplash-colors.h"
-#include "psplash-poky-img.h"
+#include "psplash-core-img.h"
#include "psplash-bar-img.h"
-#include "radeon-font.h"
+#include "font.h"

#define SPLIT_LINE_POS(fb) \
( (fb)->height \
@@ -45,7 +45,7 @@ psplash_draw_msg (PSplashFB *fb, const char *msg)
{
int w, h;

- psplash_fb_text_size (&w, &h, &radeon_font, msg);
+ psplash_fb_text_size (&w, &h, &font, msg);

DBG("displaying '%s' %ix%i\n", msg, w, h);

@@ -62,7 +62,7 @@ psplash_draw_msg (PSplashFB *fb, const char *msg)
(fb->width-w)/2,
SPLIT_LINE_POS(fb) - h,
PSPLASH_TEXT_COLOR,
- &radeon_font,
+ &font,
msg);
}

@@ -280,18 +280,18 @@ main (int argc, char** argv)

/* Draw the Poky logo */
psplash_fb_draw_image (fb,
- (fb->width - POKY_IMG_WIDTH)/2,
+ (fb->width - CORE_IMG_WIDTH)/2,
#if PSPLASH_IMG_FULLSCREEN
- (fb->height - POKY_IMG_HEIGHT)/2,
+ (fb->height - CORE_IMG_HEIGHT)/2,
#else
(fb->height * PSPLASH_IMG_SPLIT_NUMERATOR
- / PSPLASH_IMG_SPLIT_DENOMINATOR - POKY_IMG_HEIGHT)/2,
+ / PSPLASH_IMG_SPLIT_DENOMINATOR - CORE_IMG_HEIGHT)/2,
#endif
- POKY_IMG_WIDTH,
- POKY_IMG_HEIGHT,
- POKY_IMG_BYTES_PER_PIXEL,
- POKY_IMG_ROWSTRIDE,
- POKY_IMG_RLE_PIXEL_DATA);
+ CORE_IMG_WIDTH,
+ CORE_IMG_HEIGHT,
+ CORE_IMG_BYTES_PER_PIXEL,
+ CORE_IMG_ROWSTRIDE,
+ CORE_IMG_RLE_PIXEL_DATA);

/* Draw progress bar border */
psplash_fb_draw_image (fb,
37 changes: 36 additions & 1 deletion snapcraft.yaml
Expand Up @@ -22,4 +22,39 @@ parts:
- grub-common
plugin: make
after: [grub-prepare]

psplash:
source: https://github.com/ogra1/psplash.git
plugin: make
prepare: |
export TREE="../../../psplash"
. ${TREE}/config
if ! $(echo "$FONT"|grep -q ^/); then \
FONT="${TREE}/${FONT}"; \
fi
if ! $(echo "$SPLASH"|grep -q ^/); then \
SPLASH="${TREE}/${SPLASH}"; \
fi
git apply ${TREE}/psplash.patch
${TREE}/font-gen.sh "$FONT"
./make-image-header.sh "$SPLASH" CORE psplash-core
aclocal
autoreconf --install
./configure
install: |
rm -rf $SNAPCRAFT_PART_INSTALL/usr
cp -a ../../../psplash/initrd .
mkdir -p initrd/bin
cp psplash initrd/bin
cd initrd && find . | cpio --quiet -o -H newc| lzma >>$SNAPCRAFT_PART_INSTALL/psplash.img
build-packages:
- libgdk-pixbuf2.0-dev
- automake
- autoconf
- gcc
- otf2bdf
- libbogl-dev
- ttf-ubuntu-font-family
- cpio
- findutils
- xz-utils
after: [grub]

0 comments on commit b8ea0f9

Please sign in to comment.