# Install syncthing
mkdir -p $PKG/usr/bin
install -Dm755 syncthing $PKG/usr/bin/syncthing

# Install rc script
#mkdir -p $PKG/etc/rc.d
#cat $CWD/rc.syncthing > $PKG/etc/rc.d/rc.syncthing

#mkdir -p $PKG/var/lib64/syncthing
#mkdir -p $PKG/var/log/syncthing
#mkdir -p $PKG/var/run/syncthing

mkdir -p $PKG/etc/xdg/autostart
cp -f $CWD/syncthing-autostart.desktop $PKG/etc/xdg/autostart/syncthing.desktop
chmod 664 $PKG/etc/xdg/autostart/syncthing.desktop

mkdir -p $PKG/usr/share/icons/hicolor/scalable/apps
cp -f $CWD/syncthing.svg $PKG/usr/share/icons/hicolor/scalable/apps/syncthing.svg

mkdir -p $PKG/usr/share/applications
cp -f $CWD/syncthing.desktop $PKG/usr/share/applications/syncthing.desktop

mkdir -p $PKG/usr/bin
cp -f $CWD/syncthing-launch $PKG/usr/bin/syncthing-launch
chmod 755 $PKG/usr/bin/syncthing-launch

mkdir -p $PKG/usr/share/syncthing
cp -f $CWD/syncthing-*.png $PKG/usr/share/syncthing

# PYSHORTVERSION="$(python3 -V | sed -n 's|^Python \([0-9\.]\{3\}\).*$|\1|p')"
mkdir -p $PKG/usr/lib64/syncthing
PYTHONUSERBASE=$PKG pip install --no-deps --target $PKG/usr/lib64/syncthing pystray

#mv $PKG/usr/lib64/python$PYSHORTVERSION/site-packages/* $PKG/usr/lib64/syncthing/
#rm -rf $PKG/usr/lib64/python$PYSHORTVERSION
