2022/02/14

SVN 筆記

checkout

    從 server 拉來本地, 簡寫 co
    checkout URL[@REV]... [PATH]
    例:
        svn co svn+ssh://repo/home/svn/mybranch mybranch 

    直接 checkout 指定版本
        svn co -r version svn+ssh://repo/home/svn/mybranch mybranch

commit

    將本地的修改推到 server, 簡寫 ci
    commit [PATH...]
    例:
        svn ci file1 file2 path1/file3

copy

    複製成新的 branch, 簡寫 cp
    copy SRC[@REV]... DST
    例:
        svn cp svn+ssh://repo/home/svn/mybranch svn+ssh://repo/home/svn/newbranch

status

    檔案狀態, 簡寫 st
    svn st [PATH...]
    例:
        svn st

merge

    合併,
    svn merge [-c M[,N...] | -r N:M ...] SOURCE[@REV] [TARGET_WCPATH]
    例: 把 trunk 的修改合併進來.
        svn merge svn+ssh://repo/trunk
    例: 退回 oldver. 完成後重新 commit. 可以保留原先變更的版本參考
        svn merge -r 123:115 svn+ssh://repo/develop
    例: 檔案退回 oldver. 完成後重新 commit 可以保留原先變更的版本參考
        svn merge -r 123:115 path/filename

update

    更新,
    svn update [PATH...]
    例:
        svn up
    例:
        svn up -r 115

cherry-pick

    摘櫻桃
    svn merge -r N:M SOURCE

    例: (從 repo/develop 摘取從 r98 到 r99 所做的變更)
        svn merge -r 98:99 svn+ssh://repo/develop

svn merge 出現下列訊息:

    svn local file obstruction incoming file add upon merge
        這是因為本地跟merge源個別 add 檔案造成的, 解決方法:
            先手動比較兩個版本的差異, 並將檔案修改到最終想要的版本. 然後執行
                svn resolve --accept working <file>
            意思是接受 working 的版本來解決衝突.


2022/01/26

Mount sshfs on linux or windows

 Linux

    Install fuse and sshfs
        #sudo apt-get install fuse sshfs

    Mount
        usage: sshfs [user@]host:[dir] mountpoint [options]
        example:
            #sshfs aimwang@192.168.1.253:/home/aimwang /home/aimwang/nas1

    If you want to give the host direct access in WSL, you need to enable user_allow_other.

        Enable user_allow_other:
            Edit /etc/fuse.conf
            Uncomment user_allow_other

        Mount by your id
            Get user/group id number
                #id -u aimwang
                #id -g aimwang
        Mount with a specific user and group id
                #sshfs -o uid=1000,gid=1000,allow_other nas1:/home/aimwang /home/aimwang/nas1

Windows

    Install WinFsp, SSHFS-Win and SSHFS-Win-Manager.

    Execute SSHFS-Win-Manager
        

    
    Click [Add Connection]


    Fill the connection information.


    Click the connect button.
            



    You can see that it is mounted on the specified disk letter, when the connected.





2022/01/24

使用 WSL2 建構 Ubuntu 16.04 的環境

安裝

    公司的編譯伺服器使用 Ubuntu 16.04, 為了減低編譯環境造成的影響, 所以在本機編譯環境也採用相同的版本.

    Windows Store 沒有提供 Ubuntu 16.04, 所以要手動安裝

        1. 下載 Ubuntu 16.04 的 appx. (連結)

        2. 執行 Windows PowerShell, 切換到下載目錄.

        3. 在 PowerShell 裡面執行 Add-AppxPackage .\Ubuntu_1604.2019.523.0_x64.appx

    完成後就可以看到 Ubuntu 16.04 的應用程式. 第一次執行要設定使用者.


檔案系統

    打開檔案總管應該就能看到 WSL 的資夾, 各資料夾進去都是對到 / 根目錄.

    如果沒有看到, 也可以使用 \\wsl$ 進入.

    這真是太方便了, winsshfs 跟 samba 都省下來了.


sudo 免密碼

    #echo "aimwang ALL=(ALL:ALL) NOPASSWD:ALL" | sudo tee /etc/sudoers.d/aimwang


固定IP

    [無效]
    為了方便使用慣用的 ssh client, 還是要設定成固定 IP
    #sudo nano /etc/network/interfaces.d/eth0.cfg
    auto eth0
        iface eth0 inet static
        address 172.19.240.2
        netmask 255.255.240.0
        gateway 172.19.240.1
        dns-nameservers 172.19.240.1


    [host 端的 vEthernet 沒有固定 IP 無意義]

    執行, 或加入開機 task
        
wsl -d Ubuntu-16.04 -u root ifconfig eth0 172.19.240.2 netmask 255.255.240.0
        wsl -d Ubuntu-16.04 -u root rout add default gw 172.19.240.1

啟動 SSH server

    立即啟動 ssh server
    #service ssh start

    開機自動啟動
    #sudo systemctl enable ssh
        無效, 提示改用
            #/lib/systemd/systemd-sysv-install enable ssh
            也是無效
            rc?.d 裡面有看到 S02ssh, 但是似乎沒有去執行.
            ? 系統採用 sysv 的 /init, 但是沒看到 /etc/inittab
    
    手動執行
        wsl -d Ubuntu-16.04 -u root /etc/init.d/ssh start
    建一個任務在開機的時候自動執行, 至少每次 Windows 重開會自動起來一次. 基於 wsl -t 也不常用, 足夠目前的使用情境了.

重新啟動

    wsl -t Ubuntu-16.04
    下次開 shell 的時候就會自動重啟

解除安裝

在 cmd 裡列出已經安裝的套件清單
    wsl --list

執行 unregister 取消登錄並刪除根檔案系統
    wsl --unregister Ubuntu-16.04

安裝開發基本包

    預設是 64-bit 架構, i386 架構要手動增加
    #sudo dpkg --add-architecture i386
    #sudo apt-get update

    安裝常用 packages
    #sudo apt-get install openssh-client openssh-server subversion git make gcc g++ gawk wget python curl


編譯錯誤訊息與解方

    fatal error: sys/cdefs.h: No such file or directory

        缺乏 libc-dev. 連同 i386 一起安裝
        #sudo apt-get install libc6-dev libc6-dev:i386

    fatal error: openssl/ssl.h: No such file or directory

compilation terminated.

        缺乏 libssl-dev
        #sudo apt-get install libssl-dev libssl-dev:i386

    cannot find -lasound

        缺乏 libasound2
        #sudo apt-get install libasound2-dev libasound2-dev:i386

    cannot find -lstdc++
    cannot find -lgcc_s
    cannot find -lgcc

        需要安裝 lib 包
        #sudo apt-get install g++-multilib gcc-multilib

    Please install ncurses. (Missing libncurses.so or ncurses.h)

        #sudo apt-get install libncurses5-dev

    Please install 'unzip'

        #sudo apt-get install unzip

    fatal: unable to access 'xxx': server certificate verification failed.

        伺服器憑證不被信任.
        下 git 指令之前先執行
            #export GIT_SSL_NO_VERIFY=1

        或永遠不檢查憑證    
            #git config --global http.sslverify false

        或將該站設定為信任. (未完成)

    "__DATE__" might prevent reproducible builds
    "__TIME__" might prevent reproducible builds

        除錯的時候常常要將編譯的日期時間放進去參考, 使用的時候忽略報錯.
        CFLAGS += -Wno-error=date-time