Create a local repository for Ubuntu 16.04LTS using apt-mirror and apache2.

To make a local repository you will need the following requirements:

  • apt-mirror package (sudo apt install apt-mirror)
  • apache2 package (sudo apt install apache2)
  • about 200GB of storage per release, per architecture

Once these requirements are met you can begin configuring the apt-mirror tool. The main items that you’ll need to define are:

  • storage location (base_path)
  • number of download threads (nthreads)
  • release(s) and architecture(s) you want

The configuration is in the /etc/apt/mirror.list file. A default config was put in place when you installed the package, but it is generic. You’ll need to update the values mentioned above.

Below I have included a complete configuration which will mirror Ubuntu 16.04 LTS for both 32 and 64 bit installations. It will require nearly 250GB of storage space, which I will be putting on a removable drive. The drive will be mounted at /media/STORAGE/.

# apt-mirror configuration file
##
## The default configuration options (uncomment and change to override)
##
#

set base_path /media/STORAGE/
# set mirror_path $base_path/mirror
# set skel_path $base_path/skel
# set var_path $base_path/var
#
# set defaultarch <running host architecture>
set nthreads 20
#
# 16.04 "xenial" i386 mirror
deb-i386 http://vn.archive.ubuntu.com/ubuntu xenial main restricted universe 
multiverse
deb-i386 http://vn.archive.ubuntu.com/ubuntu xenial-updates main restricted 
universe multiverse
deb-i386 http://vn.archive.ubuntu.com/ubuntu xenial-security main restricted 
universe multiverse
deb-i386 http://vn.archive.ubuntu.com/ubuntu xenial-backports main restricted 
universe multiverse
deb-i386 http://vn.archive.ubuntu.com/ubuntu xenial-proposed main restricted 
universe multiverse
deb-i386 http://vn.archive.ubuntu.com/ubuntu xenial main/debian-installer 
restricted/debian-installer universe/debian-installer multiverse/debian-installer
deb-i386 http://packages.medibuntu.org/ xenial free non-free

# 16.04 "xenial" amd64 mirror

deb-amd64 http://vn.archive.ubuntu.com/ubuntu xenial main restricted universe 
multiverse
deb-amd64 http://vn.archive.ubuntu.com/ubuntu xenial-updates main restricted 
universe multiverse
deb-amd64 http://vn.archive.ubuntu.com/ubuntu xenial-security main restricted 
universe multiverse
deb-amd64 http://vn.archive.ubuntu.com/ubuntu xenial-backports main restricted 
universe multiverse
deb-amd64 http://vn.archive.ubuntu.com/ubuntu xenial-proposed main restricted 
universe multiverse
deb-amd64 http://vn.archive.ubuntu.com/ubuntu xenial main/debian-installer 
restricted/debian-installer universe/debian-installer multiverse/debian-installer
deb-amd64 http://packages.medibuntu.org/ xenial free non-free

# Cleaning section
clean http://vn.archive.ubuntu.com/
clean http://packages.medibuntu.org/

Once your configuration is saved you can begin to populate your mirror by running the command:

apt-mirror

In order for this repository to be available to other clients on your local area network you’ll need to share the contents over http. This is why we listed Apache2 as a requirement above. In my example configuration above I mirrored the repository on a removable drive, and mounted it at /media/STORAGE. What I need to do now is make that address available over the web. This can be done by way of a symbolic link.

cd /var/www/
sudo ln -s /media/STORAGE/mirror/vn.archive.ubuntu.com/ubuntu/ ubuntu

The commands above will tell the filesystem to follow any requests for “ubuntu” back up to the mounted external drive, where it will find your mirrored contents. If you have any problems with this linking double-check your paths (as compared to those suggested here) and make sure your link points to the ubuntu directory, which is a subdirectory of the mirror you pulled from. If you point anywhere below this point your clients will not properly be able to find the contents.

If you get the “403 Forbidden” error then make sure the user and group of apache2 process have at least read and execute permission for every folder in the full-path to your local repository, for this article, the full-path to your local repository is:

/media/STORAGE/mirror/vn.archive.ubuntu.com/ubuntu/

shell commands that helps you check user and group of apache2 process are:

ps -ef | grep apache2#orps -aux | grep apache2

The default user and group of apache2 process are: “www-data” and “www-data”. If the “403 Forbidden” error happens, you usually can solve this error by “chmod” command. For example:

sudo chmod -R o+rx /media

