#!/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/Cpanel/API/Plugins-can_show_promotions.openapi.yaml
install -D -m 644 $SOURCE5 $buildroot/usr/local/cpanel/Cpanel/API/Plugins-get_uuid.openapi.yaml
install -D -m 644 $SOURCE6 $buildroot/usr/local/cpanel/Cpanel/API/Plugins-reset_uuid.openapi.yaml
install -D -m 644 $SOURCE7 $buildroot/usr/local/cpanel/Cpanel/API/Plugins.pm
install -D -m 644 $SOURCE8 $buildroot/usr/local/cpanel/Cpanel/Admin/Modules/Cpanel/plugin_method_cache.pm
install -D -m 644 $SOURCE9 $buildroot/usr/local/cpanel/Cpanel/Plugins/Cache.pm
install -D -m 644 $SOURCE10 $buildroot/usr/local/cpanel/Cpanel/Plugins/Promotions.pm
install -D -m 644 $SOURCE11 $buildroot/usr/local/cpanel/Cpanel/Plugins/RestApiClient.pm
install -D -m 644 $SOURCE12 $buildroot/usr/local/cpanel/Cpanel/Plugins/UUID.pm
install -D -m 700 $SOURCE13 $buildroot/usr/local/cpanel/scripts/manage_extra_marketing
install -D -m 644 $SOURCE14 $buildroot/usr/local/cpanel/t/medium/Cpanel-API-Plugins.t
install -D -m 644 $SOURCE15 $buildroot/usr/local/cpanel/t/medium/Cpanel-Admin-Modules-Cpanel-plugin_method_cache.t
install -D -m 644 $SOURCE16 $buildroot/usr/local/cpanel/t/medium/Cpanel-Plugins-Cache.t
install -D -m 644 $SOURCE17 $buildroot/usr/local/cpanel/t/medium/Cpanel-Plugins-Promotions.t
install -D -m 644 $SOURCE18 $buildroot/usr/local/cpanel/t/medium/Cpanel-Plugins-RestApiClient.t
install -D -m 644 $SOURCE19 $buildroot/usr/local/cpanel/t/medium/Cpanel-Plugins-UUID.t
install -D -m 644 $SOURCE20 $buildroot/var/cpanel/plugins/common/README.md
echo "Tree for buildroot: $buildroot"
tree $buildroot
