-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcreate_ipk_package.sh
executable file
·53 lines (41 loc) · 1.47 KB
/
create_ipk_package.sh
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
#!/bin/bash
# Builds IPK package for OpenWRT
set -e
NAME=$1
PACKAGE=wgpull-$1
# "wgpull"
VERSION=$(grep '^version' crates/$NAME/Cargo.toml | sed -E 's/version = "(.+)"/\1/')
# TODO figure out what arch to use for armv7-unknown-linux-musleabihf rust target
ARCH="all"
BUILD_DIR="target/armv7-unknown-linux-musleabihf/minsize"
# The directory where the .ipk will be created
DEST_DIR="ipk-build"
DATA_DIR="$DEST_DIR/data"
CONTROL_DIR="$DEST_DIR/control"
# Create directories
mkdir -p $DATA_DIR
mkdir -p $CONTROL_DIR
# Copy static files
cp -R package/openwrt/* $DATA_DIR/
# Copy the binary
cp $BUILD_DIR/wgpull-$NAME $DATA_DIR/usr/bin/
# Copy the configuration files
mkdir -p $DATA_DIR/etc/wgpull/
cp node.toml lighthouse.toml $DATA_DIR/etc/wgpull/
# Create the control file
echo "Package: $PACKAGE" > $CONTROL_DIR/control
echo "Version: $VERSION" >> $CONTROL_DIR/control
echo "Architecture: $ARCH" >> $CONTROL_DIR/control
echo "Maintainer: Matthias Hecker <[email protected]>" >> $CONTROL_DIR/control
echo "Section: base" >> $CONTROL_DIR/control
echo "Priority: optional" >> $CONTROL_DIR/control
echo "Description: Wireguard Configuration Management" >> $CONTROL_DIR/control
pushd $DEST_DIR
echo $(pwd)
tar --owner=root --group=root -czf data.tar.gz -C data/ .
tar --owner=root --group=root -czf control.tar.gz -C control/ .
echo 2.0 > debian-binary
tar -czf $PACKAGE-$VERSION.ipk debian-binary './control.tar.gz' './data.tar.gz'
popd
cp $DEST_DIR/$PACKAGE-$VERSION.ipk package/
rm -Rf ipk-build