#!/bin/bash

source debian/vars.sh

# Clean the build root first
rm -rf $buildroot
# Installing directories
install -d -m 755 $buildroot/usr
install -d -m 755 $buildroot/usr/local
install -d -m 755 $buildroot/usr/local/cpanel
install -d -m 755 $buildroot/usr/local/cpanel/scripts
install -d -m 755 $buildroot/var
install -d -m 755 $buildroot/var/cpanel
install -d -m 755 $buildroot/var/cpanel/plugins
install -d -m 755 $buildroot/var/cpanel/plugins/common
# Installing source files
install -D -m 644 $SOURCE4 $buildroot/usr/local/cpanel/Common/JSONC.pm
install -D -m 644 $SOURCE5 $buildroot/usr/local/cpanel/Common/Plugins/LoadRun.pm
install -D -m 644 $SOURCE6 $buildroot/usr/local/cpanel/Common/Plugins/ServerInfo.pm
install -D -m 644 $SOURCE7 $buildroot/usr/local/cpanel/Common/Plugins/Setup.pm
install -D -m 644 $SOURCE8 $buildroot/usr/local/cpanel/Common/Plugins/Setup/Steps.pm
install -D -m 644 $SOURCE9 $buildroot/usr/local/cpanel/Cpanel/API/Plugins-can_show_promotions.openapi.yaml
install -D -m 644 $SOURCE10 $buildroot/usr/local/cpanel/Cpanel/API/Plugins-create_user.openapi.yaml
install -D -m 644 $SOURCE11 $buildroot/usr/local/cpanel/Cpanel/API/Plugins-get_uuid.openapi.yaml
install -D -m 644 $SOURCE12 $buildroot/usr/local/cpanel/Cpanel/API/Plugins-reset_uuid.openapi.yaml
install -D -m 644 $SOURCE13 $buildroot/usr/local/cpanel/Cpanel/API/Plugins.pm
install -D -m 644 $SOURCE14 $buildroot/usr/local/cpanel/Cpanel/Admin/Modules/Cpanel/plugin_method_cache.pm
install -D -m 644 $SOURCE15 $buildroot/usr/local/cpanel/Cpanel/Admin/Modules/Cpanel/server_id.pm
install -D -m 644 $SOURCE16 $buildroot/usr/local/cpanel/Cpanel/Plugins/Cache.pm
install -D -m 644 $SOURCE17 $buildroot/usr/local/cpanel/Cpanel/Plugins/Promotions.pm
install -D -m 644 $SOURCE18 $buildroot/usr/local/cpanel/Cpanel/Plugins/RestApiClient.pm
install -D -m 644 $SOURCE19 $buildroot/usr/local/cpanel/Cpanel/Plugins/ServerId.pm
install -D -m 644 $SOURCE20 $buildroot/usr/local/cpanel/Cpanel/Plugins/UUID.pm
install -D -m 644 $SOURCE21 $buildroot/usr/local/cpanel/Whostmgr/API/1/EcosystemFeatures-local_disable.openapi.yaml
install -D -m 644 $SOURCE22 $buildroot/usr/local/cpanel/Whostmgr/API/1/EcosystemFeatures-local_enable.openapi.yaml
install -D -m 644 $SOURCE23 $buildroot/usr/local/cpanel/Whostmgr/API/1/EcosystemFeatures.pm
install -D -m 700 $SOURCE24 $buildroot/usr/local/cpanel/scripts/manage_extra_marketing
install -D -m 700 $SOURCE25 $buildroot/usr/local/cpanel/scripts/modify_featurelist
install -D -m 700 $SOURCE26 $buildroot/usr/local/cpanel/scripts/run_plugin_lifecycle
install -D -m 644 $SOURCE27 $buildroot/usr/local/cpanel/t/medium/Common-JSONC.t
install -D -m 644 $SOURCE28 $buildroot/usr/local/cpanel/t/medium/Common-Plugins-LoadRun.t
install -D -m 644 $SOURCE29 $buildroot/usr/local/cpanel/t/medium/Common-Plugins-Setup-Steps.t
install -D -m 644 $SOURCE30 $buildroot/usr/local/cpanel/t/medium/Common-Plugins-Setup.t
install -D -m 644 $SOURCE31 $buildroot/usr/local/cpanel/t/medium/Common-Plugins-Utils.t
install -D -m 644 $SOURCE32 $buildroot/usr/local/cpanel/t/medium/Cpanel-API-Plugins.t
install -D -m 644 $SOURCE33 $buildroot/usr/local/cpanel/t/medium/Cpanel-Admin-Modules-Cpanel-plugin_method_cache.t
install -D -m 644 $SOURCE34 $buildroot/usr/local/cpanel/t/medium/Cpanel-Admin-Modules-Cpanel-server_id.t
install -D -m 644 $SOURCE35 $buildroot/usr/local/cpanel/t/medium/Cpanel-Plugins-Cache.t
install -D -m 644 $SOURCE36 $buildroot/usr/local/cpanel/t/medium/Cpanel-Plugins-Promotions.t
install -D -m 644 $SOURCE37 $buildroot/usr/local/cpanel/t/medium/Cpanel-Plugins-RestApiClient.t
install -D -m 644 $SOURCE38 $buildroot/usr/local/cpanel/t/medium/Cpanel-Plugins-ServerId.t
install -D -m 644 $SOURCE39 $buildroot/usr/local/cpanel/t/medium/Cpanel-Plugins-UUID.t
install -D -m 644 $SOURCE40 $buildroot/usr/local/cpanel/t/medium/Whostmgr-API-1-EcosystemFeatures_plugin.t
install -D -m 644 $SOURCE41 $buildroot/var/cpanel/plugins/common/README.md
echo "Tree for buildroot: $buildroot"
tree $buildroot
