SVN 命令列使用技巧

有時候必須使用 命令列 方式 來 commit files
但經常有很多散在各個子目錄裡的新增檔案
若用 svn add 一個一個來新增 實在費時費工
後來在這裡找到一個好方法:

    svn status | grep “^?” | awk ‘{print $2}’ | xargs svn add

這樣就可一次將新增檔案加入
不過要小心不要加到垃圾檔了….

Mac OS X 10.8 安裝 SVN Server

自從買了新的 2012 Late Mac Mini 之後
就開始將舊的 資料 搬到 新機器上
不過發現無法啟動 SVN server on apache2 web server
後來發現 原來是 Mac OS X 10.8 把 mod_dav_svn.so 給拿掉了… 很奇怪耶?
只好自己 compile 再補回去 …

首先,先確認 Mac OS X 10.8 內建的 SVN 版本

$ svn --version
svn, version 1.6.18 (r1303927)
   compiled Nov  2 2012, 23:47:41

Copyright (C) 2000-2009 CollabNet.
Subversion is open source software, see http://subversion.apache.org/
This product includes software developed by CollabNet (http://www.Collab.Net/).

The following repository access (RA) modules are available:

* ra_neon : Module for accessing a repository via WebDAV protocol using Neon.
  - handles 'http' scheme
  - handles 'https' scheme
* ra_svn : Module for accessing a repository using the svn network protocol.
  - handles 'svn' scheme
* ra_local : Module for accessing a repository on local disk.
  - handles 'file' scheme

接下來要下載 相同版本的 SVN source code,並重新 Compile 後
將所缺少的 module 補回去

$ cd ~/Download
$ wget http://archive.apache.org/dist/subversion/subversion-1.6.18.tar.bz2
$ tar -jxvf subversion-1.6.18.tar.bz2
$ cd subversion-1.6.18
$ ./configure
$ make
$ sudo cp subversion/mod_dav_svn/.libs/mod_dav_svn.so /usr/libexec/apache2/
$ sudo cp subversion/mod_authz_svn/.libs/mod_authz_svn.so /usr/libexec/apache2/

接下來,建立 /etc/apache2/other/svn.conf

$ vi /etc/apache2/other/svn.conf
LoadModule dav_svn_module /usr/libexec/apache2/mod_dav_svn.so
LoadModule authz_svn_module /usr/libexec/apache2/mod_authz_svn.so
<Location /svn>;
    DAV svn
    SVNParentPath /PATH-TO-SVN-REPOSITORY
    SVNListParentPath on
    AuthType Basic
    AuthName &quot;Subversion repository&quot;
    AuthUserFile /etc/apache2/svn-auth-file
    Require valid-user
</Location>;

記得變更 svn repository 的 權限

$ chown -R www:www /PATH-TO-SVN-REPOSITORY

重新啟動 Apache

$ sudo apachectl restart

SVN + http + NIS Authentication on OpenSUSE 11.2

Step.1 Install OpenSUSE 11.2

  • New Installation
  • English
  • select GNOME Desktop
  • LVM Partitioning
      /boot : 70.57MB
      / : 40GB
      /srv : max
      swap : 4GB
  • disable Fireware
  • NTP: time.stdtime.gov.tw

Step.2 Network

  • IP : 192.168.103.xxx
  • Gateway : 192.168.103.254
  • Subnet Mask : 255.255.0.0
  • DNS : 192.168.xxx.xxx
  • Hostname : svn

Step.3 NIS Client

  • domain: xxx
  • server: 192.168.xxx.xxx
  • Enable automount
  • Check /etc/nsswitch.conf setting
      passwd: files nis
      group: files nis
      shadow: files nis
      hosts: files nis dns

Step.4 Add Software Repository

  • Apache Module
      http://download.opensuse.org/repositories/Apaches:/Modules/OpenSUSE_11.2
  • RemoteDesktop
      http://download.opensuse.org/repositories/X11:/RemoteDesktop/OpenSUSE_11.2

Step.5 Install Nvidia Driver

    Visit http://en.opensuse.org/NVIDIA_drivers

Step.6 Software Install by using yast2

  • Update All Patches
  • Install Apache
      apache2
      apache2-mod_perl, apache2-mod_php5,
      apache2-mod_authnz_external
      apache2-mod_security2
      yast2-http-server
  • Install FTP server
      pure-ftpd
      yast2-ftp-server
  • Install Development Tools
      gcc, gcc-c++, make, autoconf, compat

Step.7 Enable Network Service

    enable sshd, autofs, httpd service

Step.8 SVN Repository

  • create directory

      #mkdir /srv/svn/projects
      #mkdir /srv/svn/users
  • Change Owner

      # chown -R wwwrun /srv/svn
      # chgrp -R www /srv/svn
  • Create SVN Repository

      # sudo -u wwwrun svnadmin create /srv/svn/projects
      # sudo -u wwwrun svnadmin create /srv/svn/users

Step.9 Apache + NIS Auth

    Reference: http://forums.opensuse.org/get-help-here/network-internet/436171-nis-system-auth-apache-subversion.html
  • Download pwauth source code, modify and Recompile
      Download pwauth-2.3.8.tar.gz from http://code.google.com/p/pwauth/downloads/list


        # tar -zxvf pwauth-2.3.8.tar.gz
        # cd pwauth-2.3.8
        # vi config.h

          change

            #define SERVER_UIDS 72 /* user "nobody" */

          to

            #define SERVER_UIDS 30 /* user "wwwrun" */

        # make
        # cp ./pwauth /usr/bin
        # chmod 4755 /usr/bin/pwauth

  • Install checkpassword-pam
      Download checkpassword-pam-0.99.tar.gz from http://sourceforge.net/projects/checkpasswd-pam/files


        # tar -zxvf checkpassword-pam-0.99.tar.gz
        # cd checkpassword-pam-0.99
        # ./configure
        # make
        # make install
  • create /etc/pam.d/httpd is

      auth include common-auth
      account include common-account
      password include common-password
      session include common-session
  • In /etc/apache2/default-server.conf, add:

      AddExternalAuth pwauth /usr/bin/pwauth
      AddExternalAuth checkpassword-pam "/usr/local/bin/checkpassword-pam -H --noenv --debug --stdout -s httpd -- /bin/true"
      SetExternalAuthMethod checkpassword-pam checkpassword
      AddExternalGroup unixgroup /usr/bin/unixgroup
      SetExternalGroupMethod unixgroup environment
  • In the /etc/apache2/conf.d/subversion.conf:

        DAV svn
        SVNParentPath /home/srv/svn
        SVNListParentPath on
        # Limit write permission to list of valid users.
        # Require SSL connection for password protection.
        # SSLRequireSSL
        AuthType Basic
        AuthName "Subversion Server"
        AuthExternal checkpassword-pam
        AuthBasicProvider external
        Require valid-user
        AuthzSVNAccessFile /srv/svnaccess.conf

  • In the /etc/apache2/conf.d/authnz_external.conf :
      AddExternalAuth pwauth /usr/sbin/pwauth
      SetExternalAuthMethod pwauth pipe
  • Enable aoache module and restart apache2

      # a2enmod authnz_external
      # a2enmod dav
      # a2enmod dav_svn
      # a2enmod authz_svn
      # a2enmod perl
      # rcapache2 restart

Step.10 Setup FreeNX

    # nxsetup –install –setup-nomachine-key –clean