[forgejo] rewrite
This commit is contained in:
parent
5dad8a25be
commit
9b92bb181a
3 changed files with 164 additions and 182 deletions
164
n/forgejo-bin/SlackBuild
Executable file
164
n/forgejo-bin/SlackBuild
Executable file
|
@ -0,0 +1,164 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
CWD=$(pwd)
|
||||||
|
|
||||||
|
PRGNAM=$(basename $CWD)
|
||||||
|
VERSION=${VERSION:-$(curl -q https://codeberg.org/forgejo/forgejo/releases.rss | grep title | head -n2 | tail -n1 | sed 's|<title>||g' | sed 's|</title>||g' | xargs)}
|
||||||
|
ARCH=${ARCH:-$(uname -m)}
|
||||||
|
BUILD=${BUILD:-1}
|
||||||
|
TAG=${TAG:-gwh}
|
||||||
|
|
||||||
|
TMP=${TMP:-/tmp/$TAG}
|
||||||
|
PKG=$TMP/pkg-$PRGNAM
|
||||||
|
OUTPUT=${OUTPUT:-/tmp}
|
||||||
|
PREFIX=/usr
|
||||||
|
|
||||||
|
REPOSITORY=${REPOSITORY:-/home/installs/SlackBuilds/_repositories/$PRGNAM}
|
||||||
|
|
||||||
|
mkdir -p $REPOSITORY
|
||||||
|
|
||||||
|
GITEA_WORK_DIR=/var/lib/gitea
|
||||||
|
|
||||||
|
# Check if the gitea user and group exist. If not, then bail.
|
||||||
|
if [ "$(id -g gitea 2> /dev/null)" != "817" -o "$(id -u gitea 2> /dev/null)" != "817" ]; then
|
||||||
|
echo " You must have an 'gitea' user and group to run this script."
|
||||||
|
echo " # groupadd -g 817 gitea"
|
||||||
|
echo " # useradd -d /var/lib/gitea -g gitea -s /bin/bash -u 817 gitea --system "
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo $ARCH | grep -q arm && SRC_ARCH=arm-7
|
||||||
|
echo $ARCH | grep -q 86 && SRC_ARCH=386
|
||||||
|
echo $ARCH | grep -q 64 && SRC_ARCH=amd64
|
||||||
|
|
||||||
|
mkdir -p $REPOSITORY
|
||||||
|
|
||||||
|
if [ ! -e $REPOSITORY/forgejo-${VERSION}-linux-${SRC_ARCH}.xz ]; then
|
||||||
|
wget -c https://codeberg.org/forgejo/forgejo/releases/download/${VERSION}/forgejo-${VERSION#v}-linux-${SRC_ARCH}.xz -O $REPOSITORY/forgejo-${VERSION}-linux-${SRC_ARCH}.xz
|
||||||
|
fi
|
||||||
|
xz -d $REPOSITORY/forgejo-${VERSION}-linux-${SRC_ARCH}.xz
|
||||||
|
|
||||||
|
rm -fr $PKG
|
||||||
|
|
||||||
|
mkdir -p $PKG$PREFIX/bin
|
||||||
|
cp $REPOSITORY/forgejo-${VERSION}-linux-${SRC_ARCH} $PKG$PREFIX/bin/gitea
|
||||||
|
chmod +x $PKG$PREFIX/bin/gitea
|
||||||
|
|
||||||
|
mkdir -p $PKG/etc/gitea/
|
||||||
|
cp $CWD/app.ini $PKG/etc/gitea/app.ini.new
|
||||||
|
chown -R gitea:gitea $PKG/etc/gitea
|
||||||
|
chmod 770 $PKG/etc/gitea
|
||||||
|
|
||||||
|
mkdir -p $PKG${GITEA_WORK_DIR}/{custom,data/gitea-repositories,indexers,public,log,.ssh}
|
||||||
|
chown -R gitea:gitea $PKG/var/lib/gitea
|
||||||
|
chmod 750 $PKG${GITEA_WORK_DIR}/{data,indexers,log}
|
||||||
|
|
||||||
|
mkdir -p $PKG/var/log/gitea
|
||||||
|
chown -R gitea:gitea $PKG/var/log/gitea
|
||||||
|
|
||||||
|
( cd $PKG
|
||||||
|
find . | xargs file | grep "executable" | grep ELF | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null || true
|
||||||
|
find . | xargs file | grep "shared object" | grep ELF | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null
|
||||||
|
)
|
||||||
|
|
||||||
|
mkdir -p $PKG/etc/rc.d/
|
||||||
|
cat <<EOF > $PKG/etc/rc.d/rc.gitea
|
||||||
|
#!/bin/bash
|
||||||
|
#Slackware startup deamon script
|
||||||
|
|
||||||
|
# Name of Service
|
||||||
|
NAME="Forgejo Daemon"
|
||||||
|
|
||||||
|
# Command to run
|
||||||
|
CMD="/usr/bin/gitea"
|
||||||
|
|
||||||
|
# user used to run the daemon
|
||||||
|
USERNAME=gitea
|
||||||
|
|
||||||
|
# Process name of daemon, for killing it.
|
||||||
|
PROCESSNAME=\$CMD
|
||||||
|
|
||||||
|
# Option to run with deamon
|
||||||
|
OPTIONS=" --config /etc/gitea/app.ini"
|
||||||
|
|
||||||
|
PIDFILE=/var/lib/gitea/gitea.pid
|
||||||
|
|
||||||
|
GITEA_WORK_DIR=$GITEA_WORK_DIR
|
||||||
|
|
||||||
|
func_stop() {
|
||||||
|
[ -e \$PIDFILE ] && kill \$(cat \$PIDFILE)
|
||||||
|
# if [ "\$(ps aux | grep \$PROCESSNAME | grep -v grep)" ]; then
|
||||||
|
# echo -n "Stopping \$NAME ... "
|
||||||
|
# killall \$PROCESSNAME
|
||||||
|
# sleep 2
|
||||||
|
# fi
|
||||||
|
|
||||||
|
if [ ! "\$(ps aux | grep \$PROCESSNAME | grep -v grep)" ]; then
|
||||||
|
echo "Done!"
|
||||||
|
else
|
||||||
|
echo "Error!"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
func_start() {
|
||||||
|
echo -n "Starting \$NAME ... "
|
||||||
|
su - \$USERNAME -c "GITEA_WORK_DIR=$GITEA_WORK_DIR \$CMD --pid \$PIDFILE \$OPTIONS" &
|
||||||
|
sleep 2
|
||||||
|
|
||||||
|
if [ "\$(ps aux | grep \$PROCESSNAME | grep -v grep)" ]; then
|
||||||
|
echo "Done!"
|
||||||
|
else
|
||||||
|
echo "Error!"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
case \$1 in
|
||||||
|
"start")
|
||||||
|
func_start
|
||||||
|
;;
|
||||||
|
|
||||||
|
"stop")
|
||||||
|
func_stop
|
||||||
|
;;
|
||||||
|
|
||||||
|
"restart")
|
||||||
|
func_stop
|
||||||
|
sleep 2
|
||||||
|
func_start
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
echo "Usage; start|stop|restart"
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
EOF
|
||||||
|
chmod +x $PKG/etc/rc.d/rc.gitea
|
||||||
|
|
||||||
|
mkdir -p $PKG/install
|
||||||
|
cat <<EOF > $PKG/install/slack-desc
|
||||||
|
# HOW TO EDIT
|
||||||
|
THIS FILE:
|
||||||
|
# The "handy ruler" below makes it easier to edit a package description. Line
|
||||||
|
# up the first '|' above the ':' following the base package name, and the '|'
|
||||||
|
# on the right side marks the last column you can put a character in. You must
|
||||||
|
# make exactly 11 lines for the formatting to be correct. It's also
|
||||||
|
# customary to leave one space after the ':'.
|
||||||
|
|
||||||
|
|-----handy-ruler--------------------------------------------------------|
|
||||||
|
$PRGNAM: $PRGNAM (A painless self-hosted Git service.)
|
||||||
|
$PRGNAM:
|
||||||
|
$PRGNAM: Gitea is a community managed fork of Gogs, lightweight code hosting
|
||||||
|
$PRGNAM: solution written in Go and published under the MIT license.
|
||||||
|
$PRGNAM:
|
||||||
|
$PRGNAM: edit /etc/gitea/app.ini
|
||||||
|
$PRGNAM: see https://docs.gitea.io/en-us/config-cheat-sheet/
|
||||||
|
$PRGNAM:
|
||||||
|
$PRGNAM:
|
||||||
|
$PRGNAM: https://gitea.io/
|
||||||
|
$PRGNAM:
|
||||||
|
EOF
|
||||||
|
|
||||||
|
cd $PKG
|
||||||
|
rm -f $PKG/{,usr/}lib$(uname -m | grep -o 64)/*.la
|
||||||
|
|
||||||
|
/sbin/makepkg --linkadd y --chown n --prepend $OUTPUT/$PRGNAM-$(echo $VERSION | tr - _)-$ARCH-$BUILD$TAG.txz
|
|
@ -1,182 +0,0 @@
|
||||||
#!/bin/bash
|
|
||||||
|
|
||||||
CWD=$(pwd)
|
|
||||||
|
|
||||||
PRGNAM=$(basename "$CWD")
|
|
||||||
VERSION=${VERSION:-latest}
|
|
||||||
ARCH=${ARCH:-$(uname -m)}
|
|
||||||
BUILD=${BUILD:-2}
|
|
||||||
TAG=${TAG:-gwh}
|
|
||||||
|
|
||||||
TMP=${TMP:-/tmp/$TAG}
|
|
||||||
PKG=$TMP/pkg-$PRGNAM
|
|
||||||
OUTPUT=${OUTPUT:-/tmp}
|
|
||||||
PREFIX=/usr
|
|
||||||
|
|
||||||
REPOSITORY=${REPOSITORY:-/home/installs/SlackBuilds/_repositories/$PRGNAM}
|
|
||||||
|
|
||||||
APP_WORK_DIR=/var/lib/gitea
|
|
||||||
|
|
||||||
# Check if the gitea user and group exist. If not, then bail.
|
|
||||||
if [ "$(id -g gitea 2> /dev/null)" != "817" ] || [ "$(id -u gitea 2> /dev/null)" != "817" ]; then
|
|
||||||
echo " You must have an 'gitea' user and group to run this script."
|
|
||||||
echo " # groupadd -g 817 gitea"
|
|
||||||
echo " # useradd -d /var/lib/gitea -g gitea -s /bin/bash -u 817 gitea --system "
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
# nettoyage préalable
|
|
||||||
rm -r "$PKG"
|
|
||||||
mkdir -p "$PKG"
|
|
||||||
|
|
||||||
# mise en place
|
|
||||||
[ ! -e "$REPOSITORY" ] && git clone https://codeberg.org/forgejo/forgejo.git "$REPOSITORY"
|
|
||||||
cd "$REPOSITORY" || exit 1
|
|
||||||
git pull --all
|
|
||||||
|
|
||||||
mkdir -p "$TMP"
|
|
||||||
cd "$TMP" || exit 1
|
|
||||||
[ -e "$PRGNAM" ] && rm -r "$PRGNAM"
|
|
||||||
cp -r "$REPOSITORY" .
|
|
||||||
|
|
||||||
cd "$TMP/$PRGNAM" || exit 1
|
|
||||||
case $VERSION in
|
|
||||||
trunk)
|
|
||||||
VERSION="git_r$(git rev-list --count HEAD)_$(git log -1 --format=%h)"
|
|
||||||
;;
|
|
||||||
latest)
|
|
||||||
VERSION=$(git describe --tags --abbrev=0)
|
|
||||||
git checkout "$VERSION"
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
git checkout "$VERSION"
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
|
|
||||||
make
|
|
||||||
|
|
||||||
mkdir -p "$PKG$PREFIX"/bin
|
|
||||||
cp gitea "$PKG$PREFIX"/bin/gitea # ${PRGNAM}
|
|
||||||
chmod +x "$PKG$PREFIX"/bin/gitea # ${PRGNAM}
|
|
||||||
|
|
||||||
mkdir -p "$PKG$PREFIX/doc/$PRGNAM"
|
|
||||||
cp -r DCO LICENSE MAINTAINERS ./*.md docs/ "$PKG$PREFIX/doc/$PRGNAM"
|
|
||||||
|
|
||||||
mkdir -p "$PKG"/etc/gitea/
|
|
||||||
cp "$CWD"/app.ini "$PKG"/etc/gitea/app.ini.new
|
|
||||||
chown -R gitea:gitea "$PKG"/etc/gitea
|
|
||||||
chmod 770 "$PKG"/etc/gitea
|
|
||||||
|
|
||||||
mkdir -p "$PKG${APP_WORK_DIR}"/{custom,data/gitea-repositories,indexers,public,log,.ssh}
|
|
||||||
chown -R gitea:gitea "$PKG"/var/lib/gitea
|
|
||||||
chmod 750 "$PKG${APP_WORK_DIR}"/{data,indexers,log}
|
|
||||||
|
|
||||||
mkdir -p "$PKG"/var/log/gitea
|
|
||||||
chown -R gitea:gitea "$PKG"/var/log/gitea
|
|
||||||
|
|
||||||
cd "$PKG" || exit 1
|
|
||||||
find . -print0 | xargs file | grep "executable" | grep ELF | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null || true
|
|
||||||
find . -print0 | xargs file | grep "shared object" | grep ELF | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null
|
|
||||||
|
|
||||||
|
|
||||||
mkdir -p "$PKG"/etc/rc.d/
|
|
||||||
cat <<EOF > "$PKG"/etc/rc.d/rc.gitea
|
|
||||||
#!/bin/bash
|
|
||||||
#Slackware startup deamon script
|
|
||||||
|
|
||||||
# Name of Service
|
|
||||||
NAME="Gitea Daemon"
|
|
||||||
|
|
||||||
# Command to run
|
|
||||||
CMD="/usr/bin/gitea"
|
|
||||||
|
|
||||||
# user used to run the daemon
|
|
||||||
USERNAME=gitea
|
|
||||||
|
|
||||||
# Process name of daemon, for killing it.
|
|
||||||
PROCESSNAME=\$CMD
|
|
||||||
|
|
||||||
# Option to run with deamon
|
|
||||||
OPTIONS=" --config /etc/gitea/app.ini"
|
|
||||||
|
|
||||||
PIDFILE=/var/lib/gitea/gitea.pid
|
|
||||||
|
|
||||||
APP_WORK_DIR=$APP_WORK_DIR
|
|
||||||
|
|
||||||
func_stop() {
|
|
||||||
[ -e \$PIDFILE ] && kill \$(cat \$PIDFILE)
|
|
||||||
# if [ "\$(ps aux | grep \$PROCESSNAME | grep -v grep)" ]; then
|
|
||||||
# echo -n "Stopping \$NAME ... "
|
|
||||||
# killall \$PROCESSNAME
|
|
||||||
# sleep 2
|
|
||||||
# fi
|
|
||||||
|
|
||||||
if [ ! "\$(ps aux | grep \$PROCESSNAME | grep -v grep)" ]; then
|
|
||||||
echo "Done!"
|
|
||||||
else
|
|
||||||
echo "Error!"
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
func_start() {
|
|
||||||
echo -n "Starting \$NAME ... "
|
|
||||||
su - \$USERNAME -c "GITEA_WORK_DIR=$APP_WORK_DIR \$CMD --pid \$PIDFILE \$OPTIONS" &
|
|
||||||
sleep 2
|
|
||||||
|
|
||||||
if [ "\$(ps aux | grep \$PROCESSNAME | grep -v grep)" ]; then
|
|
||||||
echo "Done!"
|
|
||||||
else
|
|
||||||
echo "Error!"
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
case \$1 in
|
|
||||||
"start")
|
|
||||||
func_start
|
|
||||||
;;
|
|
||||||
|
|
||||||
"stop")
|
|
||||||
func_stop
|
|
||||||
;;
|
|
||||||
|
|
||||||
"restart")
|
|
||||||
func_stop
|
|
||||||
sleep 2
|
|
||||||
func_start
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
echo "Usage; start|stop|restart"
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
EOF
|
|
||||||
chmod +x "$PKG"/etc/rc.d/rc.gitea
|
|
||||||
|
|
||||||
mkdir -p "$PKG"/install
|
|
||||||
cat <<EOF > "$PKG"/install/slack-desc
|
|
||||||
# HOW TO EDIT
|
|
||||||
THIS FILE:
|
|
||||||
# The "handy ruler" below makes it easier to edit a package description. Line
|
|
||||||
# up the first '|' above the ':' following the base package name, and the '|'
|
|
||||||
# on the right side marks the last column you can put a character in. You must
|
|
||||||
# make exactly 11 lines for the formatting to be correct. It's also
|
|
||||||
# customary to leave one space after the ':'.
|
|
||||||
|
|
||||||
|-----handy-ruler--------------------------------------------------------|
|
|
||||||
$PRGNAM: $PRGNAM (a self-hosted lightweight software forge.)
|
|
||||||
$PRGNAM:
|
|
||||||
$PRGNAM: Brought to you by an inclusive community under the umbrella of Codeberg
|
|
||||||
$PRGNAM: e.V., a democratic non-profit organization, Forgejo can be trusted to be
|
|
||||||
$PRGNAM: exclusively Free Software. It includes and cooperates with hundreds of
|
|
||||||
$PRGNAM: projects (Gitea, Git, ...) and is focused on scaling, federation and
|
|
||||||
$PRGNAM: privacy.
|
|
||||||
$PRGNAM:
|
|
||||||
$PRGNAM: edit /etc/gitea/app.ini
|
|
||||||
$PRGNAM: https://forgejo.org/
|
|
||||||
$PRGNAM:
|
|
||||||
EOF
|
|
||||||
|
|
||||||
cd "$PKG" || exit 1
|
|
||||||
rm -f "$PKG"/{,usr/}lib"$(uname -m | grep -o 64)"/*.la
|
|
||||||
|
|
||||||
/sbin/makepkg --linkadd y --chown n --prepend "$OUTPUT/$PRGNAM-$VERSION-$ARCH-$BUILD$TAG.txz"
|
|
Loading…
Reference in a new issue