Skip to content

Commit

Permalink
Merge pull request #145 from wslutilities/lts/master
Browse files Browse the repository at this point in the history
wslu 3.2.1 LTS
  • Loading branch information
patrick330602 authored Sep 13, 2020
2 parents a33ce0a + 863e942 commit 2e68fca
Show file tree
Hide file tree
Showing 20 changed files with 127 additions and 29 deletions.
4 changes: 3 additions & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,12 @@ sudo make res_install
wslu
|-src
| |-etc
| | |-wslview.desktop: XDG-style app definition for wslview
| | |-wsl.ico: legacy default icon for wslusc
| | |-wsl-gui.ico: default icon for wslusc GUI shortcut
| | |-wsl-term.ico: default icon for wslusc cli shortcut
| | |-sudo.ps1: helper script for wslgsu
| | |-sudo.ps1: helper script for wslgsu
| | |-get_dpi.ps1: helper script for dpi function in wslsys
| | |-wslsc-helper.sh: helper script for wslusc on WSL side
| | \-runHidden.vbs: helper script for wslusc on Windows side
| |-wslu-header: Header file of all script
Expand Down
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ res_install:
install -Dm 644 src/etc/*.ps1 -t $(DESTDIR)$(PREFIX)/share/wslu
install -Dm 644 src/etc/*.ico -t $(DESTDIR)$(PREFIX)/share/wslu
install -Dm 755 src/etc/*.sh -t $(DESTDIR)$(PREFIX)/share/wslu
install -Dm 644 src/etc/*.desktop $(DESTDIR)$(PREFIX)/share/wslu

clean:
rm -rf $(OUTPATH)
Expand Down
6 changes: 4 additions & 2 deletions README.eo.md
Original file line number Diff line number Diff line change
Expand Up @@ -131,15 +131,17 @@ sudo yum install wslu

> Attenu!
>
> La Ubuntu versio de `wslu` estas modifita versio. Oni devas raporti cimojn [ĉi tie](https://bugs.launchpad.net/ubuntu/+source/wslu).
> Por Ubuntu versio, Oni devas ne nur raporti cimojn ĉi tie sed ankaŭ raporti cimojn ĉe [Launchpad](https://bugs.launchpad.net/ubuntu/+source/wslu).
Antaŭinstalita en la plej freŝa versio. Sur pli aĝaj instaloj de Ubuntu, oni povas instali `ubuntu-wsl` kiu dependas de `wslu`:
Antaŭinstalita en la plej freŝa versio. Sur pli aĝaj instaloj de Ubuntu, oni povas instali `ubuntu-wsl` kiu dependas de `wslu`: <https://launchpad.net/~wslutilities/+archive/ubuntu/wslu>

```
sudo apt update
sudo apt install ubuntu-wsl
```

Por instali la plej freŝan version antaŭ ol `wslu` atigas `main` deponejon, vi povas instali per nia PPA:

### OpenSUSE

Oni povas instali `wslu` per la jenaj komandoj:
Expand Down
4 changes: 3 additions & 1 deletion README.hans.md
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ sudo yum install wslu

> 注意!
>
> Ubuntu 版本的 `wslu` 为修改版。你需要在[](https://bugs.launchpad.net/ubuntu/+source/wslu)反馈 Ubuntu 版问题
> Ubuntu 版本不仅需要需要在此反馈, 同时也要在 [Launchpad](https://bugs.launchpad.net/ubuntu/+source/wslu) 反馈
最新版本已预装。针对旧版本的安装,请安装依赖于 wslu 的 ubuntu-wsl:

Expand All @@ -138,6 +138,8 @@ sudo apt update
sudo apt install ubuntu-wsl
```

在最新版 `wslu` 进入 `main` 仓库前,请从以下 PPA 安装: <https://launchpad.net/~wslutilities/+archive/ubuntu/wslu>

### OpenSUSE

你可以用以下命令安装 `wslu`
Expand Down
2 changes: 2 additions & 0 deletions README.hant.md
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,8 @@ sudo apt update
sudo apt install ubuntu-wsl
```

在最新版 `wslu` 進入 `main` 倉庫前,請從以下 PPA 安裝: <https://launchpad.net/~wslutilities/+archive/ubuntu/wslu>

### OpenSUSE

你可以用以下指令安装 `wslu`
Expand Down
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ sudo yum install wslu

> Attention!
>
> The Ubuntu version of `wslu` is a modified version. You should report bug [here](https://bugs.launchpad.net/ubuntu/+source/wslu).
> For Ubuntu version, you should not only report bug here but also report bug at [Launchpad](https://bugs.launchpad.net/ubuntu/+source/wslu).
Preinstalled in the latest apps. On older installations of Ubuntu please install `ubuntu-wsl` that depends on `wslu`:

Expand All @@ -138,6 +138,8 @@ sudo apt update
sudo apt install ubuntu-wsl
```

To install the latest version before `wslu` reaches `main` reporsitory, you can install via our PPA: <https://launchpad.net/~wslutilities/+archive/ubuntu/wslu>

### OpenSUSE

You can install `wslu` with the following command:
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3.2.0-1
3.2.1-1
2 changes: 1 addition & 1 deletion extras/build/alpine/APKBUILD
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Maintainer: Patrick Wu <[email protected]>
# Contributor: Patrick Wu <[email protected]>
pkgname=wslu
pkgver=3.2.0
pkgver=3.2.1
pkgrel=0
pkgdesc="A collection of utilities for Windows 10 Linux Subsystems"
url="https://github.com/wslutilities/wslu"
Expand Down
5 changes: 5 additions & 0 deletions extras/build/alpine/wslu.post-install
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/sh

date +"%s" | tee /usr/share/wslu/updated_time >/dev/null

exit 0
5 changes: 5 additions & 0 deletions extras/build/alpine/wslu.post-upgrade
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/sh

date +"%s" | tee /usr/share/wslu/updated_time >/dev/null

exit 0
3 changes: 3 additions & 0 deletions extras/build/alpine/wslu.pre-deinstall
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/sh

rm /usr/share/wslu/updated_time
2 changes: 1 addition & 1 deletion extras/build/arch/PKGBUILD
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Maintainer: Patrick Wu <[email protected]>

pkgname=wslu
pkgver=3.2.0
pkgver=3.2.1
pkgrel=0
pkgdesc="A collection of utilities for Windows 10 Linux Subsystems"
arch=('any')
Expand Down
36 changes: 36 additions & 0 deletions extras/build/arch/wslu.install
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# This is a default template for a post-install scriptlet.
# Uncomment only required functions and remove any functions
# you don't need (and this header).

## arg 1: the new package version
#pre_install() {
# do something here
#}

## arg 1: the new package version
post_install() {
date +"%s" | tee /usr/share/wslu/updated_time >/dev/null
}

## arg 1: the new package version
## arg 2: the old package version
#pre_upgrade() {
# do something here
#}

## arg 1: the new package version
## arg 2: the old package version
post_upgrade() {
date +"%s" | tee /usr/share/wslu/updated_time >/dev/null
}

## arg 1: the old package version
pre_remove() {
# do something here
rm /usr/share/wslu/updated_time
}

## arg 1: the old package version
#post_remove() {
# do something here
#}
2 changes: 1 addition & 1 deletion extras/build/debian/control
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@ Vcs-Git: https://github.com/wslutilities/wslu.git

Package: wslu
Architecture: all
Depends: bc, imagemagick
Depends: bc, imagemagick, desktop-file-utils
Description: A collection of utilities for Windows 10 Linux Subsystem
This is a collection of utilities for Windows 10 Linux Subsystem, such as converting WSL path to Windows path or creating your favorite linux app shortcuts on Windows 10 Desktop. Requires Windows 10 Creators Update and higher.
4 changes: 4 additions & 0 deletions extras/build/debian/postinst
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,8 @@ set -e
if [ "$1" = "configure" ] || [ "$1" = "abort-upgrade" ] ; then
update-alternatives --install /usr/bin/x-www-browser x-www-browser /usr/bin/wslview 30
update-alternatives --install /usr/bin/www-browser www-browser /usr/bin/wslview 30
date +"%s" | tee /usr/share/wslu/updated_time >/dev/null
fi

desktop-file-install --dir=/usr/share/applications /usr/share/wslu/wslview.desktop
update-desktop-database
7 changes: 7 additions & 0 deletions extras/build/debian/prerm
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,12 @@ set -e
if [ "$1" = "remove" ] ; then
update-alternatives --remove x-www-browser /usr/bin/wslview
update-alternatives --remove www-browser /usr/bin/wslview
if [ -f /usr/share/wslu/updated_time ]; then
rm /usr/share/wslu/updated_time
fi
if [ -f /usr/share/applications/wslview.desktop ]; then
rm /usr/share/applications/wslview.desktop
update-desktop-database
fi
fi

16 changes: 13 additions & 3 deletions extras/build/rpm/wslu.spec
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ Version: BUILDVERPLACEHOLDER
Release: RELVERPLACEHOLDER
Source: wslu-BUILDVERPLACEHOLDER.tar.gz
BuildArch: noarch
Requires: bc ImageMagick
Requires(post): %{_sbindir}/update-alternatives
Requires(postun): %{_sbindir}/update-alternatives
Requires: bc ImageMagick desktop-file-utils
Requires(post): %{_sbindir}/update-alternatives %{_bindir}/update-desktop-database %{_bindir}/desktop-file-install
Requires(postun): %{_sbindir}/update-alternatives %{_bindir}/update-desktop-database
BuildRoot: %{_tmppath}/%{name}-%{version}-build
URL: https://github.com/wslutilities/wslu/
License: GPL-3.0-or-later
Expand Down Expand Up @@ -39,8 +39,18 @@ ln -sf /usr/share/man/man1/wslview.1.gz %{?buildroot}/usr/share/man/man1/wstart.
%post
%{_sbindir}/update-alternatives --install %{_bindir}/www-browser www-browser %{_bindir}/wslview 1
%{_sbindir}/update-alternatives --install %{_bindir}/x-www-browser x-www-browser %{_bindir}/wslview 1
%{_bindir}/date +"%s" | %{_bindir}/tee /usr/share/wslu/updated_time >/dev/null
%{_bindir}/desktop-file-install --dir=/usr/share/applications /usr/share/wslu/wslview.desktop
%{_bindir}/update-desktop-database

%postun
if [ -f /usr/share/wslu/updated_time ]; then
%{_sbindir}/rm /usr/share/wslu/updated_time
fi
if [ -f /usr/share/applications/wslview.desktop ]; then
%{_sbindir}/rm /usr/share/applications/wslview.desktop
%{_bindir}/update-desktop-database
fi
%{_sbindir}/update-alternatives --remove www-browser %{_bindir}/wslview
%{_sbindir}/update-alternatives --remove x-www-browser %{_bindir}/wslview

Expand Down
9 changes: 9 additions & 0 deletions src/etc/wslview.desktop
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[Desktop Entry]
Name=WSLView
Comment=Open files and addresses in Windows
Icon=windows
Exec=/usr/bin/wslview %U
Terminal=false
Type=Application
Categories=Utility;
MimeType=x-scheme-handler/http;x-scheme-handler/https;x-scheme-handler/file
2 changes: 1 addition & 1 deletion src/wslsys.sh
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ function call_theme() {
function call_display_scaling() {
up_path="$(wslvar -s USERPROFILE)"
wslu_file_check "$(wslpath "$up_path")/wslu" "get_dpi.ps1" "?!S"
display_scaling="$(winps_exec "$(double_dash_p "$up_path")\\wslu\\get_dpi.ps1" | sed -e 's|\r||g')"
display_scaling="$(winps_exec "$(double_dash_p "$up_path" | sed -e 's| |\` |g')\\wslu\\get_dpi.ps1" | sed -e 's|\r||g')"
bc -l <<< "$(printf "%d\n" "$display_scaling")/100" | sed -e "s/\.0//g" -e "s/0*$//g"
}

Expand Down
40 changes: 24 additions & 16 deletions src/wslu-header
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,19 @@ function baseexec_gen {
fi
}

function var_gen {
date +"%s" > ~/.config/wslu/triggered_time

rm ~/.config/wslu/baseexec
rm ~/.config/wslu/oemcp

# generate oem codepage
"$(interop_prefix)$(sysdrive_prefix)"/Windows/System32/reg.exe query "HKLM\\SYSTEM\\CurrentControlSet\\Control\\Nls\\CodePage" /v OEMCP 2>&1 | sed -n 3p | sed -e 's|\r||g' | grep -o '[[:digit:]]*' > ~/.config/wslu/oemcp
# generate base exe location
baseexec_gen

}

function wslu_file_check {
should_i_show=""
[[ "$3" == "?!S" ]] && should_i_show="n"
Expand Down Expand Up @@ -208,22 +221,17 @@ if [ ! -d ~/.config/wslu ]; then
mkdir -p ~/.config/wslu
fi

# generate oem codepage
if [ ! -f ~/.config/wslu/oemcp ]; then
"$(interop_prefix)$(sysdrive_prefix)"/Windows/System32/reg.exe query "HKLM\\SYSTEM\\CurrentControlSet\\Control\\Nls\\CodePage" /v OEMCP 2>&1 | sed -n 3p | sed -e 's|\r||g' | grep -o '[[:digit:]]*' > ~/.config/wslu/oemcp
fi

# generate base exe locaiton
if [ ! -f ~/.config/wslu/baseexec ]|| [ -z "$(cat ~/.config/wslu/baseexec)" ]; then
# if it is not generated
baseexec_gen
elif grep -q "/" ~/.config/wslu/baseexec; then
# if baseexec is using the old linux style, regenerate
baseexec_gen
elif which "$(cat ~/.config/wslu/baseexec)" &>/dev/null; then
# if baseexec cannnot be executed, regenerate
rm ~/.config/wslu/baseexec
baseexec_gen
# This gets tirggered then:
# 1. if it's the first time the script is triggered, i.e.,
# ~/.config/wslu/triggered time
# 2. if update_time is also not present, i.e.,
# badly installed packages or installed via install script
if [ ! -f ~/.config/wslu/triggered_time ] || [ ! -f /usr/share/wslu/updated_time ]; then
var_gen
# This gets triggered when:
# installed time is larger than the last triggered time
elif [ $(cat ~/.config/wslu/triggered_time) -lt $(cat /usr/share/wslu/updated_time) ]; then
var_gen
fi

# basic distro detection
Expand Down

0 comments on commit 2e68fca

Please sign in to comment.