Private git server set up pod private warehouse

Much of the information on existing networks are the main private warehouse into escrow platform, such as gitee and so on. Many users may not want to talk about private warehouse custodian to third parties. This paper attempts to do his will into the private warehouse private git server.

Process as substantially

  1. Set up git server
  2. cocoapods create a private library
  3. Creating a remote repository components
  4. Create a local component repository
  5. Local component to the remote component associated warehouse warehouse
  6. Submit local component to the remote component Warehouse Code Warehouse
  7. Submission component podspec files to a private warehouse
  8. use

Note: Step 5 non-essential, we can first establish a remote repository to a local clone and then create a local warehouse, thus better direct access to the associated local warehouse, but there may be a problem mentioned below.

Set up git server

Git server to build a lot of tutorials, you can refer to the following article.
Git server is set up
to use Smart HTTP and Gitweb set up makeshift personal git server

Note: After the installation are generally used git ssh protocol git pull and server push, if necessary using the http protocol is used, an additional container and a http configuration. Nginx, etc. can be used as an http container.

cocoapods create a private library

Git can make use of third-party platform is completed, create a private warehouse here on our own git server built.

First of all server-side implementation

sudo git init --bare repos.git

repos.git private library name --bare (bare Chinese means: bare, bare) initialization of the repository (for the time being called a bare repository) will generate a class file: used to record the history of the repository .git directory the following documents; and not contain a copy of the actual project source files; --bare benefits can prevent conflicts.

Will create a complete remote private warehouse added to the local cocoapod go.
Executed locally

pod repo add repos http://10.10.1.1/git/repos.git

After machining, cocoapods will repos clone in ~ / .cocoapods / repos directory.
The main effect of this step is to allow us to find the code from our need to import from our warehouse in the private Bank of China pod install or pod search time.

First, there is no corresponding pod looking for from our local warehouse cocoapods official repository, if not then look for the corresponding components from our local private warehouse. If neither is failure. (Old version cocoapods might want to perform first pod update update the local warehouse, the new version will need to manually invoke pod update).

You can also view a list of local repository with the following command, master is cocoapods official warehouse, repos to create our own private warehouse.

pod repo list
5873462-24e97a27d6f03cfd.png
image.png

Creating a remote repository components

The server side

sudo git init --bare FchKit.git

FchKit.git name for the component warehouse

Create a local component repository

It can be divided into two basic ways

  1. pod lib create FchKit created directly
  2. Existing project file is configured to generate podpec

The following is a way to create a process

pod lib create FchKit

Answer a few questions


5873462-e65cf4a55133ad00.png
image.png

Creating success


5873462-b66f80eba7d0e22d.png
image.png

The class files in the component code components onto the folder name, file back to the next to the next Example

pod install

Each time you add files need to re-pod install. After the implementation of projects under the pod file taget files will be added, can be modified.

Note that, the local file structure, imported after we import the folder structure, the file structure when we use it, and all three may not be the same,

Development file structure.


5873462-c15dc033d2a7a7a7.png
Development .png

Local file structure.


5873462-f5f4d8164a9bf957.png
Local .png

By pod FchKit import file structure.


5873462-434bfddd18ee6cdb.png
.Png official use

To set the incoming pod folder directory structure needs to be set in the sub podspec file, reference may be sub podsepc AFNetworking the set. (More complex)
AFNetworking

Modify podspec submit documents to facilitate follow-up to a private library


5873462-1af0bf294e7e9917.png
image.png

If you can not find the home page address s.homepage dispensable when added to the formation of a private warehouse warning will pop up
s.source remote warehouse address
pod from a remote trousers s.source_files use components pull files
" " means match All files
" .
{H, m}" indicates matches all .h files ending .m and
"**" means match all subdirectories
s.dependency dependent components other libraries can write a plurality
s.swift_version variation may be provided version prevent the compiler to compile a version mismatch caused by the problem that others can not import.

Local component to the remote component associated warehouse warehouse

Set Associations

 git remote add origin http://10.10.1.1/git/FchKit.git

Unlinked

git remote remove origin

View related

git remote show origin

origin for the name

Above-mentioned problems

Mentioned above, we can remote component repository by clone down, and then in the warehouse common local repository to avoid local warehouse and associated remote warehouse this step. However, the actual operation may be problematic.
For example if we create a remote repository component test. Then git clone to the local Executive pod lib create test locally created components warehouse code. In this case the following directory structure


5873462-4a3874b7a9b25fb1.png
image.png

So when should submit code after we finish how to modify the code under test catalog or test-test it in the directory?
Ruoguo warning git add appear in the test directory.


5873462-dae6d758b9596b33.png
image.png

git repository conflict, test is a git repository. test-test is a git repository.

If the test - test directory. git add git commit no problem, but git push origin master has encountered a problem.


5873462-4897c7ef6a6de7ab.png
image.png

This is because we did not test the remote repository test inside the warehouse, so there will not be test-test at the origin.

In this case we can test-test the entire contents copied to the test directory during the git push to.

Submit local component to the remote component Warehouse Code Warehouse

git push origin master

Enter the correct user name and password will be a success


5873462-256673c0e2b25020.png
image.png
common problem

1.unable to access 'xxx': The requested URL returned error: 500

5873462-5d01f2a3dda1e419.png
image.png

The server is not configured correctly, you need to configure the user name and password on the server side.
First check http server configuration information

vi /etc/apache2/sites-enabled/000-default.conf

Adding information about the configuration file

SetEnv GIT_PROJECT_ROOT /var/www/html/git
SetEnv GIT_HTTP_EXPORT_ALL
ScriptAlias /git/ /usr/lib/git-core/git-http-backend/

RewriteEngine On
RewriteCond %{QUERY_STRING} service=git-receive-pack [OR]
RewriteCond %{REQUEST_URI} /git-receive-pack$
RewriteRule ^/git/ - [E=AUTHREQUIRED]

<Files "git-http-backend">
    AuthType Basic
    AuthName "Git Access"
    AuthUserFile /var/www/html/.htpasswd
    Require valid-user
    Order deny,allow
    Deny from env=AUTHREQUIRED
    Satisfy any
</Files>

5873462-30597c20693bc855.png
image.png

Arrowhead portion may be modified as needed, address represents the repository and user profiles address.

Secondly side configuration file .htpasswd username and password below

sudo htpasswd -c /var/www/html/.htpasswd 用户名
5873462-f49bfe884b10446f.png
image.png

2. error: RPC failed; curl 52 Empty reply from server

5873462-4d0a8b95c1db6c83.png
image.png

The reason may be because the file is too large to be submitted, enter the following command

git config --global http.postBuffer 524288000

It may also be because the network reasons, or git server problems without the http server users write access to the need to increase the permissions on the server.

chmod u=rwx  /var/www/html/git -r

It represents an increase file owner read and write execute permissions. / Var / www / html / git stored address as a remote.

Submission component podspec files to a private warehouse

On the server side component code will be submitted before playing tag and tag the version number to be consistent with podspec file.

Executed on the server side

git tag 0.1.0

Or playing tag at the local and then submit the corresponding tag version to the server.
Local execution

git tag 0.1.0
git push origin 0.1.1

Then verify the spec

pod spec lint
5873462-5c42185d40ab3bfd.png
image.png

Problems mentioned above can be added --allow-warnings parameter is ignored warnings

pod lib lint --allow-warnings

It appears xxx passed validation represents the validation by


5873462-6f3c797a40c37901.png
image.png

After verification by using the pod repo push command file to be submitted podsepc private warehouse, repos are private warehouse name FchKit.podspec warehouse spec file.

pod repo  push repos FchKit.podspec
common problem

1. Authentication failed for 'xxx'

5873462-a304cabc4bd747d7.png
image.png

Prompt the user to verify because you did not pass, because s.source here is wrong, pointing to github, and I was not a local terminal to log github account.
Log in to view the user by the following command

git config user.name  

Modify User

git config --global user.name "Your_username"
git config --global user.email "Your_email"

2.Remote branch 0.1.0 not found in upstream origin

5873462-eb2776dcfe48232b.png
image.png

No remote repository of tag 0.1.0. You need to play tag in the remote repository. Of course, before that you have to have associated with the local warehouse remote repository. And the local repository of code push to a remote repository.

Referring to the tag to be solved.
Server-side execution

 git tag 0.1.0

Or local execution

git tag 0.1.0
git push origin 0.1.1

The following command to view all tag warehouse

 git tag 

3. xxx did not pass validation, due to 6 errors and 3 warnings.

5873462-cea9ab09ba78aebe.png
image.png

Libraries are not compiled by the need to modify the errors in the library

4. remote:error:insufficient permission fo adding an object to repository database ./object

5873462-edd4b42bc608402f.png
image.png

Server permissions problems, generally related to most of permission errors for server-side permissions issue, you need to set appropriate permissions on the server. www-data is FchSpecs.git owner user name.

chown www-data FchSpecs.git -R
chgrp www-data FchSpecs.git -R

Here FchSpecs.git private warehouse name, with more than repos.git same.


5873462-29ee8abae8741a21.png
image.png

After the success can be searched through the pod search.

pod search FchKit
5873462-23863a779b8cc80a.png
image.png

Components for the update process

  • Modify and component code
  • Modifying the local podspec file version
  • Submission component code.
  • Server-side play tag, must be consistent with podspec file version.
  • Resubmit the file to the private warehouse component podspec

Using Components

Adding to the local private warehouse. If in the creation of a private warehouse has been added there is no need to add again.

pod repo add repos http://10.10.1.1/git/repos.git

Adding Podfile documents referenced assembly

source 'http://10.10.1.1/git/repos.git'
source 'https://github.com/CocoaPods/Specs.git'

Find components from the local repos.git and official specs.git inside.
Join our library

pod 'FchKit'

Then execute

 pod install
5873462-4f1c4920aded6663.png
image.png

5873462-52caab417c826c2b.png
image.png

Guess you like

Origin blog.csdn.net/weixin_34211761/article/details/90841743