Skip to content

Commit

Permalink
enhance: remove build.info, replace with build info in APKBUILD #32
Browse files Browse the repository at this point in the history
update build info in APKBUILD when run the workflow.
set place holder in APKBUILD.
add apshd.initd.
  • Loading branch information
ericwq committed Feb 1, 2024
1 parent d95ff55 commit 4f58145
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 14 deletions.
10 changes: 4 additions & 6 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ jobs:
run: |
apk update
apk add git bash
# apk add git nodejs
- name: checkout
uses: actions/checkout@master
Expand Down Expand Up @@ -86,12 +85,11 @@ jobs:
shell: bash
run: |
git config --global --add safe.directory /__w/aprilsh/aprilsh
# touch build.info
echo "tag: `git describe --tags`" >> build.info
echo "commit: `git rev-parse HEAD`" >> build.info
echo "branch: `git rev-parse --abbrev-ref HEAD`" >> build.info
sed -i -e "s/.*_GitVersion=.*/_GitVersion=`git describe --tags`/g" -- "./build/APKBUILD"
sed -i -e "s/.*_GitCommit=.*/_GitCommit=`git rev-parse HEAD`/g" -- "./build/APKBUILD"
sed -i -e "s/.*_GitBranch=.*/_GitBranch=`git rev-parse --abbrev-ref HEAD`/g" -- "./build/APKBUILD"
echo "*****"
head build.info
head -n 21 "./build/APKBUILD"
echo "*****"
# mkdir -p ${{ steps.vars.outputs.PKG_STAGING }}
Expand Down
Empty file removed build.info
Empty file.
17 changes: 10 additions & 7 deletions build/APKBUILD
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,15 @@ depends="musl-locales utmps ncurses-terminfo wezterm-extra-terminfo"
makedepends="go protoc utmps-dev"
install=""
subpackages=""
subpackages="$pkgname-client $pkgname-server"
source="$pkgname-$pkgver.tar.gz::https://github.com/ericwq/aprilsh/archive/refs/tags/$pkgver.tar.gz"
subpackages="$pkgname-client $pkgname-server $pkgname-openrc"
source="$pkgname-$pkgver.tar.gz::https://github.com/ericwq/aprilsh/archive/refs/tags/$pkgver.tar.gz
apshd.initd"
builddir="$srcdir"/$pkgname-$pkgver

#_GitVersion=0.5.14-5-gd95ff55
#_GitCommit=d95ff55cb86eea8d91a360e9b62924e5813855ba
#_GitBranch=main

export PATH=$PATH:~/go/bin
export GOCACHE="${GOCACHE:-"$srcdir/go-cache"}"
export GOTMPDIR="${GOTMPDIR:-"$srcdir"}"
Expand Down Expand Up @@ -45,16 +50,13 @@ build() {
protoc --go_out=. -I . ./protobufs/userInput.proto

# prepare build info
_BuildVersion=`head build.info | grep "tag:" | awk '{print $2}'`
_ModuleName=`head ./go.mod | grep "^module" | awk '{print $2}'`
_BuildTime=`date "+%F %T"`
_GoVersion=`go version | grep "version" | awk '{print $3,$4}'`
_GitCommit=`head build.info | grep "commit:" | awk '{print $2}'`
_GitBranch=`head build.info | grep "branch:" | awk '{print $2}'`

echo "build server start: `date '+%F %T'`"
go build -ldflags="-s -w
-X '${_ModuleName}/frontend.BuildVersion=${_BuildVersion}'
-X '${_ModuleName}/frontend.BuildVersion=${_GitVersion}'
-X '${_ModuleName}/frontend.GoVersion=${_GoVersion}'
-X '${_ModuleName}/frontend.GitCommit=${_GitCommit}'
-X '${_ModuleName}/frontend.GitBranch=${_GitBranch}'
Expand All @@ -64,7 +66,7 @@ build() {

echo "build client start: `date '+%F %T'`"
go build -ldflags="-s -w
-X '${_ModuleName}/frontend.BuildVersion=${_BuildVersion}'
-X '${_ModuleName}/frontend.BuildVersion=${_GitVersion}'
-X '${_ModuleName}/frontend.GoVersion=${_GoVersion}'
-X '${_ModuleName}/frontend.GitCommit=${_GitCommit}'
-X '${_ModuleName}/frontend.GitBranch=${_GitBranch}'
Expand All @@ -86,6 +88,7 @@ check() {
package() {
install -Dm755 "$builddir/bin/apshd" "$pkgdir/usr/bin/apshd"
install -Dm755 "$builddir/bin/apsh" "$pkgdir/usr/bin/apsh"
install -Dm755 "$srcdir/apshd.initd" "$pkgdir/etc/init.d/apshd"
}

client() {
Expand Down
2 changes: 1 addition & 1 deletion build/abuild.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ $ apk update
% cd
% mkdir -p aports/main/aprilsh
% cd ~/aports/main/aprilsh/
% cp /home/ide/develop/aprilsh/build/APKBUILD .
% cp /home/ide/develop/aprilsh/build/* .
% abuild checksum
% abuild -r
% REPODEST=~/packages/3.19 abuild -r
Expand Down
23 changes: 23 additions & 0 deletions build/apshd.initd
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/sbin/openrc-run
# Copyright 2020-2021 Laurent Bercot for Alpine Linux
# Distributed under the terms of the ISC License.
#
name="apshd"
description="server daemon for the apshd service"

command=/usr/bin/apshd
command_args="-verbose 1 2>> /tmp/apshd.log"
command_user=utmp
command_background=yes
directory=/run/utmps
pidfile=/run/utmps/utmpd.pid

depend() {
need utmp-prepare
after bootmisc
before networking
}

start_pre() {
checkpath -d -o utmp:utmp -m 0755 /run/utmps
}

0 comments on commit 4f58145

Please sign in to comment.