#!/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/Cpanel
install -d -m 755 $buildroot/usr/local/cpanel/Cpanel/Plugins
install -d -m 755 $buildroot/usr/local/cpanel/Cpanel/Template
install -d -m 755 $buildroot/usr/local/cpanel/Cpanel/Template/Plugin
install -d -m 755 $buildroot/usr/local/cpanel/base
install -d -m 755 $buildroot/usr/local/cpanel/base/frontend
install -d -m 755 $buildroot/usr/local/cpanel/base/frontend/jupiter
install -d -m 755 $buildroot/usr/local/cpanel/base/frontend/jupiter/_assets
install -d -m 755 $buildroot/usr/local/cpanel/base/webmail
install -d -m 755 $buildroot/usr/local/cpanel/base/webmail/jupiter
install -d -m 755 $buildroot/usr/local/cpanel/base/webmail/jupiter/_assets
install -d -m 755 $buildroot/usr/local/cpanel/whostmgr
install -d -m 755 $buildroot/usr/local/cpanel/whostmgr/docroot
install -d -m 755 $buildroot/usr/local/cpanel/whostmgr/docroot/images
install -d -m 755 $buildroot/usr/local/cpanel/whostmgr/docroot/templates
install -d -m 755 $buildroot/usr/local/cpanel/whostmgr/docroot/templates/components
install -d -m 755 $buildroot/usr/local/cpanel/whostmgr/docroot/templates/master_templates
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/components
install -d -m 755 $buildroot/var/cpanel/plugins/components/locale
# Installing source files
install -D -m 644 $SOURCE5 $buildroot/usr/local/cpanel/Cpanel/Plugins/Components.pm
install -D -m 644 $SOURCE6 $buildroot/usr/local/cpanel/Cpanel/Plugins/Components/Base.pm
install -D -m 644 $SOURCE7 $buildroot/usr/local/cpanel/Cpanel/Plugins/Components/JSON.pm
install -D -m 644 $SOURCE8 $buildroot/usr/local/cpanel/Cpanel/Plugins/Components/Role/CampaignV1.pm
install -D -m 644 $SOURCE9 $buildroot/usr/local/cpanel/Cpanel/Plugins/Components/Role/CampaignV2.pm
install -D -m 644 $SOURCE10 $buildroot/usr/local/cpanel/Cpanel/Plugins/Components/Role/Cpanel/Template.pm
install -D -m 644 $SOURCE11 $buildroot/usr/local/cpanel/Cpanel/Plugins/Components/Role/Template.pm
install -D -m 644 $SOURCE12 $buildroot/usr/local/cpanel/Cpanel/Plugins/Components/Rules.pm
install -D -m 644 $SOURCE13 $buildroot/usr/local/cpanel/Cpanel/Plugins/Components/Rules/And.pm
install -D -m 644 $SOURCE14 $buildroot/usr/local/cpanel/Cpanel/Plugins/Components/Rules/Base.pm
install -D -m 644 $SOURCE15 $buildroot/usr/local/cpanel/Cpanel/Plugins/Components/Rules/CompanyId.pm
install -D -m 644 $SOURCE16 $buildroot/usr/local/cpanel/Cpanel/Plugins/Components/Rules/CompareVersion.pm
install -D -m 644 $SOURCE17 $buildroot/usr/local/cpanel/Cpanel/Plugins/Components/Rules/CpanelVersion.pm
install -D -m 644 $SOURCE18 $buildroot/usr/local/cpanel/Cpanel/Plugins/Components/Rules/DateRange.pm
install -D -m 644 $SOURCE19 $buildroot/usr/local/cpanel/Cpanel/Plugins/Components/Rules/Distributions.pm
install -D -m 644 $SOURCE20 $buildroot/usr/local/cpanel/Cpanel/Plugins/Components/Rules/DnsOnly.pm
install -D -m 644 $SOURCE21 $buildroot/usr/local/cpanel/Cpanel/Plugins/Components/Rules/FeatureEnabled.pm
install -D -m 644 $SOURCE22 $buildroot/usr/local/cpanel/Cpanel/Plugins/Components/Rules/FeatureFlag.pm
install -D -m 644 $SOURCE23 $buildroot/usr/local/cpanel/Cpanel/Plugins/Components/Rules/IsBeta.pm
install -D -m 644 $SOURCE24 $buildroot/usr/local/cpanel/Cpanel/Plugins/Components/Rules/Not.pm
install -D -m 644 $SOURCE25 $buildroot/usr/local/cpanel/Cpanel/Plugins/Components/Rules/Operator.pm
install -D -m 644 $SOURCE26 $buildroot/usr/local/cpanel/Cpanel/Plugins/Components/Rules/Or.pm
install -D -m 644 $SOURCE27 $buildroot/usr/local/cpanel/Cpanel/Plugins/Components/Rules/Personalization.pm
install -D -m 644 $SOURCE28 $buildroot/usr/local/cpanel/Cpanel/Plugins/Components/Rules/PluginEnabled.pm
install -D -m 644 $SOURCE29 $buildroot/usr/local/cpanel/Cpanel/Plugins/Components/Rules/Tiers.pm
install -D -m 644 $SOURCE30 $buildroot/usr/local/cpanel/Cpanel/Plugins/Components/Rules/Util/Filter.pm
install -D -m 644 $SOURCE31 $buildroot/usr/local/cpanel/Cpanel/Plugins/Components/Rules/Util/FindStartDate.pm
install -D -m 644 $SOURCE32 $buildroot/usr/local/cpanel/Cpanel/Plugins/Components/Rules/Util/NVData.pm
install -D -m 644 $SOURCE33 $buildroot/usr/local/cpanel/Cpanel/Plugins/Components/Rules/Util/Normalize.pm
install -D -m 644 $SOURCE34 $buildroot/usr/local/cpanel/Cpanel/Plugins/Components/Whostmgr.pm
install -D -m 644 $SOURCE35 $buildroot/usr/local/cpanel/Cpanel/Plugins/Components/YAML.pm
install -D -m 644 $SOURCE36 $buildroot/usr/local/cpanel/Cpanel/Plugins/Components/whostmgr/home/homebanner.pm
install -D -m 644 $SOURCE37 $buildroot/usr/local/cpanel/Cpanel/Plugins/State.pm
install -D -m 644 $SOURCE38 $buildroot/usr/local/cpanel/Cpanel/Template/Plugin/Components.pm
install -D -m 644 $SOURCE39 $buildroot/usr/local/cpanel/base/frontend/jupiter/_assets/component.html.tt
install -D -m 644 $SOURCE40 $buildroot/usr/local/cpanel/base/webmail/jupiter/_assets/component.html.tt
install -D -m 644 $SOURCE41 $buildroot/usr/local/cpanel/t/large/Cpanel-Plugins-Components.t
install -D -m 644 $SOURCE42 $buildroot/usr/local/cpanel/t/medium/Cpanel-Plugins-Components-Base.t
install -D -m 644 $SOURCE43 $buildroot/usr/local/cpanel/t/medium/Cpanel-Plugins-Components-JSON.t
install -D -m 644 $SOURCE44 $buildroot/usr/local/cpanel/t/medium/Cpanel-Plugins-Components-Rules-And.t
install -D -m 644 $SOURCE45 $buildroot/usr/local/cpanel/t/medium/Cpanel-Plugins-Components-Rules-Base.t
install -D -m 644 $SOURCE46 $buildroot/usr/local/cpanel/t/medium/Cpanel-Plugins-Components-Rules-CompanyId.t
install -D -m 644 $SOURCE47 $buildroot/usr/local/cpanel/t/medium/Cpanel-Plugins-Components-Rules-CompareVersion.t
install -D -m 644 $SOURCE48 $buildroot/usr/local/cpanel/t/medium/Cpanel-Plugins-Components-Rules-CpanelVersion.t
install -D -m 644 $SOURCE49 $buildroot/usr/local/cpanel/t/medium/Cpanel-Plugins-Components-Rules-DateRange.t
install -D -m 644 $SOURCE50 $buildroot/usr/local/cpanel/t/medium/Cpanel-Plugins-Components-Rules-Distributions.t
install -D -m 644 $SOURCE51 $buildroot/usr/local/cpanel/t/medium/Cpanel-Plugins-Components-Rules-DnsOnly.t
install -D -m 644 $SOURCE52 $buildroot/usr/local/cpanel/t/medium/Cpanel-Plugins-Components-Rules-FeatureEnabled.t
install -D -m 644 $SOURCE53 $buildroot/usr/local/cpanel/t/medium/Cpanel-Plugins-Components-Rules-FeatureFlag.t
install -D -m 644 $SOURCE54 $buildroot/usr/local/cpanel/t/medium/Cpanel-Plugins-Components-Rules-IsBeta.t
install -D -m 644 $SOURCE55 $buildroot/usr/local/cpanel/t/medium/Cpanel-Plugins-Components-Rules-Not.t
install -D -m 644 $SOURCE56 $buildroot/usr/local/cpanel/t/medium/Cpanel-Plugins-Components-Rules-Or.t
install -D -m 644 $SOURCE57 $buildroot/usr/local/cpanel/t/medium/Cpanel-Plugins-Components-Rules-Personalization.t
install -D -m 644 $SOURCE58 $buildroot/usr/local/cpanel/t/medium/Cpanel-Plugins-Components-Rules-PluginEnabled.t
install -D -m 644 $SOURCE59 $buildroot/usr/local/cpanel/t/medium/Cpanel-Plugins-Components-Rules-Tiers.t
install -D -m 644 $SOURCE60 $buildroot/usr/local/cpanel/t/medium/Cpanel-Plugins-Components-Rules-Util-Filter.t
install -D -m 644 $SOURCE61 $buildroot/usr/local/cpanel/t/medium/Cpanel-Plugins-Components-Rules-Util-FindStartDate.t
install -D -m 644 $SOURCE62 $buildroot/usr/local/cpanel/t/medium/Cpanel-Plugins-Components-Rules-Util-NVData.t
install -D -m 644 $SOURCE63 $buildroot/usr/local/cpanel/t/medium/Cpanel-Plugins-Components-Rules.t
install -D -m 644 $SOURCE64 $buildroot/usr/local/cpanel/t/medium/Cpanel-Plugins-Components-YAML.t
install -D -m 644 $SOURCE65 $buildroot/usr/local/cpanel/t/medium/Cpanel-Plugins-Components.t
install -D -m 644 $SOURCE66 $buildroot/usr/local/cpanel/t/medium/Cpanel-Plugins-State.t
install -D -m 644 $SOURCE67 $buildroot/usr/local/cpanel/t/medium/Cpanel-Template-Plugin-Components.t
install -D -m 644 $SOURCE68 $buildroot/usr/local/cpanel/whostmgr/docroot/images/components-error-warning-line.svg
install -D -m 644 $SOURCE69 $buildroot/usr/local/cpanel/whostmgr/docroot/templates/components/banner.tmpl
install -D -m 644 $SOURCE70 $buildroot/usr/local/cpanel/whostmgr/docroot/templates/components/warning-banner.min.js
install -D -m 644 $SOURCE71 $buildroot/usr/local/cpanel/whostmgr/docroot/templates/components/warning-banner.min.js.map
install -D -m 644 $SOURCE72 $buildroot/usr/local/cpanel/whostmgr/docroot/templates/master_templates/component.html.tt
install -D -m 644 $SOURCE73 $buildroot/var/cpanel/plugins/components/README.md
install -D -m 644 $SOURCE74 $buildroot/var/cpanel/plugins/components/homebanner.json
install -D -m 644 $SOURCE75 $buildroot/var/cpanel/plugins/components/locale/de.yaml
echo "Tree for buildroot: $buildroot"
tree $buildroot
