1#------------------------------------------------------------------------------- 2# Packages for OBOS alpha/beta testers 3#------------------------------------------------------------------------------- 4 5rule Copy 6{ 7 if $(2) { 8 SEARCH on $(2) = $(SEARCH_SOURCE) ; 9 Depends $(1) : <build>copyattr $(2) ; 10 Copy1 $(1) : <build>copyattr $(2) ; 11 } 12} 13 14actions Copy1 15{ 16 $(HOST_ADD_BUILD_COMPATIBILITY_LIB_DIR) 17 "$(2[1])" -d "$(2[2-])" "$(1)" 18} 19 20rule Packages 21{ 22 local packagenames = $(1) ; 23 local packagefiles = $(2) ; 24 local path = $(3) ; 25 for name in $(packagenames) { 26 Package $(name) : $(packagefiles) : $(path) ; 27 } 28} 29 30rule FPackageConfigSubPath 31{ 32 # FPackageConfigSubPath <packagename> 33 # 34 local packagename = $(1) ; 35 36 local configSubPath ; 37 on $(packagename) { 38 if $(PLATFORM) = host { 39 configSubPath = $(HOST_PLATFORM) $(HOST_ARCH) ; 40 } else { 41 configSubPath = $(TARGET_PLATFORM) $(TARGET_ARCH) ; 42 } 43 44 if $(DEBUG) = 0 { 45 configSubPath += release ; 46 } else { 47 configSubPath += debug_$(DEBUG) ; 48 } 49 } 50 51 return $(configSubPath) ; 52} 53 54rule Package 55{ 56 local packagename = $(1) ; 57 local packagefiles = $(2) ; 58 local path = $(3) ; 59 60 local configSubPath = [ FPackageConfigSubPath $(packagename) ] ; 61 local packagezip = $(packagename:S=.zip:G=_packages) ; 62 local targetDir = [ FDirName $(HAIKU_PACKAGE_DIR) $(configSubPath) ] ; 63 local packagedir = [ FDirName $(targetDir) $(packagename) ] ; 64 65 local installscript = install.sh ; 66 local packageinstallscript = $(installscript:G=_packages!$(packagename)) ; 67 local installzip = install.zip ; 68 local packageinstallzip = $(installzip:G=_packages!$(packagename)) ; 69 70 local packageobjectdir = [ FDirName $(HAIKU_PACKAGE_OBJECT_DIR) 71 $(configSubPath) $(packagename) ] ; 72 local packagefiledir = [ FDirName $(packageobjectdir) $(path) ] ; 73 local packagefileinstallzip 74 = $(installzip:G=_package_objects!$(packagename)) ; 75 76 # add the files to the install.zip 77 local packagefilegrist = [ FGrist _package_files $(packagename) $(path) ] ; 78 for file in $(packagefiles) { 79 if $(path[0]) = "boot" { 80 local packagefile = $(file:G=$(packagefilegrist)) ; 81 MakeLocate $(packagefile) : $(packagefiledir) ; 82 Copy $(packagefile) : $(file) ; 83 Clean cleanPackages : $(packagefile) ; 84 PackageInstallZip $(packagefileinstallzip) : $(packagefile) ; 85 } else { 86 local packagefile = $(file:G=_packages!$(packagename)) ; 87 MakeLocate $(packagefile) : $(packagedir) ; 88 Copy $(packagefile) : [ FGristFiles $(file) ] ; 89 Clean cleanPackages : $(packagefile) ; 90 Depends $(packagezip) : $(packagefile) ; 91 } 92 } 93 94 # general setup for this package -- only on first invocation 95 if ! $(_setup_$(packagename)) { 96 _setup_$(packagename) = true ; 97 98 NotFile $(packagename) ; 99 LocalDepends packages : $(packagename) ; 100 101 MakeLocate $(packagezip) : $(targetDir) ; 102 MakeLocate $(packageinstallscript) : $(packagedir) ; 103 MakeLocate $(packageinstallzip) : $(packagedir) ; 104 MakeLocate $(packagefileinstallzip) : $(packageobjectdir) ; 105 106 PackageInstallScript $(packageinstallscript) : $(packagedir) ; 107 LinkInstallZip $(packageinstallzip) : $(packagefileinstallzip) ; 108 Depends $(packagename) : $(packagezip) ; 109 PackageZip $(packagezip) : $(packagedir) 110 : $(packageinstallscript) $(packageinstallzip) ; 111 } 112 113} 114 115rule PackageSymLink 116{ 117 # PackageSymLink <packageName> : <symlink path components> 118 # : <symlink target> 119 # 120 local packagename = $(1) ; 121 local symlinkPath = $(2) ; 122 local symlinkTarget = $(3) ; 123 124 local configSubPath = [ FPackageConfigSubPath $(packagename) ] ; 125 126 local symlinkDir = [ FReverse $(symlinkPath) ] ; 127 local symlink = $(symlinkDir[1]) ; 128 symlinkDir = [ FReverse $(symlinkDir[2-]) ] ; 129 local symlinkGrist = [ FGrist _package $(packagename) $(symlinkDir) ] ; 130 symlink = $(symlink:G=$(symlinkGrist)) ; 131 132 if $(symlinkDir[1]) = boot { 133 local installzip = install.zip ; 134 local packagefileinstallzip 135 = $(installzip:G=_package_objects!$(packagename)) ; 136 137 local packageobjectdir = [ FDirName $(HAIKU_PACKAGE_OBJECT_DIR) 138 $(configSubPath) $(packagename) ] ; 139 symlinkDir = [ FDirName $(packageobjectdir) $(symlinkDir) ] ; 140 141 PackageInstallZip $(packagefileinstallzip) : $(symlink) ; 142 143 } else { 144 local packagezip = $(packagename:S=.zip:G=_packages) ; 145 146 local packagedir = [ FDirName $(HAIKU_PACKAGE_DIR) $(configSubPath) 147 $(packagename) ] ; 148 symlinkDir = [ FDirName $(packagedir) $(symlinkDir) ] ; 149 150 Depends $(packagezip) : $(symlink) ; 151 } 152 153 MakeLocate $(symlink) : $(symlinkDir) ; 154 SymLink $(symlink) : $(symlinkTarget) : false ; 155 Clean cleanPackages : $(symlink) ; 156} 157 158rule PackageDriverSymLink 159{ 160 # PackageDriverSymLink <packageName> : <devRelativeSymlinkComponents> ; 161 # <packageName>: Package name. 162 # <devRelativeSymlinkComponents>: Path components relative to the 163 # /boot/home/config/add-ons/kernel/drivers/dev directory, e.g. 164 # "graphics mga.driver" (no quotation, of course). 165 # 166 local packageName = $(1) ; 167 local symlinkComponents = $(2) ; 168 169 # construct the symlink contents 170 local symlinkPath = [ FReverse $(symlinkComponents) ] ; 171 symlinkPath = bin $(symlinkPath[1]) ; 172 173 for i in $(symlinkComponents) { 174 symlinkPath = $(DOTDOT) $(symlinkPath) ; 175 } 176 177 PackageSymLink $(packageName) 178 : boot home config add-ons kernel drivers dev $(symlinkComponents) 179 : [ FDirName $(symlinkPath) ] ; 180} 181 182rule PackageZip 183{ 184 local dir = $(2:G=dir) ; 185 Depends $(1) : $(dir) $(3) ; 186 Clean cleanPackages : $(1) ; 187 PackageZip1 $(1) : $(dir) ; 188} 189 190actions together PackageZip1 { 191 cd "$(2:P)" ; 192 zip -rq "$(1:BS)" "$(2:BS)" ; 193} 194 195rule PackageInstallScript 196{ 197 MakeLocate $(1) : $(2) ; 198 Clean cleanPackages : $(1) ; 199 PackageInstallScript1 $(1) : $(2:G=dir) ; 200} 201 202actions together PackageInstallScript1 203{ 204echo '#!/bin/sh 205base=`dirname "$0"` 206cd "$base" 207if [ -n "$TTY" ] 208then 209 unzip -d / install.zip 210else 211 response=`alert "Would you like to automatically overwrite existing files, or receive a prompt?" "Overwrite" "Prompt"` 212 if [ $response == "Overwrite" ] 213 then 214 unzip -od / install.zip 215 alert "Finished installing" "Thanks" 216 else 217 if [ -e /boot/beos/apps/Terminal ] 218 then 219 terminal=/boot/beos/apps/Terminal 220 else 221 terminal=`query Terminal | head -1` 222 fi 223 $terminal -t "installer" /bin/sh "$0" 224 fi 225fi' > "$(1)" ; 226 chmod 755 "$(1)" ; 227} 228 229rule PackageInstallZip 230{ 231 Depends $(1) : $(2) ; 232 Clean cleanPackages : $(1) ; 233} 234 235actions together PackageInstallZip 236{ 237 cd "$(1:P)" ; 238 zip -rqy "$(1:BS)" boot ; 239} 240 241rule LinkInstallZip 242{ 243 Depends $(1) : $(2) ; 244 Clean cleanPackages : $(1) ; 245} 246 247actions together LinkInstallZip 248{ 249 ln -sf "`pwd`/$(2)" "$(1)" ; 250} 251