The other cause for “403 Forbidden” error is wrong configurations for apache2. In Ubuntu 16.04LTS the apache2 version is usually 2.4.18. Version of apache2 can be checked with command:

apache2 -v

make sure that /etc/apache2/apache2.conf or /etc/apache2/sites-available/000-default.conf has the following line:

DocumentRoot /var/www/html
<Directory />
        Options FollowSymLinks Indexes
        AllowOverride None
        Require all granted
</Directory>

The additional task of keeping this newly downloaded mirror updated with the latest updates can be automated by way of a cron job. By activating the cron job your machine will automatically run the apt-mirror command on a regular daily basis, keeping your mirror up to date without any additional effort on your part.

To activate the automated cron job, edit the file /etc/cron.d/apt-mirror. There will be a sample entry in the file. Simply uncomment the line and (optionally) change the “4” to an hour more convenient for you. If left with its defaults it will run the apt-mirror command, updating and synchronizing your mirror, every morning at 4:00am.

The final step needed, now that you have your repository created, shared over http and configured to automatically update, is to configure your clients to use it. Ubuntu clients define where they should grab errata and security updates in the /etc/apt/sources.list file. This will usually point to the default or regional mirror. To update your clients to use your local mirror instead you’ll need to edit the /etc/apt/sources.list and comment the existing entries (you may want to revert to them later!)

Once you’ve commented the entries you can create new entries, this time pointing to your mirror. A sample entry pointing to a local mirror might look something like this:

deb http://192.168.0.10/ubuntu xenial main restricted universe multiverse
deb http://192.168.0.10/ubuntu xenial-updates main restricted universe multiverse
deb http://192.168.0.10/ubuntu xenial-security main restricted universe multiverse

Basically what you are doing is recreating your existing entries but replacing the archive.ubuntu.com with the IP of your local mirror. As long as the mirrored contents are made available over http on the mirror-server itself you should have no problems. If you do run into problems check your apache logs for details.

error LNK2019

I am using visual C++ 2010 Express. I am taking a example from aaindex.c and when I build I get this error:

1>—— Build started: Project: test7, Configuration: Debug Win32 ——
1>aaindex.obj : error LNK2019: unresolved external symbol __imp__glClearIndex@4 referenced in function _init
1>aaindex.obj : error LNK2019: unresolved external symbol __imp__glLineWidth@4 referenced in function _init
1>aaindex.obj : error LNK2019: unresolved external symbol __imp__glHint@8 referenced in function _init
1>aaindex.obj : error LNK2019: unresolved external symbol __imp__glEnable@4 referenced in function _init
1>aaindex.obj : error LNK2019: unresolved external symbol __imp__glFlush@0 referenced in function _display
1>aaindex.obj : error LNK2019: unresolved external symbol __imp__glPopMatrix@0 referenced in function _display
1>aaindex.obj : error LNK2019: unresolved external symbol __imp__glEnd@0 referenced in function _display
1>aaindex.obj : error LNK2019: unresolved external symbol __imp__glVertex2f@8 referenced in function _display
1>aaindex.obj : error LNK2019: unresolved external symbol __imp__glBegin@4 referenced in function _display
1>aaindex.obj : error LNK2019: unresolved external symbol __imp__glRotatef@16 referenced in function _display
1>aaindex.obj : error LNK2019: unresolved external symbol __imp__glPushMatrix@0 referenced in function _display
1>aaindex.obj : error LNK2019: unresolved external symbol __imp__glIndexi@4 referenced in function _display
1>aaindex.obj : error LNK2019: unresolved external symbol __imp__glClear@4 referenced in function _display
1>aaindex.obj : error LNK2019: unresolved external symbol _gluOrtho2D@32 referenced in function _reshape
1>aaindex.obj : error LNK2019: unresolved external symbol __imp__glLoadIdentity@0 referenced in function _reshape
1>aaindex.obj : error LNK2019: unresolved external symbol __imp__glMatrixMode@4 referenced in function _reshape
1>aaindex.obj : error LNK2019: unresolved external symbol __imp__glViewport@16 referenced in function _reshape
1>C:\Users\comet\documents\visual studio 2010\Projects\test7\Debug\test7.exe : fatal error LNK1120: 17 unresolved externals
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

Answer to this question:

You need to add opengl32.lib to your linker input additional dependencies.

File URIs in Windows

For the UNC Windows file path
\\laptop\My Documents\FileSchemeURIs.doc

The corresponding valid file URI in Windows is the following:
file://laptop/My%20Documents/FileSchemeURIs.doc

