Ticket #46954: Portfile.2

File Portfile.2, 5.9 KB (added by aszostak-partner-eso-org, 10 years ago)

Updated version with all fields set for archive_sites.conf

Line 
1# -*- coding: utf-8; mode: tcl; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- vim:fenc=utf-8:ft=tcl:et:sw=4:ts=4:sts=4
2# $Id: $
3
4PortSystem          1.0
5
6name                esorepo
7version             1.0
8categories          science
9license             GPL
10platforms           darwin
11supported_archs     noarch
12maintainers         eso.org:usd-help
13
14description         ESO repository of software for astronomical data reduction
15
16long_description    \
17    The European Southern Observatory (ESO) maintains and distributes a number \
18    of open source software packages (e.g. data reduction pipelines and front-end \
19    tools) for the astronomical science community. This port provides a convenient \
20    configuration mechanism to add an additional repository URL to allow further \
21    installation of ESO software via MacPorts.
22
23homepage            http://www.eso.org/sci/software
24master_sites        ftp://ftp.eso.org/pub/dfs/pipelines/repositories/macports/
25
26fetch {}
27checksum {}
28test {}
29
30configure {
31  set config_file [open ${prefix}/etc/macports/sources.conf r]
32  set config_data [read ${config_file}]
33  close ${config_file}
34  set already_in_sources 0
35  if {[regexp -line {^ftp://ftp\.eso\.org/pub/dfs/pipelines/repositories/macports/ports\.tar$} ${config_data}]} {
36    set already_in_sources 1
37    ui_error "${prefix}/etc/macports/sources.conf already contains a reference to ftp://ftp.eso.org/pub/dfs/pipelines/repositories/macports/ports.tar."
38  }
39  set config_file [open ${prefix}/etc/macports/archive_sites.conf r]
40  set config_data [read ${config_file}]
41  close ${config_file}
42  set already_in_archive_sites 0
43  if {[regexp -line {^urls\s+ftp://ftp\.eso\.org/pub/dfs/pipelines/repositories/macports/packages$} ${config_data}]} {
44    set already_in_archive_sites 1
45    ui_error "${prefix}/etc/macports/archive_sites.conf already contains a reference to ftp://ftp.eso.org/pub/dfs/pipelines/repositories/macports/packages."
46  }
47  set config_file [open ${prefix}/etc/macports/pubkeys.conf r]
48  set config_data [read ${config_file}]
49  close ${config_file}
50  set already_in_pubkeys 0
51  # Check for the public key reference with a loop rather than regexp, since ${prefix} may contain one of '[](){}?.\'
52  foreach line [split ${config_data} "\n"] {
53    if {"${line}" == "${prefix}/share/${name}/eso-pubkey.pem"} {
54      set already_in_pubkeys 1
55      ui_error "${prefix}/etc/macports/pubkeys.conf already contains a reference to ${prefix}/share/${name}/eso-pubkey.pem."
56      break
57    }
58  }
59  if {${already_in_sources} || ${already_in_archive_sites} || ${already_in_pubkeys}} {
60    ui_error "A number of references to the ESO repository have already been configured."
61    ui_error "Thus, either the repository is already accessible, in which case this port is"
62    ui_error "not necessary, or the configuration is not complete."
63    ui_error "If you want to add the ESO repository to MacPorts with this port then remove"
64    ui_error "all references mentioned above and try install this port again."
65    return -code error "ESO repository might have already been configured manually."
66  }
67}
68
69build {
70  set key_file [open "${workpath}/eso-pubkey.pem" w]
71  puts ${key_file} "-----BEGIN PUBLIC KEY-----"
72  puts ${key_file} "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAy2Au5qRNn/zoRRZ7rdsn"
73  puts ${key_file} "g3lbrM33Iz3xew4yZD5L6LI69qVVfmaUsELreeK+bZAf8bLl5+HYHHvM/pBZq/+6"
74  puts ${key_file} "LBf+NnESVwmKfhEppHim3MqRNyTfSOJAM+J1xt1/dvZkBX8ehZO8piRRaKUPzauW"
75  puts ${key_file} "WhahV417jD37AWKXlRCNPxUtgEk7kRrMQuP4olWWVul+m7piGrDMzQsAOtvEMX5R"
76  puts ${key_file} "J5Ygr3iZNq8WSXhAMqfm6cksxq7kMa8sfpw8lU1jXKfN4wREH3w2oJohkkTYFqUq"
77  puts ${key_file} "0FBnqBkGZlv5e1FUEFW1rnvUpbzOxgDgfdOKwzqNWw2EGl6baQT63iIqa752kCE7"
78  puts ${key_file} "SwIDAQAB"
79  puts ${key_file} "-----END PUBLIC KEY-----"
80  close ${key_file}
81}
82
83destroot {
84  xinstall -m 755 -d ${destroot}${prefix}/share/${name}
85  xinstall -m 644 ${workpath}/eso-pubkey.pem ${destroot}${prefix}/share/${name}/eso-pubkey.pem
86}
87
88pre-activate {
89  set config_file [open ${prefix}/etc/macports/sources.conf a]
90  puts ${config_file} "# ESO MacPorts Portfile source repository (automatically added by ${name})."
91  puts ${config_file} "ftp://ftp.eso.org/pub/dfs/pipelines/repositories/macports/ports.tar"
92  close ${config_file}
93  set config_file [open ${prefix}/etc/macports/archive_sites.conf a]
94  puts ${config_file} "# ESO MacPorts binary package repository (automatically added by ${name})."
95  puts ${config_file} "name             ESO repository"
96  puts ${config_file} "type             tbz2"
97  puts ${config_file} "prefix           /opt/local"
98  puts ${config_file} "applications_dir /Applications/MacPorts"
99  puts ${config_file} "frameworks_dir   /opt/local/Library/Frameworks"
100  puts ${config_file} "urls             ftp://ftp.eso.org/pub/dfs/pipelines/repositories/macports/packages"
101  close ${config_file}
102  set config_file [open ${prefix}/etc/macports/pubkeys.conf a]
103  puts ${config_file} "# ESO RSA public signature key (automatically added by ${name})."
104  puts ${config_file} "${prefix}/share/${name}/eso-pubkey.pem"
105  close ${config_file}
106}
107
108post-activate {
109  ui_msg "*** Please run 'sudo port sync' to synchronise with the ESO repository. ***"
110}
111
112post-deactivate {
113  reinplace -E "/^# ESO MacPorts Portfile source repository \\(automatically added by ${name}\\)\\.\[\[:space:]]*$/{ \
114    N;/\\nftp:\\/\\/ftp\\.eso\\.org\\/pub\\/dfs\\/pipelines\\/repositories\\/macports\\/ports\\.tar\[\[:space:]]*$/d;}" \
115    ${prefix}/etc/macports/sources.conf
116  reinplace -E "/^# ESO MacPorts binary package repository \\(automatically added by ${name}\\)\\.\[\[:space:]]*$/{ \
117    N;N;N;N;N;N;/\\nurls \[\[:space:]]*ftp:\\/\\/ftp\\.eso\\.org\\/pub\\/dfs\\/pipelines\\/repositories\\/macports\\/packages\[\[:space:]]*$/d;}" \
118    ${prefix}/etc/macports/archive_sites.conf
119  reinplace -E "/^# ESO RSA public signature key \\(automatically added by ${name}\\)\\.\[\[:space:]]*$/{ \
120    N;/\\n\[^#]*\\/share\\/${name}\\/eso-pubkey\\.pem\[\[:space:]]*$/d;}" \
121    ${prefix}/etc/macports/pubkeys.conf
122}
123