|
| 1 | +# template name attributes |
| 2 | +%define templatename fedora |
| 3 | +%define templatever 27 |
| 4 | +%define templatearch x86_64 |
| 5 | + |
| 6 | +# Human-readable attributes |
| 7 | +%define fullname Fedora %templatever |
| 8 | +%define fulltemplatearch (for AMD64/Intel EM64T) |
| 9 | + |
| 10 | +# template dirs |
| 11 | +%define templatedir /vz/template/%templatename/%templatever/%templatearch/config |
| 12 | +%define ostemplatedir %templatedir/os/default |
| 13 | + |
| 14 | +# vzpkgenv related |
| 15 | +%define pkgman 410x64 |
| 16 | +%define package_manager rpm%pkgman |
| 17 | +%define package_manager_pkg vzpkgenv%pkgman >= 7.0.0 |
| 18 | + |
| 19 | +# Files lists |
| 20 | +%define files_lst() \ |
| 21 | +find %1 -type d -printf '%%%dir %%%attr(%m,root,root) %p\\n' | sed "s,%buildroot,,g" >> %2\ |
| 22 | +find %1 -type f -printf '%%%config %%%attr(%m,root,root) %p\\n' | sed "s,%buildroot,,g" >> %2\ |
| 23 | +%nil |
| 24 | + |
| 25 | +# Sources list |
| 26 | +%define sources_lst() \ |
| 27 | +%((cd %_sourcedir;\ |
| 28 | +s=1;\ |
| 29 | +for tmpl in %1; do\ |
| 30 | +sources=$tmpl"_*";\ |
| 31 | +for file in $sources; do\ |
| 32 | +echo Source$s: $file;\ |
| 33 | +s=$((s+1))\ |
| 34 | +done;\ |
| 35 | +done))\ |
| 36 | +%nil |
| 37 | + |
| 38 | +# Obsoletes list |
| 39 | +%define obsoletes_lst() \ |
| 40 | +%((for tmpl in %1; do\ |
| 41 | +[ $tmpl = os ] && continue;\ |
| 42 | +echo "Obsoletes: $tmpl-%templatename-%templatever-%templatearch-ez < 7.0.0";\ |
| 43 | +echo "Provides: $tmpl-%templatename-%templatever-%templatearch-ez = %version-%release";\ |
| 44 | +done))\ |
| 45 | +%nil |
| 46 | + |
| 47 | +# Templates list - packages file should be always present in any template! |
| 48 | +%define templates_list() %((cd %_sourcedir; for f in *_packages; do echo -n "${f%_*} "; done)) |
| 49 | + |
| 50 | +Summary: %fullname %fulltemplatearch Template set |
| 51 | +Name: %templatename-%templatever-%templatearch-ez |
| 52 | +Group: Virtuozzo/Templates |
| 53 | +License: GPL |
| 54 | +Version: 7.0.0 |
| 55 | +Release: 1%{?dist} |
| 56 | +BuildRoot: %_tmppath/%name-root |
| 57 | +BuildArch: noarch |
| 58 | +Requires: %package_manager_pkg |
| 59 | + |
| 60 | +# template source files |
| 61 | +%sources_lst %templates_list |
| 62 | + |
| 63 | +# obsoletes |
| 64 | +%obsoletes_lst %templates_list |
| 65 | + |
| 66 | +%description |
| 67 | +%fullname %fulltemplatearch packaged as a Virtuozzo Template set. |
| 68 | + |
| 69 | +%install |
| 70 | +installfile() { |
| 71 | + local sourcename=%_sourcedir/${1}_$4 |
| 72 | + local mode=$2 |
| 73 | + local dir=$3 |
| 74 | + local name=$4 |
| 75 | + |
| 76 | + [ ! -f $sourcename ] && return |
| 77 | + |
| 78 | + install -m $mode $sourcename $dir/$name |
| 79 | +} |
| 80 | + |
| 81 | +rm -f files.lst |
| 82 | +for tmpl in %templates_list; do |
| 83 | + [ $tmpl = "os" ] && dir=%buildroot/%ostemplatedir || \ |
| 84 | + dir=%buildroot/%templatedir/app/$tmpl/default |
| 85 | + |
| 86 | + mkdir -p $dir |
| 87 | + |
| 88 | + if [ $tmpl = "os" ]; then |
| 89 | + # Os template only files |
| 90 | + |
| 91 | + # Text |
| 92 | + echo "%fullname %fulltemplatearch Virtuozzo Template" > $dir/description |
| 93 | + echo "%fullname %fulltemplatearch Virtuozzo Template" > $dir/summary |
| 94 | + |
| 95 | + # Package manager |
| 96 | + echo "%package_manager" > $dir/package_manager |
| 97 | + |
| 98 | + # Disable upgrade |
| 99 | + touch $dir/upgradable_versions |
| 100 | + |
| 101 | + # Pkgman environment |
| 102 | + installfile $tmpl 0644 $dir environment |
| 103 | + |
| 104 | + # vzctl-related |
| 105 | + installfile $tmpl 0644 $dir distribution |
| 106 | + |
| 107 | + # Kernel virtualization |
| 108 | + installfile $tmpl 0644 $dir osrelease |
| 109 | + |
| 110 | + # Os template cache scripts |
| 111 | + installfile $tmpl 0755 $dir pre-cache |
| 112 | + installfile $tmpl 0755 $dir post-cache |
| 113 | + installfile $tmpl 0755 $dir mid-pre-install |
| 114 | + installfile $tmpl 0755 $dir mid-post-install |
| 115 | + installfile $tmpl 0755 $dir pre-upgrade |
| 116 | + installfile $tmpl 0755 $dir post-upgrade |
| 117 | + else |
| 118 | + # App templates only files |
| 119 | + |
| 120 | + # Text |
| 121 | + echo "$tmpl for %fullname %fulltemplatearch Virtuozzo Template" > $dir/description |
| 122 | + echo "$tmpl for %fullname %fulltemplatearch Virtuozzo Template" > $dir/summary |
| 123 | + fi |
| 124 | + |
| 125 | + # Common things |
| 126 | + |
| 127 | + # Installation sources |
| 128 | + installfile $tmpl 0644 $dir mirrorlist |
| 129 | + installfile $tmpl 0644 $dir repositories |
| 130 | + |
| 131 | + # Packages |
| 132 | + installfile $tmpl 0644 $dir packages |
| 133 | + |
| 134 | + # Scripts |
| 135 | + installfile $tmpl 0755 $dir pre-install |
| 136 | + installfile $tmpl 0755 $dir pre-install-hn |
| 137 | + installfile $tmpl 0755 $dir post-install |
| 138 | + installfile $tmpl 0755 $dir post-install-hn |
| 139 | + |
| 140 | + # Versioning |
| 141 | + echo "%release" > $dir/release |
| 142 | + echo "%version" > $dir/version |
| 143 | + %files_lst $dir files.lst |
| 144 | +done |
| 145 | + |
| 146 | +%files -f files.lst |
| 147 | + |
| 148 | +%changelog |
| 149 | +* Wed Nov 15 2017 mechleg <[email protected]> 7.0.0-1 |
| 150 | +- Initial release |
0 commit comments