summaryrefslogtreecommitdiff
path: root/user/openjdk8/maintain
blob: 41133cf7fe07d0d928acecd5cdc54f697a02d1b9 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
#!/bin/sh -e

##
# The purpose of this script is for reproducibility,
# not to be used except for creation of the bootstrap
# tarballs and to document how they were created for
# the RC3 release. This is a TEMPORARY WORKAROUND so
# that we do not unnecessarily postpone RC3 over Java.
#
# Files are uploaded to:
#
# * https://distfiles.adelielinux.org/source/openjdk/
#
# This script downloads RC2 'openjdk8' .apk files,
# extracts some JVM bits, and produces tarballs for
# bootstrapping this package, suitable for upload to
# https://distfiles.adelielinux.org/source/openjdk/.
#
# Shared libraries may be added for compatibility to
# avoid using system-provided libraries which may be
# incompatible with the existing binaries.
#
# Note: checksums may vary between 'tar' versions or
# implementations; please do not rely on this. The
# output has been verified by 'diff -qr', may differ
# in packing order, compression, or headers only.
#
# Based on https://git.adelielinux.org/-/snippets/172.
#
HERE="$(dirname $(readlink -f ${0}))";


##
# mirror for input binaries
#
host=https://distfiles.adelielinux.org;
from=1.0-rc2;


##
# supported architectures
#
# Note: empty or broken tarballs may be created for
# architectures that are missing ingredients. We do
# not treat this as an error; we want to have a full
# set of bootstrap tarballs, fix as needed, and not
# have to update code in multiple places.
#
arch="aarch64 armv7 ppc64 ppc x86_64 pmmx";


##
# packages to fetch
#
# Note: order is important; we assume tree structure
# during the manipulation stage. Does not matter for
# extraction, which we do before manipulation anyway.
# This is easily refactored but I can't be bothered.
#
apks="
user/openjdk8-jre-lib:8.252.09-r0
user/openjdk8-jre-base:8.252.09-r0
user/openjdk8-jre:8.252.09-r0
user/openjdk8:8.252.09-r0
system/libffi:3.2.1-r6
";


##
# global variables
#
vers=; # 3.2.1-r6
repo=; # system
name=; # libffi


##
# supporting routines
#
set_metadata ()
{
    vers=${apk#*:};
    repo=${apk%/*};
    temp=${apk%:${vers}};
    name=${temp#*/};
}

brk_unsupport ()
{
    printf "E: target is missing dependency '%s'.\n" "${1}";
    break;
}


##
# H. P. Lovecraft
# knows this is daft.
#
for cpu in $arch; do

    printf "\n%s\n" "$cpu";

    # output directory (specific to APKBUILD)
    keep="${HERE}"/$cpu/boot-home;

    # always start fresh
    rm -fr "${HERE}"/$cpu;
    mkdir -p "${keep}";

    # initial download/extract
    for apk in $apks; do

        set_metadata $apk;

        printf "  * %s\n" "$name-$vers.apk";

        curl -s $host/adelie/$from/$repo/$cpu/$name-$vers.apk \
            | tar -C "${HERE}"/$cpu -xzf - 2>/dev/null \
            || brk_unsupport "$name-$vers.apk"; # armv7

    done

    # optional special-case manipulation
    for apk in $apks; do

        set_metadata $apk;

        case "${name}" in
            libffi)
                # naming does not match $cpu!
                # e.g. { x86_64 --> amd64, ppc64 --> ppc, pmmx --> i386 }
                # so we look for a known file and work relative to it
                _tmp=$(find "${keep}" -name libjvm.so || brk_unsupport "libjvm.so"); # armv7
                _dst=${_tmp%/*};
                cp -a $(find "${HERE}"/$cpu/usr/lib -name "libffi.so*") \
                    "${_dst}" \
                    || brk_unsupport "libffi.so*"; # armv7
                ;;
            openjdk8)
                cp -a "${HERE}"/$cpu/usr/lib/jvm/java-1.8-openjdk \
                    "${keep}"/$cpu \
                    || brk_unsupport "openjdk8"; # armv7
                ;;
        esac

    done

    # create bootstrap tarball
    (
        cd "${HERE}"/$cpu;

        # cleanup unnecessary files (specific to APKBUILD)
        rm -fr usr;

        chown -R 1000:1000 .;
        tar -cJf "${HERE}"/openjdk8-bootstrap-$cpu.txz .;
    )

    # cleanup intermediates
    rm -fr "${HERE}"/$cpu;

done