Files
android_vendor_pawlet/build/envsetup.sh
T
oxmc 9344e608f6 Initial commit: PawletOS vendor tree
Adds the full vendor/pawlet tree for PawletOS on Raspberry Pi 4/5:

- build/: envsetup.sh helpers (breakfast/brunch/mka), bacon OTA target,
  Soong namespace, build core hook
- config/: common.mk, version.mk, BoardConfigPawlet.mk, BoardConfigSoong.mk,
  privapp-permissions, me.pawlet.android feature XML
- hal/boot_control/rpi/: AIDL boot_control HAL for RPi A/B slot switching
- apps/Updater/: A/B OTA updater (download, verify, install, reboot)
- apps/PawletPlatform/: platform resource APK (device icons, strings)
- overlay/frameworks/base/core/res/: framework config overrides
- prebuilt/, vars/: init rc, aosp_target_release
2026-03-21 19:08:46 -07:00

228 lines
6.9 KiB
Bash

#!/bin/bash
#
# Copyright (C) 2012 The CyanogenMod Project
# Copyright (C) 2017 The LineageOS Project
# Copyright (C) 2025 oxmc / PawletOS
#
# SPDX-License-Identifier: Apache-2.0
#
# PawletOS build environment helpers.
# Adapted from vendor/lineage/build/envsetup.sh (The LineageOS Project).
# Source after AOSP's envsetup.sh:
# source build/envsetup.sh
# source vendor/pawlet/build/envsetup.sh
#
# ---------------------------------------------------------------------------
# check_product — verify the product is a pawlet_* target
# ---------------------------------------------------------------------------
function check_product()
{
local T=$(gettop)
if [ ! "$T" ]; then
echo "Couldn't locate the top of the tree. Try setting TOP." >&2
return
fi
if (echo -n $1 | grep -q -e "^pawlet_"); then
PAWLET_BUILD=$(echo -n $1 | sed -e 's/^pawlet_//g')
else
PAWLET_BUILD=
fi
export PAWLET_BUILD
TARGET_PRODUCT=$1 \
TARGET_BUILD_VARIANT= \
TARGET_BUILD_TYPE= \
TARGET_BUILD_APPS= \
_get_build_var_cached TARGET_DEVICE > /dev/null
}
# ---------------------------------------------------------------------------
# breakfast <device> [variant] — configure build for a PawletOS device
# ---------------------------------------------------------------------------
function breakfast()
{
local target=$1
local variant=$2
source ${ANDROID_BUILD_TOP}/vendor/pawlet/vars/aosp_target_release
if [ $# -eq 0 ]; then
lunch
else
if [[ "$target" =~ -(user|userdebug|eng)$ ]]; then
lunch $target
else
if [ -z "$variant" ]; then
variant="userdebug"
fi
lunch pawlet_${target}-${aosp_target_release}-${variant}
fi
fi
return $?
}
alias bib=breakfast
# ---------------------------------------------------------------------------
# brunch <device> — breakfast + make bacon
# ---------------------------------------------------------------------------
function brunch()
{
breakfast $*
if [ $? -eq 0 ]; then
mka bacon
else
echo "No such item in brunch menu. Try 'breakfast'"
return 1
fi
return $?
}
# ---------------------------------------------------------------------------
# mka — invoke the Android build system
# ---------------------------------------------------------------------------
function mka()
{
m "$@"
}
# ---------------------------------------------------------------------------
# cmka — clean + build a specific target
# ---------------------------------------------------------------------------
function cmka()
{
if [ ! -z "$1" ]; then
for i in "$@"; do
case $i in
bacon|otapackage|systemimage)
mka installclean
mka $i
;;
*)
mka clean-$i
mka $i
;;
esac
done
else
mka clean
mka
fi
}
# ---------------------------------------------------------------------------
# cout — cd to the output directory
# ---------------------------------------------------------------------------
function cout()
{
if [ "$OUT" ]; then
cd $OUT
else
echo "Couldn't locate out directory. Try setting OUT."
fi
}
# ---------------------------------------------------------------------------
# pawlet_img <device> — build the flashable SD-card image via mkimg.sh
# ---------------------------------------------------------------------------
function pawlet_img()
{
local device=${1:-${PAWLET_BUILD}}
if [[ -z "$device" ]]; then
echo "Usage: pawlet_img <device>"
return 1
fi
local mkimg="device/brcm/${device}/mkimg.sh"
if [[ ! -f "$mkimg" ]]; then
echo "mkimg.sh not found: $mkimg"
return 1
fi
bash "$mkimg"
}
# ---------------------------------------------------------------------------
# aospremote — add an 'aosp' git remote pointing at AOSP upstream
# ---------------------------------------------------------------------------
function aospremote()
{
local T=$(git rev-parse --show-toplevel 2>/dev/null)
if [ -z "$T" ]; then
echo "Git repository not found."
return 1
fi
git remote rm aosp 2>/dev/null
if [ -f "$T/.gitupstream" ]; then
local REMOTE=$(cat "$T/.gitupstream" | cut -d ' ' -f 1)
git remote add aosp ${REMOTE}
else
local PROJECT=$(pwd -P | sed -e "s#$ANDROID_BUILD_TOP/##; s#-caf.*##; s#/default##")
if [ $PROJECT = "build/make" ]; then
PROJECT="build"
fi
if (echo $PROJECT | grep -qv "^device"); then
local PFX="platform/"
fi
git remote add aosp https://android.googlesource.com/${PFX}${PROJECT}
fi
echo "Remote 'aosp' created"
}
# ---------------------------------------------------------------------------
# pawletremote — add a 'pawlet' git remote for the PawletOS Gitea instance
# ---------------------------------------------------------------------------
function pawletremote()
{
if ! git rev-parse --git-dir &>/dev/null; then
echo ".git directory not found."
return 1
fi
git remote rm pawlet 2>/dev/null
local PROJECT=$(pwd -P | sed -e "s#$ANDROID_BUILD_TOP/##; s#/#_#g" \
-e "s#platform/#android/#g")
git remote add pawlet https://git.oxmc.me/PawletOS/${PROJECT}
echo "Remote 'pawlet' created"
}
# ---------------------------------------------------------------------------
# repopick — cherry-pick patches from a Gerrit-style review server
# ---------------------------------------------------------------------------
function repopick()
{
local T=$(gettop)
$T/vendor/pawlet/build/tools/repopick.py "$@"
}
# ---------------------------------------------------------------------------
# reposync — wrapper around 'repo sync'
# ---------------------------------------------------------------------------
function reposync()
{
repo sync -j4 "$@"
}
# ---------------------------------------------------------------------------
# repodiff — show diff across all repos between two refs
# ---------------------------------------------------------------------------
function repodiff()
{
if [ -z "$*" ]; then
echo "Usage: repodiff <ref-from> [[ref-to] [--numstat]]"
return
fi
diffopts=$* repo forall -c \
'echo "$REPO_PATH ($REPO_REMOTE)"; git diff ${diffopts} 2>/dev/null;'
}
# ---------------------------------------------------------------------------
# pawlet_version — print current version info
# ---------------------------------------------------------------------------
function pawlet_version()
{
local ver=$(get_build_var PAWLET_VERSION 2>/dev/null)
local type=$(get_build_var PAWLET_BUILDTYPE 2>/dev/null)
echo "PawletOS ${ver:-unknown} (${type:-UNOFFICIAL})"
}
echo "PawletOS build helpers loaded. Try: breakfast rpi5 | brunch rpi4"