Created
September 19, 2017 13:22
-
-
Save stephgosling/96b8bd3ce38716457ef3628533704a5d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# DisplayName: Jolla f5121/@ARCH@ (release) 1 | |
# KickstartType: release | |
# SuggestedFeatures: customer-jolla, sailfish-xt9, sailfish-eas, jolla-store-apps, aliendalvik-feature | |
# SuggestedImageType: loop | |
# SuggestedArchitecture: armv7hl | |
lang en_US.UTF-8 | |
timezone --utc UTC | |
keyboard us | |
user --name nemo --groups audio,video --password nemo | |
### Commands from /tmp/sandbox/usr/share/ssu/kickstart/part/f5121 | |
part / --fstype="ext4" --size=1800 --label=root | |
part /home --fstype="ext4" --size=800 --label=home | |
part /fimage --fstype="ext4" --size=10 --label=fimage | |
## No suitable configuration found in /tmp/sandbox/usr/share/ssu/kickstart/bootloader | |
repo --name=adaptation-community-common-f5121-@RELEASE@ --baseurl=http://repo.merproject.org/obs/nemo:/devel:/hw:/common/sailfish_latest_@ARCH@/ | |
repo --name=apps-@RELEASE@ --baseurl=https://releases.jolla.com/jolla-apps/@RELEASE@/@ARCH@/ | |
repo --name=hotfixes-@RELEASE@ --baseurl=https://releases.jolla.com/releases/@RELEASE@/hotfixes/@ARCH@/ | |
repo --name=jolla-@RELEASE@ --baseurl=https://releases.jolla.com/releases/@RELEASE@/jolla/@ARCH@/ | |
%packages | |
@Jolla Configuration f5121 | |
%end | |
%attachment | |
### Commands from /tmp/sandbox/usr/share/ssu/kickstart/attachment/f5121 | |
/boot/hybris-boot.img | |
droid-config-f5121-out-of-image-files | |
/etc/hw-release | |
/system/vendor/firmware/fw_bcmdhd.bin | |
/system/vendor/firmware/fw_bcmdhd_apsta.bin | |
%end | |
%pre | |
export SSU_RELEASE_TYPE=release | |
### begin 01_init | |
touch $INSTALL_ROOT/.bootstrap | |
### end 01_init | |
%end | |
%post | |
export SSU_RELEASE_TYPE=release | |
### begin 01_arch-hack | |
if [ "@ARCH@" == armv7hl ] || [ "@ARCH@" == armv7tnhl ]; then | |
# Without this line the rpm does not get the architecture right. | |
echo -n "@ARCH@-meego-linux" > /etc/rpm/platform | |
# Also libzypp has problems in autodetecting the architecture so we force tha as well. | |
# https://bugs.meego.com/show_bug.cgi?id=11484 | |
echo "arch = @ARCH@" >> /etc/zypp/zypp.conf | |
fi | |
### end 01_arch-hack | |
### begin 01_rpm-rebuilddb | |
# Rebuild db using target's rpm | |
echo -n "Rebuilding db using target rpm.." | |
rm -f /var/lib/rpm/__db* | |
rpm --rebuilddb | |
echo "done" | |
### end 01_rpm-rebuilddb | |
### begin 50_oneshot | |
# exit boostrap mode | |
rm -f /.bootstrap | |
# export some important variables until there's a better solution | |
export LANG=en_US.UTF-8 | |
export LC_COLLATE=en_US.UTF-8 | |
export GSETTINGS_BACKEND=gconf | |
# run the oneshot triggers for root and first user uid | |
UID_MIN=$(grep "^UID_MIN" /etc/login.defs | tr -s " " | cut -d " " -f2) | |
DEVICEUSER=`getent passwd $UID_MIN | sed 's/:.*//'` | |
if [ -x /usr/bin/oneshot ]; then | |
su -c "/usr/bin/oneshot --mic" | |
su -c "/usr/bin/oneshot --mic" $DEVICEUSER | |
fi | |
### end 50_oneshot | |
### begin 60_ssu | |
if [ "$SSU_RELEASE_TYPE" = "rnd" ]; then | |
[ -n "@RNDRELEASE@" ] && ssu release -r @RNDRELEASE@ | |
[ -n "@RNDFLAVOUR@" ] && ssu flavour @RNDFLAVOUR@ | |
# RELEASE is reused in RND setups with parallel release structures | |
# this makes sure that an image created from such a structure updates from there | |
[ -n "@RELEASE@" ] && ssu set update-version @RELEASE@ | |
ssu mode 2 | |
else | |
[ -n "@RELEASE@" ] && ssu release @RELEASE@ | |
ssu mode 4 | |
fi | |
### end 60_ssu | |
### begin 70_sdk-domain | |
export SSU_DOMAIN=@RNDFLAVOUR@ | |
if [ "$SSU_RELEASE_TYPE" = "release" ] && [[ "$SSU_DOMAIN" = "public-sdk" ]]; | |
then | |
ssu domain sailfish | |
fi | |
### end 70_sdk-domain | |
%end | |
%post --nochroot | |
export SSU_RELEASE_TYPE=release | |
### begin 01_release | |
if [ -n "$IMG_NAME" ]; then | |
echo "BUILD: $IMG_NAME" >> $INSTALL_ROOT/etc/meego-release | |
fi | |
### end 01_release | |
### begin f5121 | |
cp $INSTALL_ROOT/etc/sailfish-release $IMG_OUT_DIR | |
### end f5121 | |
%end | |
%pack | |
export SSU_RELEASE_TYPE=release | |
### begin hybris | |
pushd $IMG_OUT_DIR | |
MD5SUMFILE=md5.lst | |
DEVICE_VERSION_FILE=./hw-release | |
EXTRA_NAME="" | |
if [ -n "@EXTRA_NAME@" ] && [ "@EXTRA_NAME@" != @"EXTRA_NAME"@ ]; then | |
EXTRA_NAME="@EXTRA_NAME@-" | |
fi | |
DEVICE="" | |
DEVICE_VERSION="" | |
if [[ -a $DEVICE_VERSION_FILE ]]; then | |
source $DEVICE_VERSION_FILE | |
DEVICE=$MER_HA_DEVICE | |
DEVICE_VERSION=-$VERSION_ID | |
fi | |
source ./sailfish-release | |
if [ "$SSU_RELEASE_TYPE" = "rnd" ]; then | |
RELEASENAME=$NAME-${EXTRA_NAME// /_}$SAILFISH_FLAVOUR-$VERSION_ID-$DEVICE$DEVICE_VERSION | |
else | |
RELEASENAME=$NAME-${EXTRA_NAME// /_}$VERSION_ID-$DEVICE$DEVICE_VERSION | |
fi | |
# Setup LVM image | |
dd if=/dev/zero bs=1 count=0 of=temp.img seek=3000M | |
LVM_LOOP=$(/sbin/losetup -f) | |
/sbin/losetup $LVM_LOOP temp.img | |
/usr/sbin/pvcreate $LVM_LOOP | |
/usr/sbin/vgcreate sailfish $LVM_LOOP | |
# Resize root and home to minimum | |
ROOT_LOOP=$(/sbin/losetup -f) | |
/sbin/losetup $ROOT_LOOP root.img | |
/sbin/e2fsck -f -y $ROOT_LOOP | |
BLOCKS=$(/sbin/resize2fs -M $ROOT_LOOP | /bin/grep "The filesystem on" | /bin/cut -d ' ' -f 7) | |
echo We got ourselves root blocks _ $BLOCKS _ | |
SIZE=$(/usr/bin/expr $BLOCKS \* 4096) | |
echo after maths size _ $SIZE _ | |
/usr/sbin/lvcreate -L ${SIZE}B --name root sailfish | |
/bin/sync | |
/sbin/losetup -d $ROOT_LOOP | |
/usr/sbin/vgchange -a y | |
dd if=root.img bs=4096 count=$BLOCKS of=/dev/sailfish/root | |
HOME_LOOP=$(/sbin/losetup -f) | |
/sbin/losetup $HOME_LOOP home.img | |
/sbin/e2fsck -f -y $HOME_LOOP | |
BLOCKS=$(/sbin/resize2fs -M $HOME_LOOP | /bin/grep "The filesystem on" | /bin/cut -d ' ' -f 7) | |
echo We got ourselves home size _ $BLOCKS _ | |
SIZE=$(/usr/bin/expr $BLOCKS \* 4096) | |
/usr/sbin/lvcreate -L ${SIZE}B --name home sailfish | |
/bin/sync | |
/sbin/losetup -d $HOME_LOOP | |
/usr/sbin/vgchange -a y | |
dd if=home.img bs=4096 count=$BLOCKS of=/dev/sailfish/home | |
/usr/sbin/vgchange -a n sailfish | |
# Temporary dir for making factory image backups. | |
FIMAGE_TEMP=$(mktemp -d -p $(pwd)) | |
# For some reason loop files created by imager don't shrink properly when | |
# running resize2fs -M on them. Hence manually growing the loop file here | |
# to make the shrinking work once we have the image populated. | |
dd if=/dev/zero bs=1 seek=1400000000 count=1 of=fimage.img | |
/sbin/e2fsck -f -y fimage.img | |
/sbin/resize2fs -f fimage.img | |
pigz -7 root.img | |
md5sum -b root.img.gz > root.img.gz.md5 | |
pigz -7 home.img | |
md5sum -b home.img.gz > home.img.gz.md5 | |
mount -o loop fimage.img $FIMAGE_TEMP | |
mkdir -p $FIMAGE_TEMP/${RELEASENAME} | |
mv root.img.gz* $FIMAGE_TEMP/${RELEASENAME} | |
mv home.img.gz* $FIMAGE_TEMP/${RELEASENAME} | |
umount $FIMAGE_TEMP | |
rmdir $FIMAGE_TEMP | |
/sbin/e2fsck -f -y fimage.img | |
/sbin/resize2fs -f -M fimage.img | |
# To make the file magic right lets convert to single file sparse image. | |
# 3456M size is selected so that we always will have only one file as output. | |
/usr/bin/img2simg -C 3456M fimage.img | |
rm fimage.img | |
/sbin/losetup -d $LVM_LOOP | |
mv temp.img sailfish.img | |
/usr/bin/atruncate sailfish.img | |
# To make the file magic right lets convert to single file sparse image. | |
# 3456M size is selected so that we always will have only one file as output. | |
/usr/bin/img2simg -C 3456M sailfish.img | |
rm sailfish.img | |
chmod 755 flash.* | |
FILES="flash* *.img* *.bin" | |
FILES_TO_COPY="*.urls" | |
mkdir -p ${RELEASENAME} | |
cp ${FILES_TO_COPY} ${RELEASENAME}/ | |
mv ${FILES} ${RELEASENAME}/ | |
# Calculate md5sums of files included to the tarball | |
cd ${RELEASENAME} | |
md5sum * > $MD5SUMFILE | |
cd .. | |
# Package stuff back to tarball | |
tar -cjf ${RELEASENAME}.tar.bz2 $RELEASENAME | |
# Remove the files from the output directory | |
rm -r ${RELEASENAME} | |
popd | |
### end hybris | |
%end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment