What is a Linux repository. Setting up Ubuntu repositories

Repository commonly refers to a storage location, often for safety or preservation.
- Wikipedia

This is how Wikipedia describes the repository. It just so happens that unlike some of the other slang words with which we are dealing, this term perfectly conveys its essence. A repository is the concept of storing a collection for entities of a particular type.

Repository as a collection

Probably the most important difference between repositories is that they are collections of objects. They do not describe database storage or caching or any other solution technical problem... Repositories represent collections. How you store these collections is just an implementation detail.

I want to clarify this issue. A repository is a collection. A collection that contains entities and can filter and return the result back depending on the requirements of your application. Where and how it stores these objects is an IMPLEMENTATION DETAIL.

In the PHP world, we are used to a request / response loop that ends in the death of the process. Everything that came from outside and did not survive is gone forever, at this point. Well, not all platforms work this way.

A good way to understand how repositories work is to keep your application running, in which case all objects remain in memory. The probability of critical failures and the response to them in this experiment can be neglected. Imagine you have a Singleton repository instance for the Member entities, MemberRepository.

Then create a new Member object and add it to the repository. Later, you query the repository for all the items stored in it, so you get the collection that contains that object internally. Perhaps you want to get a specific object by its ID, this is also possible. It is very easy to imagine that within a repository these objects are stored in an array or, even better, in a collection object.

Simply put, a repository is a special kind of reliable collection that you will use over and over again to store and filter entities.

Interacting with the Repository

Imagine we are creating a Member entity. We bring the object to the required state, then the request ends and the object disappears. The user tries to log in to our application and cannot. Obviously, we need to make this object available to other parts of the application as well.

$ member = Member :: register ($ email, $ password); $ memberRepository-> save ($ member);
We can now access the object later. Like that:

$ member = $ memberRepository-> findByEmail ($ email); // or $ members = $ memberRepository-> getAll ();
We can store objects in one part of our application and then retrieve them from another.

Should repositories create entities?

You can see examples like this:

$ member = $ memberRepository-> create ($ email, $ password);
I have seen many arguments for this, but I am not at all interested in such an approach.

First of all, repositories are collections. I'm not sure why a collection should be a collection and a factory. I've heard arguments like "If it is more convenient to use this, why not hang up the handler for such actions"?

In my opinion, this is an anti-pattern. Why not let the Member class have its own understanding of how and why an object is created, or why not make a separate factory to create more complex objects?

If we treat our repositories as simple collections, then we don't need to load them with unnecessary functionality. I don't want collection classes that behave like factories.

What are the benefits of using repositories?

The main advantage of repositories is the abstract storage mechanism for collections of entities.

By providing the MemberRepository interface, we free the hands of the developer, who will decide for himself how and where to store the data.

