-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.sh
More file actions
executable file
·82 lines (63 loc) · 2.13 KB
/
build.sh
File metadata and controls
executable file
·82 lines (63 loc) · 2.13 KB
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
pushd() {
command pushd "$@" > /dev/null
}
popd() {
command popd "$@" > /dev/null
}
# The --owner and --group options are not supported by the macOS tar
# So we use gtar if we are on macOS
#
# To install run "brew install gnu-tar"
if [[ $(uname) == "Darwin" ]]; then
TAR=$(which gtar)
else
TAR=$(which tar)
fi
PYTHON_VERSION=3.13
ALPINE_VERSION=3.21
ALPINE_ARCH=armv7
mkdir -p tmp
# For each package in packages/
for package in packages/*; do
# Read package name from alpine-name
ALPINE_FILE=$(cat ${package}/alpine-name)
ALPINE_BRANCH=${ALPINE_FILE%/*}
ALPINE_PACKAGE_NAME=${ALPINE_FILE#*/}
PACKAGE_NAME=${ALPINE_PACKAGE_NAME%.*}
echo "Building ${package}"
# Clean up the tmp directory
rm -rf tmp/${package}
# Create a directory for the package in tmp/
mkdir -p tmp/${package}
mkdir -p tmp/${package}/data
# Copy the control folder
cp -r ${package}/control tmp/${package}/control
# Download the package
curl --silent -o tmp/${ALPINE_PACKAGE_NAME} https://dl-cdn.alpinelinux.org/alpine/v${ALPINE_VERSION}/${ALPINE_BRANCH}/${ALPINE_ARCH}/${ALPINE_PACKAGE_NAME}
# Extract the package
$TAR --warning=no-unknown-keyword -xf tmp/${ALPINE_PACKAGE_NAME} -C tmp/${package}/data
# Remove the package
rm tmp/${ALPINE_PACKAGE_NAME}
# Alpine packages bring a .PKGINFO and a .SIGN file that we need to remove
rm -rf tmp/${package}/data/.PKGINFO
rm -rf tmp/${package}/data/.SIGN*
# Create the debian-binary file
echo 2.0 > tmp/${package}/debian-binary
pushd tmp/${package}/control
$TAR --numeric-owner --group=0 --owner=0 -czf ../control.tar.gz ./*
popd
pushd tmp/${package}/data
# In our system /lib is a symlink to /usr/lib and opkg complains if we
# try to install a package that has a file in /lib.
# So move all files in /lib to /usr/lib
if [ -d lib ]; then
mkdir -p usr/lib
mv lib/* usr/lib/
rm -rf lib
fi
$TAR --numeric-owner --group=0 --owner=0 -czf ../data.tar.gz ./*
popd
pushd tmp/${package}
$TAR --numeric-owner --group=0 --owner=0 -cf ../${PACKAGE_NAME}-alpine${ALPINE_VERSION}-${ALPINE_ARCH}.ipk ./debian-binary ./data.tar.gz ./control.tar.gz
popd
done