@@ -54,6 +54,20 @@ function reversion_armbian-bsp-cli-transitional_deb_contents() {
5454
5555}
5656
57+ function reversion_armbian-bsp-generic-transitional_deb_contents() {
58+ if [[ " ${1} " != " armbian-bsp-generic-transitional" ]]; then
59+ return 0 # Not our deb, nothing to do.
60+ fi
61+ display_alert " Reversion" " reversion_armbian-bsp-generic-transitional_deb_contents: '$* '" " debug"
62+
63+ # Depends on the new package
64+ cat << - EOF >> "${control_file_new} "
65+ Depends: ${artifact_name} (= ${REVISION} )
66+ EOF
67+
68+ }
69+
70+
5771function compile_armbian-bsp-cli() {
5872 : " ${artifact_version:? artifact_version is not set} "
5973 : " ${artifact_name:? artifact_name is not set} "
@@ -121,12 +135,6 @@ function compile_armbian-bsp-cli() {
121135 # in practice: packages/bsp-cli and variations of config/optional/...
122136 copy_all_packages_files_for " bsp-cli"
123137
124- # copy common files from a premade directory structure
125- # @TODO this includes systemd config, assumes things about serial console, etc, that need dynamism or just to not exist with modern systemd
126- display_alert " Copying common bsp files" " packages/bsp/common" " info"
127- run_host_command_logged rsync -av " ${SRC} " /packages/bsp/common/* " ${destination} "
128- wait_for_disk_sync " after rsync'ing package/bsp/common for bsp-cli"
129-
130138 mkdir -p " ${destination} " /usr/share/armbian/
131139
132140 # get bootscript information.
@@ -179,24 +187,24 @@ function compile_armbian-bsp-cli() {
179187 # TODO: Add proper handling for updated conffiles
180188 # We are runing this script each time apt runs. If this package is removed, file is removed and error is triggered.
181189 # Keeping armbian-apt-updates as a configuration, solve the problem
182- cat << - EOF > "${destination} "/DEBIAN/conffiles
183- /usr/lib/armbian/armbian-apt-updates
184- /etc/X11/xorg.conf.d/01-armbian-defaults.conf
185- EOF
190+ # cat <<- EOF > "${destination}"/DEBIAN/conffiles
191+ # /usr/lib/armbian/armbian-apt-updates
192+ # /etc/X11/xorg.conf.d/01-armbian-defaults.conf
193+ # EOF
186194
187195 # trigger uInitrd creation after installation, to apply
188196 # /etc/initramfs/post-update.d/99-uboot
189- cat << - EOF > "${destination} "/DEBIAN/triggers
190- activate update-initramfs
191- EOF
197+ # cat <<- EOF > "${destination}"/DEBIAN/triggers
198+ # activate update-initramfs
199+ # EOF
192200
193201 # copy distribution support and upgrade status
194202 # this information is used in motd to show status and within armbian-config to perform upgrades
195- declare -a releases=()
196- mapfile -t releases < <( for relorder in " ${SRC} " /config/distributions/* /order; do echo " ${relorder} $( xargs echo < " ${relorder} " ) " ; done | sort -nk2 | sed " s/\/order.*//g" )
197- for i in " ${releases[@]} " ; do
198- echo " $( echo " $i " | sed ' s/.*\///' ) =$( cat " $i " /support) $( echo " ;upgrade" | sed ' s/.*\///' ) =$( cat " $i " /upgrade) " >> " ${destination} " /etc/armbian-distribution-status
199- done
203+ # declare -a releases=()
204+ # mapfile -t releases < <(for relorder in "${SRC}"/config/distributions/*/order; do echo "${relorder} $(xargs echo < "${relorder}")"; done | sort -nk2 | sed "s/\/order.*//g")
205+ # for i in "${releases[@]}"; do
206+ # echo "$(echo "$i" | sed 's/.*\///')=$(cat "$i"/support)$(echo ";upgrade" | sed 's/.*\///')=$(cat "$i"/upgrade)" >> "${destination}"/etc/armbian-distribution-status
207+ # done
200208
201209 # execute $LINUXFAMILY-specific tweaks
202210 if [[ $( type -t family_tweaks_bsp) == function ]]; then
@@ -205,6 +213,13 @@ function compile_armbian-bsp-cli() {
205213 display_alert " Done with family_tweaks_bsp" " ${LINUXFAMILY} - ${BOARDFAMILY} " " debug"
206214 fi
207215
216+ # FIXME: this is just the dir structure from packages/bsp/common. Likely that many of these directories are unneeded.
217+ # we add them because of the below hook that may want to add contents.
218+ # FIXME: it may be better to make those hooks add the directories instead.
219+ mkdir -p " ${destination} /lib/systemd/system" " ${destination} /lib/udev"
220+ mkdir -p " ${destination} " /etc/{NetworkManager/conf.d,X11/xorg.conf.d,apt/apt.conf.d,apt/preferences.d}
221+ mkdir -p " ${destination} " /etc/{cron.d,cron.daily,default,initramfs/post-update.d}
222+ mkdir -p " ${destination} " /etc/kernel/{postinst.d,postrm.d} " ${destination} " /etc/{modprobe.d,profile.d,systemd/system,udev/rules.d,update-motd.d,skel}
208223 call_extension_method " post_family_tweaks_bsp" << - ' POST_FAMILY_TWEAKS_BSP'
209224 * family_tweaks_bsp overrrides what is in the config, so give it a chance to override the family tweaks*
210225 This should be implemented by the config to tweak the BSP, after the board or family has had the chance to.
@@ -265,6 +280,100 @@ function compile_armbian-bsp-cli() {
265280 display_alert " Done building BSP CLI package" " ${destination} " " debug"
266281}
267282
283+ function compile_armbian-bsp-generic() {
284+ : " ${artifact_version:? artifact_version is not set} "
285+ : " ${artifact_name:? artifact_name is not set} "
286+ : " ${BRANCH:? BRANCH is not set} "
287+
288+ display_alert " Creating bsp-generic on branch '${BRANCH} '" " ${artifact_name} :: ${artifact_version} " " info"
289+
290+ # "destination" is used a lot in hooks already. keep this name, even if only for compatibility.
291+ declare cleanup_id=" " destination=" "
292+ prepare_temp_dir_in_workdir_and_schedule_cleanup " deb-bsp-generic" cleanup_id destination # namerefs
293+
294+ mkdir -p " ${destination} " /DEBIAN
295+ cd " ${destination} " || exit_with_error " Failed to cd to ${destination} "
296+
297+ # array of code to be included in preinst, postinst, prerm and postrm scripts (more than default code)
298+ declare -a preinst_functions=()
299+ declare -a postinst_functions=()
300+ declare -a postrm_functions=()
301+
302+ declare -a extra_description=()
303+ [[ " ${EXTRA_BSP_NAME} " != " " ]] && extra_description+=(" (variant '${EXTRA_BSP_NAME} ')" )
304+
305+ # armbianmonitor needs curl, but if it's not there it will install it.
306+ # armbian-resize-filesystem needs parted and fdisk
307+ cat << - EOF > "${destination} "/DEBIAN/control
308+ Package: ${artifact_name}
309+ Version: ${artifact_version}
310+ Architecture: all
311+ Maintainer: Armbian
312+ Section: kernel
313+ Priority: optional
314+ Depends: bash, linux-base, parted, fdisk, bc, u-boot-tools, initramfs-tools, lsb-release, fping
315+ Recommends: bsdutils, util-linux, toilet, curl
316+ Provides: armbian-ramlog, armbian-resize-filesystem, armbian-zram-config, armbian-allwinner-battery, armbian-firstrun, armbian-hardware-monitor, armbian-hardware-optimization, armbian-led-state
317+ Description: Armbian Generic BSP for branch '${BRANCH} ' ${extra_description[@]}
318+ EOF
319+
320+ # armhwinfo, firstrun, armbianmonitor, etc. config file; also sourced in postinst
321+ mkdir -p " ${destination} " /etc
322+
323+ # copy general overlay from packages/bsp-cli
324+ # in practice: packages/bsp-cli and variations of config/optional/...
325+ copy_all_packages_files_for " bsp-generic"
326+
327+ # copy common files from a premade directory structure
328+ # @TODO this includes systemd config, assumes things about serial console, etc, that need dynamism or just to not exist with modern systemd
329+ display_alert " Copying common bsp files" " packages/bsp/common" " info"
330+ run_host_command_logged rsync -av " ${SRC} " /packages/bsp/common/* " ${destination} "
331+ wait_for_disk_sync " after rsync'ing package/bsp/common for bsp-cli"
332+
333+ mkdir -p " ${destination} " /usr/share/armbian/
334+
335+ # get bootscript information.
336+ # declare -A bootscript_info=()
337+ # get_bootscript_info
338+
339+ # won't recreate files if they were removed by user
340+ # TODO: Add proper handling for updated conffiles
341+ # We are runing this script each time apt runs. If this package is removed, file is removed and error is triggered.
342+ # Keeping armbian-apt-updates as a configuration, solve the problem
343+ cat << - EOF > "${destination} "/DEBIAN/conffiles
344+ /usr/lib/armbian/armbian-apt-updates
345+ /etc/X11/xorg.conf.d/01-armbian-defaults.conf
346+ EOF
347+
348+ # Render the postinst/postrm/etc
349+ # set up pre install script; use inline functions
350+ # This is never run in build context; instead, it's source code is dumped inside a file that is packaged.
351+ # It is done this way so we get shellcheck and formatting instead of a huge heredoc.
352+ # ## preinst
353+ # FIXME: this mentions boards, is this relevant to bsp-generic? see below for postrm & postinst too
354+ artifact_package_hook_helper_board_side_functions " preinst" board_side_bsp_cli_preinst " ${preinst_functions[@]} "
355+ unset board_side_bsp_cli_preinst
356+
357+ # ## postrm
358+ artifact_package_hook_helper_board_side_functions " postrm" board_side_bsp_cli_postrm " ${postrm_functions[@]} "
359+ unset board_side_bsp_cli_postrm
360+
361+ # ## postinst -- a bit more complex, extendable via postinst_functions which can be customized in hook above
362+ artifact_package_hook_helper_board_side_functions " postinst" board_side_bsp_cli_postinst_base " ${postinst_functions[@]} " board_side_bsp_cli_postinst_finish
363+ unset board_side_bsp_cli_postinst_base board_side_bsp_cli_postinst_update_uboot_bootscript board_side_bsp_cli_postinst_finish
364+
365+ # fixing permissions (basic), reference: dh_fixperms
366+ find " ${destination} " -print0 2> /dev/null | xargs -0r chown --no-dereference 0:0
367+ find " ${destination} " ! -type l -print0 2> /dev/null | xargs -0r chmod ' go=rX,u+rw,a-s'
368+
369+ # Build / close the package. This will run shellcheck / show the generated files if debugging
370+ dpkg_deb_build " ${destination} " " armbian-bsp-generic"
371+
372+ done_with_temp_dir " ${cleanup_id} " # changes cwd to "${SRC}" and fires the cleanup function early
373+
374+ display_alert " Done building BSP Generic package" " ${destination} " " debug"
375+ }
376+
268377# Reversion function is called with the following parameters:
269378# ${1} == deb_id
270379function reversion_armbian-bsp-cli_deb_contents() {
@@ -282,7 +391,7 @@ function reversion_armbian-bsp-cli_deb_contents() {
282391 depends_base_files=" "
283392 fi
284393 cat << - EOF >> "${control_file_new} "
285- Depends: bash, linux-base, u-boot-tools, initramfs-tools, lsb-release, fping, device-tree-compiler${depends_base_files}
394+ Depends: armbian-bsp-generic, bash, linux-base, u-boot-tools, initramfs-tools, lsb-release, fping, device-tree-compiler${depends_base_files}
286395 Replaces: zram-config, armbian-bsp-cli-${BOARD}${EXTRA_BSP_NAME} (<< ${REVISION} )
287396 Breaks: armbian-bsp-cli-${BOARD}${EXTRA_BSP_NAME} (<< ${REVISION} )
288397 Provides: armbian-bsp-cli
0 commit comments