diff --git a/build.sh b/build.sh index 67bdf2f..b970a27 100755 --- a/build.sh +++ b/build.sh @@ -16,6 +16,24 @@ LOGS=$BUILD/logs log() { printf '[%s] %s\n' "$(date '+%H:%M:%S')" "$*"; } die() { printf '[%s] ERROR: %s\n' "$(date '+%H:%M:%S')" "$*"; exit 1; } +if [ -n "$REMOVE" ]; then + ver=${KERNEL_VERSION}-${LOCAL_VERSION}.ms-r1 + log "removing modules" + pkexec rm -rf /lib/modules/$ver* || die "failed" + log "removing boot files" + pkexec rm -f /boot/vmlinuz-$ver* /boot/initrd-$ver* /boot/initramfs-$ver* /boot/System.map-$ver* /boot/config-$ver* || die "failed" + pkexec find /boot/loader/entries -name "*-${KERNEL_VERSION}-${LOCAL_VERSION}.ms-r1*" -delete || die "failed" + log "done"; exit 0 +fi + +[ -z "$CLEAN" ] || rm -rf $KERNEL_TREE $KERNEL_CORE $KERNEL_PATCHES $LOGS; mkdir -p "$LOGS" +log "building linux kernel ${KERNEL_VERSION} with sky1-${TAG} patches" + +if [ ! -d "$KERNEL_TREE" ]; then + log "cloning linux kernel repository" + git clone --depth=1 --branch=v$KERNEL_VERSION https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git "$KERNEL_TREE" > /dev/null 2>&1 || die "failed" +fi + append() { local series=$KERNEL_PATCHES/patches/series echo "$(grep -v -e'^<<<<<<<' -e '^>>>>>>>' -e'=======' $series)" > $series @@ -29,15 +47,6 @@ rebase() { git rebase $1/$2 > /dev/null 2>&1 || append || die "could not rebase branch $1:$2" } -[ -z "$CLEAN" ] || rm -rf $KERNEL_TREE $KERNEL_CORE $KERNEL_PATCHES $LOGS -mkdir -p "$LOGS" -log "building linux kernel ${KERNEL_VERSION} with sky1-${TAG} patches" - -if [ ! -d "$KERNEL_TREE" ]; then - log "cloning linux kernel repository" - git clone --depth=1 --branch=v$KERNEL_VERSION https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git "$KERNEL_TREE" > /dev/null 2>&1 || die "failed" -fi - if [ ! -d "$KERNEL_PATCHES" ]; then log "preparing for patching" git clone --depth=1 https://github.com/Sky1-Linux/linux-sky1.git > /dev/null 2>&1 || die "failed"