Is there some equivalent in Mercurial to NIX soft- or hard- links to directories or files.
Basically that a file (or directory) is linked to a file "somewhere else" and follows the version of that location (Unlike a regular branch I think, where one would have to merge)
Mercurial versions soft links that are internal to the repository just great. It'll detect them, record them, and create them for you. Is there a specific use case you're looking for? The closest thing to an link that reaches outside the repository is a subrepo, which is a pointer to a specific version of another repo.
Symlinks work
(df)Ry4ans-MacBook-Air:~ ry4an$ hg init olav
(df)Ry4ans-MacBook-Air:~ ry4an$ cd olav/
(df)Ry4ans-MacBook-Air:olav ry4an$ echo this > target
(df)Ry4ans-MacBook-Air:olav ry4an$ ln -s target link
(df)Ry4ans-MacBook-Air:olav ry4an$ ls -l
total 16
lrwxr-xr-x 1 ry4an staff 6B Feb 16 19:25 link# -> target
-rw-r--r-- 1 ry4an staff 5B Feb 16 19:25 target
(df)Ry4ans-MacBook-Air:olav ry4an$ hg commit -A -m "link and its target"
adding link
adding target
(df)Ry4ans-MacBook-Air:olav ry4an$ hg log -p
changeset: 0:42a41a431661
tag: tip
user: Ry4an Brase <ry4an-hg#ry4an.org>
date: Sat Feb 16 19:26:17 2013 -0500
summary: link and its target
diff -r 000000000000 -r 42a41a431661 link
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/link Sat Feb 16 19:26:17 2013 -0500
## -0,0 +1,1 ##
+target
\ No newline at end of file
diff -r 000000000000 -r 42a41a431661 target
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/target Sat Feb 16 19:26:17 2013 -0500
## -0,0 +1,1 ##
+this
(df)Ry4ans-MacBook-Air:olav ry4an$ hg update null
0 files updated, 0 files merged, 2 files removed, 0 files unresolved
(df)Ry4ans-MacBook-Air:olav ry4an$ ls -l
(df)Ry4ans-MacBook-Air:olav ry4an$ hg update tip
2 files updated, 0 files merged, 0 files removed, 0 files unresolved
(df)Ry4ans-MacBook-Air:olav ry4an$ ls -l
total 16
lrwxr-xr-x 1 ry4an staff 6B Feb 16 19:26 link# -> target
-rw-r--r-- 1 ry4an staff 5B Feb 16 19:26 target
But hardlinks don't
$hg commit -Am "hardlinks target"
adding link
adding target
$hg log -p
changeset: 0:ec9407634133
tag: tip
user: Chris Wesseling <chris.wesseling#cwi.nl>
date: Wed Mar 13 23:14:44 2013 +0100
summary: hardlinks target
diff -r 000000000000 -r ec9407634133 link
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/link Wed Mar 13 23:14:44 2013 +0100
## -0,0 +1,1 ##
+foo
diff -r 000000000000 -r ec9407634133 target
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/target Wed Mar 13 23:14:44 2013 +0100
## -0,0 +1,1 ##
+foo
$ls -lin
total 8
276702 -rw-r--r-- 2 1204653 5900 4 13 mrt 23:14 link
276702 -rw-r--r-- 2 1204653 5900 4 13 mrt 23:14 target
$hg update null
0 files updated, 0 files merged, 2 files removed, 0 files unresolved
$hg update tip
2 files updated, 0 files merged, 0 files removed, 0 files unresolved
$ls -lin
total 8
276719 -rw-r--r-- 1 1204653 5900 4 13 mrt 23:15 link
276721 -rw-r--r-- 1 1204653 5900 4 13 mrt 23:15 target
Path auditing on *nix
On *nix systems, hg Mercurial audits symbolic links ("symlinks") for referred path security.
For example, absolute and empty paths are considered unsafe and will therefore not be added to the repository.
Mercurial developers have not documented this feature. However, the source code contains a comment with a somewhat vague explanation:
class pathauditor(object):
'''ensure that a filesystem path contains no banned components.
the following properties of a path are checked:
- ends with a directory separator
- under top-level .hg
- starts at the root of a windows drive
- contains ".."
- traverses a symlink (e.g. a/symlink_here/b)
- inside a nested repository (a callback can be used to approve
some nested repositories, e.g., subrepositories)
'''
On Windows, symbolic links are not supported for various reasons, see:
https://www.mercurial-scm.org/bts/issue1825
https://www.mercurial-scm.org/bts/issue2579
Related
I'm trying to setup a minecraft server for my kid and screen is giving me fits. I've been following this tutorial and I've already consulted this AskUbuntu answer. I'm running on Ubuntu 16.04.5 x64. I have created the following Service file and linked it to /etc/systemd/system/minecraft.service.
[Unit]
Description=Minecraft Server
Documentation=
Wants=network.target
After=network.target
[Service]
User=minecraft
Group=minecraft
Nice=5
EnvironmentFile=-/var/minecraft/unit.conf
KillMode=none
SuccessExitStatus=0 1
ProtectHome=true
ProtectSystem=full
PrivateDevices=true
NoNewPrivileges=true
PrivateTmp=true
InaccessibleDirectories=/root /sys /srv -/opt /media -/lost+found
ReadWriteDirectories=/var/minecraft/server /usr/bin/screen
WorkingDirectory=/var/minecraft/server
#ExecStartPre= /usr/bin/screen -dmS Minecraft
ExecStart= /usr/bin/screen -dm -S Minecraft '/usr/bin/java -Xmx1500M -Xms1024M -jar /var/minecraft/server/craftbukkit-1.13.jar'
ExecStop=/usr/bin/screen -S minecraft -p 0 -X stuff "stop^M"
[Install]
WantedBy=multi-user.target
When I monitor the service startup, I get the following in the journalctl logs:
Aug 05 14:55:41 spigot-1 systemd[1]: Started Minecraft Server.
Aug 05 14:55:41 spigot-1 screen[9869]: No screen session found.
Per the SO post I referenced, I already changed the permissions in /var/run/screen. This is the current setup:
root#spigot-1:/var/minecraft/server# ls -alR /var/run/screen/
/var/run/screen/:
total 0
drwxrwxrwx 4 root root 80 Aug 5 14:12 .
drwxr-xr-x 23 root root 860 Aug 5 14:11 ..
drwx------ 2 minecraft minecraft 40 Aug 5 14:55 S-minecraft
drwx------ 2 root root 40 Aug 5 14:50 S-root
/var/run/screen/S-minecraft:
total 0
drwx------ 2 minecraft minecraft 40 Aug 5 14:55 .
drwxrwxrwx 4 root root 80 Aug 5 14:12 ..
/var/run/screen/S-root:
total 0
drwx------ 2 root root 40 Aug 5 14:50 .
drwxrwxrwx 4 root root 80 Aug 5 14:12 ..
** Debug Notes **
You'll see the commented ExecStartPre command in there... all that happens if I try to start the screen session with that command is I get a second 'No screen session found' error.
I can launch the server from the command line using 'screen -dmS Minecraft [..]' and reattach. I can do this both as root and as the 'minecraft' user.
Any help would be greatly appreciated
I don't have Ubuntu to hand, but I tried something similar on Fedora 24 and had a similar error. To investigate I added an strace to the screen command and removed PrivateTmp so that I could get the trace output.
ExecStart=/bin/strace -o /tmp/s -f screen -dm -S me bash -c 'sleep 999'
In the output I found that at the end, screen was trying to open a pseudo-tty and failed to do so:
open("/dev/ptmx", O_RDWR) = -1 EACCES (Permission denied)
...
write(1, "No more PTYs.\r\nSorry, could not "..., 52) = 52
I added some ls -l /dev commands to the Unit to see what the effect of the PrivateDevices=true option had been. There was indeed a /dev/ptmx file, but unlike my real /dev it was a symbolic link to /dev/pts/ptmx, instead of just being the special character device. For some reason on my system I have:
$ ls -l /dev/ptmx /dev/pts/ptmx
crw-rw-rw- 1 root tty 5, 2 Aug 6 14:29 /dev/ptmx
c--------- 1 root root 5, 2 Jun 27 08:29 /dev/pts/ptmx
(This is probably a bug depending on the version of systemd and udev.)
So when /dev/ptmx is replaced in the private namespace by a symbolic link to /dev/pts/ptmx, you can no longer open a new pty. A simple fix for testing was sudo chmod a+rw /dev/pts/ptmx which indeed made the Unit work and start the screen process.
This may not be the case for you, but you could undertake a similar debug method to try to find the problem.
I am making a deployment script using GitLab's CD. I've got a script:
- ssh USER#HOST "cd domains/$DOMAIN/ && mkdir build-$CI_JOB_ID"
- rsync -ar --port=22 * USER#HOST :domains/$DOMAIN/build-$CI_JOB_ID
- ssh USER#HOST "cd domains/$DOMAIN/ && ln -sfv build-$CI_JOB_ID/public public_html && ls -la"
- ssh USER#HOST "cd domains/$DOMAIN/ && ls | grep '^build\-.*$' | grep -Ev '^build-$CI_JOB_ID$' | xargs rm -rf"
everything works fine but not ln command. It works only 50% of the time. Here are logs from ` jobs runnning one after another.
Job 1 with $CI_JOB_ID = 76337215 worked properly. Link is correct.
$ ssh USER#HOST "cd domains/$DOMAIN/ && ln -sfv build-$CI_JOB_ID/public public_html && ls -la"
public_html -> build-76337215/public
total 20
drwx--x--x 5 USER 1000 7 Jun 20 22:15 .
drwx--x--x 23 USER 1000 23 Jun 19 16:34 ..
-rw-r--r-- 1 USER 1000 39 Jun 17 22:12 .htaccess
drwxr-xr-x 12 USER 1000 20 Jun 20 22:07 build-76335972
drwxr-xr-x 12 USER 1000 20 Jun 20 22:14 build-76337215
drwxr-xr-x 2 USER 1000 4 Jun 20 11:48 logs
lrwxr-xr-x 1 USER 1000 21 Jun 20 22:15 public_html -> build-76337215/public
Job 2 with $CI_JOB_ID = 76339729 did not work. Link is still to old 76337215 from Job 1.
$ ssh USER#HOST "cd domains/$DOMAIN/ && ln -sfv build-$CI_JOB_ID/public public_html && ls -la"
public_html/public -> build-76339729/public
total 20
drwx--x--x 5 USER 1000 7 Jun 20 22:28 .
drwx--x--x 23 USER 1000 23 Jun 19 16:34 ..
-rw-r--r-- 1 USER 1000 39 Jun 17 22:12 .htaccess
drwxr-xr-x 12 USER 1000 20 Jun 20 22:14 build-76337215
drwxr-xr-x 12 USER 1000 20 Jun 20 22:28 build-76339729
drwxr-xr-x 2 USER 1000 4 Jun 20 11:48 logs
lrwxr-xr-x 1 USER 1000 21 Jun 20 22:15 public_html -> build-76337215/public
What I am doing wrong? Why it is not working 100% of the time?
The problem is that if public_html already exists and is a directory (or a symlink to a directory), then your ln command creates a new link in that directory, rather than replacing public_html.
Use the -T option to avoid this:
ln -sfTv build-$CI_JOB_ID/public public_html
alternately, you can use the -n option to not dereference a link
ln -sfnv build-$CI_JOB_ID/public public_html
this will replace public_html if it is a symlink and create the symlink in the subdirectory if it is a real directory (-T would give an error in the latter case).
here is my system information:
$ apachectl -v
Server version: Apache/2.4.18 (Ubuntu)
Server built: 2016-07-14T12:32:26
$ cat /etc/*release* | grep -i dist
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=16.04
DISTRIB_CODENAME=xenial
DISTRIB_DESCRIPTION="Ubuntu 16.04.1 LTS"
$ uname -r
4.4.0-57-generic
i wish to install mod_maxminddb. i installed geoipupdate as a prerequisites and configured it to include not only geolite database, but either commercial one (using this)
$ ls -l /etc/GeoIP.conf
-rw-r--r-- 1 root root 818 Dec 24 18:29 /etc/GeoIP.conf
$ ls -l /usr/share/GeoIP/
total 0
$ geoipupdate
$ ls -l /usr/share/GeoIP/
total 187444
-rw-r--r-- 1 root root 112192399 Dec 24 18:46 GeoIP2-City.mmdb
-rw-r--r-- 1 root root 3012279 Dec 24 18:46 GeoIP2-Country.mmdb
-rw-r--r-- 1 root root 47721533 Dec 24 18:46 GeoIPCity.dat
-rw-r--r-- 1 root root 1699494 Dec 24 18:45 GeoIP.dat
-rw-r--r-- 1 root root 4189407 Dec 24 18:45 GeoIPISP.dat
-rw-r--r-- 1 root root 4299547 Dec 24 18:45 GeoLiteASNum.dat
-rw-r--r-- 1 root root 17760694 Dec 24 18:45 GeoLiteCity.dat
-rw-r--r-- 1 root root 1054583 Dec 24 18:45 GeoLiteCountry.dat
then complied and installed the mod_maxminddb, and when apache is configured to use the commercial databases, the following error is thrown
$ apachectl -M
AH00526: Syntax error on line 12 of /etc/apache2/mods-enabled/maxminddb.conf:
MaxMindDBFile: Failed to open /usr/share/GeoIP/GeoIPCity.dat: The MaxMind DB file contains invalid metadata
but that is not the case when apache is configured to use the geolite databases.
any ideas?
You didn't include your Apache config, but you appear to be trying to use mod_maxminddb with GeoIPCity.dat (GeoIP Legacy). It only works with GeoIP2. Adjust line 12 of maxminddb.conf to use GeoIP2-City.mmdb instead.
Doing my gitlab backup the backuped files have:
no timestamp
should be like this: The filename will be [TIMESTAMP]_gitlab_backup.tar
here the files::
root#gitlab:~# ll /mnt/backup-git/ -h
total 1.9G
-rw------- 1 git git 57M Nov 29 15:57 1480431448_gitlab_backup.tar
-rw------- 1 git git 57M Nov 29 15:57 1480431473_gitlab_backup.tar
-rw------- 1 git git 452M Nov 30 02:00 1480467623_gitlab_backup.tar
Here my configuration values for the backup::
$ grep -i backup /etc/gitlab/gitlab.rb | grep -v '^#'
gitlab_rails['backup_path'] = "/mnt/backup-git/"
gitlab_rails['backup_keep_time'] = 604800
To create them, following the documentation here, (omnibus installation):
root#gitlab:~# crontab -l | grep -v '^#'
0 2 * * * /opt/gitlab/bin/gitlab-rake gitlab:backup:create CRON=1
The files clearly have a timestamp already:
1480431448_gitlab_backup.tar
The bold is the unix time for the backup
I'm super-confused about file permissions in MSYS. Things started to go wrong after my company transferred my windows-user to a different domain. Now I have this concrete problem:
I want to compile cpputest. I unzipped it using windows, started an msys console and owner and group look like this:
M.Grunwald#GNA ~/Projects/cpputest-3.8
$ ls -la
total 1956
drwxrwx---+ 1 M.Grunwald Domain Users 0 16. Nov 10:21 .
drwxrwx---+ 1 M.Grunwald COMPANY_DE+Domain Users 0 16. Nov 10:21 ..
-rwxrwx---+ 1 M.Grunwald Domain Users 11030 2. Mai 2016 .cproject
-rwxrwx---+ 1 M.Grunwald Domain Users 228 2. Mai 2016 .gitattributes
-rwxrwx---+ 1 M.Grunwald Domain Users 746 25. Mai 12:32 .gitignore
and so on.
When I start autogen.sh, this happens:
$ ./autogen.sh
autom4te-2.69: cannot open autom4te.cache/requests: Permission denied
$ ls -lad autom4te.cache/
drwxr-xr-x+ 1 M.Grunwald Domain Users 0 Nov 16 10:23 autom4te.cache/
So the directory belongs to me, I have all permissions, but I'm not allowed to touch anything in it:
$ touch autom4te.cache/requests
touch: cannot touch 'autom4te.cache/requests': Permission denied
It seems that "I" am not really M.Grunwald and don't belong to "Domain Users", neither... On the other hand:
$ echo "UID: $UID GID: $GROUPS"
UID: 1117609 GID: 1049089
$ ls -lnad autom4te.cache/
drwxr-xr-x+ 1 1117609 1049089 0 Nov 16 10:23 autom4te.cache/
So the IDs match. umask is 0000, too and still group and others don't have write permission. If I want to change this:
$ chmod g+w autom4te.cache
chmod: changing permissions of 'autom4te.cache': Permission denied
Now I'm completely confused and blocked on many similar tasks (always permission problems, cpputest is just one example). Can you help me?
The problem was solved after I re-ran the mingw installer.