Class ArrayMemberRepository implements MemberRepository (private $ members =; public function save (Member $ member) ($ this-> members [(string) $ member-> getId ()] = $ member;) public function getAll () (return $ this -> members;) public function findById (MemberId $ memberId) (if (isset ($ this-> members [(string) $ memberId])) (return $ this->

Class RedisMemberRepository implements MemberRepository (public function save (Member $ member) (// ...) // you get the point)
Thus, most of our applications only know the abstract concept of MemberRepository and its use can be decoupled from the actual implementation. This is very liberating.

Are Repositories Domain or Application Service Layer?

So here's an interesting question. First, let's define that the Application Service Layer is a layered architecture that is responsible for specific implementation details of an application, such as database integrity, and various Internet protocol implementations (dispatch Email, API), etc.

Let's define the term Domain Layer as a layer of a layered architecture that is responsible for business rules and business logic.

Where does the repository end up with this approach?

Let's take a look at our example. Here is the code written earlier.

Class ArrayMemberRepository implements MemberRepository (private $ members =; public function save (Member $ member) ($ this-> members [(string) $ member-> getId ()] = $ member;) public function getAll () (return $ this -> members;) public function findById (MemberId $ memberId) (if (isset ($ this-> members [(string) $ memberId])) (return $ this-> members [(string) $ memberId];)))
In this example, I see a lot of implementation details. They should undoubtedly be part of the application layer.

Now let's remove all the implementation details from this class ...

Class ArrayMemberRepository implements MemberRepository (public function save (Member $ member) () public function getAll () () public function findById (MemberId $ memberId) ())
Hmm ... this is starting to look familiar ... What have we forgotten?

Perhaps the resulting code reminds you of this?

Interface MemberRepository (public function save (Member $ member); public function getAll (); public function findById (MemberId $ memberId);)
This means that the interface is on the border of the layers. and may actually contain domain-specific concepts, but the implementation itself shouldn't.

Repository interfaces belong to the domain layer. Implementation belongs to the application layer. This means that we are free to build the architecture at the domain layer level without having to depend on the service layer.

Freedom to change data stores

Whenever you hear someone talking about the concept of object oriented design, you could probably hear something like "... and you have the opportunity to swap one storage implementation for another in the future ..."

In my opinion, this is not entirely true ... I would even say that this is a very bad argument. The biggest problem with explaining the concept of repositories is that it immediately begs the question "Do you really want to do this?"... I do NOT want questions like this to affect the use of the repository pattern.

Any reasonably well-designed object-oriented application will automatically fall under this advantage. The central concept of OOP is encapsulation. You can provide access to the API and hide the implementation.

After all, you really won't be switching from one ORM to another and back again. But even if you want to do this, then at least you will have the opportunity to do it. However, replacing the repository implementation would be a huge plus for testing.

Testing using the "Repository" pattern

Well, everything is simple here. Let's assume you have an object that handles something like member registration ...

Class RegisterMemberHandler (private $ members; public function __construct (MemberRepository $ members) ($ this-> members = $ members;) public function handle (RegisterMember $ command) ($ member = Member :: register ($ command-> email, $ command-> password); $ this-> members-> save ($ member);))
During the next operation, I can take an instance of DoctrineMemberRepository. However, during testing, you can easily replace it with an ArrayMemberRepository instance. They both implement the same interface.

A simplified example of a test might look something like this ...

$ repo = new ArrayMemberRepository; $ handler = new RegisterMemberHandler ($ repo); $ request = $ this-> createRequest (["email" => " [email protected]"," password "=>" angelofdestruction "]); $ handler-> handle (RegisterMember :: usingForm ($ request)); AssertCount (1, $ repo-> findByEmail (" [email protected]"));
In this example, we are testing the handler. We do not need to check the correctness of storing repository data in the database (or anywhere else). We test the specific behavior of this object: register a user based on the form data, and then push it to the repository.

Collection or State

In Implementing Domain-Driven Design, Vaughn Vernon distinguishes between repository types. The idea of ​​a collection-centric repository (orig. - collection-oriented repository) the fact that the work with the repository goes in memory, as with an array. State-oriented repository (orig. - persistence-oriented repository) contains the idea that it will have some kind of deeper and more thoughtful storage system. In fact, the differences are only in the names.

// collection-oriented $ memberRepository-> add ($ member); // vs persistence-oriented $ memberRepository-> save ($ member);
Note that this is just my opinion and so far I adhere to it in matters of using repositories. However, I would like to warn you that I might change my mind. Ultimately, I focus on them as collections of objects with the same responsibilities as any other collection object.

Additional Information

created a project on Github about repositories which is definitely worth looking at. Inside you will find examples of working with memory and file storage.

Outcomes

I think that…
  1. ... it's important to give the repositories a singular task to function as a collection of objects.
  2. ... we shouldn't use repositories to create new object instances.
  3. ... we should avoid using repositories as a way to move from one technology to another, as they have so many advantages that are difficult to give up.
In the future, I plan to write a few more articles about repositories, such as caching results using a decorator, queries using a criterion pattern, the role of a repository in handling batch operations on a large number objects.

If you have questions or if your opinion differs from mine, please write in the comments below.

As always, I intend to update the article to keep it in sync with my current opinion.

Methods for installing programs in Windows systems and Linux (as well as BSD) are different. We can say that even the very ideology of installing programs is different. Windows users used to the fact that the program is supplied as an installation file (or a group of files). These files need to be downloaded from the Internet or received on CD / DVD. This method is not typical for Linux, although it also exists.

Actually, a repository is a repository of files . Linux system implies that a person who wants to install a program will refer to the repository where this program is stored. This is done through the terminal.

For example, I want to set in my Linux Mint 17.1 program for virtualization Virtual Box. I launch terminal and enter the following command:

sudo apt-get install virtualbox-4.3

The installation must be done with super administrator privileges, so we add the word sudo to the command. The terminal asks us for the super administrator's password and reports information on the packages that you are going to install.


Installing VirtualBox via Terminal

After the user agrees, the system will start downloading required files from the network storage on the Internet. Thus, you do not need to go to the program website and download setup file manually.

The installation process itself looks like this:


Installing VirtualBox on Linux Mint

After installation, the program can be found in the list of other installed programs.


VirtualBox in Linux Mint

Who can create repositories?

Anyone. As for which repositories the operating system takes programs from, these are, first of all, the repositories of the system itself. Individual programs also have their own repositories (the versions of programs for them, as a rule, are more recent), but such repositories must be added manually in the operating system settings. It does this either through the Package Manager or through the appropriate commands in the terminal.

As you can see, in my case, there were already VirtualBox files in the Linux Mint repository, so there was no need to perform additional actions. What would I have to do if such a program were not found in the system repository? Add a repository of developers of the program itself.

For example, finding the "Application Sources" item in the Linux Mint menu, and there the "Additional Repositories" section.


Adding a repository in Linux Mint

Or by writing in the terminal

sudo sh -c "echo" deb http://download.virtualbox.org/virtualbox/debian trusty contrib ">> /etc/apt/sources.list"

This is the path to a specific VirtualBox repository. In the case of other programs, the path will be different. After that we update the package cache:

sudo apt-get update

When adding a link to the repository through the package manager, it should also look like deb [link to web repository]... In addition, you may have noticed in the screenshot the section with PPA repositories. It is assigned to them.

This, perhaps, is all. And remember, taming a penguin is not as difficult as it sounds.

Repository

Repository, repository- the place where any data is stored and maintained. Most often, the data in the repository is stored in the form of files available for further distribution over the network.

There are repositories for storing programs written in one language (for example, CPAN for Perl) or targeting one platform. Many modern OS such as OpenSolaris, FreeBSD, and most Linux distributions have official repositories, but also allow you to install packages from elsewhere. Most of the repositories are free, however some companies provide access to their own repositories for a paid subscription.

Repositories are used in version control systems, they store all documents along with the history of their changes and other service information. The Russian Subversion community recommends using instead of the term repository the term repository, since it fully corresponds to both the direct translation of the word "repository" and its concept.

There are various automated systems creating repositories. One of the types of repositories: repositories on / DVD - installation discs for packages of this or that software.

see also

Links


Wikimedia Foundation. 2010.

See what "Repository" is in other dictionaries:

    The place where any data is stored and maintained. Most often, the data in the repository is stored in the form of files available for further distribution over the network. Repositories are used in source control systems, they store everything ... ... Business glossary

    repository- Database object storage. Themes information Technology in general EN repository ...

    - (histor., lat. repono, repositum to return to its place, set) an obstetric instrument used to set a fallen out umbilical cord loop ... Comprehensive Medical Dictionary

    Repository: (English repository warehouse, storage) Repository See also Repository Yucca Mountain American dry storage for spent nuclear fuel ... Wikipedia

    software package repository (repository)- 3.17 repository software packages(repository): A closed collection of software packages and meta-information about them. A repository is called closed if it is possible to calculate its closure for each binary package, i.e. you can install the package ... ... Dictionary-reference book of terms of normative and technical documentation

    Yucca Mountain ... Wikipedia

    This term has other meanings, see Sisyphus (meanings). Sisyphus is a character in Greek mythology. Sisyphus (... Wikipedia

    central repository- central storage system This system is designed to store a variety of data, including athlete biographies, medal counts, event schedules, transportation reports, and visitor information. [Department ... ... Technical translator's guide

    Institutional repository electronic archive for long-term storage, accumulation and provision of long-term and reliable open access to the results of scientific research conducted at the institution. University institutional ... ... Wikipedia

    The repository is the place where any data is stored and maintained. Most often, the data in the repository is stored in the form of files available for further distribution over the network. An example of a repository is a free software repository ... ... Wikipedia

Books

  • Ruby on Rails for beginners. Learning Rails-Based Web Application Development, Hartl Michael. Used by a wide variety of companies such as Twitter, GitHub, Disney, and the Yellow Pages, Ruby on Rails is one of the more popular frameworks for developing web applications, but its ...

After we tried to answer your questions on what is and what is, for sure you will come across a new definition - Repository (repo, repo, repository).Repository, repository this is the place where any data is stored and updated. Most often, these are data in the form of files available for further distribution via the Internet. In this article, we will explain

In contact with

about repositories in Cydia. The main difference App Store from Cydia is that Cydia is not a single repository for apps. Cydia collects data about applications from various Internet resources specially designed to work with it. These Internet resources, or simply sites, are called repositories. Anyone can create a repository by uploading, for example, their selection of applications from Cydia. There are a lot of repositories in Cydia.

By default, after Cydia installations, it already contains several repositories. The largest of these is BigBoss. This repository contains hundreds of themes and programs, such as the very popular SBSettings and Barrel. For example, the MyWi application is located in another repository - ModMyi.com. In general, in order to install the application, you first need to add the repository to Cydia, i.e. the site on which it is stored.

How to add a new repository to Cydia.

1. Click on the Cydia icon and go to the section "Manage" at the bottom of the screen, then select a section "Sources".

2. Click "Edit" in the upper right corner and then "Add" left.

4. If done correctly, then after a few seconds in the list of repositories your new source... When you click on it, you will see the applications located in it.

If suddenly you are sure that the address you entered is correct, but the repository has not been added to the list of sources and Cydia reports an error, then most likely the problem is overloading the server on which the repository is located. In this case, you should delete the added repository and reinstall it later.

List of useful repositories:

http://sinfuliphonerepo.com (apps, patches, etc.)

http://ihacksrepo.com (huge library of various files)

http://cydia.i4tips.com (many deb. packages)

http://apt.alleon.name (Russian repository: themes, fixes, hacks, programs, games, wallpapers, ringtones)

http://cydia.xsellize.com (programs, games, pictures, melodies.)

http://ispaziorepo.com/cydia/apt/ (themes, fixes, hacks, programs, games, wallpapers, ringtones, etc.)

http://cydia.hackulo.us (AppSync, installous and HackLous patches)

http://repo.hackyouriphone.org (hacks, mods, programs, etc.)

Important!!! Never install unfamiliar apps from Cydia - this may result in data loss on your device or recovery via iTunes.

Below you can see where the repository services are stored, which version control systems are supported, whether they have a desktop application and on which operating systems it can be installed.

# Company Year Version control Data storage Price (per month), $
1
0
2008 Git, SVN 7–210
2
0
2008 Git, Mercurial cloud / own server 10–200
2016
3
0
2011 Git cloud / own server 4-99
4
0
2007 Git, SVN cloud 15–200

Other repository services for storing code when processing respondents' data were: Amazon Cloud Drive, Codebase, Gitolite, Heroku, Microsoft Azure, RhodeCode, Subversion, Team Foundation Server.

About rating

The rating of repository services for storing code is held by Tagline for the third time and is formed on the basis of a survey of 540+ technical leaders of digital companies conducted from April 2016 to May 2018. The respondents were asked to choose one or several answers to the question "What repository services do you use to store your code?"

The dynamics are compared with the data obtained by Tagline for the period from August 2014 to April 2016.

In the rating, GitHub continues to lead by a rather large margin (77%) - the most famous web service for hosting projects based on the Git version control system. For open source projects, the service is free, and for private projects with private repositories, there are several tariff plans:
- personal (creating private repositories for team use, from $ 7 per month);
- for small organizations (it becomes possible to manage access settings, from $ 25 per month);
- for large companies (you can install it on your own server or your own cloud, from $ 2520 per year).
GitHub is often referred to as the social network for developers. It has all the relevant elements: following, commenting, favorites. The activity on the service can also act as a resume.

Bitbucket is in second place, with 48% of respondents voted for it. It allows you to create an unlimited number of private repositories, but has a limit of 5 users. For teams bigger size there is a paid version - from $ 10. Since Bitbucket is one of Atlassian's products, it can be integrated with other solutions of this company: JIRA, Hipchat, Bamboo.

GitLab (14%) is similar in functionality to GitHub, but you can install it on your own server for free and customize it to fit your needs. At the same time, it also exists as a SaaS - after registration, you can create private repositories for free for working together... Paid options - in the version for large companies (from $ 48 per user per year).

Finally, Beanstalk is in fourth place - 1% of the total number of respondents. Unlike competitors, it offers free version only for 2 weeks, and the choice of paid plans depends on the number of users, repositories and allocated storage space. Tariffs for paid companies ($ 50-200) also include a number of additional functions such as prioritized support or multi-server deployments at the same time.