For the local Windows file path
C:\Documents and Settings\davris\FileSchemeURIs.doc

The corresponding valid file URI in Windows is:
file:///C:/Documents%20and%20Settings/davris/FileSchemeURIs.doc

The important factors here are the use of percent-encoding and the number of slashes following the ‘file:’ scheme name.

In order to avoid ambiguity, and for your Windows file paths to be interpreted correctly, characters that are important to URI parsing that are also allowed in Windows file paths must be percent-encoded. This includes ‘#’ and ‘%’. Characters that aren’t allowed in URIs but are allowed in Windows file paths should also be percent-encoded. This includes ‘ ‘, ‘{‘, ‘}’, ‘`’, ‘^’ and all control characters. Note, for instance, that the spaces in the example URIs above have been percent-encoded to ‘%20’. See the latest URI standardfor the full list of characters that aren’t allowed in URIs.

The number of slashes following the ‘file:’ is dictated by the same rules as other well-known schemes like http and ftp. The text following two slashes is the hostname. In the case of the UNC Windows file path, the hostname appears immediately following the ‘//’. In the case of a local Windows file path, there is no hostname, and thus another slash and the path immediately follow.

The username, password, and port components of a file URI in Windows are not used. The query and fragment components may be used. The query component will not be used when locating the resource, but the application that displays the content from the file URI may use the query component. For example, if an html document contains script, the script may read the query component of its URI when accessed via the file scheme. Similarly, the fragment will be used like a fragment in any other URI scheme.

[CMAKE] [Fixed] fatal error LNK1123: failure during conversion to COFF: file invalid or corrupt.

Error LINK : fatal error LNK1123: failure during conversion to COFF: file invalid or corrupt appear often on Visual C++ 2010 and this error don’t let you to compile and run your program coded on Visual C++. If you got this error you no need to reinstall Visual C++.

Causes:

  • this error appear because you have installed Visual C++ 2012 after you have actually installed Visual C++ 2010 in your system;
  • another cause is because .net Framework 4.5 replace .net Framework 4.0;
  • .net Framework corrupted files;

How to solve

  • uninstall .Net Framework 4.5 from your system;
  • then download .Net Framework 4.0 and install it;
  • this should fix your problem;

Other ways to solve it:

Go to C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\bin\cvtres.exe and check the version of cvtres.exe:

Wrong version:  03/18/2010  01:16 PM            31,048 cvtres.exe
Correct version: 02/21/2011  06:03 PM            31,056 cvtres.exe

If you have wrong version you should go to
C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\bin\cvtres.exe
and copy cvtres.exe then replace it with
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\bin\cvtres.exe

Conclusion:

Now you know how to solve LINK : fatal error LNK1123: failure during conversion to COFF: file invalid or corrupt Visual C++ 2010 Error!

If you remove Visual C++ the error will not disappear;

Please let me know if it works property for you!

Windows and Messages.

This is my version of this.

I just make it shorter than msdn’s version and contains only what are important for me.

WINDOWS

In a graphical Windows-based application, a window is a rectangular area of the screen where the application displays output and receives input from the user. Therefore, one of the first tasks of a graphical Windows-based application is to create a window.

A window shares the screen with other windows, including those from other applications. Only one window at a time can receive input from the user. The user can use the mouse, keyboard, or other input device to interact with this window and the application that owns it.

WINDOW-CREATION MESSAGES

When creating any window, the system sends messages to the window procedure for the window. The system sends the WM_NCCREATE message after creating the window’s nonclient area and the WM_CREATE message after creating the client area. The window procedure receives both messages before the system displays the window. Both messages include a pointer to a CREATESTRUCT structure that contains all the information specified in the CreateWindowEx function. Typically, the window procedure performs initialization tasks upon receiving these messages.

When creating a child window, the system sends the WM_PARENTNOTIFY message to the parent window after sending the WM_NCCREATE and WM_CREATE messages. It also sends other messages while creating a window. The number and order of these messages depend on the window class and style and on the function used to create the window. These messages are described in other topics in this help file.

MULTITHREAD APPLICATIONS

A Windows-based application can have multiple threads of execution, and each thread can create windows. The thread that creates a window must contain the code for its window procedure.

An application can use the EnumThreadWindows function to enumerate the windows created by a particular thread. This function passes the handle to each thread window, in turn, to an application-defined callback function, EnumThreadWndProc.

The GetWindowThreadProcessId function returns the identifier of the thread that created a particular window.

To set the show state of a window created by another thread, use the ShowWindowAsync function.